What Makes Good Examples for Visual In-Context Learning?

Yuanhan Zhang, Kaiyang Zhou, Ziwei Liu
2/12/2026

No official code found. Best implementation: ZhangYuanhan-AI/visual_prompt_retrieval (182 stars, CC0-1.0, last commit 2024-03-04).

Abstract

Large-scale models trained on broad data have recently become the mainstream architecture in computer vision due to their strong generalization performance. In this paper, the main focus is on an emergent ability in large vision models, known as in-context learning, which allows inference on unseen tasks by conditioning on in-context examples (a.k.a.~prompt) without updating the model parameters. This concept has been well-known in natural language processing but has only been studied very recently for large vision models. We for the first time provide a comprehensive investigation on the impact of in-context examples in computer vision, and find that the performance is highly sensitive to the choice of in-context examples. To overcome the problem, we propose a prompt retrieval framework to automate the selection of in-context examples. Specifically, we present (1) an unsupervised prompt retrieval method based on nearest example search using an off-the-shelf model, and (2) a supervised prompt retrieval method, which trains a neural network to choose examples that directly maximize in-context learning performance. The results demonstrate that our methods can bring non-trivial improvements to visual in-context learning in comparison to the commonly-used random selection.

View on arXivView PDF

Code Implementations(1)

CC0-1.0

[NeurIPS2023] Official implementation and model release of the paper "What Makes Good Examples for Visual In-Context Learning?"

1829Shell, PythonJan 30, 20232 years agoCC0-1.0
in-context-learningpromptvisual-prompting

Similar Papers

Cite this paper

@article{zhang2026what,
  title  = {What Makes Good Examples for Visual In-Context Learning?},
  author = {Yuanhan Zhang and Kaiyang Zhou and Ziwei Liu},
  year   = {2026},
  eprint = {2301.13670},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2301.13670},
  journal = {NEURIPS 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2301.13670.svg)](https://codeofpaper.com/paper/2301.13670)

Discussion