Abstract
In-Context Learning (ICL) allows Large Language Models (LLMs) to perform new tasks using a few demonstrations in the prompt. However, performance is highly sensitive to the specific examples chosen. We present D.Va (Demonstration Validation), a framework that treats demonstration selection as a mini-validation process. By "testing" candidate demonstrations on a proxy task and selecting those that minimize a calibrated validation loss, D.Va consistently outperforms existing selection methods. Furthermore, D.Va exhibits strong cross-model generalization, allowing small models to act as efficient selectors for larger ones.
Introduction
Large Language Models (LLMs) have demonstrated remarkable capabilities in In-Context Learning (ICL), where they adapt to new tasks via a few-shot prompt. Despite this, the selection of demonstrations remains a critical bottleneck; minor changes in the example set can lead to significant performance swings. Existing selection strategies generally rely on data-dependent similarity (e.g., BM25 or semantic embeddings) or self-adaptive scoring by the LLM itself.
However, current self-adaptive metrics often fail to capture the true utility of a demonstration in reaching a ground-truth answer and frequently struggle with generalization across different model scales. D.Va addresses these issues by introducing a "select-then-rank" pipeline that validates demonstrations on a proxy task before final inference.
The D.Va Framework
D.Va (Demonstration Validation) operates through a three-stage process designed to identify the most informative examples for a given test query.
- Candidate Retrieval: A standard retriever, such as TopK semantic similarity, is used to identify a pool of $K$ candidate demonstrations from the training data.
- Demonstration Validation: This stage is the core of the D.Va method. From the candidate pool, the example most similar to the test query is designated as a "validation anchor" ($d_v$). Since the ground-truth answer for $d_v$ is known, it serves as a proxy task. Each other candidate $d$ is evaluated based on:
- Validation Loss ($L_v$): The model's ability to predict the correct answer for $d_v$ when $d$ is provided as a demonstration.
- Calibration Remainder ($\epsilon$): To account for the distribution shift between the test query and the validation anchor, D.Va applies a calibration step. This uses the Bradley-Terry preference model to adjust for the model's inherent biases toward specific inputs.
- Inference: Candidates are re-ranked based on their calibrated validation scores. The top-performing examples are then prepended to the test query in the final prompt.
Experimental Evaluation
The researchers evaluated D.Va across a diverse set of tasks and models. The benchmark included 8 Natural Language Understanding (NLU) datasets (e.g., Trec, AgNews, SST-2/5, and the NLI suite) and 3 Natural Language Generation (NLG) tasks (translation, QA, and summarization). The models tested ranged from GPT2-XL to the Llama-3 family (1B, 3B, and 8B parameters).
Results and Discussion
D.Va demonstrates superior performance and robustness compared to traditional and state-of-the-art baselines.
- State-of-the-Art Accuracy: D.Va achieved significant gains, with an average improvement of 2.60% on Llama-3.2-1B and 0.94% on Llama-3.1-8B over the next best methods in classification tasks.
- Cross-Model Generalization: A key finding is the efficiency of using "small surrogates." Examples selected by a 1B model using D.Va transfer effectively to an 8B model with minimal performance loss (<0.30%). This suggests that D.Va captures fundamental demonstration utility that transcends model scale.
- Scaling and Calibration: Performance improves consistently as the number of in-context examples increases. Additionally, the calibration parameter $\lambda$ shows a stable peak around 0.6, indicating that balancing validation loss with the calibration remainder is essential for optimal results.
- Ordering Effects: The study found that a descending order—placing the highest-scoring demonstrations closest to the test query—yields the best results, likely due to the recency bias inherent in LLMs.
Limitations and Future Work
While D.Va is highly effective, it introduces additional computational overhead compared to simple retrieval because it requires inference passes to rank candidates. Future work could explore the scalability of the "small surrogate" strategy to frontier models exceeding 70B parameters and further refine the selection of validation anchors to reduce sensitivity in niche domains.
Summary updated