Abstract
Training Large Language Models (LLMs) on massive, heterogeneous web-scraped datasets presents a significant challenge: not all data contributes equally to model performance. Traditional static data mixing methods fail to account for the evolving needs of a model during training. This paper introduces ToReMi (Topic-aware Reweighting for Model improvement), a novel two-stage framework that dynamically adjusts training data importance based on semantic topics. By prioritizing challenging topics early and downweighting noisy topics later, ToReMi achieves faster convergence and superior downstream performance compared to standard baselines.
Introduction
The quality and composition of pre-training data are primary drivers of LLM success. Current approaches typically rely on static quality filtering or fixed distribution optimization across data sources. However, these methods are rigid; they ignore the fact that a model's learning requirements change as it matures. Furthermore, they often treat data sources as monolithic blocks rather than collections of diverse semantic topics.
ToReMi addresses these limitations by asking: How can we dynamically prioritize high-quality, informative data while accounting for the semantic topics that emerge across a massive corpus?
Methodology
ToReMi introduces a dynamic reweighting mechanism centered on topic categories. The process involves three primary steps: topic annotation, monitoring training dynamics, and a two-stage weight update strategy.
Topic Annotation
Since pre-training data is largely unlabeled, ToReMi employs a "Cluster & Label" approach. Samples are grouped using K-means clustering on embeddings, and keywords are extracted via TF-IDF. A large model (Llama3-70B) then assigns semantic labels based on a Wikipedia-derived taxonomy, resulting in 39 broad categories such as "Technology" or "Human Behavior."
The Two-Stage Update Strategy
The core of ToReMi is its ability to distinguish between "hard but informative" data and "noisy" data based on training loss dynamics.
- Stage 1 (Aggressive Learning): In the early phase, the system identifies topics with higher-than-average loss. It assumes these represent foundational patterns the model has yet to master. These topics are upweighted to accelerate learning.
- Stage 2 (Noise Reduction): As training progresses, topics that persistently show high loss are flagged as likely containing noise, garbled text, or outliers. ToReMi pivots to downweight these topics to prevent them from hindering convergence.
Weights are updated every 100 steps based on the model's own training loss, requiring zero additional overhead from proxy or reference models.
Experimental Results
Faster Convergence Across Domains
ToReMi was evaluated using a 124M parameter GPT-2 architecture trained on a 2.6B token subset of the Dolma-v1_5 dataset. Performance was measured using log perplexity across 12 distinct domains in the Paloma dataset.
As shown in the figures above, ToReMi variants consistently reduced log perplexity faster than standard training, particularly during the critical window between 1,000 and 5,000 training steps. This indicates that the model learns more efficiently by focusing on the right topics at the right time.
Downstream Task Performance
Beyond perplexity, ToReMi demonstrated significant gains in linguistic understanding and reasoning:
- GLUE Benchmark: ToReMi achieved a 5.78% improvement over the standard baseline on the CoLA task (grammaticality judgment).
- Noise Resilience: In experiments where synthetic noise was injected, ToReMi maintained a 1.9% average performance lead on GLUE benchmarks, proving its ability to dynamically ignore detrimental data.
- Optimal Transition: Ablation studies revealed that for an 8,000-step run, transitioning from Stage 1 to Stage 2 at approximately 6,000 steps yielded the best overall results.
Discussion and Future Work
ToReMi provides a computationally efficient path toward more intelligent data selection. By using the model's own loss as a quality signal, it avoids the cost of auxiliary models while maintaining semantic consistency through topic-level anchoring.
However, limitations remain. The current study focused on a 124M parameter model; future work must validate these findings at the scale of 7B+ parameters. Additionally, while ToReMi excels at general linguistic tasks, it showed some sensitivity in complex reasoning tasks like WNLI, suggesting that the downweighting mechanism may need further refinement to preserve rare but essential reasoning patterns. Future iterations may also explore finer-grained topic hierarchies to further optimize the learning signal.
Summary updated