TaskVICL: Task-Conditioned Decoder States for Visual In-Context Learning
Organizations: National University of Singapore · Nanyang Technological University · Sun Yat-sen University · Institute of Advanced Intelligence and Computing (IAIC), Singapore ·
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.
Figures & tables
| Classification | Question answering | Overall | |||||||||
| NICO++ | |||||||||||
| VLM | Method | Object | Context | DTD | Aircraft | CUB | Dogs | Pets | ScienceQA | OK-VQA | Avg. |
| Query count | 1080 | 1080 | 1880 | 3333 | 5794 | 8580 | 3669 | 2017 | 5046 | – | |
| Qwen3-VL-4B | Training-free | ||||||||||
| Zero-shot | 91.57 | 38.89 | 67.07 | 32.31 | 37.18 | 54.39 | 82.47 | 90.73 | 58.74 | 61.02 | |
| Random-4 | 90.74 | 39.17 | 58.78 | 33.21 | 28.34 | 49.69 | 70.18 | 89.84 | 57.14 | 56.52 | |
| Qwen | InternVL | |||
|---|---|---|---|---|
| Method | Image | + Task | Image | + Task |
| RICES (CLIP ViT-B/32) [ 40 , 28 ] | 69.03 | 76.20 | 68.61 | 73.75 |
| RICES (CLIP ViT-L/14) [ 40 , 28 ] | 69.73 | 77.64 | 70.65 | 75.42 |
| RICES (DINOv3) [ 40 , 31 ] | 69.17 | 76.76 | 70.51 | 75.37 |
| GPT-MM [ 33 ] | 77.69 | 76.06 | ||
| MMICES [ 8 ] | 77.82 | 74.77 | ||
| Dataset | Zero-shot | RICES | Raw | |
|---|---|---|---|---|
| NICO++ object | 90.83 | 91.11 | 92.69 | |
| NICO++ context | 37.41 | 54.44 | 64.44 | |
| mean | 64.12 | 72.78 | 78.56 | |
| DTD | 67.87 | 81.54 | 82.66 | |
| OK-VQA | 34.73 | 54.28 | 57.92 |
| Retrieval key | DTD | CUB | OK-VQA |
|---|---|---|---|
| TaskVICL-Raw (Ours) | 84.04 | 81.50 | 60.75 |
| Extraction text | |||
| Generic | 78.56 | 46.29 | 54.07 |
| Generic + List | 83.78 | 69.18 | – |
| Decoder depth | |||
| Early | 71.01 | 32.05 | 58.07 |
| Dataset | Raw | Vote | Prob. | Log. | |
|---|---|---|---|---|---|
| DTD | 84.04 | 82.13 | 76.01 | 81.70 | |
| Aircraft | 73.84 | 70.33 | 59.59 | 73.84 | |
| CUB | 81.50 | 78.41 | 64.20 | 80.88 | |
| Dogs | 82.97 | 81.75 | 73.41 | 81.77 | |
| Pets | 94.96 | 93.10 | 91.99 | 94.49 | |
| NICO++ obj. | 94.54 | 93.15 | 93.52 | 92.50 |
| Setting | Retrieval | Model | Reference |
|---|---|---|---|
| OK-VQA | Raw, Task | 54.61 | 60.75 |
| Raw, Generic | 53.27 | 54.07 | |
| CUB, all | RICES | 36.18 | 71.21 |
| Raw | 37.73 | 81.50 | |
| CUB, initially wrong | RICES | 7.88 | 63.30 |
| Raw | 4.62 | 74.92 |
| Dataset | Task | Context | Descr. | No quest. | |
|---|---|---|---|---|---|
| Aircraft | 0.585 | 0.349 | 0.429 | 0.375 | |
| CUB | 0.844 | 0.432 | 0.529 | 0.492 | |
| Dogs | 1.076 | 0.569 | 0.666 | 0.643 | |
| Pets | 1.056 | 0.451 | 0.576 | 0.549 | |
| NICO++ | 0.970 | 0.501 | 0.539 | 0.523 |
Appendix figures & tables22 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Qwen3-VL-4B | InternVL3.5-4B |
|---|---|---|
| NICO++ object | ||
| NICO++ context | ||
| DTD | ||
| Aircraft | ||
| CUB | ||
| Dogs |
| DTD | CUB | |||
| Projection | Dev. | Lin. X | Dev. | Lin. X |
| Gaussian | 78.72 | 68.44 | ||
| PCA | 78.51 | 67.11 | ||
| Shared MLP | 84.89 | 72.41 | ||
| Shared linear | 83.51 | – | 74.12 | – |
| DTD | CUB | ||||||
|---|---|---|---|---|---|---|---|
| Acc. | Dev. | Acc. | Dev. | Cache (%) | |||
| 32 | 85.48 | 83.19 | 82.45 | 73.38 | 1.25 | ||
| 64 | 85.43 | 83.56 | 83.26 | 74.30 | 2.50 | ||
| 128 | 85.21 | 83.46 | 82.90 | 74.45 | 5.00 | ||
| 256 | 85.64 | 83.51 | – | 83.15 | 74.12 | – | 10.00 |
| 512 | 85.85 | 83.46 | 82.88 | 74.16 | 20.00 | ||
| Method | DTD | Aircraft | CUB | Dogs | Pets |
|---|---|---|---|---|---|
| RICES | |||||
| GPT-MM | |||||
| DeTriever | |||||
| CIRCLES | |||||
| TaskVICL-Raw | |||||
| TaskVICL-Proj |
| RICES | Raw | Raw RICES | |
| DTD | |||
| 1 | 73.83 | 82.71 | |
| 4 | 78.72 | 84.04 | |
| 8 | 80.37 | 84.15 | |
| CUB | |||
| 1 | 58.66 | 75.61 | |
| Order | DTD | CUB |
|---|---|---|
| Nearest last (default) | 83.67 | 81.20 |
| Nearest first | 84.36 | 81.39 |
| Random | 83.78 | 80.95 |
| Nearest first last | ||
| Random last |
| Method | DTD | Aircraft | CUB | Dogs | Pets |
|---|---|---|---|---|---|
| Qwen3-VL-4B | |||||
| Random-4 | 2.05 (0.08) | 0.97 (0.04) | 0.50 (0.02) | 0.73 (0.03) | 2.87 (0.11) |
| RICES | 60.56 (2.42) | 31.56 (1.26) | 46.62 (1.86) | 39.24 (1.57) | 65.71 (2.63) |
| GPT-MM | 76.61 (3.06) | 55.74 (2.23) | 58.13 (2.33) | 69.53 (2.78) | 88.54 (3.54) |
| DeTriever | 67.50 (2.70) | 57.21 (2.29) | 51.54 (2.06) | 66.22 (2.65) | 86.41 (3.46) |
| CIRCLES | 65.12 (2.60) | 33.15 (1.33) | 50.28 (2.01) | 45.72 (1.83) | 65.15 (2.61) |
| Neighbors | Prediction | DTD | Aircraft | CUB | Dogs | Pets | Avg. |
|---|---|---|---|---|---|---|---|
| RICES (CLIP ViT-B/32) | Vote | 69.04 | 39.99 | 58.61 | 51.48 | 74.71 | 58.77 |
| RICES (CLIP ViT-L/14) | Vote | 75.37 | 55.75 | 77.13 | 71.32 | 88.09 | 73.53 |
| TaskVICL-Raw | Vote | 82.13 | 70.33 | 78.41 | 81.75 | 93.10 | 81.14 |
| RICES (CLIP ViT-B/32) | ICL | 78.72 | 59.68 | 71.21 | 74.32 | 91.52 | 75.09 |
| RICES (CLIP ViT-L/14) | ICL | 80.80 | 68.47 | 80.93 | 80.35 | 93.30 | 80.77 |
| TaskVICL-Raw | ICL | 84.04 | 73.84 | 81.50 | 82.97 | 94.96 | 83.46 |
| Layers | Metric | DTD | CUB | OK-VQA |
|---|---|---|---|---|
| Last | Raw | 81.72 | 79.93 | 59.05 |
| Untrained | 81.72 | 79.64 | 59.65 | |
| Proj | 85.05 | 83.76 | 60.42 | |
| Early | Raw | 71.01 | 32.05 | 58.07 |
| Untrained | 71.54 | 32.12 | 57.97 | |
| Proj | 78.72 | 41.85 | 57.92 |
| Representation | DTD | CUB | OK-VQA |
|---|---|---|---|
| RICES (CLIP ViT-B/32) | |||
| RICES (CLIP ViT-L/14) | |||
| RICES (Qwen vision tower) | |||
| VLM2Vec | |||
| Caption BGE-M3 | |||
| Caption BM25 |
| Task-matched RICES | Qwen | InternVL |
|---|---|---|
| CLIP ViT-B/32 | ||
| CLIP ViT-L/14 | ||
| DINOv3 |
| Queries | Retriever | Model | Reference | Gain | 95% CI | Rescued | Harmed |
|---|---|---|---|---|---|---|---|
| All (5794) | Raw | 37.73 | 81.50 | 2672 | 136 | ||
| All (5794) | RICES | 36.18 | 71.21 | 2247 | 217 | ||
| Initially wrong (3640) | Raw | 4.62 | 74.92 | 2570 | 11 | ||
| Initially wrong (3640) | RICES | 7.88 | 63.30 | 2060 | 43 | ||
| Initially correct (2154) | Raw | 93.69 | 92.62 | 102 | 125 | ||
| Initially correct (2154) | RICES | 83.98 | 84.59 | 187 | 174 |
| Raw | RICES | ||||||
|---|---|---|---|---|---|---|---|
| Subset | Model | Reference | Model | Reference | Gain diff. | 95% CI | |
| Equal error count | 1925 | 11.12 | 79.06 | 10.39 | 68.10 | ||
| Initially wrong | 1714 | 2.86 | 78.65 | 3.33 | 67.33 | ||
| Method | Retrieval | Generation | Peak | Bank |
|---|---|---|---|---|
| RICES | 7.68 | 671.61 | 9.44 | 11.71 |
| Raw | 267.35 | 674.92 | 10.91 | 2107.27 |
| Proj ( ) | 255.10 | 660.46 | 9.05 | 210.73 |
| Proj ( ) | 255.45 | 662.85 | 8.86 | 26.34 |
| CIRCLES (ViT-B/32) | 10682.75 | 693.03 | 9.44 | 23.41 |
| NICO++ | |||||
| Method | Obj. | Ctx. | Avg. | DTD | OK-VQA |
| Zero-shot | 92.22 | 41.48 | 66.85 | 67.55 | 60.51 |
| RICES | 93.06 | 50.37 | 71.71 | 80.32 | 57.34 |
| Raw | 93.89 | 64.63 | 79.26 | 83.99 | 61.15 |
| Raw RICES | |||||
| 95% CI | |||||
| Dataset | Raw Prob. |
|---|---|
| DTD | |
| Aircraft | |
| CUB | |
| Dogs | |
| Pets | |
| NICO++ object |
| Initially correct | Initially wrong | |||||
|---|---|---|---|---|---|---|
| Dataset | Raw Prob. | Raw Log. | Raw Prob. | Raw Log. | ||
| DTD | 1261 | 619 | ||||
| Aircraft | 1077 | 2256 | ||||
| CUB | 2154 | 3640 | ||||
| Dogs | 4667 | 3913 | ||||
| Pets | 3026 | 643 | ||||
| Prob. | Log. | ||||
|---|---|---|---|---|---|
| Dataset | Overlap | None | Overlap | None | Top ZS |
| DTD | 18.0 | 47.6 | 42.4 | 13.6 | 98.1 |
| Aircraft | 12.1 | 63.8 | 37.1 | 17.4 | 94.8 |
| CUB | 20.4 | 44.2 | 50.8 | 5.8 | 96.9 |
| Dogs | 13.6 | 57.4 | 45.7 | 9.2 | 96.3 |
| Pets | 13.8 | 57.0 | 33.3 | 21.5 | 99.1 |
In-Context Learning
In-context learning studies how models adapt to new tasks from examples or instructions supplied at inference time, without changing their weights.
See all 448 papers