Migrating to Transformers v4.49.0-SigLIP-2
Version v4.49.0-SigLIP-2 introduces 4 breaking changes. This guide details how to update your code.
Released: 2/21/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
Siglip2ModelSiglip2ProcessorSiglip2VisionModelSiglip2TextModelGemmaTokenizerFastBreaking Changes
●Issue #1
When using SigLIP2 models, the output logits should be processed using the sigmoid activation function instead of softmax, as the training loss differs from standard CLIP models.
✓Solution
Replace any usage of softmax on the output logits of SigLIP2 models with torch.sigmoid().
●Issue #2
If using the standalone [GemmaTokenizerFast] for text preprocessing with SigLIP2, specific padding arguments are required to match training configuration.
✓Solution
When using GemmaTokenizerFast, ensure you pass padding="max_length" and max_length=64 during tokenization.
●Issue #3
The model was trained with lowercased text, meaning input text labels must match this format for optimal performance.
✓Solution
Ensure all text labels used for classification or retrieval tasks are converted to lowercase before processing.
●Issue #4
To achieve results consistent with the provided examples (especially for zero-shot classification), a specific prompt template must be used.
✓Solution
Use the prompt template "this is a photo of {label}" when formatting text inputs for classification tasks.
Migration Steps
- 1If you are installing this new version via Git, update your installation command to use the specific tag: `pip install git+https://github.com/huggingface/transformers@v4.49.0-SigLIP-2`.
- 2If you are using SigLIP2 models, modify your inference code to apply torch.sigmoid() to the raw output logits instead of torch.softmax().
- 3If you are manually tokenizing text inputs for SigLIP2 using GemmaTokenizerFast, ensure you set `padding="max_length"` and `max_length=64`.
- 4Verify that all text inputs (labels or prompts) passed to the SigLIP2 model are lowercased.
- 5If using the model for zero-shot classification, adopt the recommended prompt template: "this is a photo of {label}".
Release Summary
This release introduces SigLIP-2, a new family of multilingual vision-language encoders featuring improved semantic understanding and support for native aspect ratio image processing via the NaFlex variant.
Need More Details?
View the full release notes and all changes for Transformers v4.49.0-SigLIP-2.
View Full Changelog