Skip to content

Commit 4f882be

Browse files
authored
[Model] Siglip2 Model Support (#27566)
Signed-off-by: piood <[email protected]>
1 parent 9273754 commit 4f882be

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

docs/models/supported_models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ The following table lists those that are tested in vLLM.
775775
| `CLIPModel` | CLIP | T / I | `openai/clip-vit-base-patch32`, `openai/clip-vit-large-patch14`, etc. | | |
776776
| `LlavaNextForConditionalGeneration`<sup>C</sup> | LLaVA-NeXT-based | T / I | `royokong/e5-v` | | ✅︎ |
777777
| `Phi3VForCausalLM`<sup>C</sup> | Phi-3-Vision-based | T + I | `TIGER-Lab/VLM2Vec-Full` | | ✅︎ |
778-
| `SiglipModel` | SigLIP | T / I | `google/siglip-base-patch16-224` | | |
778+
| `SiglipModel` | SigLIP, SigLIP2 | T / I | `google/siglip-base-patch16-224`, `google/siglip2-base-patch16-224` | | |
779779
| `*ForConditionalGeneration`<sup>C</sup>, `*ForCausalLM`<sup>C</sup>, etc. | Generative models | \* | N/A | \* | \* |
780780

781781
<sup>C</sup> Automatically converted into an embedding model via `--convert embed`. ([details](./pooling_models.md#model-conversion))

tests/models/multimodal/pooling/test_siglip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
)
2121

22-
MODELS = ["google/siglip-base-patch16-224"]
22+
MODELS = ["google/siglip-base-patch16-224", "google/siglip2-base-patch16-224"]
2323

2424

2525
def _run_test(

vllm/model_executor/models/siglip.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ class SiglipMultiModalProcessor(BaseMultiModalProcessor[SiglipProcessingInfo]):
174174
@cached_property
175175
def image_token_id(self) -> int:
176176
tokenizer = self.info.get_tokenizer()
177-
dummy_token_id = 0
178-
179-
assert dummy_token_id not in tokenizer.all_special_ids
177+
dummy_token_id = next(
178+
token_id
179+
for token_id in range(tokenizer.vocab_size)
180+
if token_id not in tokenizer.all_special_ids
181+
)
180182

181183
return dummy_token_id
182184

vllm/transformers_utils/config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
)
2727
from transformers import GenerationConfig, PretrainedConfig
2828
from transformers.models.auto.image_processing_auto import get_image_processor_config
29-
from transformers.models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
29+
from transformers.models.auto.modeling_auto import (
30+
MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,
31+
MODEL_MAPPING_NAMES,
32+
)
3033
from transformers.models.auto.tokenization_auto import get_tokenizer_config
3134
from transformers.utils import CONFIG_NAME as HF_CONFIG_NAME
3235

@@ -616,6 +619,13 @@ def get_config(
616619
model_type = MODEL_FOR_CAUSAL_LM_MAPPING_NAMES[config.model_type]
617620
config.update({"architectures": [model_type]})
618621

622+
# Architecture mapping for models without explicit architectures field
623+
if not config.architectures:
624+
if config.model_type not in MODEL_MAPPING_NAMES:
625+
raise ValueError(f"Cannot find architecture name for {config.model_type}")
626+
model_type = MODEL_MAPPING_NAMES[config.model_type]
627+
config.update({"architectures": [model_type]})
628+
619629
# ModelOpt 0.31.0 and after saves the quantization config in the model
620630
# config file.
621631
quantization_config = config_dict.get("quantization_config", None)

0 commit comments

Comments
 (0)