Introduction
The efficacy of large language models (LLMs) is fundamentally tied to the quality and composition of their pretraining data. While massive web-scale corpora like The Pile or Common Crawl provide the necessary scale, they are often saturated with low-quality content, including noise, gibberish, and toxic material. Traditional approaches to data selection—such as heuristic classification or manual curation—either fail to preserve distributional diversity or lack the scalability required for modern datasets.
This paper introduces Data Selection with Importance Resampling (DSIR), a fast and principled framework designed to select high-quality subsets from large raw datasets. By matching a raw data pool to a desired target distribution (e.g., Wikipedia or specialized domain text), DSIR provides a scalable solution that outperforms standard filtering techniques while maintaining the efficiency needed for web-scale processing.
Methodology
DSIR leverages importance resampling, a statistical technique adapted for high-dimensional text data. The framework operates in three primary stages:
1. Feature Reduction
To ensure computational tractability, text documents are mapped into a lower-dimensional feature space. The authors utilize hashed n-grams (specifically unigrams and bigrams) mapped into 10,000 discrete buckets. This approach captures essential lexical characteristics without the overhead of dense neural embeddings.
2. Importance Weighting
The framework estimates two generative models—one for the target distribution ($p$) and one for the raw data pool ($q$). For each document in the raw pool, an importance weight $w$ is calculated as the ratio of the target probability to the raw probability:
$$w = p(text) / q(text)$$
Unlike discriminative classifiers, which often focus on the most distinct "modes" of the target data, these generative models capture the full breadth of the target distribution, ensuring greater diversity in the selected subset.
3. Resampling
Rather than simply selecting the top-k documents with the highest weights—which would bias the dataset toward a few over-represented patterns—DSIR samples documents with a probability proportional to their importance weights. The "Gumbel top-k trick" is employed to perform this sampling efficiently and without replacement.
Experimental Results
The authors evaluated DSIR using The Pile (1.6 billion examples) as the raw source and various target distributions, including Wikipedia, Books, and domain-specific datasets like PubMed and ACL-ARC.
General-Domain Performance
In pretraining from scratch, models trained on DSIR-selected data showed a 2.0–2.5% improvement in GLUE benchmark scores compared to those trained on randomly selected or heuristically filtered data.
Domain-Specific Adaptation
In the context of Domain-Adaptive Pretraining (DAPT), DSIR matched or exceeded the performance of manual expert curation across eight diverse domains, including Computer Science, Biomedicine, and News. This suggests that DSIR can effectively automate the labor-intensive process of data curation for specialized tasks.
Efficiency and Scalability
A key advantage of DSIR is its operational efficiency. By utilizing CPU-optimized sampling and hashed n-grams, the framework can process 100 million documents from The Pile in approximately 4.5 hours on a single node.
Analysis: KL Reduction as a Proxy for Performance
A significant contribution of this work is the introduction of "KL reduction" as a metric for data quality. This metric measures the reduction in Kullback-Leibler (KL) divergence between the selected data and the target distribution relative to a random sample. The authors found a strong correlation ($r = 0.82$) between KL reduction and downstream model accuracy. This provides a valuable "North Star" for researchers, allowing them to estimate the quality of a selected dataset before committing to expensive training runs.
Limitations and Conclusion
While DSIR is highly effective, it relies on superficial lexical features (hashed n-grams) that do not capture deep semantic or logical structures. Furthermore, the quality of the selection is inherently limited by the quality of the provided target sample. If the target sample is biased, DSIR will faithfully replicate those biases in the selected subset.
In conclusion, DSIR represents a major step toward principled, scalable data selection for LLMs. By combining the statistical rigor of importance resampling with an efficient implementation, it offers a practical tool for building better models from noisy, web-scale data. Future work may explore the integration of more sophisticated feature spaces, such as transformer-based embeddings, to further refine the selection process.
Summary updated