CLIP-style dual encoders map images and text through two separate towers into a shared embedding space where the two modalities occupy distinct regions separated by a modality gap. Retrieval fails when wrong matches or hard negatives outrank the correct pair and the gap is usually blamed. Yet removing it post hoc degrades retrieval on every CLIP checkpoint the authors test. This unexpected result motivates a different approach: rather than erasing the gap, the authors seek to narrow it selectively around the instances that cause failures.

A Paired Statistic for Hard-Negative Direction Identification

The authors introduce a paired statistic that identifies directions where the two towers agree more on hard negatives than on matched pairs. This statistic is computed from 25,000 labelled pairs in seconds. Mildly attenuating these directions improves retrieval while largely preserving the gap. The statistic reveals that the two towers exhibit correlated behaviour on hard examples in weight space, and targeting this correlation yields the observed gains.

Weight-Space Programming via an LLM Agent

Guided by the statistic, an LLM agent inspects both towers and writes closed-form weight edits without backpropagation. The agent is free to edit any component and improves COCO test retrieval on all 13 CLIP checkpoints, editing an output projection in 12 of the 13. This demonstrates that weight-space edits can be both effective and broadly applicable across checkpoints without requiring gradient-based optimization.

Distilling TowerBridge: A Closed-Form Recipe

The authors distill and refine the agent's recurring correction into TowerBridge, a closed-form recipe motivated by a first-order analysis of the hard-negative margin. The recipe requires no model-specific tuning and leaves the architecture and inference cost unchanged. Computed from 25,000 labelled pairs, it provides a repeatable correction that can be applied to any CLIP-style dual encoder.

Retrieval Improvements Across CLIP Checkpoints

TowerBridge improves COCO test retrieval by 16.8 RSUM and Flickr30k test retrieval by 6.6 on average across all 21 evaluated CLIP checkpoints, including 8 checkpoints unseen by the agent. The gains are consistent across the full set, indicating that the correction generalizes beyond the specific checkpoints used during agent exploration.

Preserving the Modality Gap While Gaining Accuracy

The correction limits any drop in ImageNet zero-shot accuracy to 0.5 points. This shows that the approach narrows the gap selectively around hard instances without broadly collapsing the modality separation that supports zero-shot classification.

Hubness Reduction and Cross-Family Generalization

TowerBridge reduces hubness on all 21 checkpoints. It also improves retrieval on 4 of 5 dual encoders from other families, demonstrating that the underlying principle extends beyond the CLIP family of models.

Limitations and Trade-Offs

The authors acknowledge that the 0.5-point ImageNet accuracy drop, while small, is a non-zero trade-off. The method relies on a paired statistic computed from a fixed set of 25,000 labelled pairs, and its effectiveness may vary with different data distributions or encoder architectures outside the tested families.

Read the paper on arXiv