Abstract
Cross-modal retrieval systems often face a trade-off between the high accuracy of cross-encoders and the computational efficiency of bi-encoders. This paper presents a fine-tuning framework that bridges this gap by utilizing a two-stage retrieve-and-rerank strategy. We introduce JOINT+COOP, a novel approach that jointly trains bi-encoders and cross-encoders using shared weights. Our results demonstrate that this framework achieves state-of-the-art accuracy on standard benchmarks while reducing search latency by several orders of magnitude, making high-performance cross-modal retrieval feasible for real-world, large-scale applications.
Introduction
The task of cross-modal retrieval—identifying relevant images for a given text query or vice versa—is central to modern search engines and multimedia applications. Currently, the field is divided between two primary architectural paradigms: Cross-Encoders (CE) and Bi-Encoders (BE).
Cross-Encoders, such as OSCAR or M3P, achieve superior performance by employing cross-attention mechanisms that allow for fine-grained interaction between modalities. However, this comes at a significant computational cost; evaluating a single query against a large database requires processing every possible pair, leading to prohibitive latencies. Conversely, Bi-Encoders encode modalities independently into a shared embedding space, enabling rapid similarity searches via vector indexing. While efficient, BEs often lack the nuanced understanding required for complex queries because they do not allow for early-stage cross-modal interaction.
This work addresses the "performance vs. efficiency" deadlock by proposing a cooperative framework that combines the strengths of both architectures.
Methodology: The Retrieve-and-Rerank Framework
We propose a two-stage pipeline designed to optimize both speed and precision. The system first uses a "Scout" (Bi-Encoder) to narrow down the search space and then a "Judge" (Cross-Encoder) to finalize the ranking.
Model Architectures
The framework supports several configurations of these encoders:
- Bi-Encoder (BE): Pre-computes embeddings for the entire corpus. At inference, it quickly identifies a small shortlist of candidates (e.g., top 20).
- Cross-Encoder (CE): Reranks only the shortlist provided by the BE.
- SEP+COOP: The BE and CE are trained independently before being deployed in the pipeline.
- JOINT+COOP: Our primary contribution. The BE and CE are trained simultaneously using a single Transformer backbone with shared weights. This joint training forces the model to learn representations that are effective for both global embedding and local cross-attention.
Experimental Setup
The proposed models were evaluated across a diverse set of benchmarks to ensure robustness:
- MSCOCO & Flickr30k: Standard English image-text retrieval datasets.
- Multi30k: Evaluated multilingual performance in German, French, and Czech.
- Conceptual Captions (CC): Used for zero-shot generalization tests.
- 20k Distractor Set: A custom benchmark created by the authors to simulate more realistic, large-scale retrieval scenarios where performance typically degrades compared to smaller, cleaner datasets.
Results and Discussion
Our experiments reveal significant improvements in both latency and accuracy.
Efficiency Gains
The retrieve-and-rerank approach offers a massive reduction in latency. For a database of one million images, a standard Cross-Encoder requires approximately 36 minutes to process a query. Our framework reduces this to just 94 milliseconds—a ~23,000x speedup. We found that reranking just the top 20 candidates (k=20) is sufficient to capture nearly all the accuracy benefits of a full cross-encoder.
Accuracy and Joint Training
The JOINT+COOP model outperformed standalone architectures. On the MSCOCO 5k test set, it achieved a Recall@1 (R@1) of 54.7 for image retrieval, surpassing the original OSCAR cross-encoder (54.0). This suggests that joint training with shared weights acts as a form of regularization, helping the model benefit from two different perspectives: global semantic embeddings and local cross-modal attention.
Insights on Sample Efficiency
We observed that Bi-Encoders are generally less sample-efficient than Cross-Encoders. Without the benefit of early cross-attention to align modalities, BEs require more training data to achieve comparable performance levels.
Conclusion and Future Work
This paper demonstrates that the trade-off between retrieval speed and accuracy is not insurmountable. By training bi-encoders and cross-encoders jointly, we can create systems that are both highly precise and computationally efficient.
While successful, challenges remain. Storing pre-computed embeddings for massive datasets requires significant memory overhead. Future research will focus on extending this framework to video and audio modalities and exploring more memory-efficient embedding techniques to handle even larger "distractor" sets in real-world environments.
Summary updated