Does the Modality Gap Make CLIP Retrieval Seed-Dependent?

Image-text models such as CLIP (Contrastive Language-Image Pre-training, which trains an image encoder and a text encoder so that matching pairs land close together) are routinely compared by a single number such as retrieval recall or zero-shot accuracy. If you retrain the same model with a different random seed, that number barely moves. Work on word and graph embeddings, however, shows that stable averages can hide large changes underneath. The individual nearest neighbors and the individual predictions often change from run to run. Nobody has measured this for image-text models. In particular, nobody has asked whether a known quirk of these models, the "modality gap" (image embeddings and text embeddings sit in two separate regions of the shared space instead of mixing), is one of the reasons individual retrievals change between seeds.

This note proposes a specific mechanism and a cheap test of it. Because of the gap, every retrieval score contains a term that does not depend on the query. It acts like a per-caption "popularity" bonus that comes from the offset between the two clusters. If that offset is set by the seed, then the bonus is seed-specific, and some of the captions an image retrieves will change between seeds for reasons unrelated to meaning. Removing this term from the query side should then make individual retrievals agree more across seeds. The prediction can fail cleanly: a competing account says the gap acts as a protective buffer, and under that account removing it would make retrievals more fragile.

Core Claim

Write each image embedding as $i = \mu_I + \tilde i$ and each text embedding as $t = \mu_T + \tilde t$. Here $\mu_I$ and $\mu_T$ are the two modality centroids, and $\tilde i, \tilde t$ are each item's deviation from its own centroid. The similarity score then splits into four parts:

$$ \langle i, t\rangle = \langle \mu_I,\mu_T\rangle + \langle \mu_I,\tilde t\rangle + \langle \tilde i,\mu_T\rangle + \langle \tilde i,\tilde t\rangle . $$

When an image queries a gallery of captions, the first and third terms are the same for every caption and do not affect the ranking. The ranking is decided by the meaningful interaction $\langle \tilde i,\tilde t\rangle$ plus a caption bias $b(t)=\langle \mu_I,\tilde t\rangle$ that is identical for every image query. Text-to-image retrieval has the mirror-image bias $\langle \tilde i,\mu_T\rangle$.

The claim has three parts. First, the gap direction $\mu_I-\mu_T$ and the bias $b$ vary substantially across seeds, even after the runs are rotated into a common frame. Second, the interaction term $\langle \tilde i,\tilde t\rangle$ is markedly more consistent across seeds than the raw score. Third, as a consequence, centering the query removes the bias term and raises the fraction of queries whose top retrieval is the same across seeds. This "stable core" should rise by more than what we get from removing a random direction of equal size, and it should do so without lowering mean recall.

What Is Known and What Is New

Three papers motivate the question. Mind the Gap shows that the gap already exists at random initialization. Deep nonlinear encoders squeeze outputs into narrow cones, and two independently initialized encoders point their cones in different directions. The contrastive loss then preserves the separation. That paper initializes from random weights, but it never asks whether the gap's direction is reproducible across seeds. Towards understanding the modality gap in CLIP shows on toy 3D spheres that the multimodal contrastive loss has local minima that trap the two modalities apart. Different seeds landing in different minima is exactly what would make the gap seed-specific. I0T traces the gap to a few modality-specific spike dimensions in one Long-CLIP checkpoint. If those spikes appear at different coordinates for different seeds, they are a natural carrier of the seed-specific bias $b$.

The stability side supplies the methods. Towards Qualitative Word Embeddings Evaluation defines neighbor variation, the fraction of an item's top-$k$ neighbors that change between runs. It reports 0.17 for identical Skip-gram retrains, which we use only as an orientation point from text. The Effects of Randomness on the Stability of Node Embeddings defines the stable core, the fraction of items whose predicted label is identical across all seeds. It shows that micro-F1 can stay flat while the stable core is low. Procrustes alignment, used in On the Surprising Behaviour of node2vec to compare runs, gives us the common frame needed to compare gap vectors. We reuse all three tools without changing them.

The papers that intervene on the gap constrain the design. Is the Modality Gap a Bug or a Feature? argues the gap is orthogonal to both modalities' subspaces and buffers against input noise, reporting up to 10% robustness gains under Gaussian noise. Its argument implies that closing the gap could also make retrievals more sensitive to training noise, which is the opposite of our prediction. Mitigate the Gap warns that mean subtraction distorts within-modality neighborhoods, so we measure those neighborhoods too. These papers, along with It's Not a Modality Gap, judge their fixes on one checkpoint by aggregate scores. We judge them on agreement across seeds.

The contribution is therefore not a new gap-closing method. It is a measurement of seed-induced churn in image-text models, a decomposition that assigns part of that churn to the gap-induced bias term, and a causal test that removes that term.

Research Program

We train two families of models.

The first family uses the cheaper fine-tuning regime of It's Not a Modality Gap. We start from a fixed pretrained CLIP and fine-tune on MS COCO captions with eight seeds. The seeds vary data order and head initialization, while hyperparameters and step counts stay identical.

The second family is trained from scratch with the MetaCLIP codebase. We use eight seeds of a small CLIP on a fixed curated subset with an identical schedule. In a factorial split, four seeds vary only weight initialization and four vary only data order. This tells us which source of randomness moves the gap.

For each run we compute four things on the COCO and Flickr30k test splits:

  • Gap geometry. We record the centroids, the gap vector, and the I0T-style spike dimensions.
  • Interaction stability. We record the full score matrix and its centered interaction matrix.
  • Neighbor variation. We record neighbor variation with $k=10$ for image-to-text neighbors, image-to-image neighbors, and text-to-text neighbors.
  • Prediction stability. We record the top-1 retrieval stable core, plus the zero-shot prediction stable core on CIFAR-10/100 and ImageNet.

To compare gap vectors across runs, we fit an orthogonal Procrustes map between each pair of runs using paired embeddings of the same images and texts. We then report the cosine between aligned gap vectors. As a control, we report the same cosine between aligned per-class centroid differences, which tells us what "consistent" looks like for directions that carry meaning.

The decomposition analysis asks three questions. Across seeds, how much of the variance in raw scores is variance in the bias term $b$? Among queries whose top-1 caption changes between two seeds, how often does the switch disappear once each run's $b$ is subtracted? Is $b$ concentrated in each run's spike dimensions, and do those dimensions coincide across seeds?

Baselines

The naive reference is uncorrected CLIP evaluated seed by seed. Its across-seed neighbor variation and stable core are the quantities everything else must improve on. Its mean recall is the bar that corrections must not fall below. No reported result was found on Lacuna for cross-seed neighbor variation or stable core in any image-text model, so these numbers are produced here.

The strongest existing training-free method is I0T_post from I0T. It subtracts modality means and renormalizes. On Flickr30k that paper reports image-to-text retrieval accuracy rising from 69.60% for CLIP to 73.30%, and text-to-image from 67.10% to 76.30%. It is the strongest competitor because it already removes the bias term as a side effect. Our claim is that its benefit includes a stability gain no one has measured. We run it on every seed with centroids estimated on a held-out split of the same data, so that no test statistics leak.

The second training-free competitor is the closed-form orthogonal-gap projection of Is the Modality Gap a Bug or a Feature?, which moves one modality along the gap vector only. We run it on the same checkpoints and data.

Training-time competitors are the uniformity and alignment losses of It's Not a Modality Gap and the shared-parameter model of Mitigate the Gap. For the uniformity and alignment losses, the authors report COCO centroid distance falling from 0.66 to 0.08 and Caltech101 zero-shot accuracy rising from 0.42 to 0.49. For the shared-parameter model, the authors report positive-pair cosine rising from 0.47 to 0.67. Each is trained with the same eight seeds, data, steps, and a matched hyperparameter sweep of equal size. A seed ensemble that averages scores over all eight runs serves as an upper bound that costs eight times as much compute.

The key ablation replaces query centering with removal of a random direction of the same norm. It also compares query-side centering against gallery-side centering without renormalization. Gallery-side centering of that kind leaves rankings unchanged by construction, so it is a built-in sanity check.

Beating the field means three things. Query centering must raise the top-1 stable core by more than the random-direction ablation, with confidence intervals obtained by resampling seed pairs. It must do so while matching I0T_post's mean recall. It must also keep within-modality neighbor variation no worse than the uncorrected model.

Why not just…?

Why not just align the runs with Procrustes? A rotation applied to both modalities leaves every cosine score unchanged. Procrustes can therefore put runs in a common frame for measurement, which is how we use it, but it cannot change which caption any run retrieves. Churn that lives in the rankings is untouched by it.

Why not just ensemble several seeds? This is a real threat on stability alone. Averaging eight models will almost certainly raise agreement. We include the ensemble as an upper bound and report what fraction of its stability gain single-model query centering recovers at one-eighth of the cost. If that fraction is small, the practical case for the mechanism weakens and we will say so.

Why not just report seed variance of recall? The Effects of Randomness on the Stability of Node Embeddings shows flat micro-F1 alongside widespread per-item label flips. Towards Qualitative Word Embeddings Evaluation shows models with matching benchmark scores whose neighborhoods differ by 40% or more. We report recall variance as well, expecting it to be small, to make exactly this contrast.

Why not assume the flips are just near-ties? Flips may simply concentrate on queries whose top two captions score almost equally, regardless of the gap. We control for this by binning queries by their margin, computed from the interaction term alone. We then test whether removing the bias term still reduces flips within margin bins. If it does not, the gap mechanism is falsified.

Decisive Checks

The idea is supported if three things hold. First, aligned gap vectors agree across seeds clearly less than aligned class-centroid differences do. Second, a substantial share of cross-seed top-1 switches on COCO and Flickr30k disappear once the bias term is removed. Third, query centering beats the random-direction ablation on the stable core within margin bins, without recall loss.

The idea is refuted in either of two cases. Gap directions may turn out to be as reproducible as directions that carry meaning, which would make the bias term seed-stable. Alternatively, centering may lower the stable core, which would side with the buffer account of Is the Modality Gap a Bug or a Feature? at the level of training noise. Either outcome would be publishable and would settle part of the bug-versus-feature dispute along an axis that dispute has not yet examined.

A secondary check tests whether I0T's spike dimensions reappear at the same coordinates across from-scratch seeds. If they do, they come from the architecture rather than from chance during training.