Demonstration Selection for In-Context Learning via Reinforcement Learning
Xubin Wang, Jianfei Wu, Yichen Yuan, Deyu Cai, Mingzhe Li, Weijia Jia
TL;DR
This paper tackles the challenge of demonstration selection for in-context learning by introducing Relevance-Diversity Enhanced Selection (RDES), an RL-based framework that jointly optimizes demonstration relevance and diversity. It develops two optimization pipelines, Q-learning and a PPO-based variant, and supports Chain-of-Thought prompting to further boost reasoning performance. Through extensive experiments across four classification benchmarks and a mix of closed- and open-source LLMs, RDES demonstrates significant accuracy gains over ten baselines, with CoT-enhanced RDES/C often achieving the best results. The study highlights the potential of adaptive demonstration selection to improve generalization in data-scarce settings and discusses future work on efficiency, adaptive CoT usage, and extension to broader NLP tasks.
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 few-shot 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 closed-source 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.
