Hyperparameter

A hyperparameter is a setting that controls how a machine learning model is built or trained, chosen by people (or by an automated search) rather than learned from the data. The model’s weights, by contrast, are parameters: training adjusts them. Hyperparameters set the conditions under which that adjustment happens.

Examples

Common hyperparameters include the learning rate, which sets how big a step gradient descent takes; the batch size, the number of examples used for each update step; the number of training steps; the architecture itself, such as how many layers and how many parameters a network has; and regularization settings, such as the dropout rate, that help prevent overfitting. Some settings apply when a trained model is used rather than trained: the “temperature” of a language model controls how random its token choices are, low for predictable answers and high for more varied ones (see Inference).

Tuning

Finding good hyperparameters is part craft, part search. Engineers try combinations and compare results on held-out validation data. Systematic methods include grid search, which tests every combination of a few values; random search, which James Bergstra and Yoshua Bengio showed in 2012 is often more efficient; and Bayesian optimization, which uses earlier results to choose the next trial. For very large models, trial and error is prohibitively expensive, since a single training run can cost hundreds of millions of dollars, with billion-dollar runs expected soon. Researchers therefore tune small models and transfer the settings: a 2022 technique from Microsoft and OpenAI researchers, μTransfer, relies on a parameterization called μP (“mu-P”) under which the best learning rate and many other settings stay roughly stable as networks get wider, so settings tuned on a small model carry over to a large one.

Scaling decisions

Some of the most consequential hyperparameters concern scale: how many parameters a model should have and how much data it should be trained on for a given computing budget. DeepMind’s 2022 “Chinchilla” study concluded that many large models were undertrained and that, for compute-optimal training, model size and training data should grow in proportion, which works out to roughly 20 tokens of text per parameter (see Scaling Laws). Developers now often train smaller models on much more data than that, because smaller models are cheaper to run: Meta trained its 8-billion-parameter Llama 3 model on more than 15 trillion tokens, far beyond the compute-optimal amount. Regulators also use training compute as a rough proxy for risk – California’s SB 53, for example, covers models trained with more than 10^26 operations (see Compute Threshold).

Why it matters

Hyperparameters are one of the main places where engineering judgment enters machine learning. The same algorithm and data can produce a mediocre or an excellent model depending on them, which is why published results can be hard to reproduce and why experience with large training runs is a valuable – and closely guarded – asset of leading AI labs.

Written with Claude, made by Anthropic, which, like most frontier developers, does not publish Claude’s hyperparameters, model size or training-data volume, and which endorsed California’s SB 53, a law that uses a training-compute threshold.

Related

Gradient Descent · Weights · Scaling Laws · Overfitting · Inference · Compute Threshold · Training Data

Sources: James Bergstra, Yoshua Bengio: Random Search for Hyper-Parameter Optimization (Journal of Machine Learning Research) (2012) · Greg Yang, Edward J. Hu: Feature Learning in Infinite-Width Neural Networks (arXiv) (2020) · Greg Yang et al.: Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter Transfer (arXiv) (2022) · Jordan Hoffmann et al.: Training Compute-Optimal Large Language Models (arXiv) (2022) · Ben Cottier et al. (Epoch AI): How much does it cost to train frontier AI models? (June 3, 2024) · Meta AI: Introducing Meta Llama 3 (April 18, 2024) · Gábor Melis, Chris Dyer, Phil Blunsom: On the State of the Art of Evaluation in Neural Language Models (arXiv) (2017)

Leave a Reply

Your email address will not be published. Required fields are marked *