When a vision-language model answers a question by in-context learning, meaning it reads a few solved examples placed in its prompt and then answers a new one without any weight updates, the choice of examples matters a great deal. The strongest example selectors are trained: a retriever learns to pick the examples that most lower the model's loss on the query. This proposal starts from a worry about that training signal. If the model has already memorized parts of the benchmark during pre-training, which is known to happen for both images and text, then the examples that "most help" may be the ones that cue a memorized answer rather than the ones that teach the task. A learned retriever would then be optimizing a contamination shortcut, and its reported gains over simple similarity search would be partly an artifact.
We propose to measure this effect directly and then remove it. To measure it, we deliberately inject known contamination into an open model and check whether learned retrievers preferentially exploit the contaminated items. To remove it, we build a two-stage example selector. A cheap first stage gathers candidate examples. A second-stage re-ranker is then trained on a utility signal computed on synthetic "twin" queries. Each twin is a verified, freshly generated variant of a benchmark item that the model cannot have seen. The claim is simple: utility measured on unseen twins rewards examples that teach, while utility measured on possibly memorized originals rewards examples that trigger recall.
Core Claim
Utility-supervised demonstration retrieval inflates measured in-context gains on contaminated multimodal benchmarks, because the teacher model's loss signal favors examples that cue memorized answers. We test the claim with two quantities. The first is the contamination premium: the retriever's gain over plain similarity retrieval on contaminated items, minus its gain on matched clean items. The second is a fix. If the second-stage re-ranker is trained on utility from contamination-free synthetic twins, the premium should shrink toward zero while the clean-item gain over similarity retrieval stays the same.
Several prior papers motivate the claim. How Does the Textual Information Affect the Retrieval of Multimodal In-Context Learning? trains the supervised retriever MSIER on a teacher model's loss and reports large gains over image-only similarity retrieval. It never asks whether that loss is shaped by memorization. Both Text and Images Leaked! shows that multimodal models are contaminated on ScienceQA, more severely on its training split. That training split is exactly the gallery a retriever draws examples from. What Makes Multimodal In-Context Learning Work? shows that these prompts are mostly read through their text and are prone to copying shortcuts: emitting the majority label in the prompt, or the answer of the last example. That is the kind of behavior a memorization cue would ride on.
The closest connecting work does something different. Detecting Data Contamination in LLMs via In-Context Learning (CoDeC) uses the effect of in-context examples on log-likelihood as a contamination detector for text-only models. We instead study how contamination corrupts the selection of in-context examples, in the multimodal setting. Retrieving Counterfactuals Improves Visual In-Context Learning (CIRCLES) retrieves counterfactual examples from a fixed image database to break spurious correlations. It neither tests contamination nor generates new items. Dynamic Multimodal Evaluation via Knowledge-Enhanced Benchmark Evolution generates fresh question-answer items to counter saturation, but only evaluates models zero-shot. We reuse its idea of evolved items as a source of twins and turn them into a training signal for a retriever.
Research Program
The first component is a ground-truth contamination testbed. Detectors for closed models only give indirect evidence. We therefore take open models from the cited work, namely Qwen-VL-7B (used by Multimodal Task Vectors), Gemma3-4B (used by CIRCLES) and IDEFICS (used by Baldassini et al.). We fine-tune each lightly with low-rank adapters on a random half of the ScienceQA and OK-VQA test items and their nearest gallery neighbors. The other half stays clean. Because the split is random, any difference in retriever gain between the two halves is caused by contamination rather than by item difficulty. A dose sweep varies how many fine-tuning epochs the contaminated half receives. CoDeC reports that its signal appears after about 2% of training data, which suggests even light exposure should register.
The second component is the twin generator. It follows the decoupled-and-verified recipe of VeriSciQA. A text model rewrites each item's question and answer by changing the entity, quantity or attribute the reasoning depends on. An image editor in the style of InstructPix2Pix renders the matching visual change. Two filters then remove failures. A blind test drops twins answerable without the image, and an independent vision-language model must agree on the answer. VeriSciQA kept only 3.0% of its candidates through such filters, so we budget for heavy over-generation. We also hand-check a sample of a few hundred twins.
Twins are expected to be harder than originals, because diffusion editing introduces artifacts and the items are new. For that reason we never compare absolute accuracy between originals and twins. We compare each retriever's gain over a common similarity baseline within each item set. Fine-grained species classification on CUB-200 is not twinned, because synthetic birds are unreliable. CUB is used only in the injection testbed.
The third component is the selector itself. The first stage pools roughly 100 candidates from the union of image-embedding nearest neighbors and lexical matching on the question text. Lexical and neural gains combine additively, as Critically Examining the "Neural Hype" argues for text retrieval, and recall here bounds everything downstream. The second stage is a re-ranker with the same architecture and training budget as MSIER. The only change is how its utility labels are computed. For each twin query, a gallery example's label is how much including it lowers the target model's loss on that twin. Twin queries are new by construction, so this label cannot reward cueing a memorized query answer.
Baselines
The naive reference points are random example selection and image-similarity retrieval, the standard RICES method used in What Makes Multimodal In-Context Learning Work?. RICES is untrained and cannot learn to exploit memorization. It therefore anchors the contamination premium: every learned method's gain is measured relative to it, on the same gallery, shot counts (4 and 8) and prompt template.
The strongest existing competitor is MSIER, whose teacher-supervised training is exactly the mechanism under suspicion. It reports 106.17 CIDEr on MS COCO captioning, against 99.22 for image-only RICES and 100.65 for its unsupervised variant MUIER (How Does the Textual Information Affect...). We retrain MSIER on our gallery with its original teacher-loss labels, using the same re-ranker architecture, data, number of training queries and tuning budget as our method. The only difference is whether utility labels come from original or twin queries. This comparison is also the key ablation: it isolates the twin-utility ingredient from the two-stage architecture.
CIRCLES is the second strong competitor. It reports 71.97% accuracy on CUB-200 with Gemma3-4B versus 65.40% for RICES (Retrieving Counterfactuals...). We run it in the injection testbed to see whether a retriever driven by causal attributes also pays a contamination premium. The file contains no reported result for in-context ScienceQA accuracy from any of these selectors, and none for OK-VQA, so on those benchmarks all numbers will come from our own reruns.
Our method beats MSIER if two things both hold. Its contamination premium must be significantly smaller under a paired bootstrap over items. Its gain over RICES on the clean half and on twins must be statistically indistinguishable from or larger than MSIER's. A method that only lowers the premium by also losing clean-item gains does not count as a win.
Why not just…?
Why not just deduplicate the gallery against the test set? Near-duplicate filtering on image embeddings and question n-grams removes the crudest leak, an example that literally contains the answer. It does not address the case where gallery items and queries are both memorized from the same source documents, so that topically related examples act as recall cues without being duplicates. Snoopy shows that models exploit frequency statistics without verbatim matches. Still, this is a real threat. We will apply aggressive deduplication to every method. If the contamination premium of MSIER disappears after deduplication, the problem is only duplicate leakage, and the twin re-ranker is unnecessary.
Why not just filter out memorized gallery items with a contamination detector? A multimodal version of CoDeC could flag and drop memorized examples. This is the most serious alternative, and we run it as a baseline using a text-plus-image adaptation of CoDeC's likelihood-shift score. Two concerns make us doubt it suffices. First, CoDeC's 99.9% separation AUC is a dataset-level, text-only result. Image context moves VQA predictions by only 1.2 to 1.5 points (What Makes Multimodal In-Context Learning Work?), so item-level visual signals may be weak. Second, dropping items treats contamination as a property of the example. The exploit we hypothesize is a property of the example–query pairing, which only a re-trained utility signal changes. The injection testbed decides between these: if filtering matches the twin re-ranker on both premium and clean gain, the simpler method wins and we will report that.
Why not just evaluate on fresh benchmarks and leave retrievers alone? Evolved benchmarks like those of Dynamic Multimodal Evaluation tell us a model's honest score. They do not tell a practitioner which example selector to deploy, and they do not stop a retriever trained on contaminated data from learning the wrong preference. Our twin sets double as such a fresh evaluation, so this alternative is subsumed rather than ignored.
Decisive Experiments
The first check is whether the premium exists. In the injection testbed, we compare MSIER's gain over RICES on the contaminated half against its gain on the clean half, across the epoch sweep. We also measure how often its top-ranked examples are injected gallery items compared with the base rate. A premium that grows with exposure dose supports the hypothesis. A flat premium falsifies it, and then the project reports that utility-supervised selection is robust, which is itself useful.
The second check is the same comparison on twins for off-the-shelf models, with no injection. This connects the controlled result to naturally contaminated ScienceQA, which MM-DETECT already flags.
The third check is the fix. The twin-trained re-ranker should shrink the premium without losing clean gain, and should do better than deduplication and detector filtering. Throughout, we also measure the rate of majority-label and last-example copying. This tests whether the premium operates through the shortcuts Baldassini et al. identified.
References
- How Does the Textual Information Affect the Retrieval of Multimodal In-Context Learning?
- Both Text and Images Leaked! A Systematic Analysis of Data Contamination in Multimodal LLMs
- What Makes Multimodal In-Context Learning Work?
- Detecting Data Contamination in LLMs via In-Context Learning
- Retrieving Counterfactuals Improves Visual In-Context Learning
- Dynamic Multimodal Evaluation via Knowledge-Enhanced Benchmark Evolution
- Multimodal Task Vectors Enable Many-Shot Multimodal In-Context Learning
- VeriSciQA: An Auto-Verified Dataset for Scientific Visual Question Answering
- InstructPix2Pix: Learning to Follow Image Editing Instructions
- Critically Examining the "Neural Hype": Weak Baselines and the Additivity of Effectiveness Gains from Neural Ranking Models
- Snoopy: An Online Interface for Exploring the Effect of Pretraining Term Frequencies on Few-Shot LM Performance