Skip to content

Commit c77d530

Browse files
author
Nikolay Borisov
committed
convert: Fix detection of LLAMA2
In recent downloads of LLAMA2 dataset the norm_eps is set to 1e-06, this leads to convert.py erroneously considering the model to be LLAMA1 and setting the context to 2k tokens. Fix it by extending the existing hack to also check for the 1e-06 value.
1 parent 2833a6f commit c77d530

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

convert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,13 @@ def loadHFTransformerJson(model: LazyModel, config_path: Path) -> Params:
245245
@staticmethod
246246
def loadOriginalParamsJson(model: LazyModel, config_path: Path) -> Params:
247247
config = json.load(open(config_path))
248+
norm_eps = config["norm_eps"]
248249

249250
# hack to determine LLaMA v1 vs v2 vs CodeLlama
250251
if config.get("rope_theta") == 1000000:
251252
# CodeLlama
252253
n_ctx = 16384
253-
elif config["norm_eps"] == 1e-05:
254+
elif norm_eps == 1e-05 or norm_eps == 1e-06:
254255
# LLaMA v2
255256
n_ctx = 4096
256257
else:

0 commit comments

Comments
 (0)