Retrieval-Enhanced Contrastive Vision-Text Models

Ahmet Iscen, Mathilde Caron, Alireza Fathi, Cordelia Schmid · OpenReview

Abstract

Contrastive image-text models such as CLIP form the building blocks of many state-of-the-art systems. While they excel at recognizing common generic concepts, they still struggle on fine-grained entities which are rare, or even absent from the pre-training dataset. Hence, a key ingredient to their success has been the use of large-scale curated pre-training data aiming at expanding the set of concepts that they can memorize during the pre-training stage. In this work, we explore an alternative to encoding fine-grained knowledge directly into the model's parameters: we instead train the model to retrieve this knowledge from an external memory. Specifically, we propose to equip existing vision-text models with the ability to refine their embedding with cross-modal retrieved information from a memory at inference time, which greatly improves their zero-shot predictions. Remarkably, we show that this can be done with a light-weight, single-layer, fusion transformer on top of a frozen CLIP. Our experiments validate that our retrieval-enhanced contrastive (RECO) training improves CLIP performance substantially on several challenging fine-grained tasks: for example +10.9 on Stanford Cars, +10.2 on CUB-2011 and +7.3 on the recent OVEN benchmark.

Introduction

State-of-the-art vision-language models (VLMs) like CLIP have revolutionized zero-shot visual recognition. However, their performance often degrades when encountering fine-grained or rare entities—the "long tail" of visual concepts. Traditionally, the solution has been to scale up pre-training datasets to ensure these concepts are "memorized" within the model's weights. This approach is computationally expensive and often fails to capture the nuances of rare entities.

This paper introduces RECO (Retrieval-Enhanced COntrastive models), which shifts the paradigm from pure memorization to a retrieval-augmented approach. By consulting an external "knowledge book" at inference time, RECO allows models to refine their internal representations with specific, retrieved details.

The RECO Architecture

The RECO framework augments a frozen dual-encoder (e.g., CLIP) with a lightweight fusion transformer. This module, comprising only about 2% of the total parameters, is trained to integrate retrieved information into the query's embedding.

The RECO architecture: Uni-modal search followed by cross-modal fusion.

The inference process follows two distinct steps:

  1. Uni-modal Search: Given an input query (image or text), the system performs a k-Nearest Neighbor (k-NN) search within an external memory of image-text pairs. Crucially, this search is within-modality (e.g., image-to-image), leveraging the fact that current models are highly effective at identifying visual or textual similarity within the same domain.
  2. Cross-modal Fusion: The system retrieves the complementary modality from the memory. For an image query, it retrieves the captions of the most similar images. A single-layer fusion transformer then aggregates these "cross-modal hints" with the original query embedding to produce a refined, knowledge-enhanced representation.

Analysis of Search and Fusion Strategies

A key contribution of this work is the analysis of different retrieval paradigms. The authors compared four combinations of search and fusion modalities to determine the most effective way to leverage external memory.

Comparison of different search and fusion strategies. Uni-modal search with cross-modal fusion (RECO) proves most effective.

The experiments revealed that uni-modal search combined with cross-modal fusion is the most effective strategy. Searching for similar images to find relevant text is more robust than trying to bridge the semantic gap directly via cross-modal search (image-to-text) for rare entities. Furthermore, fusing an image with retrieved text provides a stronger "labeling" signal than simply fusing it with more images.

Experimental Results

RECO was evaluated on several challenging fine-grained benchmarks, using a 1-billion-pair subset of WebLI as the external memory. The base encoders remained frozen throughout.

  • Fine-Grained Recognition: RECO achieved significant gains over the CLIP-B/32 baseline: +10.9% on Stanford Cars and +10.2% on CUB-2011 (Birds).
  • Open-Domain Recognition: On the OVEN benchmark, which involves 6 million potential entities, RECO showed a relative improvement of +132% over the baseline for unseen classes.
  • Efficiency and Flexibility: The fusion module is highly efficient, requiring only ~10 hours of training on a 4x4 TPUv2 pod. Because the base encoders are frozen, the external memory can be updated post-training to include new concepts without retraining the model.

Conclusion

RECO demonstrates that retrieval-augmentation is a powerful and efficient way to enhance the fine-grained capabilities of vision-language models. While it introduces a modest increase in inference latency (~25%), the substantial gains in accuracy and the flexibility of an updatable memory make it a compelling alternative to massive-scale pre-training. Future work may explore integrating web-scale search APIs to provide models with real-time access to evolving global knowledge.

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