Abstract
Existing pretraining data mixing methods for large language models (LLMs) typically follow a domain-wise methodology, a top-down process that first determines domain weights and then performs uniform data sampling across each domain. However, these approaches neglect significant inter-domain overlaps and commonalities, failing to control the global diversity of the constructed training dataset. Further, uniform sampling within domains ignores fine-grained sample-specific features, potentially leading to suboptimal data distribution. To address these shortcomings, we propose a novel sample-wise data mixture approach based on a bottom-up paradigm. This method performs global cross-domain sampling by systematically evaluating the quality and diversity of each sample, thereby dynamically determining the optimal domain distribution. Comprehensive experiments across multiple downstream tasks and perplexity assessments demonstrate that SampleMix surpasses existing domain-based methods. Meanwhile, SampleMix requires 1.4x to 2.1x training steps to achieves the baselines' performance, highlighting the substantial potential of SampleMix to optimize pre-training data.
Introduction
Training a Large Language Model (LLM) requires a massive "data mixture"—a blend of web crawls, books, code, and academic papers. Currently, researchers use a domain-wise approach: they decide on a fixed percentage for each source (e.g., 50% CommonCrawl, 10% ArXiv) and then sample randomly from within those buckets.
However, this top-down method suffers from two major flaws:
- Inter-domain Overlap: "Domains" are often defined by their source, not their content. Semantic overlaps (e.g., ArXiv and Wikipedia both containing detailed articles on physics) lead to redundancy when fixed domain weights are used.
- Suboptimal Intra-domain Distribution: Uniformly sampling within a domain treats high-quality, unique research papers the same as low-quality, repetitive blog posts, failing to prioritize the most informative samples.
Methodology
SampleMix replaces domain-level weights with a sample-wise weighting system based on two pillars:
- Data Quality Evaluation: The authors defined seven dimensions of quality (Clarity, Coherence, Structure, etc.) and used GPT-4o to score a subset of data. They then trained a smaller "evaluator" model (based on
gte-en-mlm-base) using ordinal regression to respect the inherent ranking of scores. - Data Diversity Evaluation: To ensure conceptual variety, K-means clustering was used in the embedding space. A diversity score for each sample was calculated by multiplying Cluster Compactness (similarity to neighbors) by Cluster Separation (uniqueness of the cluster).
Each sample is assigned a weight $p(x)$ that balances quality and diversity. A softmax-based distribution then determines how many times a specific sample should appear in the final training set, allowing the strategy to adapt dynamically to different token budgets.
Experimental Setup
The strategy was tested using the SlimPajama dataset (627B tokens) across seven domains. Evaluation was conducted on 8 downstream tasks (e.g., OpenBookQA, LAMBADA, ARC) and perplexity assessments on The Pile and xP3.
Key Results and Insights
SampleMix demonstrates significant improvements in both performance and efficiency:
- Superior Performance: A 1B-parameter LLaMA model trained with SampleMix achieved an average accuracy of 47.77% across downstream tasks, outperforming the Vanilla baseline (46.13%) and other state-of-the-art methods like DoReMi and DoGE.
- Massive Efficiency Gains: SampleMix reached the average baseline accuracy in just 100k steps—1.9x faster than the averaged baselines. In some configurations, efficiency gains reached 2.1x.
- Diversity vs. Quality: Grid search for the weighting factor ($\alpha$) showed optimal performance at $\alpha = 0.8$, suggesting that diversity is more critical than raw quality for pre-training.
- Dynamic Adaptation: Unlike static proportions, SampleMix naturally adjusts. For small budgets, it selects the highest quality/diversity samples; as the budget grows, it incorporates lower-weighted samples to ensure generalization.
Conclusion and Future Work
SampleMix proves that a bottom-up, sample-wise approach to data mixing is far more effective than traditional domain-wise methods. Future work will explore applying this strategy to code data (GitHub) and moving toward "model-perspective" metrics that evaluate data based on what a specific model learns from it.
Summary updated