Explaining and Mitigating the Modality Gap in Contrastive Multimodal Learning

Can Yaras, Siyi Chen, Peng Wang, Qing Qu

TL;DR

Contrastive multimodal models like CLIP suffer from a "modality gap" where image and text embeddings segregate into distinct regions rather than fully aligning. Through continuous-time gradient flow analysis, the authors prove that random initialization causes mismatched pairs to widen the gap early on, while standard learnable temperature schedules lock the gap into an excruciatingly slow $\Omega(1/\log(t)^2)$ closing rate. Guided by this theory, the authors introduce temperature control and modality swapping techniques that shrink the gap and boost cross-modal retrieval performance.

What Problem Does This Paper Address?

In multimodal contrastive learning (e.g., CLIP), models are trained to maximize similarity between matching image-text pairs while pushing mismatched pairs apart. Under ideal global optimization, matching embeddings should align identically. In practice, however, representations exhibit a persistent modality gap: image and text features occupy completely separate cones or approximately parallel manifolds in embedding space.

Existing explanations have remained largely empirical or relied on toy intuitions like information imbalance. This work tackles the fundamental questions: Why does the modality gap emerge at initialization, widen early in training, and stabilize at a non-zero value even after extended optimization?

Methods

The authors analyze the learning dynamics using continuous-time gradient flow under a parallel-embedding formulation:

  • Theoretical Framework: Image and text embeddings are parameterized on parallel hyperplanes separated by a scalar margin $\gamma$, where the modality gap satisfies $\Delta \ge 2\gamma$. The training dynamics of the encoders, the separation parameter $\gamma$, and the inverse temperature $\beta(\nu) = \exp(\nu)$ are tracked via differential equations.
  • Mitigation Strategies:
  • Temperature Control: Because rapid growth of inverse temperature freezes gap shrinkage, the authors propose:
  • Temperature Scheduling (TS): Linearly increasing temperature $\tau = 1/\beta$ across training.
  • Temperature Reparameterization (TR): Using slower-growing parameterizations (e.g., softplus $1/\tau = \log(1 + e^\nu)$).
  • Smaller Learning Rate for Temperature (SLRT): Slowing down the temperature update compared to encoder weights.
  • Fixed Large Temperature (FLT): Freezing $\tau$ at a relatively large constant value.
  • Modality Swapping: Manually disrupting parallel cone separation by exchanging (Hard Swapping, HS) or linearly interpolating (Soft Swapping, SS) feature dimensions between paired images and texts with a certain probability during training.

Datasets

  • Pretraining: MSCOCO (train split) using an OpenCLIP ResNet-50 visual backbone and a Transformer text backbone.
  • Evaluation Benchmarks:
  • MSCOCO test split for image-to-text and text-to-image retrieval.
  • CIFAR-10 for zero-shot classification and linear probing.
  • MMVP-VLM: A benchmark testing visual question answering across 9 visual patterns to evaluate fine-grained multimodal understanding.
  • Synthetic Data: Used for verifying early-stage dynamics and geometric trajectories.

Key Insights and Ideas

  • Mismatches Widen the Gap at Initialization: Under random spherical initialization, cross-entropy loss derivatives reveal that negative pairs exert repelling forces that push the two modalities apart: $\left.\frac{d\Delta}{dt}\right|_{t=0} > 0$. High initial inverse temperatures significantly exacerbate this early separation.
  • Learned Temperature Freezes the Gap: As training proceeds and pairs match, inverse temperature $\beta$ increases exponentially. The authors prove that the ratio between gap contraction and temperature growth decays as $\Theta(1/\beta)$, causing the modality gap to diminish at an impractically slow rate of $\Omega(1/\log(t)^2)$.
  • Closing the Gap Helps Retrieval, Not Classification: Closing the modality gap strongly benefits symmetric cross-modal retrieval. However, zero-shot and linear-probe classification correlate much more strongly with feature space uniformity (spreading features across the hypersphere) rather than closing the modality gap.

Key Results

  • Theory Validation: Practical CLIP models trained on MSCOCO confirm that $\Delta(t)$ versus $-1/\log(t)^2$ follows a strict linear trend, matching the theoretical lower bound.
  • Retrieval Improvements:
  • Baseline CLIP: Modality gap of 0.294; Image Retrieval: 68.23%; Text Retrieval: 78.37%.
  • Temperature Scheduling (TS): Reduced modality gap to 0.088, boosting Image Retrieval to 75.72% (+7.49%) and Text Retrieval to 85.31% (+6.94%).
  • Fixed Large Temperature (FLT, $\tau = 7\cdot 10^{-2}$): Slashed gap to 0.033, yielding 75.53% Image Retrieval and 82.88% Text Retrieval.
  • Soft Swapping (SS): Lowered the gap to 0.139, improving retrieval to 68.91% (image) and 79.16% (text).
  • Classification Trade-Offs: Overly aggressive gap reduction (e.g., FLT with $\tau = 0.1$) degrades uniformity (dropping to -1.251), causing linear probing accuracy to plummet from 65.55% to 48.29%.

Limitations and Future Work

  • Idealized Data Assumptions: The theoretical proofs assume parallel modality embeddings and positive classification margins throughout optimization, which simplifies the complex geometries encountered in real data.
  • Pretraining vs. Fine-tuning: The study primarily focuses on training models from scratch on moderate-scale datasets (MSCOCO with ResNet-50); investigating these dynamics in massive web-scale pretraining (e.g., LAION) remains an open direction.
  • Domain Discrepancy: The authors suggest extending gradient flow analyses to model varying amounts of mutual information across modalities and studying the modality gap during downstream transfer and fine-tuning.

Summary updated

BibTeX
@inproceedings{yaras2025explaining,
  author = {Can Yaras and Siyi Chen and Peng Wang and Qing Qu},
  title = {{Explaining and Mitigating the Modality Gap in Contrastive Multimodal Learning}},
  booktitle = {CPAL (Proceedings Track)},
  year = {2025},
  url = {https://openreview.net/forum?id=2sThreW73a},
}
Figure