SampleMix: A Sample-wise Pre-training Data Mixing Strategey by Coordinating Data Quality and Diversity

Xiangyu Xi, Deyang Kong, Jian Yang, Jiawei Yang, Zhengyu Chen, Wei Wang, Jingang Wang, Xunliang Cai, Shikun Zhang, Wei YearXiv 2025

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:

  1. 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.
  2. 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:

Comparison between traditional domain-wise reweighting (a) and the proposed sample-wise SampleMix strategy (b).
  • 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.
Performance on downstream tasks over training steps, showing SampleMix achieving baseline performance 1.9x faster.
  • 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

BibTeX
@misc{xi2025samplemix,
  author = {Xiangyu Xi and Deyang Kong and Jian Yang and Jiawei Yang and Zhengyu Chen and Wei Wang and Jingang Wang and Xunliang Cai and Shikun Zhang and Wei Ye},
  title = {{SampleMix: A Sample-wise Pre-training Data Mixing Strategey by Coordinating Data Quality and Diversity}},
  year = {2025},
  eprint = {2503.01506},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.01506},
}
Figure