From f36a777bbc20ccf1e61d3d19777ecf57461c8dd7 Mon Sep 17 00:00:00 2001 From: Nikolay Borisov Date: Mon, 6 Nov 2023 13:03:31 +0200 Subject: [PATCH] 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 --- convert.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/convert.py b/convert.py index d88dd096d..1c30df656 100755 --- a/convert.py +++ b/convert.py @@ -253,6 +253,11 @@ class Params: elif config["norm_eps"] in (1e-05, 1e-06): # LLaMA v2 n_ctx = 4096 + # For some reason FB writes -1 to vocab size for their LLAMA2 models + # simply remove this bogus value and let the return statement belo + # figure it out + if config["vocab_size"] == -1: + del config["vocab_size"] else: # LLaMA v1 n_ctx = 2048