Towards Retrieval-Augmented Architectures for Image Captioning

Sara Sarto, Marcella Cornia, Lorenzo Baraldi, Alessandro Nicolosi, Rita Cucchiara

This paper presents a novel approach to image captioning by shifting the burden of "knowledge" from the model's weights to an external memory. By using a retrieval-augmented architecture, the authors demonstrate that models can generate more accurate and semantically rich descriptions by looking up similar examples at inference time.

TL;DR

The authors propose two retrieval-augmented Transformer architectures (RA-T$^S$ and RA-T$^X$) that use a $k$-nearest neighbor ($k$NN) memory to provide contextual "hints" during caption generation. This approach significantly improves performance on standard benchmarks and generalizes better to novel objects without requiring massive increases in model parameters.

What Problem Does This Paper Address?

Traditional image captioning models are "parametric," meaning all the knowledge they have about the world is baked into their internal weights during training. To describe a rare object or a complex scene, these models usually need to be scaled up to billions of parameters, which is computationally expensive.

The authors address this by decoupling language modeling (the ability to construct a sentence) from memorization (knowing what specific objects are called). They treat image captioning as a semi-parametric task: when the model sees a new image, it "remembers" similar images it has seen before, looks at their captions, and uses that information to guide its own generation process.

Methods

The core of the system is a Knowledge Retriever. Given an input image, the system uses CLIP-based visual features to perform a $k$NN search in an external memory of image-caption pairs (using the Faiss library for speed).

The authors propose two ways to integrate these retrieved "hints" into a Transformer-based decoder:

  1. RA-T$^S$ (Self-attention based): The retrieved captions are cleaned (stop words and duplicates removed) and prepended to the decoder's input sequence as a prefix. This is essentially a form of "prompting" the model with relevant vocabulary.
  2. RA-T$^X$ (Cross-attention based): This is a more sophisticated architectural change. The retrieved captions are encoded by a separate Transformer. The decoder then uses a parallel cross-attention layer to attend to these retrieved features. A learnable gating mechanism ($\alpha$) allows the model to decide how much to weight the retrieved information versus its own internal predictions.

The models are trained in two stages: standard cross-entropy loss followed by Reinforcement Learning (Self-Critical Sequence Training) to directly optimize for the CIDEr metric.

Datasets

  • COCO: The primary benchmark for training and evaluation.
  • CC3M (Conceptual Captions 3M): Used as a larger, more diverse retrieval index. Interestingly, the authors used a "cleaned" version of CC3M where captions were re-generated by a BLIP model to ensure high-quality, descriptive text instead of noisy web alt-text.
  • nocaps: A challenging dataset specifically designed to test how well models describe "novel" objects not present in the COCO training set.

Key Insights and Ideas

  • The "Oracle" Potential: The authors performed an "Oracle" analysis, showing that if the model could perfectly pick the best caption from the retrieved set, it would achieve massive performance gains (up to 141.8 CIDEr points). This suggests that the bottleneck isn't the quality of the retrieved data, but how effectively the model integrates it.
  • Memory Quality > Memory Size: Using the original, noisy CC3M captions actually hurt performance. However, using the "cleaned" BLIP-generated captions for the same images provided a significant boost. This highlights that for retrieval-augmentation, the "cleanliness" of the external knowledge is paramount.
  • Generalization to the Unknown: The retrieval mechanism acts as a bridge for "out-of-domain" objects. On the nocaps dataset, the model could describe objects it had never "learned" in training simply because it could find and reference them in the external memory.

Key Results

  • State-of-the-Art Performance: On the COCO Karpathy-test split, the RA-T$^X$ model achieved 136.7 CIDEr points, outperforming standard Transformer baselines (135.3) and several other complex architectures.
  • Robustness on Novel Objects: On the nocaps "Out-of-domain" subset, the retrieval-augmented models showed a clear advantage, with the RA-T$^S$ model reaching 69.5 CIDEr points compared to the baseline's 66.7.
  • Architectural Preference: While both variants performed well, RA-T$^X$ (cross-attention) generally proved more robust and easier to tune thanks to its explicit gating mechanism.

Limitations and Future Work

  • Inference Latency: While $k$NN search is fast with libraries like Faiss, it still adds a computational step to the inference pipeline compared to a standard parametric model.
  • Retrieval-Generation Gap: The gap between the "Oracle" scores and the actual model performance indicates that the decoder sometimes ignores useful retrieved information or fails to filter out irrelevant "noise" from the $k$NN results.
  • Static Memory: The current work uses a fixed external memory. Future research could explore "active" memories that update or learn which examples are most helpful to store.

Summary updated

BibTeX
@article{sarto2024towards,
  author = {Sara Sarto and Marcella Cornia and Lorenzo Baraldi and Alessandro Nicolosi and Rita Cucchiara},
  title = {{Towards Retrieval-Augmented Architectures for Image Captioning}},
  journal = {ACM Trans. Multim. Comput. Commun. Appl.},
  year = {2024},
  url = {https://openreview.net/forum?id=7nsxepFmD7},
}
Figure