Does the Modality Gap Bend When Images Deform?

Vision-language models such as CLIP embed images and captions into one shared space. In practice, the two modalities never fully mix. Image embeddings and text embeddings sit in two separate clusters, offset by a roughly constant direction called the modality gap. A simple linear classifier can tell them apart perfectly on COCO Captions (Towards understanding the modality gap in CLIP). Several practical fixes rest on treating this gap as one fixed vector: subtracting a mean offset after training, or bridging spaces with a single linear layer (Extending Multi-modal Contrastive Representations).

This note asks whether that assumption survives a kind of image change that medical imaging has studied for a decade but multimodal learning has ignored: smooth, non-rigid "rubber-sheet" warps of image content. Biomedical segmentation relies on elastic deformation augmentation, meaning training on images whose pixel coordinates are bent by a smooth random field, because organs and bodies change shape (Deep convolutional networks for pancreas segmentation in CT imaging). A caption like "a dog lying on a couch" does not change when the dog's outline is gently stretched. We hypothesize that the image embedding does change, and that it drifts partly along or across the gap direction. If so, the gap is not a constant offset but a function of shape, and corrections that assume a fixed offset silently fail on deformed inputs. The proposal first measures this effect. It then tests a targeted training fix: warp-invariant alignment with an explicit penalty that keeps the image-to-text offset constant across warp strengths.

Core Claim

The claim has two parts. The first is diagnostic. In pretrained contrastive vision-language models, applying a smooth, invertible elastic warp of increasing strength $s$ to an image moves its embedding in a way that changes the modality gap vector itself, not just semantic content. Here "invertible" means the warp never folds space onto itself, so the Jacobian determinant stays positive. If this holds, it directly tests the linear-gap finding of Ex-MCR, which was established only on rigid CAD shapes and undeformed images. It would also give a mechanistic reason why naive shifting distorts neighborhoods, as Mitigate the Gap observed.

The second part is interventional. Ordinary elastic augmentation only asks the model to recognize warped images. We add a gap-invariance term. Let $\mu_I(s)$ be the mean image embedding over a batch warped at strength $s$, and let $\mu_T$ be the mean text embedding. The gap at strength $s$ is $g(s)=\mu_I(s)-\mu_T$, and we add

$$\mathcal{L}_{\text{gap-inv}} = \mathbb{E}_{s}\,\lVert g(s) - g(0)\rVert_2^2$$

to the standard contrastive loss. Every warped view is also treated as a positive for its original caption. The prediction is that this term flattens the dependence of the gap on shape, and that it does so better than elastic augmentation alone or temperature fixes alone. The term does not force the gap to zero, so it should not collapse the spread of embeddings that classification needs, which Explaining and Mitigating the Modality Gap found matters for zero-shot accuracy.

Research Program

Prior work plays three roles here. Work that supplies the method comes from medical augmentation. Thin-plate spline (TPS) warps perturb a grid of control points and interpolate a smooth field (Deep convolutional networks for pancreas segmentation in CT imaging; DeepOrgan). Topology-preserving variants avoid spurious holes and bridges when warps become aggressive (Topology-preserving augmentation for congenital heart defects). Shape-model constraints keep warps anatomically plausible (anatomy-aware strategy). We reuse TPS with a controllable displacement scale, plus a folding-free variant that integrates a smooth velocity field so the Jacobian determinant stays positive.

Work that motivates the proposal comes from the gap literature. That literature shows the gap is produced by the contrastive loss itself: early repulsion between mismatched pairs, then a temperature drop that freezes the separation, which closes only at rate $\Omega(1/\log(t)^2)$ (Explaining and Mitigating; Towards understanding). It also reports that multimodal alignment is fragile under spatial perturbation (AMLRIS).

Work that constrains the design comes from two directions. Ex-MCR's finding that a linear bridge works inside a pretrained space, and non-linear bridges hurt, is exactly what we stress-test. AlignCLIP's result that shifting damages local structure warns us not to fix a warp-dependent gap by shifting.

The closest bordering work, Ascending the Infinite Ladder, benchmarks whether language-capable vision models can reason about discrete rigid transformations such as Rubik's-cube turns. It finds that they collapse in 3D. It neither trains with deformations nor measures embedding geometry, and its operations are rigid and combinatorial rather than continuous and elastic. The multimodal registration papers, such as Multimodal Elastic Matching of Brain Images and Large Language Models for Multimodal Deformable Image Registration, use "modality" to mean imaging sensors such as CT and MRI, and they treat warping as the task rather than as a tool for studying an image-text embedding space.

The program has three phases. Phase one is a measurement study on frozen pretrained CLIP models, using COCO images and captions. We sweep warp strength and warp type (rigid, TPS, folding-free, deliberately folding) and record five quantities as functions of $s$: the gap norm, the cosine between $g(s)$ and $g(0)$, linear separability, how far each image moves in the direction of the gap compared with other directions, and retrieval recall. Phase two trains small contrastive models from scratch on CC3M at matched compute, comparing training arms that differ only in augmentation and loss. Phase three transfers to grounding, testing referring image segmentation on RefCOCO/RefCOCO+ under elastic test-time warps, where shape change of the referred object is the natural failure mode.

Baselines

The naive reference point is a CLIP model trained on CC3M with its standard augmentation (random resized crops) and a learned temperature. This measures how the gap behaves under warps when nothing is done. The same model with post-hoc mean-shift correction is a second naive reference. It tests whether a fixed offset suffices, and it is the design our diagnostic claim predicts will fail on deformed inputs.

The strongest existing gap-closing method in the file is temperature scheduling from Explaining and Mitigating the Modality Gap. On MSCOCO it reduced the gap from 0.294 to 0.088 and raised image retrieval from 68.2% to 75.7% and text retrieval from 78.4% to 85.3%. It is the strongest competitor because it attacks the cause the theory identifies. We will reimplement it on the same CC3M data, architecture, and step budget, with an equal hyperparameter search budget for its schedule and for our penalty weight. A second strong competitor is AlignCLIP from Mitigate the Gap, which uses shared encoder weights plus text-guided image separation. It raised positive-pair cosine alignment from 0.47 to 0.67 on CC12M; we will train it on CC3M under the same budget. We only claim to beat these if two things hold. First, retrieval on warped COCO test sets must be better at moderate and strong warp levels. Second, the drift of the gap direction across warp strengths must be smaller, while clean retrieval stays within noise of each baseline.

For grounding, the reference is AMLRIS. It reports up to +1.92% mIoU on RefCOCO+ and an average +3.50% mIoU across seven image perturbation scenarios on RefCOCO. Those perturbations do not include elastic warps, so we will rerun its public configuration on our elastic test sets rather than compare against its reported numbers directly.

Four ablations isolate the key ingredient. The first is elastic augmentation with the warped-view positives but without the gap-invariance term; this is the obvious approach, and the penalty must add something beyond it. The second applies the gap-invariance term with rigid-only augmentation, which tests whether non-rigid shape change is what matters. The third uses folding warps instead of folding-free ones. It tests whether the plausibility constraints from medical augmentation carry over, and follows the concern in Topology-preserving augmentation that implausible geometry harms learning. The fourth combines temperature scheduling with our term, to test whether the two are complementary.

Why not just…?

Why not just use temperature scheduling, since it already shrinks the gap? Temperature scheduling shrinks the average gap on clean data. Nothing in Explaining and Mitigating the Modality Gap addresses whether the remaining gap is stable when image geometry changes. This is a real threat: a much smaller gap might leave little room for drift. Phase two settles it directly. If the temperature-scheduled model already shows a flat $g(s)$ across warp strengths and matches our warped-retrieval numbers, the intervention is unnecessary, and the contribution reduces to the diagnostic.

Why not just add elastic warps as one more augmentation? This is the most obvious combination and a serious threat. Warped-view positives alone may already teach shape invariance. The first ablation is designed to answer this. The gap-invariance term earns its place only if it reduces drift of the gap direction and improves warped retrieval beyond augmentation alone. If it does not, we will report that plain elastic augmentation suffices and drop the extra loss.

Why not just subtract the mean gap, or learn a linear bridge as Ex-MCR does? Mitigate the Gap already shows that shifting distorts neighborhood structure on clean data. Our phase-one measurement tests whether a single offset can even be correct under deformation. If the cosine between $g(s)$ and $g(0)$ stays near one at all warp strengths, the fixed-offset view is vindicated for this setting, and that would be a publishable negative result.

Proposed Experiments

The decisive first check is cheap. On frozen CLIP models with COCO, if the gap direction and norm stay essentially constant across folding-free TPS warps up to strengths where humans still read the scene correctly, then the premise fails and we stop. If instead the gap rotates, and the rotation grows faster than semantic change measured by caption-to-image retrieval rank, then shape-dependence of the gap is established, which neither Ex-MCR nor Inf-Bench measured.

The second check is the CC3M training comparison. It is evaluated on clean and graded-warp COCO retrieval (Recall@1/5), zero-shot CIFAR-10/100 to monitor the embedding spread that classification relies on, and ImageNet-R and ImageNet-Sketch. The last two are included because renditions and sketches alter shape, and AlignCLIP reported roughly 2% gains there. The third check is RefCOCO/RefCOCO+ segmentation mIoU under elastic warps applied jointly to the image and its mask, compared against AMLRIS.

A falsifying outcome for the method, as distinct from the diagnostic, is any of the following: the plain elastic-augmentation ablation matching the full method, temperature scheduling matching it on warped retrieval, or a drop in clean retrieval or zero-shot accuracy beyond seed noise. The file contains no image-report medical dataset, so the anatomical setting that motivates elastic warps is left as future work rather than claimed here.