Abstract
Finetuning foundation models for specialized tasks is often hindered by the redundancy and noise inherent in web-scale datasets. We present TSDS (Task-Specific Data Selection), a framework that leverages Optimal Transport (OT) and Kernel Density Estimation (KDE) to identify high-quality, diverse training subsets. By matching the distribution of a massive data pool to a small set of target examples, TSDS avoids the common pitfalls of similarity-based selection and data duplication. Experimental results across instruction tuning and continued pretraining demonstrate that TSDS can select a 1% subset that outperforms training on the entire dataset, while maintaining computational efficiency at scale.
1. Introduction
In the current AI landscape, the "last mile" of model development involves specializing foundation models—such as LLaMA or BERT—for specific domains like medical advice, sentiment analysis, or technical reasoning. While the quantity of available data in repositories like Common Crawl or The Pile is vast, the quality and relevance of this data are highly variable. Recent studies suggest that over half of the documents in large-scale crawls are near-duplicates, which can lead to overfitting and inefficient training. TSDS addresses the challenge of finding the "goldilocks" subset: data that is aligned with the target task, diverse enough for generalization, and free from the noise of redundant examples.
2. Problem Statement: The Traps of Data Selection
Existing data selection methods frequently fall into two categories of failure:
- The Similarity Trap: Methods that prioritize individual similarity to a target task often select a homogenous subset. This lack of diversity prevents the model from learning the broader facets of a domain.
- The Duplicate Trap: Standard selection algorithms often over-sample high-quality examples that have numerous near-duplicates in the source pool. This redundancy leads to poor generalization and wasted computational resources.
3. Methodology
TSDS formulates data selection as a distribution matching problem rather than a point-wise similarity search. The framework consists of three core pillars:
3.1 Optimal Transport (OT)
Instead of measuring the distance between individual points, TSDS uses OT to measure the distance between the distribution of the selected data and the distribution of the target task. This ensures that the selected subset reflects the overall "shape" and structural characteristics of the goal task.
3.2 KDE Regularization
To mitigate the impact of near-duplicates, the authors incorporate Kernel Density Estimation (KDE). This technique estimates the local density of data points in the embedding space. If a point resides in a highly crowded neighborhood of duplicates, the algorithm down-weights its importance, forcing the selection process to seek out more diverse examples.
3.3 Computational Efficiency
Solving OT problems at the scale of hundreds of millions of sequences is traditionally cost-prohibitive. TSDS bridges this gap by establishing a mathematical connection between the optimization problem and Nearest Neighbor Search (NNS). By utilizing Hierarchical Navigable Small World (HNSW) graphs, the framework can process 150 million sequences in approximately 28 hours of pre-processing, with task-specific selection taking less than one hour thereafter.
4. Experimental Evaluation
The researchers evaluated TSDS in two distinct training regimes:
- Instruction Tuning: Using a 270k example pool (FLAN V2, CoT, Dolly, Open Assistant) to finetune LLaMA-2-7B and Mistral-7B. Benchmarks included TydiQA, MMLU, and Big-Bench Hard (BBH).
- Continued Pretraining: Adapting an ALBERT model using a 150-million sequence subset of The Pile for domains such as biomedicine (ChemProt), movies (IMDB), and computer science (SCIERC).
5. Key Results and Insights
5.1 Performance Gains
TSDS consistently outperformed state-of-the-art baselines. In instruction tuning, it exceeded the performance of the LESS baseline by an average of 1.5 F1 points. On the TydiQA task, TSDS achieved a score 2 points higher than the "Full Dataset" baseline while using only 1% of the available data. In continued pretraining, TSDS showed improvements of up to 3 F1 points over competing selection methods.
5.2 Robustness and the "Less is More" Effect
A critical finding was TSDS’s resilience to data pollution. In controlled experiments where 1% of the data was duplicated 1,000 times, TSDS maintained stable performance, whereas baselines like DSIR experienced significant degradation. This reinforces the "Less is More" hypothesis: training on a meticulously selected 1% subset can be more effective than training on the full 100%, as the latter often contains distracting "junk" data.
6. Limitations and Future Work
TSDS relies on a "query set"—a small, representative sample of the target task. If this set is biased, the selection will be similarly skewed. Furthermore, the method's efficacy is tied to the quality of the underlying embeddings. Future research may explore more advanced OT variants, such as Sinkhorn distances, to further optimize the computational overhead of the selection phase.
7. Conclusion
TSDS provides a mathematically grounded and computationally viable approach to data selection for task-specific finetuning. By prioritizing distribution matching and diversity over simple similarity, it enables researchers to build more effective models with significantly less data, offering a path toward more efficient and robust AI development.
Summary updated