Skip to content

Commit

Permalink
convert.py : fix llama/llama2 conversion due to vocab_size=-1 (ggerga…
Browse files Browse the repository at this point in the history
…nov#5019)

PR ggerganov#4818 (merged last week) reintroduced a config check for vocab_size that was addressed in PR ggerganov#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?`
  • Loading branch information
databyte authored and jordankanter committed Feb 3, 2024
1 parent a35f739 commit da1b04e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def load_torch_params(model: LazyModel, config_path: Path) -> "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,
Expand Down

0 comments on commit da1b04e

Please sign in to comment.