Learning to Select Visual In-Context Demonstrations

June 1, 2026 ยท View on GitHub

Learning to Select Visual In-Context Demonstrations

Paper arXiv Project Page Code

Overview of LSD Framework

This is the official repository for the CVPR 2026 paper, Learning to Select Visual In-Context Demonstrations.

Our framework, Learning to Select Demonstrations (LSD), reframes K-shot demonstration selection as a sequential decision-making problem. We utilize a Dueling Deep Q-Network (DQN) agent with a query-centric Transformer Decoder to actively balance visual relevance with diversity, constructing optimal demonstration sets for visual regression tasks.


Setup

cd Learning-to-Select-Demonstrations
conda create -n LSD python=3.10 -y
conda activate LSD
pip install -r requirements.txt


Process Data

1. Download Dataset

Download the datasets from the following sources:

2. Prepare Dataset

./scripts/prepare_data.sh

3. Update datasets.yaml


LSD Training

./scripts/train_lsd.sh

Note: Results will be saved in the train_res directory.

LSD Evaluation

./scripts/eval_lsd.sh

Note: Results will be saved in the eval_res directory.


Citation

If you find this work helpful or use our code in your research, please consider citing our paper:

@inproceedings{lee2026learning,
  title={Learning to Select Visual In-Context Demonstrations},
  author={Lee, Eugene and Lin, Yu-Chi and Diao, Jiajie},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={9455--9465},
  year={2026}
}