betaFeedback

WorksComputer Science

TaskVICL: Task-Conditioned Decoder States for Visual In-Context Learning

Abstract

The usefulness of an in-context demonstration for a vision-language model (VLM) depends on both the query image and the task posed about it. Common retrievers rank examples by image similarity and ignore the task, while task-aware alternatives require answer generation, external encoders or retriever training. We ask whether the frozen target VLM's own decoder states, read before it answers, can select demonstrations directly. TaskVICL represents each image and task by a task-conditioned processing signature: the hidden states at the final input position across all decoder layers. Its training-free variant, TaskVICL-Raw, averages cosine similarities between corresponding layer states and passes the retrieved examples with their reference answers to the same VLM. Across two VLMs and eight classification and visual question answering datasets, Raw achieves the highest average accuracy among training-free retrievers, exceeding the strongest baseline by 3.30 points on Qwen3-VL and 1.41 on InternVL3.5, with gains carrying over to Gemma-3-12B. When the same NICO++ image is asked about its object or its context, Raw retrieves largely different demonstrations for the two questions and outperforms an image retriever given task-matched demonstrations. A lightweight shared projection, TaskVICL-Proj, adds further gains on classification. Controls show that task text at extraction drives most of the gains, and attention analysis describes how it shifts attention toward the classified object. These results support the target VLM's internal states as a practical basis for task-aware demonstration retrieval.

Introduction

Visual in-context learning (ICL) lets a vision-language model (VLM) solve a task from a few demonstrations placed in its prompt, without updating its weights [2]. Each demonstration pairs an image and a task with its answer, and the query supplies a new image and task (Figure 1). Which demonstrations help depends on both parts: the same NICO++ image can be classified by its object or by its context, and the two questions call for different examples (Figure 3).

Figure 1. Image-only vs. image-and-task retrieval for visual in-context learning. The query is a NICO++ image asked about its context (reference: rock). The dashed boxes mark what each retriever uses. RICES uses the image only (orange), TaskVICL-Raw the image and the task text (blue). The four retrieved demonstrations, each with its question and reference answer, precede the query, and the frozen VLM (Qwen) answers it.

Figure 3. Retrieval on paired NICO++ tasks with Qwen. Left, an example query. RICES retrieves with the image alone and selects the same images for both questions. TaskVICL-Raw retrieves with the image and the question together and selects different demonstrations for each. Right, over all 1080 queries, the share of retrieved images whose native label matches the query for the asked question, and the share retrieved for both questions.

Existing retrievers only partly address this. RICES ranks examples by image similarity [2, 40] and returns the same demonstrations whatever the question. MMICES adds question-text similarity [8], which reduces to visual similarity when every query shares one instruction, as on single-task classification datasets. Task-aware alternatives pay elsewhere: GPT-MM retrieves with a state taken after answer generation [33], CIRCLESS builds counterfactual contexts at over ten seconds per query in our setup [36], and DeTriiever trains transformations of decoder states [20]. We ask whether the states a target VLM already computes for the query, before it answers, can serve as the retrieval key directly.

At the final input position, the decoder has attended to the whole image and the complete task text, so its hidden states across layers summarize how the model processes this image under this task. We call them a task-conditioned processing signature and hypothesize that examples with similar signatures make effective demonstrations. TaskVICL extracts signatures from all decoder layers in one forward pass, without answer generation, external encoders or retriever training. Its training-free Raw variant normalizes each layer state, averages per-layer cosine similarities and retrieves four demonstrations from the full bank with the same rule on every dataset; the same frozen VLM then answers from the selected images, task texts and reference answers. An optional Proj variant learns one shared linear projection from bank labels.

Following recent work [5, 8, 11, 22, 33, 35, 36], we judge each retriever by the accuracy of the VLM that receives its demonstrations, which also covers open-ended question answering. On Qwen3-VL-4B and InternVL3.5-4B across five fine-grained classification datasets, paired object and context questions on NICO++ and two VQA datasets, Raw has the highest average among training-free retrievers, 81.42 and 68.11, ahead of the strongest baselines by 3.30 and 1.41 points. On NICO++ its neighbors for the two questions about the same image overlap by only 12.08%, and it beats an image retriever given task-matched demonstrations. Gains carry over to Gemma-3-12B. Our contributions are:

  • TaskVICL, a training-free retriever that compares the frozen target VLM’s decoder states at the final input position, layer by layer, before generation.

  • The highest average accuracy among training-free retrievers across two VLMs and eight classification and VQA datasets, with demonstrations that adapt to the question asked about the same image.

  • Controls showing that task text at extraction drives most of the gains, that TaskVICL matches or exceeds retrieval by zero-shot label log-probabilities on all seven classification tasks, and that reference answers correct many initial errors; descriptively, task text also shifts attention toward the classified object.

Related Work

In-context learning with VLMs. Flamingo showed that VLMs can solve new tasks from a few interleaved image–text demonstrations [2], retrieving them by image similarity as proposed in PICa [40]. This ability is sensitive to the demonstrations: what makes a good visual in-context example is not obvious [43], and studies of captioning and VQA show that both the choice and the order of demonstrations strongly affect accuracy [19, 37, 38].

Selecting multimodal demonstrations. Language ICL retrieves demonstrations by sentence-embedding similarity [23] or with retrievers trained on language-model feedback [30, 41]. Multimodal selectors combine visual and textual cues [8], compose demonstrations from task-oriented image summaries [44], or retrieve discriminative examples through counterfactual contexts [36]. Other methods learn to configure demonstration sequences [5, 22, 39], build compact candidate coreset sets [6, 35] or curate context with an agent [11]. TaskVICL shares their goal of task-relevant selection but draws relevance from the frozen target VLM itself and keeps the bank’s reference answers for prediction.

Model-internal states as retrieval keys.

GPT-MM retrieves with model predictions [33]; our adaptation uses the final-layer state after answer generation. DeTriever learns layer-specific transformations and aggregation weights from supervised similarity targets for text-to-SQL [20]. TaskVICL instead compares states at corresponding depths before generation and needs no supervision in its Raw form. More broadly, VLM2Vec learns instruction-conditioned multimodal embeddings [16], E5-V uses the final-token state of a prompted multimodal LLM as a universal embedding [15], and multimodal task vectors compress demonstrations into attention-head activations [13]. These works use internal states as general-purpose embeddings or as substitutes for demonstrations, whereas TaskVICL uses the prediction model’s own states to select labeled demonstrations.

Interpreting visual processing. Token Activation Maps attribute generated tokens to multimodal inputs [21], while work on attention and saliency cautions against reading internal measurements as explanations of decisions [1, 14]. We therefore use attention only to describe how processing changes with the task across depth, and measure demonstration utility separately through final predictions.

Method

Task-conditioned processing signature

Let FF be a frozen VLM and B={(xi,ti,yi)}i=1N\mathcal{B} = \{(x_i,t_i,y_i)\}_{i=1}^{N} a labeled bank, where xix_i is an image, tit_i its task text and yiy_i its reference answer. A query supplies (xq,tq)(x_q,t_q). For classification, the task text contains the instruction and the label list. For visual question answering (VQA), it contains the question and any answer options.

For the native input sequence u(x,t)u(x,t), let T(x,t)T(x,t) be the final input position, including the assistant prefix. We extract

hℓ(x,t)=Fℓ(u(x,t))T(x,t),ℓ=1,…,L,(1)h_\ell(x,t)=F_\ell(u(x,t))_{T(x,t)},\qquad\ell=1,\ldots,L, \tag*{(1)}

from all decoder layers in a single forward pass before generation, excluding the embedding output and keeping native image processing. Qwen gives L=36L=36 states of width d=2560d=2560.

Under causal attention, the final input position follows the complete image and task text and can draw on both. Its states therefore change with the requested prediction even when the image stays the same. On single-task datasets all entries share one task text, which fixes the instruction and label list. NICO++ and question answering vary the task across entries. We call {hℓ(x,t)}ℓ=1L\{h_\ell(x,t)\}_{\ell=1}^{L} a task-conditioned processing signature. The final input position also prepares the first answer token, so the signature reflects how the model is about to respond to this image and task. Reading it requires no answer generation, and the bank’s reference answers still guide the final prediction. Figure 2 summarizes the pipeline.

Figure 2. TaskVICL retrieves demonstrations with states of the frozen prediction VLM. Each decoder layer contributes its state at the final input position. Raw averages per-layer cosine similarities. Proj adds a shared projection learned from bank labels, and PCA gives an unsupervised projection for question answering. The selected examples enter the final four-shot prompt.

Training-free retrieval

For an input a=(x,t)a=(x,t), each state is normalized separately as zℓ(a)=hℓ(a)/∥hℓ(a)∥2z_\ell(a)=h_\ell(a)/\lVert h_\ell(a)\rVert_2. TaskVICL-Raw compares corresponding layers with

sRaw(a,b)=1L∑ℓ=1Lzℓ(a)⊤zℓ(b).(2)s_{\mathrm{Raw}}(a,b)=\frac{1}{L}\sum_{\ell=1}^{L}z_\ell(a)^{\top}z_\ell(b). \tag*{(2)}

Every layer contributes equally, and the score equals the cosine similarity between concatenated normalized states.

We cache the bank signatures, select the four highest-scoring entries and order them from lower to higher similarity, so the nearest example comes last. Each demonstration contributes its image, original task text and reference answer, followed by the query, and the same frozen VLM predicts the answer. In every ablation that alters the extraction text, the final prompt keeps the original task.

Shared projection

TaskVICL-Proj keeps the signature and the uniform layer average and applies one matrix W∈Rp×dW\in\mathbb{R}^{p\times d} with p=256p=256 to every layer. With ν(v)=v/∥v∥2\nu(v)=v/\lVert v\rVert_2, the score is

sW(a,b)=1L∑ℓ=1Lν(Wzℓ(a))⊤ν(Wzℓ(b)).(3)s_W(a,b)=\frac{1}{L}\sum_{\ell=1}^{L}\nu(Wz_\ell(a))^{\top}\nu(Wz_\ell(b)). \tag*{(3)}

For Qwen, WW has 655,360 parameters and reduces the bank cache tenfold. The VLM stays frozen.

For classification, WW is trained so that bank examples with the same label score higher. For each anchor aa in a balanced batch A\mathcal{A}, let P(a)P(a) contain the other examples sharing its label. We minimize a supervised contrastive loss [18],

L(W)=−1∣A∣∑a∈Alog⁡∑b∈P(a)exp⁡(sW(a,b)/τ)∑c∈A∖{a}exp⁡(sW(a,c)/τ).(4)\mathcal{L}(W)=-\frac{1}{|\mathcal{A}|}\sum_{a\in\mathcal{A}}\log\frac{\sum_{b\in P(a)}\exp(s_W(a,b)/\tau)}{\sum_{c\in\mathcal{A}\setminus\{a\}}\exp(s_W(a,c)/\tau)}. \tag*{(4)}

Single-task datasets use class labels, and NICO++ uses the 66 groups formed by task and native label. Training runs 1500 steps with learning rate 3×10−43\times10^{-4}, τ=0.07\tau=0.07 and batches of 16 label groups with four examples each. Ten bank images per class, or per object class with both questions on NICO++, are held out, and we keep the earliest checkpoint with the best top-four label agreement on them.

Question answering has no fixed label set, and few training answers repeat often enough to form groups. OK-VQA has only five answers shared by at least 14 bank questions. For ScienceQA and OK-VQA we therefore replace the learned map with a 256-dimensional PCA basis fitted on bank states without using reference answers, and keep the normalization and layer average of Eq. (3). We report this unsupervised variant as TaskVICL-PCA in Table 1, with a supervised OK-VQA map in Appendix § 9.3.

VLMMethodNICO++ ObjectNICO++ ContextDTDAircraftCUBDogsPetsScienceQAOK-VQAAvg.
Query count108010801880333357948580366920175046–
Qwen3-VL-4BTraining-free
Zero-shot91.5738.8967.0732.3137.1854.3982.4790.7358.7461.02
Random-490.7439.1758.7833.2128.3449.6970.1889.8457.1456.52
RICES (CLIP ViT-B/32) [28, 40]92.7845.2878.7259.6871.2174.3291.5289.9957.6374.01
RICES (CLIP ViT-L/14) [28, 40]93.0646.3980.8068.4780.9380.3593.3089.9957.1777.59
RICES (DINOv3) [31, 40]91.9446.3982.5057.7665.3676.5992.2090.2857.3673.90
GPT-MM [33]93.7061.6781.6069.3772.6478.6892.8692.5159.6478.12
CIRCLES [36]93.2452.5980.8567.5781.9179.3693.3290.2852.3977.32
MMICES [8]94.0761.5782.6165.3578.3477.1691.6390.2856.9777.52
TaskVICL-Raw (Ours)94.5463.7084.0473.8481.5082.9794.9694.2060.7581.42
Training-based
DeTriever [20]92.6959.6378.2468.3868.8177.6892.4093.3658.9276.74
TaskVICL-Proj (Ours)94.4465.2885.9078.6783.3685.2095.42–––
TaskVICL-PCA (Ours)–––––––94.3560.79–
InternVL3.5-4BTraining-free
Zero-shot89.7235.3753.1414.0414.9318.5550.1565.2032.1438.84
Random-487.6941.5734.959.6310.4113.6133.6993.3647.6238.49
RICES (CLIP ViT-B/32) [28, 40]89.5447.6973.2443.0256.8055.2178.6992.6147.6264.48
RICES (CLIP ViT-L/14) [28, 40]90.4650.8373.6246.4155.2661.8681.2593.3147.7266.26
RICES (DINOv3) [31, 40]90.6550.3776.6043.8654.0662.6682.8392.8648.2466.45
GPT-MM [33]90.0962.0470.0537.5646.2548.8875.3992.8150.5562.20
CIRCLES [36]91.3955.1976.1243.5354.9562.5382.1792.2748.7766.70
MMICES [8]89.9159.6375.9633.4532.0340.6560.4892.8148.4757.33
TaskVICL-Raw (Ours)91.4862.3175.9642.3357.5863.0484.3393.4151.3168.11
Training-based
DeTriever [20]89.6360.6572.5540.7154.4562.0985.9992.2749.9566.64
TaskVICL-Proj (Ours)91.9463.5277.5049.1467.4567.8488.61–––
TaskVICL-PCA (Ours)–––––––93.2651.61–

Table 1. Prediction results with 4 shots, in percent. Classification and ScienceQA report accuracy and OK-VQA the official consensus score. Avg. weights each dataset equally after averaging the two NICO++ tasks. Training-free retrievers use no parameters fitted on the bank. Training-based retrievers fit parameters on the bank, with labels for DeTriever and Proj and without labels for TaskVICL-PCA on question answering. Bold marks the best result within each segment. GPT-MM uses only its retrieval component, and MMICES uses the target VLM’s visual features. InternVL zero-shot ScienceQA counts 31.9% invalid outputs as errors.

Experiments

Setup

We evaluate Qwen3-VL-4B-Instruct [3] and InternVL3.5-4B [34] on eight datasets. NICO++ [42] provides paired object and context classification on the same images. We draw a seeded sample of its official training images, stratified over 60 objects and six contexts, with 3960 bank images and 1080 disjoint query images. Every image carries both questions, giving 7920 bank entries and 2160 queries in one mixed bank. DTD [9], FGVC Aircraft [25], CUB [32], Stanford Dogs [17] and Oxford Pets [27] cover single-task classification, and the 2,017 image questions of ScienceQA [24] and all 5046 OK-VQA validation questions [26] cover question answering. Classification and ScienceQA report accuracy, and OK-VQA uses the official ten-answer consensus score.

Every ICL method retrieves four demonstrations from the same bank. Zero-shot uses no demonstrations, and Random-4 samples them uniformly. All classification predictions, including zero-shot, use legal-label decoding over the listed categories. RICES ranks bank images by cosine similarity of frozen image features [2, 40], computed with CLIP ViT-B/32 or ViT-L/14 [28] or with DINOv3 ViT-B/16 [31]. RICES without a qualifier denotes the CLIP ViT-B/32 variant. GPT-MM retrieves with the target VLM’s final-layer state after it generates an answer [33]. Our DeTriever adaptation learns per-layer nonlinear maps and layer weights on the target VLM’s states, using bank input and reference-answer representations as similarity targets [20]. CIRCLES adds retrieval guided by counterfactual attributes generated with the target VLM [36]. MMICES preselects 32 bank images with the target VLM’s own visual features and keeps the four whose question text is most similar under CLIP ViT-B/32 [8]. Appendix § 9.2 details all baselines.

Paired 95% confidence intervals use 2000 query-bootstrap resamples [10], and NICO++ resamples images with both questions kept together. Invalid outputs remain in every denominator, and differences are computed from unrounded scores.

Main results

Table 1 evaluates each retriever through the final VLM prediction. Among training-free retrievers, Raw has the highest average on both VLMs, 81.42 on Qwen and 68.11 on InternVL. The strongest training-free baselines, GPT-MM on Qwen and CIRCLES on InternVL, trail it by 3.30 and 1.41 points. CLIP ViT-L/14 RICES trails it by 3.83 points on Qwen with a 95% interval of [3.38, 4.27] and by 1.85 points on InternVL with interval [1.41, 2.26]. With task-matched RICES on NICO++, these two gaps become 2.84 and 1.25 points. On NICO++, Raw has the best mean over the two questions on both VLMs. Its gains come mainly from context questions, where it reaches 63.70 on Qwen against at most 46.39 for the RICES variants. Image retrievers return the same images for both questions, while Raw’s neighbors share the query’s question type, which § 4.3 controls for with task-matched RICES. MMICES also matches the question type through its text reranking. On single-task datasets this text is constant, so MMICES ranks by the VLM’s visual features alone. On InternVL these come from one untitled view, and MMICES falls well below Raw.

On Qwen, Raw exceeds every baseline in eight of the nine result columns, and only CIRCLES is higher on CUB (81.91 vs. 81.50). On InternVL, Raw again has the highest average among training-free retrievers. Raw is numerically highest in seven of nine columns among training-free methods. On question answering, all three RICES variants fall below zero-shot on Qwen, while Raw improves to 94.20 on ScienceQA and 60.75 on OK-VQA. On InternVL ScienceQA, all ICL methods lie within 1.2 points, and Raw’s gain over RICES has an interval including zero.

Proj improves 13 of 14 classification scores over Raw and lowers only Qwen NICO++ object accuracy. On question answering, PCA changes Raw by at most 0.30 points with intervals including zero, while reducing storage tenfold (Appendix § 9.3). Results over three runs, one to eight demonstrations and the label precision of retrieved examples appear in Appendix § 9.4.

Task changes on the same image

Figure 3 shows how retrieval responds when the same image is asked a different question. RICES returns the same images for both questions. Raw returns different images, and only 12.08% of its neighbors are shared by the two questions. The native labels of the retrieved images follow the question. Under object questions, 92.50% of Raw’s neighbors share the query object, against 69.19% for RICES. Under context questions, 58.98% share the query context, against 44.42%.

Part of this gain could come from retrieving demonstrations of the same question type. A task-matched RICES control keeps the RICES images and their order and supplies each with the question and bank answer of the query task, for all three RICES encoders. Task matching helps every encoder on both VLMs (Table 2), and TaskVICL-Raw still exceeds the strongest task-matched RICES control, CLIP ViT-L/14, by 1.48 points on both VLMs, with paired 95% intervals of [0.19, 2.73] on Qwen and [0.19, 2.78] on InternVL. Task matching closes 7.17 of the 10.09-point gap between CLIP ViT-B/32 RICES and Raw on Qwen. The remaining gap reflects which images Raw retrieves for each question.

MethodQwen ImageQwen + TaskInternVL ImageInternVL + Task
RICES (CLIP ViT-B/32) [28, 40]69.0376.2068.6173.75
RICES (CLIP ViT-L/14) [28, 40]69.7377.6470.6575.42
RICES (DINOv3) [31, 40]69.1776.7670.5175.37
GPT-MM [33]77.6976.06
MMICES [8]77.8274.77
TaskVICL-Raw (Ours)79.1276.90

Table 2. NICO++ accuracy, mean of object and context questions. Image uses RICES neighbors as retrieved; + Task keeps the same images and order but pairs each with the query’s question and its bank answer. Image rows for ViT-L/14 and DINOv3 are averaged from Table 1.

Model scale and cost

Larger model. We run Gemma-3-12B-IT [12], a larger model from another family, on NICO++, DTD and OK-VQA with the same protocol. Raw exceeds RICES by 5.79 points on NICO++, mostly through a 10.00-point gain on context questions, and by 3.65 on OK-VQA (Table 3). On DTD it is 1.12 points higher with an interval including zero. Appendix § 9.11 reports results on the same three datasets for Qwen3-VL-8B-Instruct.

DatasetZero-shotRICESRawΔ\Delta
NICO++ object90.8391.1192.69+1.57 [0.37, 2.78]
NICO++ context37.4154.4464.44+10.00 [7.13, 12.69]
mean64.1272.7878.56+5.79 [4.30, 7.36]
DTD67.8781.5482.66+1.12 [−0.43, 2.66]
OK-VQA34.7354.2857.92+3.65 [2.37, 4.84]

Table 3. Gemma-3-12B-IT with 4 shots. Accuracy, except the OK-VQA consensus score. RICES [40] uses CLIP ViT-B/32 [28], and Raw is TaskVICL-Raw (Ours). Δ\Delta is Raw − RICES with paired 95% intervals; gray marks an interval that includes zero.

Cost. Bank states are extracted once and cached, and each query needs one extra forward pass before generation. On an RTX 4090, Raw retrieval takes 267 ms per query including preprocessing, against 675 ms for four-shot generation and over ten seconds for CIRCLES. Proj reduces the CUB bank cache from 2107 to 211 MiB (Appendix § 9.10).

Ablations and Analysis

This section isolates the sources of TaskVICL’s gains by varying what is extracted, where it is read from, and which answers accompany the retrieved demonstrations. All analyses use Qwen unless stated otherwise.

Task information during extraction

We vary the text supplied during state extraction while the final prompt stays fixed. Task uses the original instruction or question. Generic replaces it with Describe the image briefly, and Generic + List appends the full class list (examples in Appendix § 9.8). Table 4 shows that the class list alone raises Generic accuracy by 5.21 to 22.89 points, and the full task text is best on DTD and CUB. On OK-VQA, task text raises Raw from 54.07 to 60.75 (§ 5.5), so its benefit extends beyond the class list.

Retrieval keyDTDCUBOK-VQA
TaskVICL-Raw (Ours)84.0481.5060.75
Extraction text
Generic78.5646.2954.07
Generic + List83.7869.18–
Decoder depth
Early71.0132.0558.07
Middle83.2478.0559.22
Late83.3581.0060.77
Last81.7279.9359.05
Other representations
GPT-MM [33]81.6072.6459.64
RICES [40] (Qwen vision tower)82.6678.5157.39
VLM2Vec [16]81.6570.2660.69
Caption BGE-M3 [7]78.3555.6857.38
Caption BM25 [29]78.8845.3157.04

Table 4. Retrieval keys on Qwen. Each group varies one part of TaskVICL-Raw (all layers, final input position, task prompt). Generic uses Describe the image briefly; + List appends the class list. GPT-MM uses the final-layer state after generation.

Decoder depth

We keep the final input position and vary the layers used. Last is the final decoder layer, Early, Middle and Late are consecutive groups of 12 of Qwen’s 36 layers, and All is Raw. All exceeds Last by 2.32 points on DTD and 1.57 on CUB, with intervals of [1.60, 3.04] and [1.01, 2.13], and matches

Late on OK-VQA with a difference of −0.02-0.02 and interval [−0.66,0.58][-0.66, 0.58]. Uniform averaging over all layers needs no layer selection and matches or exceeds every layer group within the intervals.

Zero-shot label beliefs

The final input position prepares the first answer token, so Raw might only retrieve examples that the model would label in the same way. We test this with a belief retriever that uses the same input and scores the log-likelihood of every legal label without demonstrations. Prob. compares softmax label probabilities by cosine similarity, and Log. compares mean-centered log-probabilities. On NICO++, belief retrieval searches only bank entries of the query’s question type. The

top belief label equals the zero-shot prediction for 94.8% to 99.1% of images, so these vectors encode the model’s zero-shot answer.

Raw exceeds Prob. on all seven tasks by 1.02 to 17.29 points, with every interval excluding zero (Table 5). The gap comes from queries that the model misclassifies without demonstrations, where Raw leads Prob. by 16.17 to 24.67 points on the single-task datasets, while the two differ by at most 4.83 points on initially correct queries. Log. matches Raw on Aircraft, CUB and Pets, yet Raw still leads on DTD, Dogs and both NICO++ questions, most clearly by 9.91 points on context questions with only six labels. The decoder states therefore carry information beyond the zero-shot label distribution (Appendix § 9.12). Where accuracy matches, the retrieved examples still differ, and Log. shares at most 50.8% of its neighbors with Raw on any task. Belief retrieval also needs a fixed label list and one likelihood per label, so it cannot serve open-ended questions such as OK-VQA, where Raw applies unchanged. Baldassini et al. find that ICL with image retrieval often fails to beat label voting over the retrieved examples [4]. Majority voting over Raw’s neighbors without the VLM reaches 81.14 on the five single-task datasets, and ICL adds 2.32 points and exceeds voting on all seven tasks

DatasetRawVoteProb.Log.Δ\Delta
DTD84.0482.1376.0181.70+2.34 [1.17, 3.62]
Aircraft73.8470.3359.5973.840.00 [−1.29,1.32][-1.29, 1.32]
CUB81.5078.4164.2080.88+0.62 [−0.22,1.47][-0.22, 1.47]
Dogs82.9781.7573.4181.77+1.20 [0.56, 1.86]
Pets94.9693.1091.9994.49+0.46 [−0.08,0.98][-0.08, 0.98]
NICO++ obj.94.5493.1593.5292.50+2.04 [1.11, 2.97]
NICO++ ctx.63.7062.5951.6753.80+9.91 [7.69, 12.41]

Table 5. TaskVICL-Raw (Ours) against zero-shot label beliefs on Qwen. Vote is the majority label of Raw’s neighbors. Δ\Delta is Raw − Log. with paired 95% intervals; gray marks an interval that includes zero.

(Appendix E).

External representations

We next compare Raw with representations outside the target decoder (Table 4). VLM2Vec is a trained instruction-conditioned multimodal embedder that receives the same image and task text [16]. The caption selectors join an offline generic caption from Qwen3-VL-4B with the task text and rank it with BGE-M3 embeddings [7] or BM25 [29].

Raw exceeds VLM2Vec by 2.39 points on DTD and 11.24 on CUB, with intervals of [1.01, 3.83] and [10.10, 12.39], and the two are on par on OK-VQA with interval [−0.83, 0.97]. Raw exceeds both caption selectors on all three datasets, and all six paired intervals exclude zero. Qwen’s vision tower trails Raw by 1.38 points on DTD, 2.99 on CUB and 3.36 on OK-VQA, which suggests that the decoder’s joint processing of image and task contributes to the gain (paired differences in Appendix F). These controls separate Raw from post-generation and general-purpose embeddings. Pre-generation states of all layers exceed the GPT-MM state, decoder states exceed the vision tower, and task text exceeds a generic prompt (Table 4).

Bank answers and corrective context

We cross the extraction source (Task or Generic) with the answers shown for the retrieved examples, either reference answers or the VLM’s own zero-shot predictions (Model), while the retrieved examples stay fixed. On OK-VQA (Table 6), reference answers add 6.14 points under Task retrieval with interval [5.16, 7.08] and only 0.80 under Generic retrieval with interval [0.19, 1.41]. Figure 4 illustrates this on two OK-VQA queries. Image-only retrieval returns visually similar images whose answers address other questions, whereas Raw returns examples that ask the same question, so their reference answers apply directly.

Table 6: Demonstration answers with fixed retrieved examples on Qwen. Model shows the VLM’s own zero-shot predictions as demonstration answers, and Reference shows bank reference answers. OK-VQA uses Raw with Task or Generic extraction text. On CUB, Initially wrong covers the 3640 of 5794 queries Qwen misclassifies without demonstrations, and RICES uses CLIP ViT-B/32.

SettingRetrievalModelReference
OK-VQARaw, Task54.6160.75
Raw, Generic53.2754.07
CUB, allRICES36.1871.21
Raw37.7381.50
CUB, initially wrongRICES7.8863.30
Raw4.6274.92

Table 6.

OK-VQA examples with InternVL

Figure 4. OK-VQA examples with InternVL. RICES retrieves visually similar images whose questions differ from the query, while TaskVICL-Raw retrieves demonstrations asking the same question.

We then ask whether reference answers help recover queries the VLM gets wrong on its own. On CUB, Qwen first predicts every bank and query label without demonstrations. Model shows these predictions as demonstration answers, and Reference replaces the wrong ones with reference labels. Reference answers add 43.77 points for Raw and 35.04 for RICES (Table 6). On the 3640 initially wrong queries, Raw rises from 4.62 to 74.92 and RICES from 7.88 to 63.30. When the two retrievers are matched on the number of wrong demonstration answers, Raw still gains 10.23 points more than RICES, with interval [8.00, 12.52] (Appendix H).

Raw retrieves well even where the model itself answers poorly. Qwen labels only 37.18% of CUB queries correctly without demonstrations, yet 72.20% of Raw’s retrieved examples share the query class, against 46.62% for RICES (Appendix D). Images of one class thus receive similar states even when the model misnames them, and the reference answers supply the correct name.

Task-Conditioned Visual Attention

To see how the task text changes what the extraction position reads from the image, we examine attention at the final input position TT used for retrieval. We sample 300 images from each of Aircraft, CUB, Dogs, Pets and NICO++ before extracting attention. Each image receives four prompts. Task uses the original instruction (the object question on NICO++), Context asks about the image context, Description requests a generic description and No question omits the question.

We average attention from TT to the VV image tokens over heads and layers and normalize it to pvp_v over image tokens. The task region covers the classified object, that is the aircraft, bird, dog, pet or NICO++ object, and stays fixed across prompts in original image coordinates. For a region with token coverage rv∈[0,1]r_v \in[0,1], the density DR=∑vrvpv/∑vrv/VD_R = \sum_v r_v p_v / \sum_v r_v / V divides the region’s share of image attention by its share of area, so uniform attention gives one (Appendix I).

Task gives the highest task-region density on all five datasets (Table 7). Relative to the context question, it raises density by 0.24 to 0.61 with every interval excluding zero, and it does so on at least 95% of the images in each dataset. Description and No question also stay well below Task, so the shift requires the task text. Figure 5 shows that the shift emerges after about layer 18, where the Task curve rises above uniform density on CUB, Dogs, Pets and NICO++. We use these measurements to describe internal processing and measure demonstration utility through predictions [1, 14].

Table 7: Mean task-region density with attention averaged over 36 layers. Δ\Delta is Task − Context with paired image-bootstrap 95% intervals.

DatasetTaskContextDescr.No quest.Δ\Delta
Aircraft0.5850.3490.4290.375+0.24 [0.22, 0.25]
CUB0.8440.4320.5290.492+0.41 [0.39, 0.44]
Dogs1.0760.5690.6660.643+0.51 [0.45, 0.57]
Pets1.0560.4510.5760.549+0.61 [0.56, 0.66]
NICO++0.9700.5010.5390.523+0.47 [0.41, 0.54]

Table 7.

Figure 5. Attention at the final input position. Top: mean task-region density per layer; Task is the object question, and grey lines mark uniform density. Bottom: a NICO++ example averaged over 36 layers, selected after inspecting maps.

Conclusion

We presented TaskVICL, which selects visual in-context demonstrations with task-conditioned decoder states of the frozen target VLM. Its training-free Raw variant compares all decoder layers before generation. Across two VLMs and eight datasets, Raw has the highest average among training-free retrievers, and on NICO++ it adapts its demonstrations to the question asked. Ablations show that task text at extraction underlies most gains and that bank reference answers correct many initial errors; task text also draws more attention to the classified object. A projection learned from bank labels adds classification gains at a tenth of the storage, and unsupervised PCA keeps question answering accuracy at the same cost.

Limitations. TaskVICL reads hidden states and therefore applies only to open-weight VLMs. Raw stores all layer states (360 KiB per Qwen bank entry), and a new target model or label set requires re-extracting the bank. Retrieval quality also depends on the target model: on InternVL Aircraft and CUB, where zero-shot accuracy is below 15%, Raw retrieves about as many same-class examples as RICES. Our largest evaluated model is Gemma-3-12B-IT, and our intervals cover query sampling but not variation from bank splits, prompt templates or demonstration order.

Acknowledgments. This research/project is supported by the National Research Foundation, Singapore under its National Large Language Models Funding Initiative (AISG Award No: AISG-NMLP-2024-004). Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not reflect the views of National Research Foundation, Singapore.

LLM Usage Statement

ChatGPT assisted with editing the manuscript, revising its language, checking related-work descriptions and editing the LaTeX source. Claude (Anthropic) assisted with revising and condensing the text, editing the LaTeX source and TikZ figures, checking numerical consistency across tables, and simulating reviewer feedback on drafts. ChatGPT also helped organize the experimental discussion and summarize the paired corrective-effect analysis. Reported quantitative results come from the authors’ experimental records. Codex assisted with approximate image-only subject outlines for the NICO++ attention study before attention maps were extracted. Qwen3-VL-4B and InternVL3.5-4B are the target models evaluated in the experiments.

Supplementary Material

Implementation Details

State extraction. TaskVICL extracts the state at the final input position of each decoder layer, including the assistant prefix, before any answer is generated. Images go through the target VLM’s own processor. Qwen uses processor pixel bounds of 65,536 and 16,777,216, and its classification messages carry 224 × 224 image-size hints. InternVL uses native dynamic tiling with up to 12 tiles plus a thumbnail, each 448 × 448 with 256 visual tokens. Both models run in BF16.

Prediction. Classification, including zero-shot, uses legal-label decoding. Question answering uses greedy decoding with at most 32 new tokens. The four demonstrations appear in ascending similarity, with the nearest last. Without demonstrations, InternVL often appends the option text to the ScienceQA option letter, so 31.9% of its zero-shot ScienceQA outputs are invalid, while all four-shot ScienceQA runs have at least 99.7% valid outputs. The equal InternVL OK-VQA scores of RICES and Random-4 (47.62) come from two separate runs with different demonstrations.

Uncertainty. Seed 73 fixes the sampling of Random-4 and the training of Proj and DeTriever, and the other retrievers are deterministic. Paired intervals use 2000 bootstrap resamples of the same query units with seed 73. The CUB answer intervention and its matched analyses use 20000 resamples. NICO++ resamples the 1080 images with both questions kept together. These intervals describe query uncertainty for fixed runs, and Sec. D reports variation across seeds.

Baseline Details

All baselines receive the image and the original task text, search the same complete bank, return four demonstrations in ascending similarity and use the common final prompt with reference answers. Query reference answers never enter representation extraction or retriever training.

RICES and image encoders. RICES ranks bank images by cosine similarity of L2-normalized FP32 image features. RICES without a qualifier denotes the CLIP ViT-B/32 variant throughout. CLIP ViT-B/32 and ViT-L/14 use the OpenAI checkpoints at 224 × 224. DINOv3 uses the frozen ViT-B/16 model at its native 256-pixel resolution with mean patch features. The vision-tower control mean-pools the output tokens of Qwen3-VL-4B’s own vision encoder under its native processor. On NICO++, the four demonstrations have distinct images.

VLM2Vec. We use TIGER-Lab/VLM2Vec-Full with frozen weights, its Phi vision processor and 16 crops. The input combines the image with a fixed representation instruction and the complete task text, including the label list for classification and the question and options for question answering. The normalized 3072-dimensional final state at the last input position ranks the bank by cosine similarity.

Caption selectors. Qwen3-VL-4B generates one question-independent description per image with at most 64 new tokens, computed offline. Each description is joined with the original task text. BGE-M3 embeds this text into a normalized 1024-dimensional CLS feature with maximum length 8192, and BM25 ranks it with k1=1.2k_1 = 1.2 and b=0.75b = 0.75. The banks contain 3760 DTD, 5994 CUB and 9009 OK-VQA entries.

GPT-MM. GPT-MM combines task-aware retrieval with label-induced reasoning [33]. We evaluate its retrieval component with the target VLM as the representation model and keep the shared final prompt without generated reasoning. The frozen VLM first answers every bank example and query greedily without demonstrations, with at most 12 new tokens for classification and 32 for question answering. Let mm be the number of generated tokens before the first end-of-sequence token and TT the number of available hidden-state steps. We take the final-layer state at the last position of step min⁡(max⁡(1,m),T−1)\min(\max(1,m),T-1), or the last step if generation reaches the cap. These 2560-dimensional vectors are normalized and ranked by cosine similarity without fitted parameters.

DeTriever. DeTriever learns a weighted combination of decoder-layer transformations for NL2SQL retrieval [20]. We apply it to the frozen final-input states of decoder layers L={1,6,11,16,21,26,31,36}\mathcal{L} = \{1,6,11,16,21,26,31,36\}. Each layer has its own MLP fℓf_\ell with widths 2560→1024→1024→5122560 \to1024 \to1024 \to512 and ReLU after the first two maps, and learned logits aℓa_\ell give the layer weights,

e(x,t)=v(∑ℓ∈Lαℓfℓ(hℓ(x,t))),e(x,t)=v\left(\sum_{\ell\in\mathcal{L}}\alpha_\ell f_\ell(h_\ell(x,t))\right),
αℓ=exp⁡(aℓ)∑j∈Lexp⁡(aj).(5)\alpha_\ell=\frac{\exp(a_\ell)}{\sum_{j\in\mathcal{L}}\exp(a_j)}. \tag*{(5)}

For the training target, we append each bank example’s reference answer as the assistant response and take the teacher-forced final-layer state at the last chat position. Dot products between these vectors rank the other bank entries for each anchor, and the 40 most and 100 least similar entries form its positives and negatives. A supervised contrastive loss trains the head for 10000 steps with batch size 64, temperature 0.07, AdamW with learning rate 10−410^{-4}, weight decay 0.01 and coefficients (0.9, 0.98), refreshing a cache of candidate embeddings every 100 steps. A separate head is trained per model and dataset on the bank alone. Queries are encoded from the image and task text before generation.

CIRCLES. CIRCLES generates attribute and counterfactual descriptions with the target VLM, using at most 512 new tokens per auxiliary generation, and encodes images and text with CLIP ViT-g/14, truncating text to 77 tokens [36]. It retains its two image-based and two counterfactual-based retrieval arms. Images are distinct within each arm, and an image retrieved by both arms appears twice.

MMICES. We follow Algorithm 1 of MMICES [8]. It preselects the K=32K = 32 bank entries with the highest visual similarity to the query and selects N=4N = 4 of them by text similarity, placing the most similar last. Visual features are the visual tokens that the target VLM’s own vision encoder passes to the language model, mean-pooled and L2-normalized. Qwen uses its native resolution, and InternVL uses a single 448×448448 \times448 view without tiling. The original method runs on OpenFlamingo, whose vision encoder is CLIP, so this choice carries its design over to the evaluated VLMs. Text similarity is the cosine similarity of CLIP ViT-B/32 text features with 77-token truncation. The text contains only the question and never an answer. For classification it is the task instruction, which is identical for all entries. On NICO++ it is the object or context question, and the two questions differ from the second token. For ScienceQA and OK-VQA it is the question sentence without instruction, context or options, and every such text fits within 77 tokens. Ties in text similarity keep the visual order. On the five single-task datasets the reranking is therefore constant, and the selected examples equal the four visual nearest neighbors for every query. Qwen DTD accuracy is accordingly 82.61, against 82.66 for the vision-tower RICES control. On NICO++ every selected example shares the query’s question type. Prediction uses the four-shot prompt and decoding of the main results. Table S1 gives paired intervals for Raw against MMICES.

DatasetQwen3-VL-4BInternVL3.5-4B
NICO++ object+0.46 [−0.56, 1.48]+1.57 [0.46, 2.78]
NICO++ context+2.13 [0.09, 4.17]+2.69 [1.37, 4.01]
DTD+1.44 [0.16, 2.71]0.00 [−1.70, 1.70]
Aircraft+8.49 [6.84, 10.17]+8.88 [7.11, 10.68]
CUB+3.16 [2.11, 4.21]+25.54 [24.02, 27.01]
Dogs+5.82 [4.95, 6.70]+22.39 [21.18, 23.59]
Pets+3.33 [2.51, 4.14]+23.85 [22.21, 25.57]
ScienceQA+3.92 [2.68, 5.11]+0.59 [−0.45, 1.54]
OK-VQA+3.78 [2.68, 4.91]+2.85 [1.88, 3.80]

Table S1.

Table S1: Raw minus MMICES, in points with paired 95% intervals. NICO++ resamples images.

Projection Variants

Supervised projection. Proj applies one bias-free linear map to every normalized layer state, with 2560×256=6553602560 \times256 = 655360 parameters for Qwen. The contrastive objective sums the exponentiated similarities to all same-group examples inside the logarithm, and the denominator contains every other batch example. Group slots may repeat when fewer than 16 eligible groups exist. Classification holds out ten bank examples per class for checkpoint selection. A supervised variant for question answering groups bank questions by normalized training answer and keeps groups with at least 14 questions, ten of which form the development split. OK-VQA then yields only five groups (kite, travel, ski, mountain and eat), with 83 questions in total, 33 for training and 50 for development. This weakly supervised Proj gives the OK-VQA Proj entries in Secs. F and H, and Table 1 uses PCA for question answering.

PCA for question answering. PCA fits a 256-dimensional basis to bank states without answers, and projected layer states are normalized and averaged uniformly as in Proj. PCA minus Raw is +0.15 [−0.49, 0.79] on Qwen ScienceQA, +0.04 [−0.63, 0.71] on Qwen OK-VQA, −0.15 [−0.79, 0.40] on InternVL ScienceQA and +0.30 [−0.31, 0.92] on InternVL OK-VQA. PCA therefore keeps Raw’s accuracy at a tenth of the storage.

Learned layer weights. Learning layer weights on top of Proj changes Qwen accuracy by at most 0.59 points across the five classification datasets and the two question answering datasets. On InternVL it adds 0.27 to 1.78 points on Aircraft, CUB, Dogs and Pets. We keep uniform weights for simplicity.

Projection forms. We compare projection forms on Qwen DTD and CUB with the same cached states, development split (3290 and 470 DTD images, 3994 and 2000 CUB images), uniform averaging and final prompts. Gaussian entries have variance 1/p1/p, PCA pools normalized training-bank states across layers without whitening, and the bias-free MLP has widths 2560→1024→2562560 \to1024 \to256. Learned forms share the objective and 1500 AdamW steps with learning rate 0.0003 and weight decay 0.01, refitted separately from the main-table checkpoints. The paired 95% intervals for Linear minus X are [1.12, 3.46], [0.74, 3.24] and [−0.48, 2.02] on DTD and [1.19, 2.83], [2.05, 3.73] and [0.02, 1.43] on CUB, for Gaussian, PCA and MLP respectively. Table S2 reports development label precision at four. The linear map exceeds the Gaussian and PCA projections by 1.97 to 2.89 points, so the gain of Proj stems from bank supervision and dimensionality reduction alone does not explain it. The MLP adds 2.2M parameters without improving over the linear map.

ProjectionDTD Dev.DTD Lin. − XCUB Dev.CUB Lin. − X
Gaussian78.72+2.2968.44+2.03
PCA78.51+1.9767.11+2.89
Shared MLP84.89+0.8072.41+0.75
Shared linear83.51−74.12−

Table S2.

Table S2: Projection forms at p=256p = 256 on Qwen. Dev. is development label precision at four on held-out bank examples. Linear − X is the accuracy difference in points.

Width. Table S3 varies the linear output width from 32 to 512 with everything else fixed. Accuracy changes by less than one point across widths, so even p=32p = 32 (1.25% of the Raw cache) retains most of the gain. The main paper keeps p=256p = 256, fixed before this study.

DTDCUBCache (%)
ppAcc.Dev.Δ\DeltaAcc.Dev.Δ\Delta
3285.4883.19−0.16 [−0.96, 0.64]82.4573.38−0.71 [−1.33, −0.05]1.25
6485.4383.56−0.21 [−0.96, 0.53]83.2674.30+0.10 [−0.47, 0.67]2.50
12885.2183.46−0.43 [−1.12, 0.32]82.9074.45+0.26 [−0.79, 0.31]5.00
25685.6483.51−83.1574.12−10.00
51285.8583.46+0.21 [−0.43, 0.80]82.8874.16−0.28 [−0.76, 0.21]20.00

Table S3. Shared linear width on Qwen. Acc. and Dev. (development precision at four) are percentages. Δ\Delta is accuracy minus the p=256p = 256 run with paired 95% intervals. Cache is the FP32 feature size relative to Raw.

Additional Results

Repeated runs. Table Table S4 repeats the Qwen classification evaluation with seeds 73, 74 and 75. RICES, GPT-MM, CIRCLES and Raw retrieve deterministically, so their spread reflects runtime differences between resumed runs. For DeTriever and Proj it also includes the training seed. Standard deviations stay below 0.5 points for Raw and Proj, and their ranking against the baselines is unchanged on every dataset.

MethodDTDAircraftCUBDogsPets
RICES78.71±0.0878.71 \pm0.0859.71±0.0559.71 \pm0.0571.23±0.0371.23 \pm0.0374.25±0.0774.25 \pm0.0791.59±0.1191.59 \pm0.11
GPT-MM81.56±0.0681.56 \pm0.0668.85±0.4968.85 \pm0.4972.78±0.2472.78 \pm0.2478.67±0.0278.67 \pm0.0293.05±0.3393.05 \pm0.33
DeTriever78.09±0.6878.09 \pm0.6868.29±0.4768.29 \pm0.4770.69±1.7670.69 \pm1.7677.69±0.8977.69 \pm0.8992.88±0.4392.88 \pm0.43
CIRCLES80.83±0.1380.83 \pm0.1367.53±0.0367.53 \pm0.0381.94±0.0481.94 \pm0.0479.33±0.0379.33 \pm0.0393.29±0.0393.29 \pm0.03
TaskVICL-Raw84.01±0.1184.01 \pm0.1173.95±0.1073.95 \pm0.1081.45±0.1881.45 \pm0.1883.05±0.1083.05 \pm0.1094.90±0.1294.90 \pm0.12
TaskVICL-Proj85.43±0.4485.43 \pm0.4478.62±0.1478.62 \pm0.1483.42±0.1883.42 \pm0.1885.05±0.1385.05 \pm0.1395.38±0.2195.38 \pm0.21

Table S4. Qwen classification accuracy over seeds 73, 74 and 75, as mean ±\pm sample standard deviation.

Number of demonstrations. Table Table S5 varies the number of demonstrations on Qwen DTD, CUB and OK-VQA with k∈{1,4,8}k \in\{1, 4, 8\}. The kk nearest bank examples enter the prompt in ascending similarity order, with the nearest last. RICES uses CLIP ViT-B/32. The DTD and CUB RICES results use the main-table rankings. On OK-VQA, the reported four-shot scores are 60.75 for Raw and 57.52 for RICES, compared with 60.75 and 57.63 in the main table. Within each dataset and method, the one-, four- and eight-shot comparisons shown here use the corresponding ranking. OK-VQA uses the original prompt with only the number of answered examples changed, and the official ten-annotator consensus score.

Table S5: Qwen results with kk demonstrations on DTD (1,880 queries), CUB (5,794) and OK-VQA (5,046 queries, consensus score). Raw − RICES uses paired 95% query-bootstrap intervals.

kkRICESRawRaw − RICES
DTD
173.8382.71+8.88 [7.18, 10.80]
478.7284.04+5.32 [3.77, 6.97]
880.3784.15+3.78 [2.29, 5.27]
CUB
158.6675.61+16.95 [15.57, 18.29]
471.2181.50+10.29 [9.11, 11.41]
873.7381.60+7.87 [6.78, 9.01]
OK-VQA
156.5058.99+2.48 [1.34, 3.63]
457.5260.75+3.23 [2.12, 4.35]
858.2661.22+2.95 [1.76, 4.02]

Table S5.

Raw exceeds RICES at every evaluated kk on all three datasets, and all nine available paired intervals exclude zero. On classification, RICES benefits more from additional demonstrations. From one to eight shots, RICES gains 6.54 points on DTD and 15.07 on CUB, compared with 1.44 and 5.99 for Raw. A single Raw neighbor exceeds eight RICES neighbors by 2.34 points on DTD and 1.88 on CUB. The Raw advantage narrows with kk on classification but remains at 3.78 and 7.87 points with eight shots. On OK-VQA, both methods gain about two points from one to eight demonstrations, and the Raw advantage stays between 2.48 and 3.23 points.

Demonstration order. TaskVICL places the four demonstrations in ascending similarity order, with the nearest last. To test whether this convention matters, we keep the four Raw demonstrations of every query fixed and change only their order. Nearest first reverses the order. Random applies a uniformly sampled permutation per query with seed 73. We evaluate Qwen3-VL-4B-Instruct on all DTD and CUB queries with the main-table prediction settings. All three orders use the same re-extracted Raw rankings. Nearest last scores 83.67 on DTD and 81.20 on CUB, compared with 84.04 and 81.50 in the main table with the original states.

All four order differences in Table Table S6 are within 0.69 points and their intervals include zero. Under the tested permutations, performance is not strongly dependent on nearest-last ordering.

Table S6: Qwen accuracy with the same four Raw demonstrations in different orders. Differences from nearest last are paired 95% query-bootstrap intervals (2000 resamples, seed 73). DTD has 1880 queries and CUB 5794.

OrderDTDCUB
Nearest last (default)83.6781.20
Nearest first84.3681.39
Random83.7880.95
Nearest first − last+0.69 [−0.16, 1.54]+0.19 [−0.40, 0.78]
Random − last+0.11 [−0.74, 0.91]−0.26 [−0.88, 0.38]

Table S6.

Label precision of retrieved examples. For a classification query qq with label yqy_q and demonstration labels yq1,…,yq4y_{q_1}, \ldots, y_{q_4}, label precision@4 is 100 ∑ccq/(4Q)\sum_{c} c_q/(4Q) with cq=∑j=141[yqj=yq]c_q = \sum_{j=1}^{4} \mathbf{1}[y_{q_j} = y_q]. Query labels are used only for this diagnostic after retrieval, and repeated CIRCLES images count at every position. Table Table S7 shows that Raw retrieves more same-class examples than RICES on all five Qwen datasets, and Proj raises precision further on every dataset for both models. On InterVL Aircraft and CUB, where zero-shot accuracy is only 14.04 and 14.93, Raw is close to RICES.

MethodDTDAircraftCUBDogsPets
Qwen3-VL-4B
Random-42.05 (0.08)0.97 (0.04)0.50 (0.02)0.73 (0.03)2.87 (0.11)
RICES60.56 (2.42)31.56 (1.26)46.62 (1.86)39.24 (1.57)65.71 (2.63)
GPT-MM76.61 (3.06)55.74 (2.23)58.13 (2.33)69.53 (2.78)88.54 (3.54)
DeTriever67.50 (2.70)57.21 (2.29)51.54 (2.06)66.22 (2.65)86.41 (3.46)
CIRCLES65.12 (2.60)33.15 (1.33)50.28 (2.01)45.72 (1.83)65.15 (2.61)
TaskVICL-Raw80.27 (3.21)64.48 (2.58)72.20 (2.89)76.81 (3.07)92.43 (3.70)
TaskVICL-Proj83.64 (3.35)71.95 (2.88)76.54 (3.06)80.09 (3.20)94.04 (3.76)
InternVL3.5-4B
Random-42.05 (0.08)0.97 (0.04)0.50 (0.02)0.73 (0.03)2.87 (0.11)
RICES60.56 (2.42)31.56 (1.26)46.62 (1.86)39.24 (1.57)65.71 (2.63)
GPT-MM62.38 (2.50)29.21 (1.17)34.18 (1.37)39.32 (1.57)67.97 (2.72)
DeTriever67.09 (2.68)34.19 (1.37)45.24 (1.81)55.18 (2.21)83.81 (3.35)
CIRCLES62.13 (2.48)31.51 (1.26)44.56 (1.77)40.32 (1.61)70.65 (2.83)
TaskVICL-Raw69.81 (2.79)32.85 (1.31)46.34 (1.85)53.47 (2.14)78.82 (3.15)
TaskVICL-Proj74.52 (2.98)39.69 (1.59)59.00 (2.36)61.99 (2.48)86.89 (3.48)

Table S7. Label precision@4 (%) with the mean number of same-class demonstrations in parentheses.

Label Voting over Retrieved Examples

This section is a supplementary diagnostic. TaskVICL is a demonstration retriever for VLM in-context learning, and the main paper evaluates it, like every baseline, through the predictions of the VLM that receives the demonstrations. Recent demonstration-selection methods for VLMs follow the same protocol and do not report a classifier that votes over the labels of the retrieved examples [5, 6, 8, 11, 22, 33, 35, 36, 37]. Baldassini et al. [4] compare RICES-based ICL with such voting

and find that ICL often does not outperform it. We therefore report voting here to characterize the retrieved neighbors.

Protocol. Each query receives the majority reference label among a retriever’s top four bank examples, without running the VLM. Ties go to the label of the nearest example. We evaluate the five Qwen single-task classification datasets with CLIP ViT-B/32, CLIP ViT-L/14 and TaskVICL-Raw neighbors.

Raw states are a stronger retrieval representation. Table S8 shows that voting over Raw neighbors exceeds voting over CLIP ViT-B/32 neighbors by 22.37 points on average and over CLIP ViT-L/14 neighbors by 7.61. Raw voting alone already exceeds ViT-B/32 RICES with four-shot ICL on all five datasets. The training-free states therefore place same-class examples much closer to the query than image encoders, which explains part of the ICL gains in Table 1.

NeighborsPredictionDTDAircraftCUBDogsPetsAvg.
RICES (CLIP ViT-B/32)Vote69.0439.9958.6151.4874.7158.77
RICES (CLIP ViT-L/14)Vote75.3755.7577.1371.3288.0973.53
TaskVICL-RawVote82.1370.3378.4181.7593.1081.14
RICES (CLIP ViT-B/32)ICL78.7259.6871.2174.3291.5275.09
RICES (CLIP ViT-L/14)ICL80.8068.4780.9380.3593.3080.77
TaskVICL-RawICL84.0473.8481.5082.9794.9683.46

Table S8. Label voting over the top four retrieved examples (Vote) and four-shot ICL with the same neighbors (ICL) on Qwen. Values are accuracy percentages.

ICL adds to the retrieved labels. With the same neighbors, four-shot ICL exceeds voting on every dataset and for every retriever, by 2.32 points on average for Raw. On NICO++, voting over Raw neighbors reaches 93.15 on object questions and 62.59 on context questions, against 94.54 and 63.70 with four-shot ICL. The VLM thus uses the demonstrations beyond their majority label, for example on queries whose neighbors disagree.

Question answering. Voting is undefined on ScienceQA and OK-VQA, whose options or open-ended answers differ across questions. There the comparison must go through the VLM, and Raw exceeds every baseline retriever on both datasets and both VLMs (Table 1). Relative to ViT-B/32 RICES, Raw gains 4.21 points on Qwen ScienceQA with interval [3.02, 5.45], 3.12 on Qwen OK-VQA with [2.01, 4.17] and 3.69 on InternVL OK-VQA with [2.70, 4.67]. The InternVL ScienceQA difference of 0.79 has an interval including zero, [−0.25, 1.83].

Layer and Representation Controls

Decoder layers. Early, Middle and Late use Qwen layers 1 to 12, 13 to 24 and 25 to 36, and Last uses layer 36. Table S9 adds an untrained random projection and Proj at each depth. Later layers retrieve better than early ones, and Proj helps classification at every depth while a random projection of the same width changes little. All minus Last is +2.32 [1.60, 3.04] on DTD, +1.57 [1.01, 2.13] on CUB and +1.70 [0.40, 2.97] on OK-VQA. All minus Late is +0.69 [0.02, 1.30] on DTD, +0.50 [0.08, 1.09] on CUB and −0.02 [−0.66, 0.58] on OK-VQA.

LayersMetricDTDCUBOK-VQA
LastRaw81.7279.9359.05
LastUntrained81.7279.6459.65
LastProj85.0583.7660.42
EarlyRaw71.0132.0558.07
EarlyUntrained71.5432.1257.97
EarlyProj78.7241.8557.92
MiddleRaw83.2478.0559.22
MiddleUntrained82.9878.0359.26
MiddleProj84.4779.7558.95
LateRaw83.3581.0060.77
LateUntrained83.4680.8860.83
LateProj85.4884.1760.59
AllRaw84.0481.5060.75
AllUntrained83.9481.2460.52
AllProj85.9083.3660.62

Table S9. Layer groups and projections on Qwen. Untrained is a fixed random projection with the width of Proj.

Retrieval representations. Table S10 gives paired differences between Raw and the image, embedding and caption retrievers on Qwen. Strong image encoders come close to Raw on one of DTD and CUB, yet every image encoder trails Raw on OK-VQA by more than three points. Over all eight datasets of Table 1, Raw exceeds CLIP ViT-L/14 RICES by 3.83 points on Qwen with interval [3.38, 4.27], and by 1.85 points on InternVL with interval [1.41, 2.26]. Among the caption selectors, BGE-M3 exceeds BM25 on CUB by 10.37 points, and the two are on par on DTD and OK-VQA.

RepresentationDTDCUBOK-VQA
RICES (CLIP ViT-B/32)+5.32+5.32 [3.77, 6.97]+10.29+10.29 [9.11, 11.41]+3.12+3.12 [2.01, 4.17]
RICES (CLIP ViT-L/14)+3.24+3.24 [1.76, 4.73]+0.57+0.57 [−0.45-0.45, 1.55]+3.58+3.58 [2.43, 4.76]
RICES (Qwen vision tower)+1.38+1.38 [0.05, 2.71]+2.99+2.99 [1.90, 4.06]+3.36+3.36 [2.26, 4.50]
VLM2Vec+2.39+2.39 [1.01, 3.83]+11.24+11.24 [10.10, 12.39]+0.06+0.06 [−0.83-0.83, 0.97]
Caption BGE-M3+5.69+5.69 [4.15, 7.23]+25.82+25.82 [24.49, 27.15]+3.37+3.37 [2.27, 4.45]
Caption BM25+5.16+5.16 [3.72, 6.70]+36.19+36.19 [34.78, 37.54]+3.71+3.71 [2.56, 4.78]

Table S10. Raw minus other retrieval representations on Qwen, in points with paired 95% intervals.

NICO++ Paired Tasks

Construction. We sample from the official NICO++ public training set [42], whose native labels cover 60 object classes and six contexts (autumn, dim, grass, outdoor, rock and water). We draw 84 images per object class and 840 per context, 5040 in total, after removing duplicate source paths. The bank holds 3960 images and the query set 1080, with three query images per object and context combination, split by image with seed 73. Images and labels are unchanged. We will release the bank and query lists, and the code upon acceptance of the paper. Each image supplies an object question with the 60-class list and a context question with the six-class list, giving 7920 bank entries and 2160 queries. All methods search the same mixed bank without filtering by question type, and labels are not edited.

Diagnostics. Plain RICES ranks images, and each retrieved image enters the prompt with its object question and the matching reference answer. Image label agreement at four is the share of retrieved images whose native object or context label matches the query image, inspected after retrieval. Neighbor overlap is the number of images shared by the object and context retrieval sets divided by four. The task-matched RICES control keeps the four RICES images and their order and supplies each with its question and reference answer for the query task, both of which are available for every bank image. It reuses the neighbors of each RICES encoder in the main results. Paired differences between Raw and task-matched RICES appear in Table S11.

Task-matched RICESQwenInternVL
CLIP ViT-B/32+2.92+2.92 [1.62, 4.21]+3.15+3.15 [1.90, 4.44]
CLIP ViT-L/14+1.48+1.48 [0.19, 2.73]+1.48+1.48 [0.19, 2.78]
DINOv3+2.36+2.36 [1.11, 3.66]+1.53+1.53 [0.23, 2.82]

Table S11.

Table S11: NICO++ Raw minus task-matched RICES, averaged over object and context questions, with paired image-bootstrap 95% intervals. Full method accuracies are in the main paper.

Proj. NICO++ Proj uses the 66 groups formed by task and native label. Ten bank images per object class form the development split with both questions, the remaining 3360 images supply training entries, and final retrieval uses all 3960 bank images.

Extraction Text and Bank Answers

Extraction source on OK-VQA. Figure S1 shows the Task and Generic extraction inputs. The Raw source-by-answer results are already reported in the main paper. Repeating the OK-VQA study with Proj, fitted separately for each source, gives 60.62 and 54.19 for Task retrieval with reference and model answers and 54.33 and 53.71 for Generic retrieval, closely following Raw.

Extraction inputs for one CUB image

Figure S1. Extraction inputs for one CUB image. The Task excerpt omits the full label list and formatting suffix for readability, and extraction uses the complete prompt. Both conditions lead to the original classification prompt at prediction.

CUB answer intervention. Qwen predicts every bank image and query of CUB (5994 and 5794) without demonstra-

tions using legal-label decoding, which yields 2154 correct queries (37.18%) and 3640 initially wrong ones. Raw and RICES keep their saved neighbors and order for every query. Model shows the independently predicted bank labels and Reference shows the reference labels, so the two conditions differ only where a bank prediction was wrong. The Reference predictions are those of Table 1, and their demonstration identities were checked query by query against the intervention records.

Table S12 shows that nearly all of the gain comes from initially wrong queries, where Raw gains 70.30 points and RICES 55.41. On initially correct queries, both changes have intervals including zero.

QueriesRetrieverModelReferenceGain95% CIRescuedHarmed
All (5794)Raw37.7381.50+43.77[42.39, 45.17]2672136
All (5794)RICES36.1871.21+35.04[33.62, 36.45]2247217
Initially wrong (3640)Raw4.6274.92+70.30[68.82, 71.81]257011
Initially wrong (3640)RICES7.8863.30+55.41[53.74, 57.12]206043
Initially correct (2154)Raw93.6992.62−1.07[−2.46, 0.32]102125
Initially correct (2154)RICES83.9884.59+0.60[−1.07, 2.32]187174

Table S12. CUB answer intervention with 20000 paired query-bootstrap resamples. Rescued and Harmed count queries that switch from wrong to correct and from correct to wrong between Model and Reference.

Matched subsets. Raw retrieves four independently mispredicted bank examples for 2620 queries, compared with 1908 for RICES, so its larger gain could reflect more corrected labels. We therefore restrict to the 1925 queries where both retrievers return the same nonzero number of mispredicted examples (116, 123, 239 and 1447 queries with one to four), 1714 of them initially wrong. Membership depends only on independent predictions and bank labels. Table S13 shows that Raw still gains 10.23 points more than RICES on this subset, so the number of corrected labels alone does not explain the difference.

SubsetnnRaw ModelRaw ReferenceRICES ModelRICES ReferenceGain diff.95% CI
Equal error count192511.1279.0610.3968.10+10.23[8.00, 12.52]
Initially wrong17142.8678.653.3367.33+11.79[9.33, 14.24]

Table S13. Matched CUB subsets. Gain diff. is the Reference minus Model gain of Raw minus that of RICES, with 20000 paired resamples.

Figure S2 shows Qwen queries that the model misclassifies zero-shot, on which RICES stays wrong and Raw is correct. RICES returns visually similar images of other classes. Raw returns examples of the true class that the model itself labels as the same wrong class, and their reference answers correct the prediction.

Figure S2. RICES and TaskVICL-Raw on Qwen3-VL-4B with four demonstrations. GT is the query label and ZS the model’s zero-shot prediction. Labels under each demonstration are its reference answer, green when it matches GT, and grey ZS gives the model’s zero-shot prediction for that demonstration. Examples are selected among queries where zero-shot and RICES are wrong and Raw is correct.

Attention Protocol

Images and prompts. We sample 300 images from each of Aircraft, CUB, Dogs, Pets and NICO++ before any attention is extracted. Each image receives the Task, Context, Description and No question prompts. The assistant prefix is present in all four, and the image tensors and visual token grids are identical across them.

Regions. The task region covers the classified object. Pets uses the released foreground trimap. Aircraft, CUB and Dogs use subject outlines drawn on the images, and NICO++ uses approximate subject outlines drawn from the images alone with assistance from Codex. All regions are fixed in original image coordinates before attention is extracted. It stays the same across the four prompts, and no image is removed based on attention. Each region maps to the token grid by fractional area coverage rv∈[0,1]r_v \in[0, 1].

Attention and density. We reconstruct the attention row at the final input position TT from the saved normalized and position-encoded query and key tensors. The softmax covers all visible positions, including text. For selected layers SS, HH heads and VV image tokens,

av=1∣S∣H∑ℓ∈S∑h=1Haℓ,h(T,v),pv=av∑uau.(6)a_v = \frac{1}{|S|H}\sum_{\ell\in S}\sum_{h=1}^{H} a_{\ell,h}(T,v), \qquad p_v = \frac{a_v}{\sum_u a_u}. \tag*{(6)}

Raw weights are averaged across layers before normalization, which preserves differences in image attention mass across layers. Maps display dv=Vpvd_v = Vp_v, and the regional density is

DR=∑vrvpv/(∑vrv/V),D_R = \sum_v r_v p_v \bigg/ \left(\sum_v r_v/V\right),

so uniform attention gives one. Early, Middle and Late average layers 1 to 12, 13 to 24 and 25 to 36. Intervals resample images with 2000 resamples and seed 73.

Display. Maps use nearest-neighbor cells on the native token grid overlaid on the image at opacity 0.55, with a shared viridis scale from zero to four. Larger values saturate in the display only, and all statistics use the unclipped values. The NICO++ truck example in the main paper and the CUB example in Figure S3 were chosen after inspecting maps for clear subjects. This choice does not affect the aggregate statistics.

Attention at the final input position for a CUB image

Figure S3. Attention at the final input position for a CUB image. Top, the four prompts with attention averaged over 36 layers. Bottom, the Task prompt at six evenly spaced layers and the all-layer average. The Task prompt concentrates attention on the bird in the later layers. All panels share a density scale from zero to four.

Computation and Storage

Cost model. Bank states are extracted once and cached. At query time, Raw needs one extra forward pass of the target VLM before generation and a bank comparison of cost O(NLd)O(NLd) for NN entries, LL layers and width dd. Proj applies the shared map and compares at O(NLp)O(NLp). An FP32 Raw cache stores 4NLd4NLd bytes, which is 360 KiB per Qwen entry, and Proj at p=256p = 256 stores one tenth of that.

Measured latency. On one RTX 4090 with BF16, PyTorch 2.8.0 and CUDA 12.8, we time 100 CUB queries after 20 warm-up queries with cached bank features. Raw extraction takes 128.76 ms on average, search 2.41 ms and four-shot generation 461.05 ms, so retrieval adds about 28% to generation time. Table S14 compares methods in a second run on the same GPU over ten CUB queries after three warm-up queries, searching all 5994 bank entries. Retrieval time includes image loading, preprocessing, representation construction and search, and for CIRCLES also its attribute and counterfactual generation. This CIRCLES variant uses CLIP ViT-B/32 to match RICES. Model loading, bank construction and head training are excluded.

MethodRetrievalGenerationPeakBank
RICES7.68671.619.4411.71
Raw267.35674.9210.912107.27
Proj (p=256p = 256)255.10660.469.05210.73
Proj (p=32p = 32)255.45662.858.8626.34
CIRCLES (ViT-B/32)10682.75693.039.4423.41

Table S14. Pilot costs on ten CUB queries. Retrieval and generation are mean milliseconds. Peak is the maximum allocated GPU memory in GiB, including the VLM, any retrieval encoder and the bank cache. Bank is the FP32 feature size in MiB.

Qwen3-VL-8B-Instruct

To test whether gains persist at a larger scale within the Qwen family, we evaluate Qwen3-VL-8B-Instruct on NICO++, DTD and OK-VQA. To fit a single 16 GB GPU, the language decoder is quantized to 4-bit NF4 with BF16 computation, while the vision encoder and output head remain in BF16. As in the Qwen3-VL-4B experiments, we use seed 73, complete banks and test sets, four demonstrations, 224 × 224 classification images and native-resolution NICO++ and OK-VQA images. NICO++ and DTD use gold label decoding for all methods, including zero-shot. OK-VQA uses greedy decoding and ten-answer consensus scoring. Raw uses the final-input-position states of all 36 decoder layers (36 × 4096), and RICES uses CLIP ViT-B/32. Paired intervals follow Sec. A, with image clusters for NICO++.

Table S15 shows that Raw exceeds RICES in every column. All paired intervals exclude zero except NICO++ object, where zero-shot already reaches 92.22. The NICO++ mean gain of 7.55 points comes mainly from context questions (+14.26). On OK-VQA, zero-shot scores 60.51. RICES lowers the score by 3.17 points, while Raw scores 0.64 points above zero-shot. Relative to zero-shot, Raw gains 12.41 points on NICO++ and 16.44 on DTD. The quantized 8B experiment tests robustness across model sizes. The precision settings differ from those of the main experiments.

MethodNICO++ Obj.NICO++ Ctx.NICO++ Avg.DTDOK-VQA
Zero-shot92.2241.4866.8567.5560.51
RICES93.0650.3771.7180.3257.34
Raw93.8964.6379.2683.9961.15
Raw − RICES+0.83+14.26+7.55+3.67+3.80
95% CI[−0.19, 1.85][11.67, 16.85][6.11, 8.94][2.23, 5.16][2.67, 4.95]

Table S15. Qwen3-VL-8B-Instruct (4-bit NF4 decoder) with zero-shot and four-shot results. NICO++ reports object, context and mean accuracy. Bold marks the best score per column.

Zero-shot Belief Retrieval

Representation. Every bank entry and query uses exactly the input of Raw, the same image and task prompt with the complete label list. For each legal label we compute the zero-shot log-likelihood of the label tokens followed by the end token. Labels are scored with and without a leading space, and the two are merged by log-sum-exp, matching the legal-label decoder. Each image thus receives a label vector, with 60 dimensions for NICO++ object questions and six for context questions.

Retrieval and prediction. Prob. compares softmax probability vectors and Log. compares mean-centered log-probability vectors, both by cosine similarity. The four most similar bank entries enter the prompt with the nearest last. The four-shot prompt and legal-label decoder are identical to Raw. On NICO++, belief retrieval searches only bank entries of the query’s question type and requires four distinct images.

Scoring checks. Packed label scoring agrees with separate full forward passes per label, with absolute errors below 0.1 for plausible labels (log p>−10p > -10) and relative errors below 3% for very unlikely labels. Batched scoring with 16 inputs agrees with single-input scoring on 16 of 16 test rows for DTD, CUB, Dogs, Pets and NICO++, with maximum probability differences of at most 0.036. On Aircraft, near ties between fine-grained labels let bf16 padding effects flip 2 of 8 test predictions, so Aircraft is scored one input at a time without padding, as in the Raw protocol.

Results. Tables S16 through S18 use 2000 paired bootstrap resamples with seed 73, resampling images with both questions on NICO++. Overall accuracy and Raw-minus-Log. intervals are reported in the main paper. Table S16 retains only the additional Raw-minus-Prob. intervals. Prob. falls behind Raw mainly on initially wrong queries, where its neighbors follow the model’s mistaken label. Log. preserves the relative ranking of labels and comes closer, yet it still trails on DTD, Dogs and NICO++, and its neighbors overlap with Raw’s for only 11.0% to 50.8% of positions.

DatasetRaw − Prob.
DTD+8.03 [6.38, 9.73]
Aircraft+14.25 [12.48, 16.02]
CUB+17.29 [16.00, 18.49]
Dogs+9.56 [8.66, 10.42]
Pets+2.97 [2.21, 3.79]
NICO++ object+1.02 [0.19, 1.94]
NICO++ context+12.04 [9.35, 14.54]
NICO++ mean+6.53 [5.09, 7.87]

Table S16. TaskVICL-Raw minus probability-vector belief retrieval (Prob.) on Qwen, with paired 95% intervals. Absolute accuracies and the Raw-minus-Log. comparison are in the main paper.

Table S17 separates the queries that the model answers correctly and incorrectly without demonstrations.

DatasetnnRaw − Prob.Raw − Log.nnRaw − Prob.Raw − Log.
DTD1261+1.27 [0.00, 2.62]+1.11 [0.08, 2.14]619+21.81 [17.77, 26.01]+4.85 [1.78, 7.92]
Aircraft1077+1.86 [−0.47, 4.27]−0.84 [−2.88, 1.11]2256+20.17 [17.86, 22.52]+0.40 [−1.33, 2.13]
CUB2154+4.83 [3.39, 6.27]+0.70 [−0.37, 1.72]3640+24.67 [22.97, 26.37]+0.58 [−0.52, 1.79]
Dogs4667+1.97 [1.14, 2.76]+0.13 [−0.51, 0.77]3913+18.60 [16.97, 20.16]+2.48 [1.30, 3.68]
Pets3026+0.17 [−0.33, 0.66]0.00 [−0.40, 0.36]643+16.17 [12.29, 19.60]+2.64 [0.16, 5.13]
NICO++ object989+0.10 [−0.77, 0.98]+1.92 [1.11, 2.83]91+10.99 [3.30, 19.78]+3.30 [−2.20, 8.79]
NICO++ context420+0.48 [−2.51, 3.46]+2.38 [−0.48, 5.48]660+19.39 [15.61, 23.18]+14.70 [11.21, 18.18]

Table S17. Raw minus belief retrieval on queries that Qwen classifies correctly or incorrectly without demonstrations, with paired 95% intervals.

Table S18 reports neighbor overlap with Raw and the agreement between belief-based top labels and zero-shot predictions.

DatasetProb.Log.Top = ZS
OverlapNoneOverlapNone
DTD18.047.642.413.698.1
Aircraft12.163.837.117.494.8
CUB20.444.250.85.896.9
Dogs13.657.445.79.296.3
Pets13.857.033.321.599.1
NICO++ object11.464.233.624.5–
NICO++ context3.588.011.065.7–

Table S18. Top-four neighbor overlap with Raw, the share of queries with no shared neighbor, and the share of images whose top belief label equals the zero-shot prediction. Values are percentages.

Figure S4 contrasts the Log. belief retriever with Raw on queries that both the model and Log. get wrong. Log. neighbors share the model’s wrong belief and carry that wrong class as their reference answer, so the VLM repeats its zero-shot error. Raw’s neighbors receive the same wrong zero-shot prediction but belong to the true class.

Figure S4. Log. belief retrieval and TaskVICL-Raw on Qwen3-VL-4B. Log. ranks bank examples by the cosine similarity of centered zero-shot label log-probabilities. Notation follows Figure S2. Examples are selected among queries where zero-shot and Log. are wrong and Raw is correct.

References

  1. [1]Julius Adebayo, Justin Gilmer, Michael Muely, Ian Goodfellow, Moritz Hardt, and Been Kim. Sanity checks for saliency maps. In Advances in Neural Information Processing Systems, 2018.arxiv.org/abs/1810.03292
  2. [2]Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, et al. Flamingo: A visual language model for few-shot learning. In Advances in Neural Information Processing Systems, 2022.arxiv.org/abs/2204.14198
  3. [3]Shuai Bai, Yuxuan Cai, Ruizhe Chen, et al. Qwen3-VL technical report. arXiv preprint arXiv:2511.21631, 2025.arxiv.org/abs/2511.21631
  4. [4]Folco Bertini Baldassini, Mustafa Shukor, Matthieu Cord, Laure Soulier, and Benjamin Piwkowski. What makes multimodal in-context learning work? In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, 2024.arxiv.org/abs/2404.15736
  5. [5]Cheng Chen, Yunpeng Zhai, Yifan Zhao, Jinyang Gao, Bolin Ding, and Jia Li. Provoking multi-modal few-shot LVLM via exploration-exploitation in-context learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2025.arxiv.org/abs/2506.09473
  6. [6]Huiyi Chen, Jiawei Peng, Kaihua Tang, Xin Geng, and Xu Yang. Enhancing multimodal in-context learning for image classification through coreset optimization. In Proceedings of the ACM International Conference on Multimedia, 2025.arxiv.org/abs/2504.14200
  7. [7]Jianyu Chen, Shitao Xiao, Peitian Zhang, Kun Luo, Defu Lian, and Zheng Liu. M3-Embedding: Multi-linguality, multi-functionality, multi-granularity text embeddings through self-knowledge distillation. In Findings of the Association for Computational Linguistics: ACL 2024, 2024.arxiv.org/abs/2402.03216
  8. [8]Shuo Chen, Zhen Han, Bailan He, Jianzhе Liu, Mark Buckley, Yao Qin, Philip Torr, Volker Tresp, and Jindong Gu. Can multimodal large language models truly perform multimodal in-context learning? In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, 2025.arxiv.org/abs/2311.18021
  9. [9]Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2014.arxiv.org/abs/1311.3618
  10. [10]Bradley Effron. Bootstrap methods: Another look at the jackknife. The Annals of Statistics, 7(1), 1979.
  11. [11]Honghao Fu, Yuan Ouyang, Kai-Wei Chang, Yiwei Wang, Zi Huang, and Yujun Cai. ContextNext: Towards agentic multimodal in-context learning. In Proceedings of the International Conference on Learning Representations, 2026.
  12. [12]Gemma Team. Gemma 3 technical report. arXiv preprint arXiv:2503.19786, 2025.
  13. [13]Brandon Huang, Chanch arik Mitra, Assaf Arbelle, Leonid Karlinsky, Trevor Darrell, and Roei Herzig. Multimodal task vectors enable many-shot multimodal in-context learning. In Advances in Neural Information Processing Systems, 2024.arxiv.org/abs/2406.15334
  14. [14]Sarthak Jain and Byron C. Wallace. Attention is not explanation. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics, 2019.
  15. [15]Ting Jiang, Minghui Song, Zihan Zhang, Haizhen Huang, Weiwei Deng, Feng Sun, Qi Zhang, Deqing Wang, and Fuzhen Zhuang. E5-V: Universal embeddings with multimodal large language models. arXiv preprint arXiv:2407.12580, 2024.arxiv.org/abs/2407.12580
  16. [16]Ziyan Jiang, Rui Meng, Xinyi Yang, Semih Yavuz, Yingbo Zhou, and Wenhu Chen. VLM2Vec: Training vision-language models for massive multimodal embedding tasks. In Proceedings of the International Conference on Learning Representations, 2025.arxiv.org/abs/2410.05160
  17. [17]Aditya Khosla, Nityananda Jayadevaprakash, Bangpeng Yao, and Fei-Fei Li. Novel dataset for fine-grained image categorization: Stanford Dogs. In Proceedings of the CVPR Workshop on Fine-Grained Visual Categorization, 2011.
  18. [18]Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and Dilip Krishnan. Supervised contrastive learning. In Advances in Neural Information Processing Systems, 2020.arxiv.org/abs/2004.11362
  19. [19]Li Li, Jiawei Peng, Huiyi Chen, Chongyang Gao, and Xu Yang. How to configure good in-context sequence for visual question answering. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2024.arxiv.org/abs/2312.01571
  20. [20]Raymond Li, Yuxi Feng, Zhenan Fan, Giuseppe Carenini, Weiwei Zhang, Mohammadreza Pourreza, and Yong Zhang. Decoder-representation-based retriever for improving NL2SQL in-context learning. In Proceedings of the International Conference on Computational Linguistics, 2025.arxiv.org/abs/2406.07913
  21. [21]Yi Li, Hualiang Wang, Xinpeng Ding, Haonan Wang, and Xiaomeng Li. Token activation map to visually explain multimodal LLMs. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2025.
  22. [22]Yanshu Li, Jianjiang Yang, Tian Yun, Pinyuan Feng, Jinfa Huang, and Ruixiang Tang. TACO: Enhancing multimodal in-context learning via task mapping-guided sequence configuration. In Proceedings of the Conference on Empirical Methods in Natural Language Processing, 2025.arxiv.org/abs/2505.17098
  23. [23]Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. What makes good in-context examples for GPT-3? In Proceedings of the Workshop on Knowledge Extraction and Integration for Deep Learning Architectures, 2022.
  24. [24]Pan Lu, Swaroop Mishra, Tanglin Xia, Liang Qiu, Kai-Wei Chang, Song-Chun Zhu, Oyvind Fjord, Peter Clark, and Ashwin Kalyan. Learn to explain: Multimodal reasoning via thought chains for science question answering. In Advances in Neural Information Processing Systems, 2022.arxiv.org/abs/2209.09513
  25. [25]Subhranshu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013.arxiv.org/abs/1306.5151
  26. [26]Kenneth Marino, Mohammad Rastegari, Ali Farhadi, and Roozbeh Mottaghi. OK-VQA: A visual question answering benchmark requiring external knowledge. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019.arxiv.org/abs/1906.00067
  27. [27]Omkar M. Parkhi, Andrea Vedaldi, Andrew Zisserman, and C. V. Jawahar. Cats and dogs. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2012.
  28. [28]Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In Proceedings of the International Conference on Machine Learning, 2021.arxiv.org/abs/2103.00020
  29. [29]Stephen Robertson and Hugo Zaragoza. The probabilistic relevance framework: BM25 and beyond. Foundations and Trends in Information Retrieval, 3(4), 2009.
  30. [30]Ohad Rubin, Jonathan Herzig, and Jonathan Berant. Learning to retrieve prompts for in-context learning. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, 2022.
  31. [31]Oriane Siméoni, Huy V. Vo, Maximilian Seitzer, et al. DINOv3. Transactions on Machine Learning Research, 2026.arxiv.org/abs/2508.10104
  32. [32]Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The Caltech-UCSD Birds-200-2011 dataset. Technical Report CNS-TR-2011-001, California Institute of Technology, 2011.
  33. [33]Zhen Wang, Fei Cheng, and Sadao Kurohashi. GPT-MM: Improving multimodal in-context learning with task-specific retrieval and reasoning. Journal of Natural Language Processing, 33(1), 2026.DOI
  34. [34]Weiyun Wang, Zhangwei Gao, Lixin Gu, et al. InternVL3.5: Advancing open-source multimodal models in versatility, reasoning, and efficiency. arXiv preprint arXiv:2508.18265, 2025.arxiv.org/abs/2508.18265
  35. [35]Zihua Wang, Jiarui Wang, Haiyang Xu, Ming Yan, Fei Huang, Xu Yang, Xiu-Sher Wei, Siya Mi, and Yu Zhang. Efficient and effective in-context demonstration selection with coreset. In Proceedings of the AAAI Conference on Artificial Intelligence, 2026.
  36. [36]Guangzhi Xiong, Sanchit Sinha, Zhenghao He, and Aidong Zhang. Retrieving counterfactuals improves visual in-context learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2026.arxiv.org/abs/2603.16737
  37. [37]Nan Xu, Fei Wang, Sheng Zhang, Hoifung Poon, and Muhao Chen. From introspection to best practices: Principled analysis of demonstrations in multimodal in-context learning. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics, 2025.
  38. [38]Xu Yang, Yongliang Wu, Mingzhuo Yang, Haokun Chen, and Xin Geng. Exploring diverse in-context configurations for image captioning. In Advances in Neural Information Processing Systems, 2023.arxiv.org/abs/2305.14800
  39. [39]Xu Yang, Yingzhe Peng, Haoxuan Ma, Shuo Xu, Chi Zhang, Yucheng Han, and Hanwang Zhang. Lever LM: Configuring in-context sequence to lever large vision language models. In Advances in Neural Information Processing Systems, 2024.arxiv.org/abs/2312.10104
  40. [40]Zhengyuan Yang, Zhe Gan, Jianfeng Wang, Xiaowei Hu, Yu-mao Lu, Zicheng Liu, and Lijuan Wang. An empirical study of GPT-3 for few-shot knowledge-based VQA. In Proceedings of the AAAI Conference on Artificial Intelligence, 2022.arxiv.org/abs/2109.05014
  41. [41]Jiacheng Ye, Zhiyong Wu, Jiangtao Feng, Tao Yu, and Lingpeng Kong. Compositional exemplars for in-context learning. In Proceedings of the International Conference on Machine Learning, 2023.arxiv.org/abs/2302.05698
  42. [42]Xingxuan Zhang, Yue He, Renzhe Xu, Han Yu, Zheyan Shen, and Peng Cui. NICO++: Towards better benchmarking for domain generalization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2023.arxiv.org/abs/2204.08040
  43. [43]Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. What makes good examples for visual in-context learning? In Advances in Neural Information Processing Systems, 2023.arxiv.org/abs/2301.13670
  44. [44]Yucheng Zhou, Xiang Li, Qianning Wang, and Jianbing Shen. Visual in-context learning for large vision-language models. In Findings of the Association for Computational Linguistics: ACL 2024, 2024.arxiv.org/abs/2402.11574

Paper details

vlnc:W_k2yy6dua
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

ChatGPT, Claude (Anthropic), Codex

View statement
Looking for related papers…
Contents