TL;DR: The Relevance-Diversity Enhanced Selection (RDES) framework uses reinforcement learning to solve the demonstration selection problem in few-shot prompting. By training an agent to balance example relevance with label diversity, researchers achieved significant accuracy boosts across 14 different LLMs and multiple complex reasoning benchmarks.
The Challenge of Demonstration Selection
In-Context Learning (ICL) has become the standard method for guiding Large Language Models (LLMs). Instead of retraining or fine-tuning a model, users provide a few "demonstrations" (example input-output pairs) within the prompt to steer its behavior on a specific task.
However, not all examples are equally effective. Most current selection methods focus purely on relevance—finding examples that semantically resemble the user's current input. While this provides immediate context, it often leads to biased prompts. For instance, if all provided examples exhibit a "Positive" sentiment, the model might struggle to correctly classify a "Neutral" or "Negative" input. This lack of diversity causes the model to overfit to the provided examples, hindering its ability to generalize to nuanced, real-world data.
The RDES Framework
To address this limitation, the authors introduce Relevance-Diversity Enhanced Selection (RDES). This approach treats the selection of prompt examples as a sequential decision-making problem, framing it as a Markov Decision Process (MDP) and solving it using Reinforcement Learning (RL).
Core Components:
- State Representation: The RL agent evaluates four key elements: the features of the input text (using TF-IDF), the embeddings of previously selected examples, the history of previous predictions, and a diversity score based on the current label distribution.
- The Reward Function: The agent receives a reward based on a multi-objective function that balances accuracy and diversity:
Reward = Accuracy + λ × Diversity Improvement. The parameterλis annealed during training, encouraging the agent to explore diverse examples early on before focusing on maximizing final accuracy. - Optimization Strategies: The framework employs Q-Learning for environments with smaller, discrete state spaces, and PPO (Proximal Policy Optimization) for high-dimensional state spaces where tabular methods fall short.
The researchers also explore RDES/C, a variant that integrates Chain-of-Thought (CoT) reasoning by asking the model to explain its logic for each selected demonstration.
Experimental Setup and Datasets
The framework was rigorously evaluated across a wide range of benchmarks to ensure robustness:
- Text Classification: BANKING77 (banking intents), CLINC150 (out-of-scope intent detection), HWU64, and LIU54.
- Reasoning Benchmarks: BigBenchHard, GSM-8K (grade school math), and SST5 (fine-grained sentiment analysis).
- Challenge Sets: To ensure rigorous evaluation, the authors utilized a "challenge set sampling" strategy, isolating the most difficult subsets of test data where models typically struggle with precision.
Key Insights and Results
The authors tested RDES against 10 established baselines (including Zero-Shot, Few-Shot, and Adaptive ICL) across 14 LLMs, ranging from GPT-3.5 to open-source models like LLaMA, Qwen, and Gemma.
- Diversity as a Regularizer: The most striking insight is that diversity acts as a safeguard against the rigidity of similarity-based selection. Forcing a broader distribution of labels in the prompt makes the model less likely to hallucinate a majority-class answer.
- Substantial Accuracy Boosts: On the BANKING77 dataset, the RDES/C variant achieved an average accuracy of 0.838, compared to just 0.360 for Zero-Shot and 0.565 for the strongest non-RL baseline (ADA). RDES consistently achieved the highest accuracy scores across the primary classification datasets.
- Scaling Synergy: The benefits of RDES scale with model size. While smaller models (e.g., LLaMA-3.2-1B) see improvements, the most dramatic gains occur in larger models (e.g., Qwen-1.5-72B) that have the inherent capacity to fully utilize diverse contexts.
- CoT Integration: Combining smart selection with Chain-of-Thought (RDES/C) consistently outperformed other methods, suggesting that what you show the model is just as important as how you ask it to reason.
Limitations and Future Work
While highly effective, RDES does have limitations. Training the RL agent requires thousands of LLM calls to calculate accuracy rewards, making the training phase computationally expensive (though inference remains efficient). Additionally, the current diversity metric relies primarily on label distribution. Future work could incorporate semantic or structural diversity, such as varying the length or complexity of the demonstrations. Finally, the authors propose making the use of Chain-of-Thought itself adaptive, allowing the RL agent to decide exactly when a demonstration requires an explanation.
Summary updated