Manuscript Offprint

arXiv:2610.27142

ICLHerd: Herding-Based Data Selection for LLMs with In-Context Learning as a Proxy

Yuqiao Wen, Lili Mou

Yuqiao Wen 1^{1}, Lili Mou 1,2^{1,2}

1^{1}Dept. Computing Science & Alberta Machine Intelligence Institute (Amii), University of Alberta, 2^{2}Canada CIFAR AI Chair

Data selection plays a central role in modern large language model training, as the quality of training data strongly influences downstream performance. A common approach is to curate a development set that encodes the desired skills (e.g., reasoning or multilinguality) and select data that are similar to them. Existing methods compute similarity using cosine distance over either the model's hidden states or gradients. However, we observe that this max-similarity strategy induces a mode-seeking bias: the selected data clusters tightly around the development samples. To address this, we propose ICLHerd, a data selection framework that leverages the von Mises–Fisher kernel to balance mode-seeking with mode-averaging. We further introduce in-context learning as a validation proxy, enabling efficient hyperparameter search over the balance trade-off. Results show that ICLHerd outperforms existing LLM data selection algorithms, highlighting the importance of balancing mode-seeking and mode-averaging.

Emails: yq.when@gmail.com doublepower.mou@gmail.com

Figure

1 Introduction

Data selection is the task of choosing training samples from a data pool in order to maximize model performance given a budget of training data. This is especially important in the large language model (LLM) era, where the candidate data pool is potentially the entire Internet (Li et al., 2024a; Penedo et al., 2024; Wenzek et al., 2020). In modern LLM training, data selection is usually one of the most crucial steps, and researchers rely heavily on intuition and trial-and-error to curate an appropriate training set tailored for the desired model capability. For example, DeepSeek-V4 incorporated different filtering strategies to remove templated data (e.g., repetitive html scripts) and mitigate the risk of model collapse (Xu et al., 2026); Qwen 3 was trained across a selected set of 119 languages and dialects in an attempt to improve data diversity and improve the model's multilingual skills (Yang et al., 2025); Llama 4 was trained on what the technical report claimed as "specialized datasets" to improve the model's long-context capabilities (Meta AI, 2025). It is important to note that the training recipes of these frontier open-weight models are not publicly available. This leaves a gap in systematic research on data selection, as the scale of training data (often trillions of tokens) makes it infeasible to ablate individual selection strategies, limiting the scientific rigor of these technical reports.

Existing open research on LLM data selection generally uses a development (dev) set to guide the selection process, where the dev samples encode the desired capabilities, e.g., math and reasoning. A promising direction is to embed all the samples and select training data based on the similarity to the dev set. Xia et al. (2024) propose LESS, which embeds training samples via down-projected LoRA gradients, and at each iteration, selects the training sample that maximizes cosine similarity to any dev sample. Ivison et al. (2025) propose RDS+, which embeds samples using the model's own hidden states for efficiency, and employs a round-robin selection that cycles through dev samples in fixed order, matching each dev sample in turn to promote data diversity.

Despite the efforts, we observe that these algorithms suffer from the mode-seeking problem, where

Wen et al.

ami

the selected dataset is overly crowded around the dev samples. Here, a mode refers to a peak in the embedding space, and both algorithms tend to select samples that are close to one or a few peaks of the dev distribution: LESS greedily pick the sample that match well against any of the dev samples, whereas RDS+ attempt to match all dev samples in a round-robin fashion. Alternatively, we may also select data based on the mean embedding of the dev set, as opposed to the maximum used in LESS and RDS+. This, on the other hand, will lead to the mode-averaging problem, where the embeddings of the selected dataset will center around the centroid of the dev distribution, losing the diversity of capabilities encoded by different dev samples.

To this end, we propose ICLHerd, a data selection framework based on the principled data herding scheme (Chen et al., 2010; Welling, 2009), where LESS and RDS+ emerge as special cases. The general idea is to make the distribution of selected samples close to that of the dev set. We use the maximum mean discrepancy (MMD, Gretton et al., 2012) to measure the similarity between two distribution based on the selected samples and those in the dev set. In particular, we adopt the von Mises–Fisher (vMF) kernel (Hall et al., 1987) on normalized features as the similarity measure, which operates on cosine similarities, since LLM representations are commonly compared by their direction rather than their magnitude (Banerjee et al., 2005; Gao et al., 2021; Reimers and Gurevych, 2019). We also design a fused kernel that combines hidden-state and gradient representations, allowing us to leverage their complementary signals for data selection. Overall, the data selection reduces to the problem of looking for similar samples with a diversity penalty. We apply the herding algorithm (Chen et al., 2010; Welling, 2009) for optimization, which greedily selects the best sample at a time and adjusts the diversity penalty accordingly.

To efficiently tune the balance between mode averaging and mode seeking, we further propose in-context-learning-as-a-proxy for our ICLHerd framework. Typically, hyperparameter tuning on data selection requires repeatedly training the model and validating the model's performance, which can be prohibitively expensive. Our proposed ICLHerd circumvents this problem by validating through in-context learning, where we put the selected data as a prompt and evaluate its loss on the dev set. Note that this is especially efficient due to prefix caching, as the same prompt is shared among dev samples. Our results establish a connection between in-context learning and gradient-descent-based learning performance.

Overall, we propose a ICLHerd framework of data selection for training LLMs. Our contributions are three-fold: (1) we address the mode-averaging and mode-seeking problems in data selection for LLMs; (2) we design a fused vMF kernel combining hidden states and gradients to control this balance; and (3) we propose in-context-learning-as-a-proxy for efficiently tuning it.

References (48)