@@ -138,8 +138,8 @@ def supports_multimodal_inputs(self, model_config: "ModelConfig") -> bool:
138
138
if not model_config .is_multimodal_model :
139
139
return False
140
140
141
- processor = self .create_processor (model_config , disable_cache = False )
142
- supported_modalities = processor . info .get_supported_mm_limits ()
141
+ info = self ._create_processing_info (model_config , tokenizer = None )
142
+ supported_modalities = info .get_supported_mm_limits ()
143
143
144
144
mm_config = model_config .get_multimodal_config ()
145
145
@@ -278,6 +278,26 @@ def _get_model_cls(self, model_config: "ModelConfig"):
278
278
model_cls , _ = get_model_architecture (model_config )
279
279
return model_cls
280
280
281
+ def _create_processing_ctx (
282
+ self ,
283
+ model_config : "ModelConfig" ,
284
+ tokenizer : Optional [AnyTokenizer ] = None ,
285
+ ) -> InputProcessingContext :
286
+ if tokenizer is None and not model_config .skip_tokenizer_init :
287
+ tokenizer = cached_tokenizer_from_config (model_config )
288
+ return InputProcessingContext (model_config , tokenizer )
289
+
290
+ def _create_processing_info (
291
+ self ,
292
+ model_config : "ModelConfig" ,
293
+ * ,
294
+ tokenizer : Optional [AnyTokenizer ] = None ,
295
+ ) -> BaseProcessingInfo :
296
+ model_cls = self ._get_model_cls (model_config )
297
+ factories = self ._processor_factories [model_cls ]
298
+ ctx = self ._create_processing_ctx (model_config , tokenizer )
299
+ return factories .info (ctx )
300
+
281
301
def create_processor (
282
302
self ,
283
303
model_config : "ModelConfig" ,
@@ -291,15 +311,13 @@ def create_processor(
291
311
if not model_config .is_multimodal_model :
292
312
raise ValueError (f"{ model_config .model } is not a multimodal model" )
293
313
294
- if tokenizer is None and not model_config .skip_tokenizer_init :
295
- tokenizer = cached_tokenizer_from_config (model_config )
296
314
if disable_cache is None :
297
315
disable_cache = not model_config .enable_mm_processor_cache
298
316
299
317
model_cls = self ._get_model_cls (model_config )
300
318
factories = self ._processor_factories [model_cls ]
301
319
302
- ctx = InputProcessingContext (model_config , tokenizer )
320
+ ctx = self . _create_processing_ctx (model_config , tokenizer )
303
321
cache = None if disable_cache else self ._get_processor_cache (
304
322
model_config )
305
323
0 commit comments