Retrieval, Analogy, and Composition: A framework for Compositional Generalization in Image Captioning

Zhan Shi, Hui Liu, Martin Renqiang Min, Christopher Malon, Li Erran Li, Xiaodan Zhu

Introduction

Modern image captioning models often struggle with "compositional generalization"—the ability to describe novel combinations of concepts. While a model might recognize "horses" and "eating" separately from its training data, it frequently fails to describe a "horse eating" if that specific pairing was never encountered. Instead, models tend to fall back on statistically common but contextually inaccurate phrases like "horse standing on grass." This limitation stems from a heavy reliance on the surface distributional characteristics of training text rather than a deep visual-semantic understanding.

The Retrieval, Analogy, and Composition (RAC) framework addresses this by enabling models to systematically recombine known concepts into new descriptions, mimicking human-like generalization.

The RAC Framework

The RAC framework operates through a three-stage pipeline designed to leverage the training set as an external knowledge base.

The RAC framework retrieves diverse prototypes (e.g., "horse" and "cow eating") to compose a novel caption for a "horse eating" scene, overcoming the biases of standard machine-generated captions.

1. Multi-Prototype Retrieval

Given a query image, the model uses CLIP to identify visually similar neighbors in the training set. To ensure broad coverage, RAC employs a greedy selection strategy based on scene graphs. This prevents the model from retrieving redundant images (e.g., three identical "horse" images) and instead ensures it gathers "prototypes" for various components of the scene, such as the primary subject, the background, and the action.

2. Analogical Reasoning

Once prototypes are retrieved, the model extracts "analogy entity pairs." Each pair links a visual feature from a prototype to its corresponding word embedding. This step is crucial; rather than simply copying features, the model learns the relationship between specific visual cues and their linguistic labels across different contexts.

3. Composition (The Editor)

The final stage involves a two-layer LSTM "editor" that attends to these analogy pairs during caption generation. By comparing the query image's visual features to those in the analogy pairs, the model can "borrow" descriptions. For instance, it can apply the "eating" description found in a "cow eating" prototype to a "horse" in the current query image.

Experimental Evaluation

The researchers evaluated RAC using the MSCOCO benchmark with specialized splits to test generalization:

  • Common Concept Split: 24 specific concept combinations (e.g., "black cat") were held out during training.
  • Rare Concept Split: Focused on concepts with very low frequency in the training data.
  • Karpathy Split: The standard benchmark to ensure general performance remains high.

Key Results

The RAC framework demonstrated significant improvements over baseline models like UpDown:

  • Novel Combinations: On the Common Concept split, Recall@5 for held-out combinations rose from 7.0% to 18.8% (with re-ranking).
  • Rare Concepts: Recall@5 improved from 13.5% to 18.7%.
  • Overall Quality: The model achieved a CIDEr score of 114.3 on the Karpathy split, up from 109.9, showing that generalization capabilities enhance overall captioning quality.

Insights and Future Directions

A key finding of the study is that retrieval acts as an effective external memory, reducing the pressure on the model to memorize every possible combination within its weights. Furthermore, the "Analogy" step proved superior to simple feature averaging, as it maintains the alignment between visual and textual features.

Despite its success, the framework faces challenges with context-dependent modifiers like "size" (e.g., "big" vs. "small"), which do not always correlate directly with bounding box dimensions. Future work will explore transitioning from LSTM-based decoders to Transformer architectures and improving the robustness of the retrieval mechanism.

Summary updated

BibTeX
@inproceedings{shi2021retrieval,
  author = {Zhan Shi and Hui Liu and Martin Renqiang Min and Christopher Malon and Li Erran Li and Xiaodan Zhu},
  title = {{Retrieval, Analogy, and Composition: A framework for Compositional Generalization in Image Captioning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.findings-emnlp.171},
}
Figure