Introduction
In the development of Large Language Models (LLMs), the composition of pre-training data—the "recipe"—is a critical determinant of model performance. Traditionally, researchers have relied on data provenance (source-based mixing) as a proxy for content variety, mixing datasets like Wikipedia, GitHub, and CommonCrawl in fixed proportions. However, this approach faces significant challenges. First, sources are often heterogeneous; a single web crawl contains a vast array of unrelated subjects. Second, as datasets scale to trillions of tokens (e.g., FineWeb), meaningful source labels often disappear.
This paper argues that organizing data by semantic content rather than source is essential for optimal model performance. By introducing Topic-based Data Mixing, the authors demonstrate that unsupervised topic models can serve as superior "data mixers," consistently outperforming traditional source-centric methods across various model scales and algorithms.
Methodology
The researchers developed a scalable, automated pipeline to categorize 600 million documents from the SlimPajama dataset (627B tokens) into a semantic taxonomy.
Topic Extraction Pipeline
- Unsupervised Clustering: Documents were converted into vectors using the BGE embedding model and grouped into 10,000 initial clusters via K-Means.
- Hierarchical Merging: Using GPT-4o, these clusters were summarized and merged into 300 topics, and eventually into 12 high-level semantic categories: Technology, Science, Politics, Health, Lifestyle, Law, Entertainment, Education, Relationships, Finance, Community, and Others.
- Scalable Classification: A BERT-based classifier was trained on 100,000 LLM-annotated samples to label the entire dataset with 84% accuracy.
Experimental Setup
The authors compared topic-based partitioning against source-based partitioning using four established data mixing algorithms: PerfRe, Temperature-based sampling, RegMix, and DoReMi. Models with 1.3B and 3.3B parameters were trained and evaluated on a suite of 9 downstream tasks covering general knowledge, commonsense reasoning, and reading comprehension.
Key Insights and Results
Superior Optimization Landscapes
A primary advantage of topic-based mixing is the creation of a more favorable optimization landscape. Theoretical analysis and 3D loss visualizations reveal that topic-based partitioning results in a "smoother" relationship between mixture weights and validation loss compared to source-based partitioning. This smoothness allows optimization algorithms to more effectively identify the ideal proportions for training.
Performance Gains
Topic-based mixing consistently outperformed source-based methods:
- Consistency: The topic-based approach was superior across all four mixing algorithms.
- Scaling: The performance gap widened as model size increased. For the 3.3B parameter model,
RegMix-Topicachieved a score of 50.06, significantly higher than both the random baseline (49.04) andRegMix-Source(49.29). - Task-Specific Boosts: Significant improvements were noted in Reading Comprehension tasks, where topic-based temperature sampling outperformed its source-based counterpart by 1.90 points.
Complementary Information
Using Normalized Pointwise Mutual Information (NPMI), the authors found that topics and sources capture different dimensions of data. While topics are more effective mixers, combining both dimensions (e.g., distinguishing "Science" in Wikipedia from "Science" in CommonCrawl) can yield even further performance improvements.
Conclusion
This research demonstrates that semantic topic modeling is a more robust and effective framework for data mixing than traditional source-based methods. By moving from "mixing in the dark" to a content-aware strategy, researchers can achieve better model performance and smoother optimization. Future work may explore finer-grained taxonomies and the application of these methods to frontier models exceeding 70B parameters.
Summary updated