The Value of Being Wrong: Self-Mined Visual In-Context Learning from Errors

Shu Zhao, Tan YuNeurIPS 2026

TL;DR

Vision-language models (VLMs) learn much better on the fly when shown examples that highlight subtle visual traps—not just similar-looking successes. Instead of building complex pipelines to artificially engineer these "counterfactual" examples, this paper introduces SMILE, a method that simply records a model's own past mistakes and feeds them back into its prompt when it’s about to make a similar blunder. The result is a unified, training-free boost in accuracy across classification and visual Q&A at 5× lower latency than the previous state of the art.

What Problem Does This Paper Address?

Imagine trying to teach someone to identify a song sparrow by only showing them photos of song sparrows. The moment a visually similar fox sparrow lands on the feeder, they’ll get confused. To prevent this, you need counterfactual examples—showing them a fox sparrow and explicitly noting, "This looks close, but it’s not it."

In Visual In-Context Learning (ICL), we adapt frozen VLMs to new tasks at test time by placing a few image-text examples into the prompt. Standard methods grab examples that look visually similar to the test image. Recently, researchers realized that adding counterfactual examples helps VLMs spot fine-grained distinctions. However, constructing these counterfactuals (like in the recent SOTA method, CIRCLES) required brittle, multi-stage pipelines: extracting visual attributes, engineering tweaked captions, and searching databases for matching images. Every stage adds latency and a point of failure. The authors ask: can we get the benefits of counterfactuals without the heavy engineering?

Figure 1: A VLM’s own past mistakes can steer attention away from visual distractors and onto the target region. Direct answering and positive-only retrieval focus on visually similar but misleading evidence, while attribute-based counterfactual retrieval fails to isolate the relevant material distinction. SMILE instead retrieves a hard negative with the same error pattern from the mined pool, making the distractor evidence explicit and steering the VLM toward the correct visual region.

Methods

The core realization behind SMILE (Self-Mined Visual In-Context Learning from Errors) is that a model's own prediction errors are natural counterfactuals. If a model looks at a concrete building surrounded by brick pavement and guesses "brick," that mistake encapsulates a specific visual trap.

SMILE splits into two lightweight phases:

  1. Offline Hard-Negative Mining (New): Before deployment, the target VLM runs zero-shot inference (using 3-sample majority voting) over a labeled corpus. Whenever its prediction disagrees with the ground truth, that example is saved into a "hard-negative pool" alongside both the true label and the model's wrong guess.
  2. Online Prediction-Conditioned Selection (Standard + New): When a new test query arrives, SMILE first grabs $K$ standard positive examples using CLIP image similarity. Next comes the clever twist: SMILE asks the VLM for a quick zero-shot guess on the test query. It uses this guess as a "direction signal," searching the hard-negative pool in text-embedding space to find $N$ past mistakes where the model made the exact same (or semantically similar) wrong guess.

Both positive examples and these targeted "tricky examples" are concatenated into the final prompt, steering the model away from its knee-jerk mistake.

Datasets

SMILE is training-free, using labeled training splits strictly as retrieval pools. No new benchmarks are introduced; the authors evaluate on four standard datasets across two regimes:

  • Closed-set Classification: CUB-200-2011 (fine-grained bird species) and Flowers-102 (flower species).
  • Open-ended Visual Question Answering (VQA): OK-VQA (questions requiring external knowledge) and VizWiz (real-world photos taken by blind users, where ~32% are unanswerable).

Key Insights and Ideas

  • Models fail in predictable, structured ways: On bird classification, 94.2% of validation mistakes repeat an exact confusion pair seen in the training set. On open-ended VQA, exact string repeats are rare (3.0%) due to phrasing variety, but wrong answers consistently land in the same semantic neighborhood as the truth (e.g., guessing "circle" instead of "round"). Using text embeddings bridges both regimes seamlessly.
Figure 2: Exact confusion-pair reuse is concentrated for classification but sparse for VQA. Green: source-corpus exact error-pair distribution; Red: validation errors covered by the top-K most frequent source pairs; Grey: permuted-prediction null.
  • "Hard" examples aren't noisy—they are load-bearing: When the authors tried restricting standard retrieval to only "clean" examples the model got right offline, CUB accuracy collapsed from 82.15% to 46.12%. Why? Because for 77 out of 200 bird species, the model got every single image wrong zero-shot—meaning hard examples were the only available source of truth for the toughest classes.
  • Mine once, reuse broadly: While mining a pool specific to your target VLM is safest, hard-negative pools transfer surprisingly well across different model sizes and families (e.g., between Gemma-3 and Qwen2.5-VL), proving that different VLMs fall for many of the same visual illusions.
  • Mistakes physically redirect attention: Visualizing decoder attention maps shows that adding hard negatives shifts the VLM's focus away from background distractors and onto the exact visual region that separates the right answer from the tempting wrong one.

Key Results

Tested across four open VLMs (Gemma-3 4B/12B and Qwen2.5-VL 3B/7B), SMILE beats all six baselines on every backbone:

  • Accuracy: Delivers an average task-score gain of +3.09 points over the counterfactual SOTA (CIRCLES) and +3.3 to +9.7 points over standard visual similarity retrieval.
  • Efficiency: Achieves these gains using fewer in-context examples (12–20 examples vs. 32 for baselines).
  • Speed: Runs 3.6–6.0× faster than CIRCLES on H100/H200 GPUs (under 1 second per query on H200), adding less than 5% latency overhead compared to standard generation. Offline mining on the largest dataset (~20K images) takes just 6.7–13.3 minutes on 8 H100s.

Limitations and Future Work

While the paper does not include a standalone limitations section, the authors note practical boundaries within their experiments:

  • Context ceiling: Performance saturates and eventually degrades when the total number of positive and negative examples ($K+N$) exceeds the VLM's effective context window.
  • Upfront mining cost & transfer limits: Building a self-mined pool requires an offline pass over a labeled corpus. While cross-model pool transfer works well as a shortcut, slight accuracy drops (up to ~2 points on OK-VQA in certain pairings) mean self-mining is still required when maximum accuracy is critical.

Summary updated

Abstract

Visual in-context learning (ICL) enables vision-language models (VLMs) to adapt at test time via demonstration examples, but its effectiveness depends critically on the examples selected. Recent counterfactual selection methods improve ICL by constructing demonstrations that expose how individual attribute changes affect the answer. However, they require multi-stage pipelines involving attribute extraction, caption engineering, and composed image matching. We propose a simpler alternative grounded in a key observation: a model's own prediction errors are natural counterfactual demonstrations that directly encode its failure modes. Our method, SMILE (Self-Mined Visual In-Context Learning from Errors), builds a model-specific pool of hard negatives offline by recording the target VLM's own mistakes. At test time, the prediction serves as a direction signal that surfaces, in the semantic embedding space, the past mistakes most likely to recur for the current query. This prediction-conditioned identification provides a unified mechanism for both closed-set classification and open-ended visual question answering without task-specific design. Across four benchmarks and four VLMs, SMILE delivers an average task-score gain of +3.09 points over the SOTA baseline at 5× lower latency. Project page: https://tree-shu-zhao.github.io/SMILE/
BibTeX
@inproceedings{zhao2026value,
  author = {Shu Zhao and Tan Yu},
  title = {{The Value of Being Wrong: Self-Mined Visual In-Context Learning from Errors}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=dVu1u4QgAp},
}
Figure