Skip to content

Commit efd316d

Browse files
authored
Fixconv (#2527)
* fix converter * remove openllama
1 parent 376a2a1 commit efd316d

File tree

2 files changed

+6
-392
lines changed

2 files changed

+6
-392
lines changed

tools/convert_HF_llamalike.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self, model_path: str):
8282
vocab_size = config.vocab_size
8383
transformer_ff = config.intermediate_size
8484

85-
if hasattr(config, "num_key_value_heads"):
85+
if hasattr(config, "num_key_value_heads") and config.num_key_value_heads != heads:
8686
num_kv = config.num_key_value_heads
8787
else:
8888
num_kv = 0
@@ -263,13 +263,15 @@ def __init__(self, model_path: str):
263263

264264
onmt_cp["vocab"] = {}
265265
onmt_cp["vocab"] = vocabs_to_dict(vocabs)
266-
"""
266+
267+
directory_path, _ = os.path.split(opt.output)
268+
os.makedirs(directory_path, exist_ok=True)
267269
with open(
268-
os.path.join(opt.model_dir, "openllama.vocab"), "w", encoding="utf-8"
270+
os.path.join(directory_path, "vocab.txt"), "w", encoding="utf-8"
269271
) as vocabfile:
270272
for tok in onmt_cp["vocab"]["src"]:
271273
vocabfile.write(tok + "\n")
272-
"""
274+
273275
onmt_cp["opt"] = Namespace(
274276
config=None,
275277
save_config=None,

0 commit comments

Comments
 (0)