Skip to content

Commit d4835b8

Browse files
slarenakawrykow
authored andcommitted
convert.py : export rope freq_base when converting CodeLlama from an HF model (ggml-org#2773)
1 parent db6b096 commit d4835b8

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

convert.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,14 @@ def guessed(model: 'LazyModel') -> 'Params':
160160
def loadHFTransformerJson(model: 'LazyModel', config_path: 'Path') -> 'Params':
161161
config = json.load(open(config_path))
162162

163-
n_vocab = config["vocab_size"]
164-
n_embd = config["hidden_size"]
165-
n_layer = config["num_hidden_layers"]
166-
n_ff = config["intermediate_size"]
167-
n_head = config["num_attention_heads"]
168-
n_head_kv = config["num_key_value_heads"] if "num_key_value_heads" in config else n_head
169-
f_norm_eps = config["rms_norm_eps"]
163+
n_vocab = config["vocab_size"]
164+
n_embd = config["hidden_size"]
165+
n_layer = config["num_hidden_layers"]
166+
n_ff = config["intermediate_size"]
167+
n_head = config["num_attention_heads"]
168+
n_head_kv = config["num_key_value_heads"] if "num_key_value_heads" in config else n_head
169+
f_norm_eps = config["rms_norm_eps"]
170+
f_rope_freq_base = config["rope_theta"] if "rope_theta" in config else None
170171

171172
n_mult = Params.find_n_mult(n_ff, n_embd)
172173

@@ -179,15 +180,16 @@ def loadHFTransformerJson(model: 'LazyModel', config_path: 'Path') -> 'Params':
179180
"Suggestion: provide 'config.json' of the model in the same directory containing model files.")
180181

181182
return Params(
182-
n_vocab = n_vocab,
183-
n_embd = n_embd,
184-
n_mult = n_mult,
185-
n_layer = n_layer,
186-
n_ctx = n_ctx,
187-
n_ff = n_ff,
188-
n_head = n_head,
189-
n_head_kv = n_head_kv,
190-
f_norm_eps = f_norm_eps,
183+
n_vocab = n_vocab,
184+
n_embd = n_embd,
185+
n_mult = n_mult,
186+
n_layer = n_layer,
187+
n_ctx = n_ctx,
188+
n_ff = n_ff,
189+
n_head = n_head,
190+
n_head_kv = n_head_kv,
191+
f_norm_eps = f_norm_eps,
192+
f_rope_freq_base = f_rope_freq_base,
191193
)
192194

193195
# LLaMA v2 70B params.json

0 commit comments

Comments
 (0)