TL;DR
Training Large Language Models (LLMs) is incredibly expensive, but researchers often discard the intermediate checkpoints saved along the way. This paper proposes a method to linearly merge adjacent pretraining checkpoints using Bayesian Optimization to find the perfect merging weights. The result is essentially a "free lunch" that boosts model performance and generalization without requiring any additional training compute.
What Problem Does This Paper Address?
Pretraining LLMs like GPT-4 or LLaMA requires millions of GPU hours, costing millions of dollars and leaving a massive carbon footprint. During this grueling process, engineers periodically save "checkpoints" (snapshots of the model's weights) to prevent data loss in case of hardware failures.
Typically, only the final checkpoint is used, while the intermediate ones are ignored. While "model merging" (combining the weights of multiple models) has become popular for fine-tuned models (e.g., Model Soups), applying it to the pretraining phase is tricky. The loss landscape is highly non-convex, and blindly averaging weights can lead to broken models. The authors ask: Can we strategically merge these intermediate pretraining checkpoints to get a better, smarter model for free?
Methods
The authors introduce a Bayesian Optimization-based Checkpoint Merging strategy. Here is how it works:
- Pairwise Merging: Instead of trying to merge dozens of checkpoints—which creates an impossibly large search space—the authors restrict the merge to just the two most recent adjacent checkpoints ($\Theta_t$ and $\Theta_{t-1}$).
- Bayesian Optimization (BayesOpt): The core challenge is finding the optimal weight ($\lambda$) to combine the two models. A simple 50/50 average rarely works best. The authors use BayesOpt with Gaussian Process (GP) regression to efficiently search for the exact $\lambda$ that maximizes performance on a validation dataset.
- GP-Hedge Strategy: To balance exploring new merging weights and exploiting known good ones, they use a "GP-Hedge" strategy that dynamically selects the best acquisition function (Expected Improvement, Probability of Improvement, or Upper Confidence Bound) during the search.
Datasets
- Models Evaluated: Baichuan2 (7B), DeepSeek (7B), and the Pythia suite (ranging from 70M to 6.9B parameters).
- Evaluation Benchmarks: C-Eval, CMMLU, MMLU, GSM8K, PIQA, WinoGrande, SciQ, and ARC-Easy.
- Validation Data: A held-out portion of the C-Eval dataset was used as the validation set to optimize the merging weights via BayesOpt.
Key Insights and Ideas
- Distance is dangerous: Merging adjacent checkpoints (e.g., from step 100 and step 101) consistently boosts performance. However, merging distant checkpoints (e.g., early training vs. late training) causes catastrophic performance drops due to destructive interference between disparate training states.
- Two is company, three is a crowd: The authors found that pairwise merging (just 2 checkpoints) consistently outperforms merging 3 or 4 consecutive checkpoints. It is both computationally cheaper and yields higher accuracy.
- Robust Out-of-Domain (OOD) Generalization: You might worry that optimizing the merging weight on a specific validation set (like the Chinese C-Eval benchmark) would overfit the model to that domain. Surprisingly, it doesn't. The merged models showed strong cross-lingual and cross-task improvements, boosting scores on English benchmarks like MMLU and math benchmarks like GSM8K.
- Theoretical backing for "Flat Minima": The authors provide PAC-Bayesian mathematical proofs showing that checkpoint merging acts as a regularizer. By averaging parameters, the model moves into flatter regions of the loss landscape, which are known to correlate with better generalization to unseen data.
Key Results
- Beats the baselines: The BayesOpt approach consistently outperformed established merging baselines like Uniform Soup, Greedy Soup, Fisher Weighted Averaging, and RegMean.
- Significant performance bumps: Merging the Baichuan2-1980B and 2200B checkpoints improved CMMLU accuracy by 0.59% over the 2200B baseline. Remarkably, this merged model even outperformed the later 2420B checkpoint.
- Scales across model sizes: The technique works regardless of model size. On the Pythia family, the method improved PIQA scores by 1.22% for the 70M model and 0.12% for the 6.9B model compared to the best baseline methods.
- Highly efficient search: BayesOpt found better merging weights in fewer evaluations compared to Random Search, Greedy Search, or Grid Search, proving its efficiency.
Limitations and Future Work
- Fails in early pretraining: The authors explicitly note that merging checkpoints from the early stages of pretraining degrades performance. The technique is only viable during the mid-to-late stages when the model is closer to convergence.
- Requires held-out data: The method relies on having a validation dataset to evaluate and optimize the merging weights. However, an ablation study showed it is highly robust, maintaining top performance even when using only 25% of the validation set.
- Future Work: While not explicitly mapped out, natural next steps would involve integrating this BayesOpt merging dynamically during the active pretraining loop to accelerate convergence, rather than just applying it post-hoc to saved checkpoints.
Summary updated