Skip to content

Commit f36a777

Browse files
author
Nikolay Borisov
committed
convert: Fix handling of LLAMA2 vocab_size = -1
When vocab_size is detected to be -1 simply remove its value from the parsed params.json and fallback to using the tok_embeddings.weight. Fixes #3900
1 parent d6d905b commit f36a777

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

convert.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ def loadOriginalParamsJson(model: LazyModel, config_path: Path) -> Params:
253253
elif config["norm_eps"] in (1e-05, 1e-06):
254254
# LLaMA v2
255255
n_ctx = 4096
256+
# For some reason FB writes -1 to vocab size for their LLAMA2 models
257+
# simply remove this bogus value and let the return statement belo
258+
# figure it out
259+
if config["vocab_size"] == -1:
260+
del config["vocab_size"]
256261
else:
257262
# LLaMA v1
258263
n_ctx = 2048

0 commit comments

Comments
 (0)