Re-ViLM: Retrieval-Augmented Visual Language Model for Zero and Few-Shot Image Captioning

Zhuolin Yang, Wei Ping, Zihan Liu, Vijay Korthikanti, Weili Nie, De-An Huang, Linxi Fan, Zhiding Yu, Shiyi Lan, Bo Li, Mohammad Shoeybi, Ming-Yu Liu, Yuke Zhu, Bryan Catanzaro, Chaowei Xiao, Anima Anandkumar

TL;DR

This paper introduces Re-ViLM, a retrieval-augmented visual language model that significantly improves zero-shot and few-shot image captioning by leveraging an external knowledge database. Re-ViLM achieves this with fewer parameters than existing models by offloading knowledge to this database, making it more efficient and adaptable to new data.

What Problem Does This Paper Address?

Current state-of-the-art image captioning models, like Flamingo, are powerful but suffer from two main limitations:

  1. Parameter Inefficiency: They store all visual and textual knowledge within their parameters, leading to massive model sizes required to capture diverse concepts and descriptions.
  2. Data Inefficiency: Incorporating new data or adapting to new domains requires computationally expensive fine-tuning, making them slow to update.

The paper aims to address these issues by developing a more efficient and adaptable model for image captioning, particularly for scenarios where the model needs to perform well with little or no task-specific training data (zero-shot and few-shot learning).

Methods

Re-ViLM builds upon the Flamingo architecture but introduces a key innovation: retrieval augmentation. Here's how it works:

  • Image Encoder: Uses a pre-trained CLIP-ViT to extract visual features from input images. These features are then processed by a trainable "perceiver resampler" to create fixed-length representations suitable for the language model.
  • Multimodal Retriever: A crucial component that stores a large database of image-text pairs. Given an input image, it uses CLIP embeddings to find the k-nearest neighbor captions from this database.
  • Filtering Strategy: To prevent "copy-pasting" and improve robustness, Re-ViLM implements a novel filtering strategy. It discards retrieved captions that are identical to the training caption or come from the exact same image as the query image. This is important for handling data duplication in large datasets.
  • Retrieval-Augmented LM: The core language model is initialized with a pre-trained RETRO model (a retrieval-augmented LM). During generation, this LM uses cross-attention layers to incorporate information from both the image encoder and the retrieved captions. This allows the model to access external knowledge without needing to store it all in its parameters.
  • Interleaved Image-Text Data: The authors construct a special dataset of interleaved image-text pairs. This dataset is designed to explicitly train the model on how to use few-shot examples provided as context, enhancing its in-context learning capabilities.

Datasets

  • Pretraining Datasets:
    • CC3M + CC12M + SBU (referred to as CCS): Approximately 15 million image-text pairs.
  • COYO-700M (filtered to 104 million high-quality pairs, referred to as COYO).
  • Interleaved Dataset: Constructed from CCS for training in-context few-shot capabilities.
  • Evaluation Datasets:
    • MSCOCO (Karpathy split): A standard benchmark for image captioning.
  • Flickr30k: Another widely used benchmark.
  • NoCaps: Used for evaluating performance on novel objects.

Key Insights and Ideas

  • Knowledge Offloading: Storing knowledge in an external database rather than solely in model parameters is a highly effective way to reduce model size and improve adaptability.
  • Effective Filtering is Crucial: Simple filtering strategies to handle data duplication (identical captions for different images, or near-duplicate images) significantly improve retrieval-augmented model performance, outperforming more complex methods like query-dropout.
  • Interleaved Data for Few-Shot: Explicitly training with interleaved image-text pairs is key to enabling strong in-context few-shot learning.
  • RETRO as a Strong Foundation: Initializing with a pre-trained retrieval-augmented LM like RETRO provides a powerful starting point for building retrieval-augmented visual models.

Key Results

Re-ViLM demonstrates significant improvements across various settings:

  • Zero-Shot: Re-ViLM achieves substantial boosts in performance (e.g., ~10.0 CIDEr score improvement over Flamingo) with up to 16% fewer parameters. Re-ViLMbase outperforms even the largest SimVLM by a large margin.
  • Few-Shot: Re-ViLM consistently outperforms comparable-sized Flamingo models, especially in zero-shot and few-shot scenarios. The benefits are most pronounced when using out-of-domain retrieval data.
  • Parameter Efficiency: Re-ViLM models are significantly smaller than their Flamingo counterparts while achieving better or comparable performance. For instance, Re-ViLMlarge (2.4B parameters) achieves better results than Flamingo-large (2.1B parameters) and significantly outperforms Flamingo-base (364M parameters) in zero-shot settings.
  • Fine-tuning: Re-ViLM still outperforms Flamingo in fine-tuning settings, though the relative improvements are smaller compared to zero-shot and few-shot.

Limitations and Future Work

  • Flamingo Dependency: The framework is built upon a reimplemented Flamingo model due to the lack of an official implementation and its training datasets.
  • Scaling: The authors acknowledge that they haven't scaled Re-ViLM to the very large sizes (e.g., 80B parameters) that might unlock further benefits from retrieval on massive visual language models.
  • Future Work: The paper suggests exploring the application of their retrieval design to other image-to-text frameworks and further investigating scaling benefits.

Summary updated

BibTeX
@inproceedings{yang2023re,
  author = {Zhuolin Yang and Wei Ping and Zihan Liu and Vijay Korthikanti and Weili Nie and De-An Huang and Linxi Fan and Zhiding Yu and Shiyi Lan and Bo Li and Mohammad Shoeybi and Ming-Yu Liu and Yuke Zhu and Bryan Catanzaro and Chaowei Xiao and Anima Anandkumar},
  title = {{Re-ViLM: Retrieval-Augmented Visual Language Model for Zero and Few-Shot Image Captioning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.793},
}
Figure