Demonstration Selection for In-Context Learning via Reinforcement Learning
Xubin Wang, Jianfei Wu, Yichen Yuan, Deyu Cai, Mingzhe Li, Weijia Jia
Abstract
Diversity in demonstration selection is critical for enhancing model generalization by enabling broader coverage of structures and concepts. Constructing appropriate demonstration sets remains a key research challenge. This paper introduces the Relevance-Diversity Enhanced Selection (RDES), an innovative approach that leverages reinforcement learning (RL) frameworks to optimize the selection of diverse reference demonstrations for tasks amenable to in-context learning (ICL), particularly text classification and reasoning, in fewshot prompting scenarios. RDES employs frameworks like Q-learning and a PPO-based variant to dynamically identify demonstrations that maximize both diversity (quantified by label distribution) and relevance to the task objective. This strategy ensures a balanced representation of reference data, leading to improved accuracy and generalization. Through extensive experiments on multiple benchmark datasets, including diverse reasoning tasks, and involving 14 closedsource and open-source LLMs, we demonstrate that RDES significantly enhances performance compared to ten established baselines. Our evaluation includes analysis of performance across varying numbers of demonstrations on selected datasets. Furthermore, we investigate incorporating Chain-of-Thought (CoT) reasoning, which further boosts predictive performance. The results highlight the potential of RL for adaptive demonstration selection and addressing challenges in ICL.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
6 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Auto-regressive In-context Demonstration Selection cites Language Models are Few-Shot Learners
- Auto-regressive In-context Demonstration Selection cites Calibrate Before Use: Improving Few-shot Performance of Language Models
- ContextIF: Enhancing Instruction-Following through Context Reward cites Language Models are Few-Shot Learners
- SAFE-SQL: Self-Augmented In-Context Learning with Fine-grained Example Selection for Text-to-SQL cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Self-Refine: Iterative Refinement with Self-Feedback cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Finetuned Language Models are Zero-Shot Learners cites Language Models are Few-Shot Learners
- Finetuned Language Models are Zero-Shot Learners cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge Transfer cites Language Models are Few-Shot Learners
- DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge Transfer cites Finetuned Language Models are Zero-Shot Learners
- DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge Transfer cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge Transfer cites Calibrate Before Use: Improving Few-shot Performance of Language Models
- Chain-of-Thought Prompting Elicits Reasoning in Large Language Models cites Calibrate Before Use: Improving Few-shot Performance of Language Models
- Calibrate Before Use: Improving Few-shot Performance of Language Models cites Language Models are Few-Shot Learners
Cited by top-tier papers6
- DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge TransferRuoyu Wang, Junda Wu, Yu Xia, Tong Yu et al.KDD 2026 · 6 citations
- SAFE-SQL: Self-Augmented In-Context Learning with Fine-grained Example Selection for Text-to-SQLJimin Lee, Ingeol Baek, Byeongjeong Kim, Hyunkyung Bae et al.EMNLP 2025 · 1 citation
- Auto-regressive In-context Demonstration SelectionYunzhe Qi, Sirui Chen, Jiaru Zou, Jingrui HeICML 2026
- ContextIF: Enhancing Instruction-Following through Context RewardYule Zhong, Jiacheng Yao, Guoxiu HeICLR 2026
- Unsupervised Process-Aware Coreset Selection for In-Context LearningWei Zheng, Zijie Wang, Xin Li, Bin Gong et al.ICML 2026
Builds on22
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
- Self-Refine: Iterative Refinement with Self-FeedbackAman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan et al.NeurIPS 2023 · 4,972 citations
- Finetuned Language Models are Zero-Shot LearnersJason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu et al.ICLR 2022 · 4,966 citations
- Calibrate Before Use: Improving Few-shot Performance of Language ModelsZihao Zhao, Eric Wallace, Shi Feng, Dan Klein et al.ICML 2021 · 1,843 citations
Related papers
- In-Context Learning with Iterative Demonstration SelectionChengwei Qin, Aston Zhang, Chen Chen, Anirudh Dagar et al.EMNLP Findings 2024 · 19 citations
- Provoking Multi-modal Few-Shot LVLM via Exploration-Exploitation In-Context LearningCheng Chen, Yunpeng Zhai, Yifan Zhao, Jinyang Gao et al.CVPR 2025
- Representative Demonstration Selection for In-Context Learning with Two-Stage Determinantal Point ProcessZhao Yang, Yuanzhe Zhang, Dianbo Sui, Cao Liu et al.EMNLP 2023 · 3 citations
- Many-Shot CoT-ICL: Making In-Context Learning Truly LearnTsz Ting Chung, Lemao Liu, Mo Yu, Dit-Yan YeungICML 2026 · 3 citations
- Universal Self-Adaptive PromptingXingchen Wan, Ruoxi Sun, Hootan Nakhost, Hanjun Dai et al.EMNLP 2023 · 4 citations
