In-Context Learning Improves Compositional Understanding of Vision-Language Models

Matteo Nulli, Anesa Ibrahimi, Avik Pal, Hoshe Lee, Ivona Najdenkoska

TL;DR

Vision-Language Models (VLMs) often treat complex captions like an unordered "bag of words," failing to properly associate objects with their attributes and spatial relationships. This paper benchmarks contrastive versus generative VLMs on compositional reasoning tasks and demonstrates that few-shot In-Context Learning (ICL)—using either synthetically generated or real image-text demonstrations—can notably boost compositional understanding without updating a single parameter.

What Problem Does This Paper Address?

Modern foundation models like CLIP or LLaVA excel at zero-shot classification and open-ended captioning. However, they famously stumble on fine-grained compositionality: distinguishing between "a dog on a chair with a book" versus "a book on a chair with a dog."

Prior literature predominantly blamed contrastive loss objectives for turning text encoders into order-agnostic "bag-of-words" matchers. Yet, whether generative VLMs suffer from the same blind spots—and whether prompting strategies like In-Context Learning (ICL) can guide models to reason about composition—remained under-explored.

Methods

The authors analyze the differences between contrastive architectures (e.g., CLIP, SigLIP) and generative VLMs (LLaVA, CogVLM), and then introduce an ICL prompting framework tailored for compositional awareness:

  1. Synthetic Few-Shot Generation: The authors prompt GPT-4o with an object list to generate a compositionally coherent description (positive caption). That caption is fed to DALL·E via GPT-4o to synthesize a matching image. Finally, GPT-4o generates a counter-caption (negative caption) that shuffles or distorts the attributes and relationships of the objects.
  2. Real Demonstrations: Five images are sampled from MS COCO and manually paired with positive and negative compositional captions.
  3. Reasoning-Oriented Prompting: Generative VLMs are fed 1-shot or 5-shot examples (positive/negative pairs) alongside a step-by-step reasoning prompt that instructs the model to inspect key elements in the scene before picking the matching caption.
  4. Logit-Based Winoground Evaluation: To overcome generation variance in generative VLMs on Winoground, the authors score candidate pairs by computing the sequence-averaged logit confidence for the "yes" token rather than relying on brittle free-form generation.

Datasets

The authors evaluate models on three compositional benchmarks:

  • ARO (Attribution, Relation, and Order): Tests binding attributes to objects (VG-Attribution), identifying inter-object relations (VG-Relation), and distinguishing natural word order from scrambled text (COCO-Order and Flickr30k-Order).
  • Winoground: 400 challenging image-caption pairs with identical words arranged in different linguistic combinations, evaluated across Text, Image, and Group metrics.
  • SugarCrepe: A fine-grained benchmark derived from MS COCO where an object, attribute, or relationship is replaced, swapped, or added to break correspondence.
  • Demonstration Data: Synthetic samples generated via GPT-4o/DALL·E and 5 annotated images from MS COCO.

Key Insights and Ideas

  • Next-Token Prediction Solves Word Order: Generative VLMs drastically outperform contrastive models on word-order benchmarks (ARO COCO-Order score of ~85% for CogVLM vs. ~18–38% for contrastive models). Autoregressive language modeling provides a strong inductive bias for word sequence that contrastive encoders lack.
  • The Asymmetry Penalty of Generative Models: While contrastive models compute symmetric similarity matrices, generative models are trained strictly in an image $\to$ text direction. As a result, generative models struggle on non-descriptive tasks like choosing between images given a caption (yielding near-zero Image and Group scores on Winoground).
  • SigLIP’s Loss Advantage: SigLIP consistently beats vanilla CLIP variants across compositional tests (improving Winoground by ~4% and ARO by ~6%). Replacing CLIP's softmax normalization with a per-pair sigmoid loss prevents cross-sample batch dilution and sharpens fine-grained discrimination.
  • Negative Formatting Dictates ICL Transfer: Demonstrations featuring multi-aspect disruptions (changing multiple relations at once) transfer well to Winoground and ARO, but hurt performance on SugarCrepe, which isolates single-concept modifications (swapping only one attribute or object).

Key Results

  • Zero-Shot Baselines: CogVLM achieved the strongest zero-shot average across benchmarks (66.2%), notably beating LLaVA (60.4%) due to its dedicated visual expert modules and object-localization pre-training.
  • ICL Boosts LLaVA:
  • Winoground: 5-shot synthetic prompting improved LLaVA’s Text score from 20.1% to 25.0%, while 1-shot real demonstrations boosted it to 26.0% (and increased the notoriously tough Group score from 0.01% to 2.10%).
  • ARO: On Flickr30k-Order, 5-shot real demonstrations raised accuracy from 83.4% to 89.1%. On Visual Genome Relations, 5-shot synthetic examples pushed performance from 54.1% to 65.3%.
  • SugarCrepe: Performance slightly degraded across few-shot settings (e.g., Replace Attribute dropped from 89.7% to 81.2%), exposing the domain mismatch between multi-attribute prompt negatives and single-attribute test perturbations.

Limitations and Future Work

  • Prompt Sensitivity and Benchmark Mismatch: The style of negative captions used in the demonstrations drastically affects transferability; coarse multi-token corruptions do not generalize to subtle, single-word alterations.
  • Directional Asymmetry in Generative VLMs: Prompting alone cannot fully resolve the difficulty generative models face when matching text-to-image rather than image-to-text.
  • Future Directions: The authors suggest moving beyond contrastive visual encoders toward patch-level self-supervised objectives (e.g., DINOv2), dense caption supervision (DAC), and neurosymbolic world models to embed structural, symbolic reasoning directly into foundational vision-language architectures.

Summary updated

BibTeX
@inproceedings{nulli2024context,
  author = {Matteo Nulli and Anesa Ibrahimi and Avik Pal and Hoshe Lee and Ivona Najdenkoska},
  title = {{In-Context Learning Improves Compositional Understanding of Vision-Language Models}},
  booktitle = {FM-Wild @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=AoqRlc4lrv},
}
Figure