Introduction
In the domain of image and video retrieval, researchers have long faced a fundamental trade-off between accuracy and computational efficiency. Traditional approaches generally fall into two categories: Dual Encoders (the "Fast" approach) and Cross-Attention Models (the "Slow" approach).
Dual encoders embed images and text into a shared space independently, allowing for lightning-fast similarity calculations via simple dot products. However, they lack the ability to model fine-grained interactions between specific words and image regions. Conversely, cross-attention models use transformers to compare every word to every image patch. While highly accurate, they are computationally prohibitive for large-scale search; querying a million-image database would require running a heavy transformer a million times for every single search query.
This paper introduces a hybrid framework that mimics the human brain's "Thinking, Fast and Slow" paradigm to bridge this gap, achieving state-of-the-art results with a $100\times$ increase in inference speed compared to traditional transformer-based models.
The Fast and Slow Framework
The proposed framework combines the efficiency of dual encoders with the precision of cross-attention transformers through a three-pronged strategy involving architectural improvements, knowledge distillation, and a two-stage re-ranking pipeline.
A Better "Slow" Model
The authors designed a transformer-based architecture that utilizes gradual upsampling. Most vision transformers lose significant detail by operating on coarse $7 \times 7$ feature maps. By upsampling these features to $56 \times 56$, the model allows the text to "attend" to much finer visual details, which is critical for accurate grounding.
Furthermore, instead of a simple matching loss, the model employs a bi-directional captioning objective (predicting the next word). This generative approach provides a richer training signal, as the cross-entropy loss effectively treats every other word in the vocabulary as a negative example.
Knowledge Distillation and Smart Re-ranking
To enhance the "Fast" model, the authors use the "Slow" model as a teacher during training. The Fast model (the student) is trained to mimic the probability distribution of the Slow model across image batches, successfully transferring the transformer's nuanced understanding into the simpler dual encoder architecture.
At test time, the system employs a "System 1 then System 2" pipeline. The Fast model quickly retrieves the top $K$ (e.g., 50) candidates from the entire dataset. Subsequently, the Slow model only scrutinizes those 50 candidates. This approach provides the accuracy of a full transformer at a fraction of the computational cost.
Key Insights
- Upsampling is Essential for Grounding: Moving from low-resolution to high-resolution feature maps allows the model to distinguish between subtle spatial relationships, such as a "cat on a bike" versus a "cat near a bike."
- Generative vs. Contrastive Loss: Training a retrieval model to generate captions makes it a superior retriever. The dense learning signal from word prediction outperforms simpler contrastive matching losses.
- The Power of Few: One of the most significant findings is that re-ranking only the top 10 to 50 images is often sufficient to match the performance of running the expensive "Slow" model on the entire dataset.
Results and Performance
The "Fast and Slow" approach was evaluated on standard benchmarks including MS-COCO, Flickr30K, and the large-scale Conceptual Captions (CC) dataset. Key results include:
- Efficiency: The re-ranking strategy achieved a $100\times$ reduction in inference time on COCO compared to pure cross-attention models.
- Accuracy: On Flickr30K, the model achieved a Recall@1 of 50.5%, significantly outperforming previous methods like VilBERT while remaining indexable.
- Distillation Gains: Distilling the Slow model into the Fast model improved the Fast model’s standalone performance by over 10% absolute on COCO R@1.
- Versatility: The method also set a new state-of-the-art on the VATEX video retrieval task, proving its effectiveness across different visual domains.
Conclusion
By combining the strengths of dual encoders and cross-attention transformers, the "Fast and Slow" framework offers a scalable solution for high-accuracy visual retrieval. While currently slightly behind massive models pre-trained on significantly larger datasets, the efficiency gains make this paradigm highly practical for real-world applications. Future work may explore scaling the teacher model further or applying this paradigm to tasks like Visual Question Answering (VQA).
Summary updated