Should I try multiple optimizers when fine-tuning pre-trained Transformers for NLP tasks? Should I tune their hyperparameters?
Nefeli Gkouti, Prodromos Malakasiotis, Stavros Toumpis, Ion Androutsopoulos
TL;DR
The study investigates whether selecting among multiple optimizers or extensively tuning their hyperparameters improves fine-tuning of pre-trained Transformers for NLP. Using five GLUE tasks, two distilled models (DistilBERT and DistilRoBERTa), and seven optimizers, with three tuning regimes, the authors find that adaptive optimizers yield similar test performance when their hyperparameters are tuned, and that tuning only the learning rate often matches full hyperparameter tuning. Non-adaptive SGD with momentum performs best only when no hyperparameter tuning is possible, while AdaBound can be competitive under defaults. The results suggest a practical guideline: choose a strong adaptive optimizer (e.g., Adam, AdamW, or Nadam) and tune only the learning rate to save compute and energy, with SGDM as a fallback under tight budgets; these conclusions hold across DistilBERT and DistilRoBERTa, though limitations remain for encoder-only models and the specific tuning budget. The work provides actionable guidance for efficient NLP training and emphasizes transparent sharing of data and code to reduce resource use in hyperparameter exploration.
Abstract
NLP research has explored different neural model architectures and sizes, datasets, training objectives, and transfer learning techniques. However, the choice of optimizer during training has not been explored as extensively. Typically, some variant of Stochastic Gradient Descent (SGD) is employed, selected among numerous variants, using unclear criteria, often with minimal or no tuning of the optimizer's hyperparameters. Experimenting with five GLUE datasets, two models (DistilBERT and DistilRoBERTa), and seven popular optimizers (SGD, SGD with Momentum, Adam, AdaMax, Nadam, AdamW, and AdaBound), we find that when the hyperparameters of the optimizers are tuned, there is no substantial difference in test performance across the five more elaborate (adaptive) optimizers, despite differences in training loss. Furthermore, tuning just the learning rate is in most cases as good as tuning all the hyperparameters. Hence, we recommend picking any of the best-behaved adaptive optimizers (e.g., Adam) and tuning only its learning rate. When no hyperparameter can be tuned, SGD with Momentum is the best choice.
