Bookmarks

Hyperparameter

A training or model setting that a person chooses in advance: unlike weights, training does not find it.

Also: hyperparameters, hyperparameters, training settings

checked 18 Nov

All terms

The training algorithm finds a model’s weights, while the developer chooses the hyperparameters before the run: how fast to change the weights, how many examples to take per step, how many times to pass over the data. They affect the quality of the result, the speed and the memory use, so they are tuned by trial runs.

What is tuned most often

HyperparameterWhat it setsDefault in Trainer
learning_ratelearning rate: the size of the step when the weights change; with warmup, its peak5e-5
per_device_train_batch_sizenumber of examples per device per step8
num_train_epochshow many times to pass over the whole dataset3.0
warmup_stepshow many steps the learning rate takes to rise from zero to the set value0
weight_decaystrength of the penalty for large weights0.0

Fine-tuning hyperparameters

The LoRA method has its own settings: the rank r determines the size of the added matrices, lora_alpha sets the scale of their contribution, and target_modules says which layers get an adapter. The PEFT documentation examples use, for instance, r=16 and lora_alpha=16. The higher the rank, the more trainable parameters and capacity, but also the more memory needed.

How they are chosen

Usually you take values from the model card or the paper describing the method and change them one at a time, comparing the loss on a held-out part of the data. The search can be done by hand, as a grid or at random. If the loss falls on the training data but rises on the held-out data, the model is overfitting: fewer epochs, a lower learning rate or more data can help.

Sources

the term is written from these pages

Verified 18 Nov

Not to be confused with

what it is mixed up with and how it differs

  • model parameters (weights)

    Model parameters are the weights, found by training; hyperparameters are set by a person before training.

In depth in the references

where the topic is covered in detail

Appears in the references