diff --git a/vllm/entrypoints/chat_utils.py b/vllm/entrypoints/chat_utils.py index 1643906894c6..a5083fed7b28 100644 --- a/vllm/entrypoints/chat_utils.py +++ b/vllm/entrypoints/chat_utils.py @@ -51,6 +51,9 @@ from vllm.multimodal.utils import MEDIA_CONNECTOR_REGISTRY, MediaConnector from vllm.tokenizers import MistralTokenizer, TokenizerLike from vllm.transformers_utils.chat_templates import get_chat_template_fallback_path +from vllm.transformers_utils.chat_templates.registry import ( + _SKIP_TOKENIZER_CHAT_TEMPLATE, +) from vllm.transformers_utils.processor import cached_get_processor from vllm.utils import random_uuid from vllm.utils.func_utils import supports_kw @@ -504,14 +507,15 @@ def resolve_hf_chat_template( return chat_template # 3rd priority: AutoTokenizer chat template - try: - return tokenizer.get_chat_template(chat_template, tools=tools) - except Exception: - logger.debug( - "Failed to load AutoTokenizer chat template for %s", - tokenizer.name_or_path, - exc_info=True, - ) + if model_config.hf_config.model_type not in _SKIP_TOKENIZER_CHAT_TEMPLATE: + try: + return tokenizer.get_chat_template(chat_template, tools=tools) + except Exception: + logger.debug( + "Failed to load AutoTokenizer chat template for %s", + tokenizer.name_or_path, + exc_info=True, + ) # 4th priority: Predefined fallbacks path = get_chat_template_fallback_path( diff --git a/vllm/transformers_utils/chat_templates/registry.py b/vllm/transformers_utils/chat_templates/registry.py index fe84b6c152ee..2a5134ad76b9 100644 --- a/vllm/transformers_utils/chat_templates/registry.py +++ b/vllm/transformers_utils/chat_templates/registry.py @@ -43,6 +43,9 @@ def _get_minicpmv_chat_template_fallback(tokenizer_name_or_path: str) -> Path | "siglip2": CHAT_TEMPLATES_DIR / "template_basic.jinja", } +# These model types skip tokenizer chat template and use fallback directly +_SKIP_TOKENIZER_CHAT_TEMPLATE: set[str] = {"siglip", "siglip2"} + def register_chat_template_fallback_path( model_type: str,