Abstract
Contrastive Language-Image Pre-training (CLIP) has drawn increasing attention recently for its transferable visual representation learning. However, due to the semantic gap within datasets, CLIP's pre-trained image-text alignment becomes sub-optimal on downstream tasks, which severely harms its transferring performance. To better adapt the cross-modality embedding space, we propose to enhance CLIP via Visual-guided Texts, named VT-CLIP. Specifically, we guide textual features of different categories to adaptively explore informative regions on the image and aggregate visual features by attention mechanisms. In this way, the texts become visual-guided, namely, more semantically correlated with downstream images, which greatly benefits the category-wise matching process. In few-shot settings, we evaluate our VT-CLIP on 11 well-known classification datasets to demonstrate its effectiveness.
Introduction
While OpenAI’s CLIP has revolutionized vision-language tasks, it faces a "static" representation challenge. In standard CLIP usage, a prompt like "a photo of a [CLASS]" generates a text feature that remains identical regardless of the specific visual instance—whether a "dog" is a tiny puppy in the corner or a large husky in the center. Existing adaptation methods like CoOp (prompt learning) or CLIP-Adapter (lightweight layers) still produce features that are fixed for all images during inference. This lack of instance-level cross-modal interaction creates a semantic gap that limits CLIP's performance, particularly in few-shot learning scenarios where data is scarce.
Methods: Visual-guided Attention
To bridge this gap, VT-CLIP introduces a Visual-guided Attention Module that allows text prompts to dynamically "look" at the image they are describing.
The process involves several key steps:
- Spatial Feature Extraction: Instead of a single global vector, VT-CLIP utilizes intermediate spatial features (a grid) from the frozen image encoder.
- Cross-Attention Mechanism: The model treats category-name text features as Queries and the spatial image features as Keys and Values.
- Dynamic Adaptation: The text queries the image to identify informative regions. For instance, the feature for "airliner" assigns high attention weights to pixels containing the aircraft.
- Feature Fusion: These visually-informed features are fused with original text features via a residual connection, creating a dynamic representation tailored to the specific image.
By freezing the heavy encoders and only training the lightweight attention module, VT-CLIP remains efficient and less memory-intensive than full model fine-tuning.
Key Insights and Interpretability
VT-CLIP's primary advantage is its instance-level flexibility. Unlike static methods, the text representation changes for every image, allowing for finer alignment. This mechanism also provides inherent interpretability; by visualizing the attention maps, we can see exactly what the text is "looking at."
As shown in the figure above, while Zero-shot CLIP might be distracted by other categories (like "peafowl"), VT-CLIP's visual guidance focuses the textual query on the relevant object, substantially increasing the prediction score for the correct class (over 90% in this instance).
Experimental Results
The model was evaluated across 11 diverse datasets, including general objects (ImageNet), fine-grained categories (OxfordPets, Flowers102), and specialized domains (EuroSAT, DTD).
- Superior Performance: VT-CLIP consistently outperformed Zero-shot CLIP, CoOp, and CLIP-Adapter. In the 16-shot setting, it achieved the highest average accuracy across all benchmarks.
- Stability: In low-shot scenarios (1 or 2 samples), VT-CLIP proved more stable than prompt-learning methods like CoOp, which can struggle to learn complex prompts from minimal data. On datasets like OxfordPets and Food101, where CoOp occasionally underperformed compared to zero-shot CLIP, VT-CLIP maintained a steady lead.
- Optimal Complexity: Ablation studies revealed that a simple configuration—one layer of cross-attention with two heads—provided the best balance, preventing overfitting in data-constrained environments.
Conclusion
VT-CLIP addresses the static nature of CLIP's text representations by introducing a visual-guided attention mechanism. By allowing text to adapt to specific visual contexts, the model achieves state-of-the-art performance in few-shot classification while maintaining efficiency and interpretability. Future work may explore extending this approach to object detection or combining it with advanced prompt-learning techniques.
Summary updated