arXiv:2609.06670cs.LGSep 2026

Manuscript Offprint

arXiv:2609.06670

Data Efficient Sample Selection for In-Context Learning

V Venktesh, Cem levi, Avishek Anand

Venktesh V ID

Stockholm University

venktesh.viswanathan

@dsv.su.se

Orcid: 0000-0001-5885-2175

Cem Levi ID

SKIM Group B.V.

c.levi

@skimgroup.com

Avishek Anand ID

TU Delft

avishek.anand

@tudelft.nl

Orcid: 0009-0003-8367-101X

Orcid: 0000-0002-0163-0739

Abstract

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: ¹

1 Introduction

Selecting representative instances from a large pool is a recurring need across applications such as training models, domain adaptation, and few-shot learning. In this work, we focus on in-context learning (ICL) with large language models (LLMs), where LLMs can solve new tasks when given a small sequence of demonstrations (v,w)(v, w) or (v,rationale,w)(v, \text{rationale}, w) in context (Brown et al., 2020). However, naively choosing demonstrations (randomly or heuristically) performs poorly (Purohit et al., 2024; Li and Qiu, 2023). One principled way to formulate this is as a subset selection problem: choosing a small set of examples that captures the task's salient structure, according to a task-specific reward signal. The class of approaches that aim to select such near-optimal example subsets that achieves the best average performance across all test / validation queries from a target task are broadly categorized as static (task-level) selection methods (Li and Qiu, 2023; Zhang et al., 2025).

Since, ICL performance depends on subset interactions, the joint effect of examples provided together, renders a large search space of example subsets. For sample-efficiency, some of the existing task-level selection methods formulates subset selection as top-mm arm identification in multi-armed bandits (MABs), where each subset of examples is an arm and rewards are sampled based on LLM performance on the task (Réda et al., 2021). Casting ICL demonstration choice as top-mm arm identification provides a principled route to select representative subsets using the task-level rewards, while reducing number of LLM evaluations. Recent works (Purohit et al., 2025, 2024), builds upon gap-index bandit frameworks like GIFA (Réda et al., 2021), introducing challenger sampling mechanisms to handle the large search space. While effective, these approaches have two major limitations. First, they rely on a linear surrogate to map arm features to rewards which cannot capture the complex dependencies between subsets and task performance.

Secondly, a fundamental limitation of task-level (static) selection approaches is that they can fail when new queries require skills absent from the fixed set of examples. Dynamic selection chooses examples per test query, which improves flexibility but involves searching through a large space of combinations and applying MAB algorithm per instance is computationally expensive. Existing approaches only employ heuristic semantic matching (Ye et al., 2023b; Rubin et al., 2022) based on embeddings that are not adapted for the subset selec-

¹https://github.com/VenkteshV/DearICL tion setting. However, training ranking models for subset ranking that can clearly distinguish between optimal example subsets from sub-optimal ones for each test query is expensive. It requires sampling of sufficient number of borderline example subsets that are hard to distinguish for the subset ranker.

Hence, it is critical to devise a sample-efficient mechanism that can help learning of subset ranking at instance-level which can also model the non-linear reward landscape of LLM based feedback. To overcome these limitations, we propose DEARICL (Data Efficient Algorithm for Ranker training for demonstration samples selection in ICL), a new bandit framework for instance-level subset selection. DEARICL is a gap-index MAB framework which focuses on top-m selection as auxiliary objective in the outer loop, while fitting a non-linear surrogate in the inner loop for instance-level subset ranking. The top-m selection aims to implicitly induce a separation between near-optimal subsets (arms) and sub-optimal ones as discussed in literature (Katariya et al., 2019) and hence the gap-index framework ensures sufficient number of borderline arms are sampled to induce this separation. Hence, by using this as auxiliary objective, our proposed approach, ensures that borderline subsets with rewards sampled at instance-level (each validation query) are used to fit the ranker in the inner loop. This enables the surrogate to clearly distinguish borderline example subsets from useful ones for each instance during inference for ranking example subsets for each test query. We provide theoretical guarantees, including bounds on pairwise gap error and sample complexity. Our approach is sample-efficient while improving performance (8.08–15.9%) on smaller LLMs.