The In-context learning (ICL) paradigm aids large language models (LLMs) to adapt to new tasks without need for fine-tuning. However, selecting an optimal combination of demonstration examples from a large pool of example subsets is a challenging problem. Existing approaches for selection do not model the complex relationship between ICL samples and downstream LLM performance. They typically perform static task-level selection, choosing subsets once offline, which can fail to generalize to unseen queries. We introduce DearICL (Data Efficient Algorithm for Ranking) ICL samples, a new framework that models demonstration example selection as a subset ranking problem. DearICL employs a non-linear surrogate employing a differentiable sorting objective within a gap-index bandit algorithm. The gap-index based approach enables fine-grained separation of good arms and borderline arms, which is used as an auxiliary objective to train the non-linear surrogate through sufficient sampling of borderline arms, supporting instance-level subset ranking. On exemplar selection benchmarks with open-source LLMs, DearICL achieves 8.08-15.9% accuracy gains over strong linear bandit baselines, with low sample complexity. Code and data: https://github.com/VenkteshV/DearICL.
Figures & tables
Figure 1: Top- m arm identification by DEARICL , CASE for AquaRAT. (a) Gap Index ( Bt(cht,bt) ) comparison and (b) Simple regret comparison, (c) subset selection time, (d) Average inference time/query.
Method
GSM8K
AquaRat
WMT19
Task level
Zero-shot-COT Kojima et al. (2022)
37.37
36.61
51.22
Few-Shot COT Wei et al. (2022b)
63.22
40.94
61.64
LENS Li and Qiu (2023)
64.97
44.88
64.09
EXPLORA Purohit et al. (2024)
69.92
47.24
66.26
BRIDGE Wan et al. (2025)
64.52
48.81
64.96
Table 1: Results using llama3.2:3b † indicates statistical significance (t-test) over CASEdynamic at 0.05 level. We report performance using the official metrics: Exact Match (EM) (AquaRAT,GSM8K) and BertScore Zhang et al. (2020) (WMT19) for the respective datasets.
Method
GSM8K
AquaRat
WMT19
CASEdynamic
1554.19
2378.04
106.54
Neural NDCG
10.59
18.51
5.20
PiRank
6.10
11.59
1.80
DearICL dynamic
6.04
11.59
1.68
Table 2: Inference Time Comparison (in seconds)
Total # LLM calls
GSM8K
AquaRat
WMT19
CASE
10200
4360
87
DEARICL static
2600
1580
48
Table 3: Results comparing the number of LLM calls.
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
Framework
Loss function
Hyperparameters
Network architecture
PiRank
PiRank surrogate loss
Presented in Section 4
(256, 256,128,64)
Other LTR baselines
Neural NDCG
N = 2, dff = 384, h = 1, dropout = 0.1
(768,96)
ListNet
N = 4, dff = 512, h = 2, dropout = 0.3
(768,128)
Neural NDCG
N = 4, dff = 512, h = 4, dropout = 0.3
(768,96)
Neural NDCG With Normalized data
N = 2, dff = 384, h = 1, dropout = 0.1
(768,96)
NDCGLoss 2++
-
(256, 512, 1024, 512, 256)
Appendix
Table 4: Details of hyperparameters used in different LTR model configurations. Categorized by loss function and framework.
Task performance
GSM8K
AquaRat
WMT19
NDCGLoss 2++
72.11
49.00
74.06
NeuralNDCG
69.83
48.30
72.75
NeuralNDCG (norm. data)
72.06
49.21
72.97
UDR
71.63
48.03
72.65
ListNet
71.79
46.06
73.64
DEARICL dynamic
75.66
55.11
78.89
Appendix
Table 5: Ablation results: Training LTR approaches on training data collected across rounds by DEARICL leveraging llama3.2:3b
Method
GSM8K
AquaRat
WMT
Task level
EXPLORA Purohit et al. (2024)
93.63
69.29
84.55
LENS ( Li and Qiu, 2023 )
76.19
64.56
83.57
Static CASE
91.13
73.23
83.49
\textscDEARICLstatic
94.84
77.16
86.25
Instance level
Appendix
Table 6: Results across datasets (we use 5-shot for all methods) using gpt-4o-mini. † indicates statistical significance (t-test) over CASEdynamic at 0.05 level
Method
GSM8K
AquaRat
WMT
Task level
EXPLORA Purohit et al. (2024)
82.63
68.10
78.59
LENS ( Li and Qiu, 2023 )
77.33
57.87
76.98
Static CASE
83.09
69.29
78.26
\textscDEARICLstatic
86.12
70.47
79.27
Instance level
Appendix
Table 7: Results across datasets using Deepseek-R1:7b (we use 5-shot for all methods). † indicates statistical significance (t-test) over CASEdynamic at 0.05 level
Figure 2: Top- m arm identification by DEARICL , CASE for GSM8k, WMT19. (a,b) Gap Index ( Bt(cht,bt) ) comparison and (c,d) Simple regret comparison
Question
A travel company wants to charter a plane to the Bahamas. Chartering the plane costs 5,000.Sofar,12peoplehavesignedupforthetrip.Ifthecompanycharges200 per ticket, how many more passengers must sign up for the trip before the company can make any profit on the charter?
Method
Exemplars
NeuralNDCG
Question: A group consists of 4 couples in which each of the 4 boys has one girlfriend. In how many ways can they be arranged in a straight line such that boys and girls occupy alternate positions?
Question: A man cycling along the road noticed that every 12 minutes a bus overtakes him and every 4 minutes he meets an oncoming bus. If all buses and the cyclist move at a constant speed, what is the time interval between consecutive buses?
Question: Find large number from below question. The difference of two numbers is 1365. On dividing the larger number by the smaller, we get 6 as quotient and the 15 as remainder?
Question: A certain sum is invested at simple interest at 18% p.a. for two years instead of investing at 12% p.a. for the same time period. Therefore the interest received is more by Rs. 840. Find the sum?
Appendix
Table 8: Exemplar subsets selected by NeuralNDCG and DearICL dynamic using LLama3.2:3b for a particular AquaRat test instance where DearICL dynamic had a correct answer and the NeuralNDCG model did not.
In-context learning (ICL) is crucial for boosting the inference performance of large language models (LLMs). However, the effectiveness of ICL in LLMs is greatly influenced by the choice of demonstration sets. Exhaustive searches over these sets are combinatorial, and existing selectors often rely on relevance or likelihood proxies to implicitly assess ICL quality. Making repeated queries to the target LLM with these strategies can incur substantial costs. This work simplifies selection by framing it as a constrained local search problem and presents local demonstration editing (LDE). Starting with an initially retrieved set of demonstrations, LDE employs a single structured edit to explore its surrounding neighborhood while balancing performance gains with search costs. Technically, LDE is reduced to a policy search problem, for which we train a small LLM, referred to as Jev-LDE. This model as the System-1 modifies the retrieved demonstration set by performing actions such as Keep, Delete, or Replace elements, all within a framework of reinforcement learning with verifiable rewards. At test time, Jev-LDE executes a single edit of the retrieved demonstration set, followed by one inference from the target LLM, avoiding the need for iterative context scoring or subset searches. Across standard classification benchmarks, various target LLMs with Jev-LDE as the plug-and-play module consistently improve ICL performance, and Jev-LDE shows transferability to held-out benchmarks and models without retraining. These findings indicate that the LDE approach offers an efficient and adaptable method for harnessing the ICL capabilities of target LLMs.
In-context learning (ICL) performance depends critically on which demonstrations are placed in the prompt, yet most existing selectors prioritize heuristic notions of relevance or diversity and provide limited insight into the coverage of a demonstration set. We propose Unseen Coverage Selection (UKS), a training-free, subset-level coverage prior motivated by the principle that a good demonstration set should expose the model to latent cluster unrevealed by the currently selected subset. UCS operationalizes this idea by (1) inducing discrete latent clusters from model-consistent embeddings and (2) estimating the number of unrevealed clusters within a candidate subset via a Smoothed Good--Turing estimator from its empirical frequency spectrum. Unlike previous selection methods, UCS is coverage-based and training-free, and can be seamlessly combined with both query-dependent and query-independent selection baselines via a simple regularized objective. Experiments on multiple intent-classification and reasoning benchmarks with frontier Large Language Models show that augmenting strong baselines with UCS consistently improves ICL accuracy by up to 2-6% under the same selection budget, while also yielding insights into task- and model-level latent cluster distributions. Code is available at https://github.com/Raina-Xin/UCS.
In-context learning (ICL) adapts large language models by conditioning on a small set of ICL examples, avoiding costly parameter updates. Among other factors, performance is often highly sensitive to the ordering of the examples. However, exhaustive search over the n! possible orderings is infeasible. Therefore more efficient ordering methods use model confidence measures (e.g., label-probability entropy) over label sets or take a direct approach to finding the best ordering. We propose PLR, a probabilistic approach to in-context example ordering that replaces discrete ordering search with learning a probability distribution over orderings with the Plackett-Luce model. PLR models orderings using a Plackett-Luce distribution and iteratively updates its parameters to concentrate probability mass on high-performing orderings under a task-level metric. Candidate orderings are sampled efficiently via a Gumbel perturb-and-sort procedure. Experiments on multiple classification benchmarks show that PLR consistently improves few-shot accuracy for k∈{4,8,16,32} examples, and we further demonstrate gains on mathematical reasoning tasks where label-based ordering methods are not applicable. Our code is available at https://github.com/Batorskq/PLR.