Papers › What Makes Good Examples for Visual In-Context Learning?

What Makes Good Examples for Visual In-Context Learning?

31 Jan 2023NeurIPS 2023 11arXiv:2301.13670archive 2025-07-28

Yuanhan Zhang, Kaiyang Zhou, Ziwei Liu

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.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2301.13670")

Code

Syntology Ran 2 of 9 code samples harvested from 1 repository linked to this paper; 7 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 1 ran · fixture could not drive it.

By repository: official repository: 9 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

zhangyuanhan-ai/visual_prompt_retrieval officialmentioned in papermentioned on GitHubpytorchCC0-1.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

9 samples harvested; 2 ran; 0 honoured the contract we drafted; 7 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
1ran · fixture could not drive it
7unverified

Licence: 0 of the 9 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from zhangyuanhan-ai/visual_prompt_retrieval. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

get_obj_from_str zhangyuanhan-ai/visual_prompt_retrieval/vqgan.py official repository ran · our draft was wrong CC0-1.0 (permissive) · 221b2d116fdf1032 · report
get_timestep_embedding zhangyuanhan-ai/visual_prompt_retrieval/vqgan.py official repository ran · fixture could not drive it fingerprinted CC0-1.0 (permissive) · cb49209c125de1b4 · report
calculate_metric zhangyuanhan-ai/visual_prompt_retrieval/evaluate/evaluate_colorization.py official repository unverified CC0-1.0 (permissive) · 764136a5eff74434 · report
calculate_metric zhangyuanhan-ai/visual_prompt_retrieval/evaluate/evaluate_reasoning.py official repository unverified CC0-1.0 (permissive) · 69532fa60013e9f4 · report
get_demo_predictions zhangyuanhan-ai/visual_prompt_retrieval/viz_utils.py official repository unverified CC0-1.0 (permissive) · c68f71948cfa9d7c · report
get_demo_predictions_with_mask zhangyuanhan-ai/visual_prompt_retrieval/viz_utils.py official repository unverified CC0-1.0 (permissive) · 8c8d20b40760059c · report
instantiate_from_config zhangyuanhan-ai/visual_prompt_retrieval/vqgan.py official repository unverified CC0-1.0 (permissive) · f0ac78b4e05be194 · report
is_square zhangyuanhan-ai/visual_prompt_retrieval/evaluate/evaluate_reasoning.py official repository unverified CC0-1.0 (permissive) · ce2513917f2cc4b5 · report
reverse_trans zhangyuanhan-ai/visual_prompt_retrieval/tta.py official repository unverified CC0-1.0 (permissive) · ebd3af8bde9488f1 · report

Tasks

In-Context LearningRetrieval

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections