Skip to main content
QUICK REVIEW

[Paper Review] What Makes Good Examples for Visual In-Context Learning?

Yuanhan Zhang, Kaiyang Zhou|arXiv (Cornell University)|Jan 31, 2023
Multimodal Machine Learning ApplicationsComputer Science19 citations
TL;DR

The paper analyzes how the choice of in-context visual examples critically affects performance and proposes a prompt retrieval framework with unsupervised and supervised variants to automatically select beneficial prompts for visual in-context learning.

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.

Motivation & Objective

  • Investigate how in-context example selection influences visual in-context learning performance.
  • Quantify the sensitivity of downstream tasks to prompt choices in vision models.
  • Develop automatic prompt retrieval methods to improve prompt quality over random selection.
  • Evaluate robustness under distribution shifts and across multiple visual tasks.

Proposed method

  • Model-agnostic visual in-context learning setup where a prompt is a set of image-label pairs guiding predictions without updating model parameters.
  • Propose a score-based prompt retrieval framework f_theta(x_n, x_q) to select top prompts for a query x_q.
  • Implement unsupervised prompt retrieval (UnsupPR) via nearest-neighbor search using fixed off-the-shelf features.
  • Implement supervised prompt retrieval (SupPR) by learning a feature extractor with a contrastive objective to maximize in-context learning performance.
  • Train SupPR with a contrastive loss to pull/repel prompts based on top-5 positive/negative performance sets.
  • Evaluate with three downstream tasks (foreground segmentation, single object detection, image colorization) using a pre-trained image inpainting model.
Figure 1 : (a) Different choices of in-context examples (outlined in green) often lead to significantly different results. Here we show 30 random query images (x-axis) from Pascal- $5^{i}$ (Shaban et al., 2017 ) split 0, and measure the performance range using 50 different in-context examples. (b) W
Figure 1 : (a) Different choices of in-context examples (outlined in green) often lead to significantly different results. Here we show 30 random query images (x-axis) from Pascal- $5^{i}$ (Shaban et al., 2017 ) split 0, and measure the performance range using 50 different in-context examples. (b) W

Experimental results

Research questions

  • RQ1How does the choice of in-context examples affect visual in-context learning performance across tasks?
  • RQ2Can automatic prompt retrieval improve performance beyond random prompt selection?
  • RQ3Are unsupervised and supervised prompt retrieval strategies effective, and which yields better results?
  • RQ4How do prompt size, backbone, and retrieval set size influence results and robustness to distribution shifts?

Key findings

  • Prompt retrieval markedly improves over random prompt selection on foreground segmentation and object detection (≥6% and ~1% mIoU gains, respectively).
  • The supervised prompt retrieval method (SupPR) consistently outperforms the unsupervised variant (UnsupPR) and random baselines across tasks.
  • Performance gains from prompt retrieval persist across different backbones (CLIP, EVA, ViT) with minimal backbone sensitivity.
  • SupPR shows better robustness to distribution shifts (Pascal to MSCOCO) than UnsupPR or Random, though overall gains under shift are smaller than in-distribution gains.
  • Increasing the number of in-context examples generally improves performance for all methods, while the order has little impact when high-quality examples are chosen.
  • SupPR tends to select prompts that are semantically and spatially closer to the query, suggesting a balance between semantic similarity and contextual similarity is beneficial.
Figure 2 : Overview of the supervised prompt retrieval method. The main idea is to compute the in-context learning result for each source example, and pick those with the highest/lowest results to form a positive/negative set for contrastive learning.
Figure 2 : Overview of the supervised prompt retrieval method. The main idea is to compute the in-context learning result for each source example, and pick those with the highest/lowest results to form a positive/negative set for contrastive learning.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.