]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
convert.py : fix llama/llama2 conversion due to vocab_size=-1 (#5019)
authorDavid Sommers <redacted>
Thu, 18 Jan 2024 17:20:59 +0000 (12:20 -0500)
committerGitHub <redacted>
Thu, 18 Jan 2024 17:20:59 +0000 (19:20 +0200)
PR #4818 (merged last week) reintroduced a config check for vocab_size that was addressed in PR #4258 (merged 2023-11-30).

Without the fix, llama2 models can't be converted. The error is:

`ValueError: The model's vocab size is set to -1 in params.json. Please update it manually. Maybe 32000?`

convert.py

index e38ee5315af30ec3b21f6e83b4c809e8e3f3908b..980e6fc720aa63486390e76d68564de01a1007e2 100755 (executable)
@@ -348,7 +348,7 @@ class Params:
             f_rope_freq_base = 1e6
 
         return Params(
-            n_vocab=config.get("vocab_size", model["tok_embeddings.weight"].shape[0]),
+            n_vocab=model["tok_embeddings.weight"].shape[0],
             n_embd=config["dim"],
             n_layer=config["n_layers"],
             n_ctx=n_ctx,