Cross-Modal Mapping: Mitigating the Modality Gap for Few-Shot Image Classification

Xi Yang, Pai Peng, Wulin Xie, Xiaohuan Lu, Jie Wen · DOI

TL;DR

This paper introduces Cross-Modal Mapping (CMM), a novel method to bridge the "modality gap" in pre-trained vision-language models like CLIP for few-shot image classification. By aligning image and text features through linear transformation and triplet loss, CMM significantly improves accuracy and efficiency, making it a powerful tool for data-scarce scenarios.

What Problem Does This Paper Address?

Few-shot image classification, the task of identifying new image categories with very few examples, is crucial in domains where data is scarce (e.g., medical imaging). Pre-trained vision-language models (VLMs) like CLIP have shown promise by aligning image and text in a shared embedding space. However, a persistent "modality gap" exists: image and text features, despite being in the same space, don't perfectly align due to differences in how they're processed and the limitations of contrastive learning. This misalignment means that using text descriptions directly as class prototypes for new images often leads to suboptimal performance, especially in fine-grained tasks where subtle visual differences might not correspond well to textual descriptions.

Methods

The authors propose Cross-Modal Mapping (CMM), a two-pronged approach to mitigate the modality gap:

  1. Global Alignment via Linear Transformation: CMM uses a learnable linear transformation matrix ($W$) to map image features into the text feature space. This transformation aims to globally align the distributions of image and text features. Crucially, it uses a residual connection ($W + I_d$) to preserve the original knowledge from the pre-trained model.
  2. Local Refinement via Triplet Loss: After global alignment, local biases might still exist. CMM employs a triplet loss to further refine the relationships between image and text features. It encourages the distance between an image feature and its corresponding text prototype (positive) to be smaller than the distance to incorrect text prototypes (negatives).

Additionally, CMM integrates the output of its own classifier with the original CLIP classifier using a learned fusion coefficient ($\alpha$) to leverage CLIP's zero-shot capabilities.

Datasets

The paper evaluates CMM on 11 standard benchmark datasets for few-shot image classification: Imagenet, Flowers102, Caltech101, FGVC Aircrafts, UCF101, EuroSAT, StanfordCars, DTD, Food101, OxfordPets, and Sun397.

To assess robustness to distribution shifts, they also use 4 distribution-shifted datasets: ImageNet-V2, ImageNet-Sketch, ImageNet-A (adversarial samples), and ImageNet-R (artistic style images).

Key Insights and Ideas

  • The Modality Gap is a Real Bottleneck: The paper provides strong evidence that the misalignment between image and text features in VLMs is a significant impediment to few-shot classification performance, even when using powerful pre-trained models.
  • Linearity is Key for Cross-Modal Alignment: Surprisingly, the study shows that introducing nonlinear transformations (like ReLU activations) degrades performance. This suggests that preserving the geometric relationships learned by linear transformations in VLMs is crucial for effective cross-modal alignment in few-shot settings.
  • Global and Local Alignment Work Synergistically: CMM's success stems from combining a global linear mapping with local triplet loss optimization, effectively addressing both broad distribution mismatches and fine-grained feature relationships.
  • Efficient Adaptation: CMM significantly reduces the need for extensive hyperparameter tuning and computational resources compared to other methods, making it practical for real-world applications.

Key Results

  • CMM achieves an average Top-1 accuracy improvement of 1.06% across 11 benchmark datasets compared to methods that partially fine-tune the backbone.
  • It demonstrates excellent performance on 4 distribution shift datasets, highlighting its generalization capabilities.
  • CMM is significantly more efficient than many existing methods, with a training speed often reported as "<1 min" for certain configurations, while still achieving state-of-the-art results.
  • Ablation studies show that each component of CMM (linear transformation, triplet loss, and fusion with CLIP) contributes to the overall performance gains.

Limitations and Future Work

  • Sensitivity to Textual Descriptions: In datasets with very similar textual descriptions for different classes (e.g., aircraft models), CMM's performance can be slightly lower than methods that fine-tune the encoder, as it relies heavily on the discriminative power of text.
  • 1-Shot Instability: In the extreme 1-shot scenario, CMM's accuracy can fluctuate significantly due to the inherent difficulty of aligning features with very few samples and the impact of single sample quality.
  • Future Work: The authors plan to explore dynamic alignment strategies to further enhance robustness in fine-grained classification and adversarial environments.

Summary updated

BibTeX
@misc{yang2024cross,
  author = {Xi Yang and Pai Peng and Wulin Xie and Xiaohuan Lu and Jie Wen},
  title = {{Cross-Modal Mapping: Mitigating the Modality Gap for Few-Shot Image Classification}},
  year = {2024},
  eprint = {2412.20110},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.20110},
}
Figure