Sample Efficient Demonstration Selection for In-Context Learning

Journal Article (2025)
Author(s)

Kiran Purohit (Indian Institute of Technology Kharagpur)

Venktesh V (TU Delft - Electrical Engineering, Mathematics and Computer Science)

Sourangshu Bhattacharya (Indian Institute of Technology Kharagpur)

Avishek Anand (TU Delft - Electrical Engineering, Mathematics and Computer Science)

Research Group
Web Information Systems
More Info
expand_more
Publication Year
2025
Language
English
Research Group
Web Information Systems
Journal title
Proceedings of Machine Learning Research
Volume number
267
Pages (from-to)
49959-49982
Event
42nd International Conference on Machine Learning, ICML 2025 (2025-07-13 - 2025-07-19), Vancouver, Canada
Downloads counter
36
Reuse Rights

Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons.

Abstract

The in-context learning paradigm with LLMs has been instrumental in advancing a wide range of natural language processing tasks. The selection of few-shot examples (exemplars / demonstration samples) is essential for constructing effective prompts under context-length budget constraints. In this paper, we formulate the exemplar selection task as a top-m best arms identification problem. A key challenge in this setup is the exponentially large number of arms that need to be evaluated to identify the m-best arms. We propose CASE (Challenger Arm Sampling for Exemplar selection), a novel sample-efficient selective exploration strategy that maintains a shortlist of “challenger” arms, which are current candidates for the top-m arms. In each iteration, only one of the arms from this shortlist or the current top-m set is pulled, thereby reducing sample complexity and, consequently, the number of LLM evaluations. Furthermore, we model the scores of exemplar subsets (arms) using a parameterized linear scoring function, leading to stochastic linear bandits setting. CASE achieves remarkable efficiency gains of up to 7× speedup in runtime while requiring 7× fewer LLM calls (87% reduc-tion) without sacrificing performance compared to state-of-the-art exemplar selection methods. We release our code and data.1