Retrieving Counterfactuals Improves Visual In-Context Learning

Guangzhi Xiong, Sanchit Sinha, Zhenghao He, Aidong Zhang · DOI

Abstract

Vision-language models (VLMs) have achieved impressive performance across a wide range of multimodal reasoning tasks, but they often struggle to disentangle fine-grained visual attributes and reason about underlying causal relationships. In-context learning (ICL) offers a promising avenue for VLMs to adapt to new tasks, but its effectiveness critically depends on the selection of demonstration examples. Existing retrieval-augmented approaches typically rely on passive similarity-based retrieval, which tends to select correlated but non-causal examples, amplifying spurious associations and limiting model robustness. We introduce CIRCLES (Composed Image Retrieval for Causal Learning Example Selection), a novel framework that actively constructs demonstration sets by retrieving counterfactual-style examples through targeted, attribute-guided composed image retrieval. By incorporating counterfactual-style examples, CIRCLES enables VLMs to implicitly reason about the causal relations between attributes and outcomes, moving beyond superficial correlations and fostering more robust and grounded reasoning. Comprehensive experiments on four diverse datasets demonstrate that CIRCLES consistently outperforms existing methods across multiple architectures, especially on small-scale models, with pronounced gains under information scarcity.

Introduction: The Similarity Trap

In-context learning (ICL) allows Vision-Language Models to adapt to new tasks by observing a few demonstration examples. Currently, most systems use similarity-based retrieval (e.g., the RICES baseline) to select these examples. For instance, when identifying a bird species, the retriever finds visually similar birds.

However, this approach often falls into a similarity trap. If all similar examples of a specific bird species are photographed in a specific environment (e.g., on pine trees), the model might learn a spurious correlation: "pine tree = species X." Standard retrieval fails to help the model distinguish which specific attributes, such as beak shape or wing color, actually cause the label. To achieve robust reasoning, models need to see counterfactuals—what happens when a single attribute changes while others remain constant.

Correlational vs. Causal Retrieval: Standard retrieval finds similar images, while composed retrieval finds counterfactuals that isolate specific attribute changes.

The CIRCLES Framework

We introduce CIRCLES (Composed Image Retrieval for Causal Learning Example Selection). Instead of relying solely on nearest neighbors, CIRCLES actively constructs a demonstration set using a four-step pipeline:

  1. Key Attribute Identification: The VLM analyzes the query image ($I_q$) and question ($Q_q$) to identify decisive attributes (e.g., "breast color: yellow").
  2. Counterfactual Captioning: The VLM generates a modified caption ($c^{do(a=v')}$) describing a "what if" scenario (e.g., "Change breast color to grey").
  3. Composed Image Retrieval (CIR): Using a specialized retrieval module (OSrCIR), the system searches the database for an image that matches the original query's context but incorporates the modified attribute.
  4. Hybrid Prompting: The final prompt combines these "causal" counterfactual examples ($\mathcal{R}_{causal}$) with standard "correlational" examples ($\mathcal{R}_{corr}$) to provide a balanced view of the task.
The CIRCLES Pipeline: Integrating correlational and causal understanding via composed image retrieval for augmented inference.

Experimental Evaluation

CIRCLES was evaluated across five diverse benchmarks to test different types of multimodal reasoning: CUB-200-2011 and Oxford Flowers 102 (fine-grained classification), OK-VQA (knowledge-based VQA), VizWiz (real-world noisy VQA), and ScienceQA (multimodal reasoning).

Key Results

  • Performance Gains: CIRCLES consistently outperformed state-of-the-art retrieval methods like MUIER and MMICES. On the CUB bird dataset using Gemma3-4B, CIRCLES achieved 71.97% accuracy, significantly outperforming the standard RICES baseline (65.40%).
  • Model Scaling: The framework provides the most significant boosts to smaller models (e.g., Gemma3-4B, Qwen2.5-VL-3B), which often lack the internal "world knowledge" to ignore irrelevant background details.
  • Data Efficiency: CIRCLES maintained high accuracy even when training data was reduced by 75%, demonstrating its ability to select highly informative contrastive pairs.
  • Efficiency: Despite the extra processing steps, CIRCLES adds only approximately 10% token overhead compared to standard retrieval, making it a practical upgrade for real-world pipelines.

Conclusion

CIRCLES demonstrates that teaching VLMs "why" through counterfactual examples is more effective than simply showing them "what" through similarity. By disentangling spurious correlations, the framework fosters more grounded reasoning. Future work will focus on reducing the computational cost of active retrieval and developing end-to-end counterfactual retrievers that bypass intermediate text generation.

Summary updated

BibTeX
@misc{xiong2026retrieving,
  author = {Guangzhi Xiong and Sanchit Sinha and Zhenghao He and Aidong Zhang},
  title = {{Retrieving Counterfactuals Improves Visual In-Context Learning}},
  year = {2026},
  eprint = {2603.16737},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.16737},
}

Loading related content...

Figure