TL;DR
When curating massive web datasets to pretrain large language models, aggressive "quality filtering" accidentally creates an intellectual monoculture, wiping out specialized knowledge like programming code. This paper introduces Leverage Score Sampling (Lev), a geometric approach that selects maximally diverse training data up to 72× faster than existing diversification methods. It not only boosts downstream model capabilities across text and code, but also exposes a hidden blind spot in how we currently filter the web.
What Problem Does This Paper Address?
If you feed a language model raw internet text, you get garbage out. To fix this, researchers rely heavily on model-based quality filtering: training lightweight classifiers (like fastText) to cherry-pick web pages that resemble "high-quality" references, such as textbooks or Q&A forums.
While this boosts general reading comprehension, it triggers a quiet catastrophe called dimensional collapse. Geometrically, if you embed your filtered documents as vectors in a high-dimensional space, they end up huddled together in a tiny, low-dimensional corner. The filter becomes an overzealous bouncer, letting in encyclopedic prose while turning away weird, specialized, yet vital data—like source code.
Directly optimizing a dataset for geometric diversity prevents this collapse, ensuring embeddings span the widest possible space. However, state-of-the-art geometric methods like DiSF require recomputing massive feature covariance matrices for every single candidate document at every step. At internet scale, that math is prohibitively slow. We need a way to maximize geometric diversity without setting our compute budget on fire.
Methods
To break this computational bottleneck, the authors reach into classical randomized numerical linear algebra and adapt leverage scores for data curation.
Imagine your currently selected documents as a cloud of unit vectors forming a multi-dimensional shape (a polytope) in embedding space. Dataset diversity corresponds to the volume of this shape. When considering a new candidate document $z$, how much would adding it stretch that volume?
The authors prove that a candidate's ridge leverage score—computed via a simple quadratic form $\ell^\lambda(z; X) = z^\top (\frac{1}{n}X^\top X + \lambda I_d)^{-1} z$—exactingly quantifies the relative expansion of the dataset's determinantal volume if $z$ is added. Statistically, this works by projecting $z$ onto the principal semantic components of the existing pool and weighting each direction by the inverse of how frequently it has already appeared. Rare semantics get massive "leverage"; redundant ones get ignored.
What makes Lev novel and fast compared to DiSF is how it tracks geometry:
- Shared Matrix Updates: Instead of recomputing a covariance matrix for every candidate, Lev evaluates an entire batch of candidates against a single, shared regularized Gram matrix, updating it incrementally as batches of winners are chosen.
- Cholesky Decomposition: Rather than inverting matrices directly (slow and numerically touchy), Lev uses Cholesky decomposition to solve a clean triangular system, slashing an entire order of batch-size complexity ($B$) out of the runtime.
Datasets
No new benchmarks were introduced; the authors used established corpora to train 1.1B-parameter Llama 3.1 models on 60B tokens:
- Pretraining Data: CommonCrawl (CC) (heuristically filtered and deduplicated, without quality filtering, to preserve raw web diversity) and StarCoderData (restricted to Python, Java, JavaScript, Go, PHP, and Ruby).
- Evaluation Benchmarks: Seven natural language understanding tasks via OLMES (ARC-easy, ARC-challenge, WinoGrande, HellaSwag, PIQA, Social IQa, and CommonSenseQA) and seven coding tasks (HumanEval and six languages in Multilingual MBPP).
Key Insights and Ideas
- Quality filters have a cross-domain blind spot: The widely used DCLM-fastText quality filter suffers from severe cross-domain dimensional collapse. Because it is trained to hunt for Q&A and instructional prose, it systematically throws away code-related web pages in CommonCrawl. Even after mixing dedicated code datasets into the training run later, models trained on quality-filtered web data remain persistently worse at coding than those trained on Lev-diversified web data.
- Unsupervised curation where "quality" is fuzzy: What makes a piece of Python code "high quality"? Unlike prose, we lack universal classifiers for code quality. Lev shows that pure geometric diversification acts as a potent, unsupervised curation tool—removing boilerplate redundancy automatically improves coding capability.
- Forgiving hyperparameters: Intuitively, grabbing larger chunks of documents per update step (step size $b$) should hurt diversity because similar items might sneak in together. Because the raw data is shuffled, high-leverage items in a batch rarely point in the exact same direction—meaning practitioners can crank up step sizes for massive speedups without losing model accuracy.
Key Results
Lev beats the strongest geometric diversification baseline (DiSF) across runtime, intrinsic diversity, and downstream model performance:
- Massive Speedup: Selecting a 40% subset of a CommonCrawl dump (with step size 1) takes DiSF 217.28 hours. Lev finishes in 3.03 hours—a 72× speedup (and up to 65× on StarCoderData).
- Higher Dataset Diversity: Lev boosts the Vendi score (a spectrum-based diversity metric) by 9.2% over DiSF (203.81 vs. 186.63) and 21.3% over random sampling.
- Stronger Text & Code Models: On CommonCrawl (40% selection ratio), Lev reaches 48.91% average accuracy across the seven language tasks, beating DiSF (48.35%) and domain-matching DSIR (44.84%). On StarCoderData (50% selection mixed with quality-filtered web text), Lev lowers code bits-per-byte (BPB)—where lower means better prediction—by 3.08% over DiSF ($63.66 \times 10^{-2}$ vs. $65.68 \times 10^{-2}$).
- Best Hybrid Recipe: Combining quality-filtered web text with Lev-diversified code yields the strongest all-around model (51.53% text accuracy and $63.66 \times 10^{-2}$ code BPB).
Limitations and Future Work
Pure diversity selection has an obvious catch: garbage can be geometrically unique, too. On general commonsense text tasks alone, quality filtering (DCLM-fastText at 50.21%) still outperforms pure unsupervised diversification (48.91%). While pairing quality-filtered web text with Lev-curated code bridges much of the gap, it treats quality and diversity as separate silos. The authors note that deeply unifying quality scoring and leverage-based diversity into a single, holistic selection objective remains a critical next step for pretraining pipelines.
Summary updated