File tree 2 files changed +11
-3
lines changed
backends/candle/src/models
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ struct Qwen2Attention {
22
22
impl Qwen2Attention {
23
23
pub fn load ( vb : VarBuilder , config : & Qwen2Config ) -> Result < Self > {
24
24
if config. use_sliding_window {
25
- candle:: bail!( "Sliding window is not supported" ) ;
25
+ candle:: bail!( "Sliding window is not supported for Qwen2" , ) ;
26
26
}
27
27
28
28
let num_attention_heads = config. num_attention_heads ;
@@ -264,7 +264,15 @@ impl FlashQwen2Model {
264
264
ModelType :: Embedding ( pool) => pool,
265
265
} ;
266
266
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
+ } ;
268
276
269
277
let embeddings = Embedding :: new (
270
278
vb. pp ( "embed_tokens" )
Original file line number Diff line number Diff line change @@ -13,6 +13,6 @@ pub struct Qwen2Config {
13
13
pub max_position_embeddings : usize ,
14
14
pub rms_norm_eps : f32 ,
15
15
pub rope_theta : f32 ,
16
- pub sliding_window : usize ,
16
+ pub sliding_window : Option < usize > ,
17
17
pub use_sliding_window : bool ,
18
18
}
You can’t perform that action at this time.
0 commit comments