Abstract
Multimodal learning has recently gained significant popularity, demonstrating impressive performance across various zero-shot classification tasks and a range of perceptive and generative applications. Models such as Contrastive Language-Image Pretraining (CLIP) are designed to bridge different modalities, such as images and text, by learning a shared representation space through contrastive learning. Despite their success, the working mechanisms underlying multimodal learning are not yet well understood. Notably, these models often exhibit a modality gap, where different modalities occupy distinct regions within the shared representation space. In this work, we conduct an in-depth analysis of the emergence of modality gap by characterizing the gradient flow learning dynamics. Specifically, we identify the critical roles of mismatched data pairs and a learnable temperature parameter in causing and perpetuating the modality gap during training. Furthermore, our theoretical insights are validated through experiments on practical CLIP models. These findings provide principled guidance for mitigating the modality gap, including strategies such as appropriate temperature scheduling and modality swapping. Additionally, we demonstrate that closing the modality gap leads to improved performance on tasks such as image-text retrieval.
Introduction
Contrastive Language-Image Pretraining (CLIP) has revolutionized multimodal AI by mapping images and text into a shared mathematical space. Ideally, semantically identical concepts across modalities—such as a photograph of a cat and the word "cat"—should occupy the same coordinates. However, empirical observations have consistently revealed a "modality gap": image and text embeddings tend to cluster into two distinct, parallel regions. While this gap has been documented, the underlying mechanisms preventing its closure during training have remained elusive. This paper provides a rigorous theoretical explanation for the modality gap and introduces practical strategies to bridge it.
Theoretical Analysis of the Modality Gap
The core of this research lies in gradient flow analysis, which models the "physics" of parameter updates during contrastive learning. The study identifies two primary drivers of the modality gap: initial data mismatches and the dynamics of the learnable temperature parameter ($\tau$).
The Two-Phase Evolution
The learning dynamics can be divided into two distinct phases:
- Enlargement Phase: At the onset of training, random initialization leads to a high number of "mismatched" pairs. The gradient flow analysis proves that these initial mismatches actually push the modalities further apart, enlarging the gap before alignment begins.
- Stabilization Phase: As training progresses, the learnable temperature $\tau$ typically decreases. This decrease increases the "repulsion" between modalities. Because $\tau$ drops faster than the alignment process can pull the modalities together, the gap becomes "stabilized" or stuck at a non-zero distance.
The most significant theoretical finding is that the modality gap diminishes at an agonizingly slow rate of $\Omega(1/\log(t)^2)$. This logarithmic decay implies that the gap would effectively require infinite training time to close completely under standard settings.
Mitigation Strategies
Based on these theoretical insights, the authors propose two categories of interventions:
- Temperature Control: To prevent the "temperature trap," they suggest Temperature Scheduling (TS)—linearly increasing the temperature over time—or Temperature Reparameterization (TR) using functions like softplus to prevent $\tau$ from dropping too rapidly.
- Modality Swapping: To manually break the separation between modality clusters, they introduced Hard Swapping (HS) and Soft Swapping (SS). These techniques involve occasionally treating image features as text features (and vice versa) during the contrastive loss calculation.
Experimental Results
The proposed strategies were validated on synthetic data and real-world benchmarks including MSCOCO and CIFAR-10.
- Gap Reduction: Temperature Scheduling (TS) successfully reduced the modality gap from 0.294 to 0.088.
- Retrieval Performance: Closing the gap yielded substantial gains in image-text retrieval. On MSCOCO, image retrieval accuracy improved from 68.2% to 75.7%, while text retrieval rose from 78.4% to 85.3%.
- Zero-Shot Classification: Zero-shot accuracy on CIFAR-10 increased from 13.6% to 17.1% using the TS method.
Crucially, the experiments confirmed that while closing the gap is vital for retrieval tasks, classification performance is more heavily influenced by the uniformity of the feature distribution (how well features are spread across the hypersphere).
Conclusion
This work provides a principled understanding of why images and text stay apart in contrastive learning. By identifying the logarithmic decay of the modality gap and the role of temperature dynamics, the researchers have turned an empirical observation into a solvable optimization problem. Future research will explore more complex, non-parallel data distributions and the impact of varying shared information between modalities.
Reference: Yaras, C., Chen, S., Wang, P., & Qu, Q. (2026). Explaining and Mitigating the Modality Gap in Contrastive Multimodal Learning. arXiv:2412.07909v2.
Summary updated