File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
experimental/transformers/qwen2 Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -1554,4 +1554,17 @@ class Qwen2VLForConditionalGenerationBlockInferenceModel(Qwen2ForCausalLMBlockIn
15541554
15551555 # NOTE: (changwenbin) This function corresponds to QWen2-VL's second part, only used for QWen2-VL.
15561556 def __init__ (self , config : Qwen2Config ):
1557- super ().__init__ (config , base_model_prefix = "model" )
1557+ super ().__init__ (config )
1558+ self .qwen2 .base_model_prefix = "model"
1559+
1560+
1561+ class Qwen2_5_VLForConditionalGenerationBlockInferenceModel (Qwen2ForCausalLMBlockInferenceModel ):
1562+ """
1563+ NOTE: (changwenbin) This class inherits from Qwen2ForCausalLMBlockInferenceModel.
1564+ Used only for QWen2-5-VL's second part.
1565+ """
1566+
1567+ # NOTE: (changwenbin) This function corresponds to QWen2-5-VL's second part, only used for QWen2-5-VL.
1568+ def __init__ (self , config : Qwen2Config ):
1569+ super ().__init__ (config )
1570+ self .qwen2 .base_model_prefix = "model"
Original file line number Diff line number Diff line change 213213 ]
214214)
215215
216+ MULTI_MODELS_MAPPING = OrderedDict (
217+ # multi models mapping
218+ [
219+ ("qwen2_vl" , "qwen2" ),
220+ ("qwen2_5_vl" , "qwen2" ),
221+ ]
222+ )
223+
216224
217225def config_class_to_model_type (config ):
218226 """Converts a config class name to the corresponding model type"""
@@ -238,8 +246,9 @@ def __init__(self, mapping):
238246
239247 def __getitem__ (self , key ):
240248 # NOTE: (changwenbin) This is to enable the qwen2_vl language model to use qwen2 reasoning optimization
241- if key == "qwen2_vl" :
242- key = "qwen2"
249+ for model_type , model_key in MULTI_MODELS_MAPPING .items ():
250+ if key == model_type :
251+ key = model_key
243252 if key in self ._extra_content :
244253 return self ._extra_content [key ]
245254 if key not in self ._mapping :
You can’t perform that action at this time.
0 commit comments