Skip to content

Commit 55a939d

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 c77d530 commit 55a939d

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
@@ -254,6 +254,11 @@ def loadOriginalParamsJson(model: LazyModel, config_path: Path) -> Params:
254254
elif norm_eps == 1e-05 or norm_eps == 1e-06:
255255
# LLaMA v2
256256
n_ctx = 4096
257+
# For some reason FB writes -1 to vocab size for their LLAMA2 models
258+
# simply remove this bogus value and let the return statement belo
259+
# figure it out
260+
if config["vocab_size"] == -1:
261+
del config["vocab_size"]
257262
else:
258263
# LLaMA v1
259264
n_ctx = 2048

0 commit comments

Comments
 (0)