Hyperparameter

A hyperparameter is a setting chosen by people to control how a model is trained, such as the learning rate or batch size, as opposed to the parameters the model learns from data.

A model's parameters, its weights and biases, are learned during training. Its hyperparameters are the settings that govern that learning, and they are chosen by the developer rather than learned. Google's machine learning glossary gives the classic example: you might set the learning rate to 0.01 for one training run, decide that is too high, and try 0.003 for the next.

Common hyperparameters include the learning rate and how it changes over time, the batch size, the number of epochs, the dropout rate, the strength of weight decay, and the settings of the optimiser. Choices about the model's design, such as how many layers it has, are often tuned in the same way.

Real training runs publish long lists of them. Meta's 2023 Llama 2 paper reports that its models were pre-trained with the AdamW optimiser, a cosine learning rate schedule with 2,000 warm-up steps decaying to 10% of the peak, weight decay of 0.1, gradient clipping at 1.0 and a global batch of 4 million tokens. The peak learning rate was 0.0003 for the 7 and 13 billion parameter models and half that, 0.00015, for the 34 and 70 billion parameter ones.

Hyperparameters matter because they decide whether training works at all. Google's glossary notes that a learning rate set too low makes training take too long, while one set too high can stop it settling on a good solution. Finding good values is a search problem of its own, called hyperparameter optimisation or tuning.

When a model is described as having 70 billion parameters, that count does not include hyperparameters. They are a handful of numbers in a configuration file, but they can make the difference between a successful training run and an expensive failure.

Common questions

What is the difference between a parameter and a hyperparameter?

Parameters are the weights and biases a model learns from data during training, and there can be billions of them. Hyperparameters are the settings a developer chooses to control training, such as the learning rate or batch size, and there are far fewer of them.

What are examples of hyperparameters?

The learning rate, batch size, number of epochs, dropout rate, weight decay and optimiser settings are all hyperparameters. Choices about the model's structure, such as the number of layers, are often counted as well.

How are hyperparameters chosen?

Developers start from values that worked for similar models and then search, trying several combinations and comparing results on validation data. Methods range from trying a grid of values to random search and Bayesian optimisation.

Why do hyperparameters matter?

Bad values can waste an entire training run. A learning rate that is too low makes training slow, and one that is too high can stop the model from settling on a good solution. For large models, where each run is expensive, getting them right matters a great deal.

Finding more

Search for "hyperparameter vs parameter", "hyperparameter tuning" or the name of a specific setting, such as "learning rate schedule". Google's machine learning glossary and Crash Course explain the basics, and developers' technical reports and model cards often list the hyperparameters used for real models. Be careful with copied hyperparameter recipes: values that work for one model and dataset often do not transfer.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.