Retrieval-Enhanced Contrastive Vision-Text Models

Ahmet Iscen, Mathilde Caron, Alireza Fathi, Cordelia Schmid

TL;DR

RECO (Retrieval-Enhanced COntrastive) training equips vision-language models like CLIP with an external "memory" to dramatically improve zero-shot performance on fine-grained tasks. By using a lightweight transformer to fuse original embeddings with cross-modal information retrieved at inference time, RECO achieves massive gains—such as +10.9% on Stanford Cars—without retraining the massive base model.

What Problem Does This Paper Address?

Contrastive vision-language models (like CLIP) have revolutionized zero-shot learning, but they have a "fine-grained" blind spot. While they easily recognize a "bird" or a "car," they struggle to distinguish between a Yellow-bellied flycatcher and an Acadian flycatcher.

The traditional fix is scaling: training on billions more images to hope the model "memorizes" these niche entities in its weights. However, this is computationally expensive and inefficient. The authors argue that the root cause is the difficulty of aligning modalities; a short, noisy caption rarely captures the full visual complexity of a specific entity. RECO proposes an alternative: instead of forcing the model to memorize everything, give it a library (an external memory) to look things up when needed.

Methods

RECO works by adding a lightweight, single-layer fusion transformer on top of a frozen pre-trained model (like CLIP or LiT). The core innovation lies in how it uses an external memory $M$ of image-text pairs:

  1. Uni-modal Search: To avoid the "modality gap," RECO performs searches within the same modality. Given a query image, it finds the $k$-nearest neighbor images in the memory. Given a query text, it finds the $k$-nearest neighbor texts.
  2. Cross-modal Fusion: Once the neighbors are found, RECO retrieves the opposite modality. For an image query, it takes the captions of the similar images. For a text query, it takes the images associated with the similar text.
  3. Transformer Refinement: These retrieved cross-modal embeddings are fed into a small fusion transformer (only ~3M parameters) alongside the original query embedding. This allows the model to "refine" its representation using the retrieved knowledge.
Figure 1: RECO works by complementing the frozen representations of pre-trained image-text encoders (such as CLIP) with knowledge retrieved from an external memory. We use an image representation as a query to identify the k most similar images and integrate their associated text embeddings to create a multi-modal representation. Likewise, given a text representation as a query, we find the top-k most similar texts and incorporate their associated images. The fusion of original and retrieved embeddings is done by learning a shallow fusion model to produce improved, multi- modal and knowledge-enhanced versions of the original embeddings. We train for alignment between the refined embeddings, as well as between the refined and original embeddings.

The model is trained using a standard contrastive loss (InfoNCE) but applied to these refined, knowledge-enhanced embeddings.

Datasets

  • Training: The fusion module is trained on Conceptual Captions 12M (CC12M).
  • External Memory: The authors primarily use WebLI (1 billion image-text pairs), but also demonstrate success using the publicly available LAION-400M.
  • Evaluation: A suite of fine-grained classification tasks including Stanford Cars, CUB-2011 (birds), Oxford Flowers, and Stanford Dogs.
  • Entity Recognition: The OVEN (Open-domain Visual Entity Recognition) benchmark, which involves 6 million potential entity candidates.
  • Retrieval: Flickr30k and MS COCO.

Key Insights and Ideas

  • Uni-modal search is the "Easy Button": The authors found that searching for an image using an image (or text using text) is far more reliable than cross-modal search for fine-grained entities. By using the "easy" search to find relevant pairs, they can then extract high-quality "hard" cross-modal information.
  • Complementarity is Key: Fusing cross-modal information (e.g., adding text descriptions to an image embedding) provides a much stronger signal than uni-modal fusion (adding more images to an image embedding). The different modalities provide non-redundant, complementary information.
  • Living Memory: Unlike standard models, RECO's "knowledge" isn't frozen in its weights. You can update the external memory bank with new data after the model is trained, and the performance improves immediately without any further training (see Figure 3).
  • Efficiency: The fusion module is tiny—only about 2% of the total parameters of a CLIP-B/32 model. This makes it a very practical "add-on" for existing systems.
Comparison of search and fusion strategies. Uni-modal search with cross-modal fusion (Ours) performs best.

Key Results

RECO delivers substantial improvements across the board, particularly where fine-grained detail matters:

  • Stanford Cars: +10.9% accuracy over the CLIP baseline.
  • CUB-2011 (Birds): +10.2% accuracy.
  • OVEN Benchmark: An impressive +7.0% improvement in harmonic mean, even outperforming some fine-tuned models on unseen classes.
  • Inference Overhead: While retrieval adds latency, the authors use optimized k-NN search, resulting in only a ~25% overhead compared to a standard CLIP forward pass, which is a small price to pay for the accuracy gains.

Limitations and Future Work

  • Memory Dependency: The model's performance is heavily tied to the quality and size of the external memory. While it works with LAION-400M, the best results require massive private datasets like WebLI.
  • Semantic Ambiguity: The authors noted failure cases when class names are ambiguous. For example, searching for "Bird of Paradise" might retrieve images of the flower rather than the bird, leading to noisy embeddings.
  • Inference Cost: Although optimized, the requirement to perform a k-NN search at inference time makes it slower than a standalone "parametric" model. Future work could explore more efficient retrieval or distillation of this knowledge back into the base model.
Qualitative examples showing how RECO retrieves relevant captions for images and relevant images for text queries.

Summary updated

BibTeX
@inproceedings{iscen2024retrieval,
  author = {Ahmet Iscen and Mathilde Caron and Alireza Fathi and Cordelia Schmid},
  title = {{Retrieval-Enhanced Contrastive Vision-Text Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=b2UlHeyyC0},
}
Figure