Abstract
Dual encoders and cross encoders have been widely used for image-text retrieval. Between the two, the dual encoder encodes the image and text independently followed by a dot product, while the cross encoder jointly feeds image and text as the input and performs dense multi-modal fusion. These two architectures are typically modeled separately without interaction. In this work, we propose LoopITR, which combines them in the same network for joint learning. Specifically, we let the dual encoder provide hard negatives to the cross encoder, and use the more discriminative cross encoder to distill its predictions back to the dual encoder. Both steps are efficiently performed together in the same model. Our work centers on empirical analyses of this combined architecture, putting the main focus on the design of the distillation objective. Our experimental results highlight the benefits of training the two encoders in the same network, and demonstrate that distillation can be quite effective with just a few hard negative examples. Experiments on two standard datasets (Flickr30K and COCO) show our approach achieves state-of-the-art dual encoder performance when compared with approaches using a similar amount of data.
Introduction
In the field of image-text retrieval, researchers typically choose between two architectural paradigms: Dual Encoders (DE) and Cross Encoders (CE). Dual encoders, such as CLIP, encode images and text separately into a shared embedding space. They are highly efficient because embeddings can be pre-computed, allowing for real-time retrieval via simple dot products. However, they often struggle to capture complex, fine-grained relationships between modalities.
Cross encoders, on the other hand, process image and text inputs jointly through deep cross-attention layers. While significantly more accurate, they are computationally expensive and too slow for large-scale ranking tasks. Historically, these two architectures have been treated as separate entities. LoopITR addresses this gap by integrating both into a unified framework where the "intelligence" of a cross encoder is used to supervise and improve a fast dual encoder during training.
The LoopITR Framework
The LoopITR architecture consists of a ViT-based image encoder and a BERT-based text encoder at its base (the Dual Encoder), with additional cross-attention layers stacked on top (the Cross Encoder). The model operates in a continuous "loop" during training:
- Hard Negative Mining (Bottom-Up): The dual encoder identifies "hard negatives"—images or captions that are semantically similar to the query but are not a correct match. These challenging examples are passed to the cross encoder to help it learn more precise discrimination.
- Knowledge Distillation (Up-Down): The cross encoder acts as an online teacher. It generates a matching score for a pair, which serves as a "soft label" to supervise the dual encoder. This forces the DE to mimic the nuanced similarity scores produced by the more complex CE.
Crucially, this is an online distillation process. Unlike traditional methods that require a pre-trained, frozen teacher model, LoopITR trains both encoders simultaneously. This allows the cross encoder to adapt its teaching as the dual encoder evolves.
Empirical Analysis and Efficiency
A major finding of this research is the efficiency of the distillation process. The authors discovered that it is not necessary to distill against every negative example in a training batch. Using just a few hard negatives ($m=4$) captures nearly all the performance gains while keeping training significantly faster than full-batch distillation.
Further analysis revealed that symmetry is key: distilling from both image-to-text and text-to-image directions yields better results than unidirectional distillation. Additionally, the joint training provides a mutual benefit; while the goal is to improve the dual encoder, the cross encoder also benefits from the better-aligned representations provided by the dual encoder base.
Results and Conclusion
LoopITR achieves state-of-the-art (SOTA) performance for dual encoders on standard benchmarks. On the MS-COCO dataset, it reached a Recall@1 (R@1) of 67.6 for text retrieval, outperforming previous models like ALBEF and CLIP when trained on similar data scales. In zero-shot settings on Flickr30K, the LoopITR dual encoder even surpassed established cross-encoder models like UNITER and OSCAR, proving that complex multi-modal reasoning can be successfully "baked" into a simpler, faster architecture.
By unifying these two paradigms, LoopITR offers a scalable solution for high-performance retrieval without sacrificing the inference speed required for real-world applications. Future work will explore how this "loop" scales to massive datasets containing hundreds of millions of images.
Summary updated