Fine-Tuning Pretrained Language Models: Weight Initializations, Data Orders, and Early Stopping

Jesse Dodge, Gabriel Ilharco, Roy Schwartz, Ali Farhadi, Hannaneh Hajishirzi, Noah A. SmitharXiv 2020

Abstract

Fine-tuning large-scale pretrained models like BERT is a standard practice in NLP, yet the process remains surprisingly inconsistent. This paper investigates the "brittleness" of fine-tuning, demonstrating that variations in random seeds—specifically affecting the weight initialization of the task-specific layer and the order of training data—can lead to drastically different outcomes. Through an extensive grid search of over 2,100 trials, we show that "lucky" seeds can enable standard BERT models to outperform more complex state-of-the-art architectures. To mitigate the computational cost of finding these seeds, we propose an efficient early-stopping strategy.

Introduction

The prevailing paradigm in NLP involves fine-tuning a massive pretrained model (e.g., BERT) on a downstream task. Despite its success, researchers often encounter high variance: identical code and hyperparameters can yield significantly different results based solely on the random seed. This study quantifies the impact of two seed-dependent factors:

  1. Weight Initialization (WI): The initial values for the final classification layer.
  2. Data Order (DO): The sequence in which training examples are presented.

Methodology

We conducted a comprehensive evaluation using four datasets from the GLUE benchmark: MRPC, RTE, CoLA, and SST. These datasets vary in size, providing a broad view of fine-tuning dynamics.

Experimental Design

For each task, we fine-tuned BERT-large hundreds of times, decoupling the seeds for WI and DO to isolate their individual contributions. We measured the Expected Validation Performance, a statistical metric representing the best score one can expect to achieve given a specific budget of trials.

Early Stopping Strategy

To optimize compute, we tested a "start many, stop early" approach. By initiating $t$ trials and continuing only the top $p$ performers after a fraction $f$ of training, we aimed to identify high-performing seeds with minimal overhead.

Analysis of Variance and the "Lucky Seed" Effect

Our analysis reveals that on smaller datasets (MRPC, RTE, CoLA), a significant portion of trials fail to converge, resulting in near-random performance. This creates a multimodal distribution of outcomes.

Density plot of validation accuracy for the RTE task, illustrating the multimodal distribution of outcomes due to random seed variation.

Key findings include:

  • Impact of Minimal Parameters: WI affects only ~0.0006% of BERT-large's parameters, yet it is a primary driver of convergence success.
  • WI vs. DO: Both factors contribute roughly equally to performance variance.
  • Global Stability: Certain WI seeds consistently perform well across different tasks, suggesting inherent architectural stability.

Results

By increasing the number of trials, we found "lucky" seeds that significantly boosted performance. On the RTE task, our best run achieved a score of 77.3, far exceeding the previously reported 70.4 and making BERT competitive with newer models like RoBERTa.

Expected validation performance across four GLUE tasks as a function of the number of random seed assignments.

The early stopping algorithm proved highly effective. For instance, starting 41 trials and retaining the top 11 after 30% of training consistently outperformed running fewer trials to completion for the same total computational cost. This is supported by a strong correlation between early-epoch performance and final validation scores.

Conclusion and Limitations

This work underscores the importance of reporting variance and exploring multiple random seeds in fine-tuning experiments. While focused on BERT-large, the findings suggest that many "state-of-the-art" gains in NLP might be attributable to seed selection rather than architectural innovation. Future research should investigate the mathematical properties of "globally good" seeds and the interaction between seeds and other hyperparameters like learning rates.

Summary updated

BibTeX
@misc{dodge2020fine,
  author = {Jesse Dodge and Gabriel Ilharco and Roy Schwartz and Ali Farhadi and Hannaneh Hajishirzi and Noah A. Smith},
  title = {{Fine-Tuning Pretrained Language Models: Weight Initializations, Data Orders, and Early Stopping}},
  year = {2020},
  eprint = {2002.06305},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2002.06305},
}
Figure