Revisiting Checkpoint Averaging for Neural Machine Translation

Yingbo Gao, Christian Herold, Zijian Yang, Hermann NeyarXiv 2022 · arXiv

TL;DR

Checkpoint averaging is the "free lunch" of Neural Machine Translation (NMT), providing a robust performance boost at zero extra inference cost. This paper systematically explores whether advanced techniques—like using gradient information or optimizing interpolation weights—can beat the standard practice of simple uniform averaging. The verdict? The loss landscape between converged checkpoints is surprisingly flat, meaning simple averaging is nearly impossible to beat.

What Problem Does This Paper Address?

In the world of NMT, training a state-of-the-art Transformer model is computationally expensive. Researchers long ago discovered a simple trick: instead of just using the final saved state (checkpoint) of a model, you take the last few checkpoints and average their weights. This almost always results in a better model.

However, the "how-to" of checkpoint averaging has remained largely empirical. Most researchers simply average the last 5 or 10 checkpoints without much justification. The authors of this paper ask: Can we do better? Specifically, they investigate if performance can be squeezed further by being smarter about which checkpoints we select, how much weight we give each one, and whether we can use auxiliary data like gradients to find a better "middle ground" in the parameter space.

Methods

The authors categorize their explorations into three main extensions of the "vanilla" approach:

  1. Weighted Averaging: Instead of a simple mean, they use development set perplexity (DEVPPL) to weight checkpoints. They introduce a temperature parameter ($\tau$) to control the distribution: a high $\tau$ makes the average behave like a "one-hot" selection of the single best checkpoint, while a low $\tau$ approaches a uniform average.
  2. Using Gradient Information: Since optimizers like Adam often store gradients at the time of checkpointing, the authors experiment with taking a small extra step in the direction of the averaged gradients after performing the weight averaging.
  3. Optimization on Dev Data: They treat the interpolation weights as learnable parameters and fine-tune them on a development set using a single step of gradient descent, ensuring the weights remain normalized.

To visualize the results, they also perform grid searches and plot the loss landscapes (BLEU scores) between multiple checkpoints to see if there are hidden "peaks" of performance.

Figure 1: An illustration of checkpoint averaging and our extensions. The isocontour plot illustrates some imagi- nary loss surface. C1 and C2 are model parameters from two checkpoints. Cavg denotes the averaged parameters. In (a), the mean of the C1 and C2 is taken. In (b), the dashed arrows refer to the gradients (could also include the momentum terms) stored in the checkpoints, and a further step (with step size η) is taken. In (c), a NN is parametrized with the interpolation weights w1 and w2, and the weights are learned on the development data.

Datasets

The study covers a wide range of benchmarks to ensure the findings are generalizable:

  • IWSLT14: German-English (de-en), Russian-English (ru-en), and Spanish-English (es-en).
  • WMT: English-Romanian (WMT16), English-German (WMT14), and Chinese-English (WMT19).

Key Insights and Ideas

  • The "Flat Landscape" Discovery: The most significant finding is that the parameter space between converged checkpoints is remarkably flat. When you interpolate between three good checkpoints, the BLEU score doesn't vary much unless you get very close to a "bad" checkpoint.
  • Selection > Weighting: The strategy for selecting checkpoints (e.g., picking the "Top-K" based on dev performance) is far more important than the specific weights assigned to them. Top-K selection is much more robust to the choice of $K$ than simply taking the "Last-K" checkpoints.
  • Automation via Temperature: The temperature-based weighting ($\tau$) effectively automates checkpoint selection. It allows the model to naturally favor better checkpoints without the researcher having to manually tune the number $K$.
  • Diminishing Returns of Complexity: Despite the mathematical elegance of using gradient information or dev-set optimization, these methods failed to provide meaningful gains over simple averaging. The "flatness" of the landscape means there isn't a sharp peak to find; you're already on a high plateau.

Key Results

  • Robustness of Top-K: In experiments on de-en, Top-K averaging remained stable even as $K$ increased to 40, whereas Last-K averaging saw performance drop sharply after $K=10$ as it began including early, poorly-trained checkpoints.
  • Gradient Failure: Taking a gradient step ($\eta$) actually led to a quick drop in BLEU scores as the model diverged from the averaged mean, suggesting the averaged gradient direction is not a reliable path to better generalization in this context.
  • Landscape Visualization: Figure 7 in the paper (and Figure 11/12 in the appendix) visually confirms the plateau. The neighborhood of the top checkpoints shows small fluctuations but no specific local optimum that is significantly better than the simple average.

Limitations and Future Work

The authors acknowledge that their study is restricted to the model parameter space. They do not compare these methods against ensembling in the probability space (averaging the output distributions of multiple models), which is known to be more powerful but comes with a massive computational cost at inference time.

The primary takeaway for engineers is a practical one: don't over-engineer your checkpoint averaging. Stick to a simple mean of your best-performing checkpoints, and focus your efforts on other parts of the pipeline. Future work might explore if these "flat" regions exist in other architectures beyond Transformers or in different domains like computer vision.

Summary updated

Abstract

Checkpoint averaging is a simple and effective method to boost the performance of converged neural machine translation models. The calculation is cheap to perform and the fact that the translation improvement almost comes for free, makes it widely adopted in neural machine translation research. Despite the popularity, the method itself simply takes the mean of the model parameters from several checkpoints, the selection of which is mostly based on empirical recipes without many justifications. In this work, we revisit the concept of checkpoint averaging and consider several extensions. Specifically, we experiment with ideas such as using different checkpoint selection strategies, calculating weighted average instead of simple mean, making use of gradient information and fine-tuning the interpolation weights on development data. Our results confirm the necessity of applying checkpoint averaging for optimal performance, but also suggest that the landscape between the converged checkpoints is rather flat and not much further improvement compared to simple averaging is to be obtained.
BibTeX
@misc{gao2022revisiting,
  author = {Yingbo Gao and Christian Herold and Zijian Yang and Hermann Ney},
  title = {{Revisiting Checkpoint Averaging for Neural Machine Translation}},
  year = {2022},
  eprint = {2210.11803},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.11803},
}
Figure