Dual encoder correction improves image text retrieval accuracy

TowerBridge: Bridging the Dual-Encoder Modality Gap via Weight-Space Programming

Computer Vision and Pattern RecognitionMachine Learning

Summary

Matching images to their descriptions can be tough because the computer treats pictures and words differently, creating a 'gap' between them. The authors found a way to adjust the model's inner parts without retraining to make it better at matching images with the right text. Their method, called TowerBridge, keeps the gap but reduces mistakes, improving search results on standard tests without slowing down the model or losing accuracy on other tasks.

What this means in practice

  • For image search engineers: Improve the accuracy of image-to-text and text-to-image search without retraining by applying TowerBridge corrections to existing dual-encoder models.
  • For multimodal ai developers: Use TowerBridge to reduce retrieval errors in systems combining images and text across different dual encoder architectures, improving consistency and precision.

Authors

Hani Alomari, Md Atabuzzaman, Chris Thomas

Abstract

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 one, and the gap is the usual suspect. Yet removing it post hoc degrades retrieval on every CLIP checkpoint we test. We introduce a paired statistic that identifies directions where the two towers agree more on hard negatives than on matched pairs. Mildly attenuating these directions improves retrieval while largely preserving the gap. We arrive at this correction through weight-space programming: guided by the statistic, an LLM agent inspects both towers and writes closed-form weight edits without backpropagation. Free to edit any component, the agent improves COCO test retrieval on all 13 CLIP checkpoints and edits an output projection in 12 of the 13. We distill and refine its recurring correction into TowerBridge, a closed-form recipe motivated by a first-order analysis of the hard-negative margin. Computed in seconds from 25,000 labelled pairs, it requires no model-specific tuning and leaves the architecture and inference cost unchanged. 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 unseen by the agent, while limiting any drop in ImageNet zero-shot accuracy to 0.5 points. It also reduces hubness on all 21 checkpoints and improves retrieval on 4 of 5 dual encoders from other families.