Abstract
Standard image captioning models often struggle to generate semantically rich and syntactically correct sentences from pixels alone. This paper introduces EXTRA (Encoder with Cross-modal representations Through Retrieval Augmentation), a model that leverages an external datastore of captions to guide the generation process. By retrieving similar captions and fusing them with visual features using a vision-and-language encoder, EXTRA achieves state-of-the-art performance and demonstrates the ability to improve through "hot-swapping" to larger datastores without retraining.
Introduction
The challenge in image captioning is that generating a coherent, semantically accurate sentence from pixels alone is difficult. While recent models use object tags or "visual words" as hints, they often miss the rich linguistic structure found in full sentences. EXTRA addresses this by using retrieved captions as a "semantic blueprint," providing the model with high-quality linguistic templates derived from how humans described similar images in the past.
Methods
The EXTRA pipeline consists of three main stages:
- Retrieval: Given a query image, the system uses CLIP to find the top $k$ most similar captions from a large datastore (usually the training set).
- Encoding: Instead of a standard visual encoder, EXTRA uses LXMERT, a pretrained Vision-and-Language BERT. It takes two inputs: the visual features of the image (detected via Faster R-CNN) and the $k$ retrieved captions concatenated into a single string. This allows the encoder to perform "cross-modal" reasoning—comparing the image directly against the retrieved text.
- Decoding: A GPT-2 based decoder generates the final caption. The researchers added cross-attention layers to the GPT-2 blocks so the decoder can "look back" at the multimodal representations produced by the LXMERT encoder.
Key Insights and Results
EXTRA was primarily trained and evaluated on MS COCO and Flickr30K. The model achieved a CIDEr score of 131.1 on the COCO dataset, outperforming several strong encoder-decoder baselines.
Attention Dynamics
By analyzing attention weights, a fascinating trend was observed: in the early layers of the decoder, the model looks at both the image and the retrieved text. However, by the final layers, the decoder almost entirely ignores the image and focuses on the retrieved text to "finalize" the sentence structure. This suggests the model uses the image for grounding and the retrieved text for linguistic refinement.
Robustness and Scalability
- Safety in Numbers: Using $k=5$ captions makes the model more robust than $k=1$, as it can aggregate information across multiple similar examples and ignore outliers.
- Hot-Swapping Datastores: A model trained on a small dataset (Flickr30K) can be instantly improved by simply giving it a larger datastore (COCO) to retrieve from at test time, requiring no additional training.
- Grounding: When the input image was "blacked out," performance dropped significantly (from 121.2 to 102.1 CIDEr), proving the model isn't just copying text; it is actively using the image to ground the retrieved information.
Conclusion
EXTRA demonstrates that retrieval-augmentation is a powerful paradigm for image captioning. By treating existing captions as a resource, the model achieves higher quality and greater flexibility. Future work will explore joint training of the retrieval and generation components and testing the model in "few-shot" settings where very little training data is available.
Summary updated