Skip to content

Commit 42c4a0d

Browse files
committed
Push model prefix only if existing
1 parent 2fed95b commit 42c4a0d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

backends/candle/src/models/flash_qwen2.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,15 @@ impl FlashQwen2Model {
264264
ModelType::Embedding(pool) => pool,
265265
};
266266

267-
let vb = vb.pp("model");
267+
// Pushing the prefix for `model` is apparently only required if the model architecture is
268+
// ForCausalLM as it contains the `lm_head`, other than that, the `model` key won't be
269+
// present e.g. a model without the `model` key as it's a `Qwen2Model` instance not a
270+
// `Qwen2ModelForCausalLM` is https://huggingface.co/mims-harvard/ToolRAG-T1-GTE-Qwen2-1.5B
271+
let vb = if vb.contains_tensor("model.embed_tokens.weight") {
272+
vb.pp("model")
273+
} else {
274+
vb
275+
};
268276

269277
let embeddings = Embedding::new(
270278
vb.pp("embed_tokens")

0 commit comments

Comments
 (0)