Introduction
Supervised Fine-Tuning (SFT) is a critical phase in the development of Large Language Models (LLMs), transforming a pre-trained base model into a specialized assistant capable of following instructions and solving complex tasks. Despite its importance, the "recipe" for SFT—specifically the ratio of different data types like mathematics, programming code, and general conversation—has historically relied on human intuition or computationally expensive trial-and-error.
This paper introduces Data Mixing Optimization (DMO), a mathematically grounded framework designed to determine the optimal data mixture for SFT. By leveraging scaling laws and modeling cross-domain interactions, DMO identifies the ideal balance of data types using only a few small-scale pilot runs, significantly outperforming traditional heuristic approaches.
The Challenges of SFT Data Mixing
While scaling laws are well-established for the pre-training phase, SFT presents unique challenges that make simple data scaling difficult to predict:
- Non-Zero Starting Point: Unlike pre-training, SFT begins with a model that already possesses extensive world knowledge. The goal is to refine and steer this knowledge rather than build it from scratch.
- Cross-Domain Transfer: Domains are not isolated. For instance, training on Python code often improves a model's logical reasoning in mathematics. Existing mixing methods frequently overlook these synergistic effects.
- The Generalist Trap: Optimizing for a simple average loss across all domains can lead to "starving" difficult domains. If a domain like advanced calculus is underrepresented, the model may lose that capability entirely in favor of easier, high-volume data.
The DMO Framework
DMO frames data mixing as a constrained optimization problem: minimizing the total validation loss within a fixed token budget. The core innovation lies in a novel parameterization of validation loss that accounts for two primary factors:
1. Effective Data Transfer
The framework models how much "equivalent data" is transferred between domains. For example, it quantifies how many tokens of "Code" data contribute to the reduction of "Math" validation loss. This allows the optimizer to exploit the "Cocktail Effect," where diverse data types support specialized performance.
2. SFT Scaling Laws
The authors adapt the standard power-law relationship ($L \approx C \cdot D^{-\beta} + E$) to the SFT context. Here, $D$ represents the "effective" amount of data, incorporating both direct training tokens and transferred knowledge from other domains.
The Workflow
The DMO process consists of three efficient steps:
- Perturbation Experiments: Researchers conduct 4–5 small-scale training runs, slightly varying the proportions of each data domain.
- Parameter Fitting: The results of these runs are used to fit the constants in the loss formula using the Trust Region Method.
- Optimization: The resulting convex optimization problem is solved using Sequential Least Squares Programming (SLSQP) to determine the optimal weights for the full-scale training budget.
Experimental Results and Insights
The researchers validated DMO across a wide range of models (Llama 3.1/3.2, Qwen 2.5) and datasets (Tulu3, Orca, OpenMathInstruct-2).
Scale-Dependent Weights
A significant finding of the study is that the optimal data mix is not static; it changes based on the total token budget. As the training volume increases, the marginal utility of "easy" or general domains decreases, requiring a shift toward "harder" or more specialized domains. A mix optimized for 5 million tokens is fundamentally different from one optimized for 200 million tokens.
"No Domains Left Behind"
The authors provide a mathematical proof that their objective function naturally prevents any domain from being excluded. Because the marginal benefit of the initial tokens in any domain is extremely high (following the power-law curve), the optimizer will always include a representative slice of every available domain to ensure broad capability.
Performance Gains
DMO-optimized models achieved validation losses within 0.66% of the absolute best possible weights found through exhaustive grid searches. On the Tulu3 benchmark, DMO-optimized weights outperformed the original human-curated mix across nearly all metrics. For Llama 3.1-70B, DMO improved the average score from 61.1 to 63.8, demonstrating that even high-performing models benefit from precise data balancing.
Conclusion
Data Mixing Optimization offers a rigorous, efficient alternative to "vibe-based" data selection. By treating data mixing as a mathematical optimization problem, researchers can maximize the potential of their SFT datasets while minimizing compute costs. Future work remains to address the sensitivity of the framework to validation set quality and to explore how DMO might guide the generation of synthetic data to fill specific gaps in a model's knowledge.
Summary updated