Resources/Model training/What happens during training

Setting

Hyperparameters

Hyperparameters are the training settings you choose, such as epochs, learning rate, batch size and adapter rank, as opposed to the weights the model learns. Auto picks them from your data and makes a good first run; this page explains each one so you can tune from there.

Chapter 65 min read4 references

Parameters and hyperparameters

A model's parameters, its weights, are learned: training sets them. Hyperparameters are set by you before training starts and control how that learning happens: how many times the data is seen, how big each update is, how many examples go into each update, how large an adapter is. Training can't find good hyperparameters on its own. You find them by running, measuring and adjusting, which is why a sensible default and a clear way of reading the results matter more than a perfect first guess.

The settings

EpochsTypical 1–3 (preference tuning 1–2)#

How many full passes the training makes over your data. Too few and the model barely changes; too many and it starts reproducing your examples word for word (overfitting), which shows as validation loss rising while training loss keeps falling. Small datasets can take a few more epochs; large ones often need only one. Preference tuning usually needs fewer epochs than supervised training. Every epoch also adds to the cost.

Learning rate / multiplierTypical Provider default (× 0.5–2)#

How large each weight update is. It is the most sensitive setting: too high and updates overshoot, the loss turns jagged and the model can lose skills it had; too low and the run ends before the model has learned much. Hosted models often expose a multiplier instead of a raw rate: the provider's own default rate for that model and your data is multiplied by your value, so 1 keeps the default, 2 doubles it and 0.5 halves it. Open models take a raw rate, such as about 1e-4 for a LoRA adapter or 1e-5 for full fine-tuning.

Batch sizeTypical Auto#

How many examples are averaged into each weight update. Larger batches give smoother, more reliable updates but fewer of them per epoch, and need more memory; smaller batches update more often but more noisily. When you change the batch size, reconsider the learning rate too: a larger batch usually tolerates, and needs, a larger rate. On a small dataset a very large batch leaves too few steps to learn from.

LoRA rank / adapter sizeTypical 4–16#

For adapter training on open models. The rank of the two small matrices LoRA trains beside each layer, which sets how much the adapter can learn. Rank 4–16 is enough for tone, style and format; larger, knowledge-heavy datasets can use more. Higher ranks cost more memory and time, and stop helping once the adapter has enough capacity. The LoRA page covers alpha, target modules and dropout.

Warm-up stepsTypical 0–10% of steps#

For the first steps of training, the learning rate ramps up from near zero to its full value instead of starting at full strength. Early on, the optimizer's running statistics are based on very few gradients, so full-size steps risk a bad first move; a short warm-up avoids an unstable start. It is given as a number of steps or a share of all steps. After warm-up the rate usually decays toward zero for the rest of the run.

WARM-UPpeak learning ratecosine decaylinear decaylearning ratetraining steps →010%100%
A typical learning-rate schedule. Warm-up ramps the rate from near zero to its peak over the first few percent of steps, so the first, noisiest updates are small. The rate then decays toward zero, by a cosine curve or a straight line, so the last updates make fine adjustments instead of big jumps.

How the settings interact

If you changeAlso considerWhy
More epochsA lower learning rate; watching validation lossMore passes and large steps together compound overfitting
A larger batchA higher learning rateThere are fewer, more reliable steps per epoch
A smaller datasetA smaller batch; possibly a few more epochsOtherwise there are too few steps to learn from
LoRA instead of full fine-tuningA higher learning rate, roughly 10×The adapter starts at zero and its output is scaled by alpha ÷ r
Preference tuning after supervisedFewer epochs and a lower learning rateIt polishes a working model; big steps make it drift

A practical tuning order

  1. Run once on Auto. It is a reasonable baseline and shows what the provider picks for your data.
  2. Read the loss curves. Validation loss rising early: fewer epochs or a lower learning rate. Both losses still falling at the end: more epochs. Neither moving: check the data first, then try a higher learning rate.
  3. Evaluate against the base model, not just the loss. A lower loss does not guarantee better answers.
  4. Change one setting at a time, keeping the rest fixed, so you know what made the difference. Learning rate and epochs first; batch size and warm-up rarely need touching.
  5. Keep the losing runs. Archived with their evaluations, they answer ‘did we try a higher learning rate?’ months later.
One adjustment, read from the curves
  1. Run 1, on Auto: 3 epochs, multiplier 1. Training loss falls throughout; validation loss is lowest early in epoch 2 and rises after that.
  2. Diagnosis: overfitting from about the middle of the run. The learning rate looks fine: the curve is smooth, not jagged.
  3. Run 2: 2 epochs, everything else unchanged. Validation loss now ends close to its lowest point, and the run costs a third less.
  4. Before keeping it: evaluate run 2 against the base model and against run 1.

Common mistakes

  • Changing several settings at once, so a better or worse result can't be explained.
  • Tuning on training loss. It almost always improves with more epochs or a higher rate; validation loss and evaluation are the judges.
  • Treating a multiplier as a raw learning rate. A multiplier of 2 doubles the provider's default; it is not a rate of 2.
  • Copying settings from a run with a very different data size. Steps, warm-up and the right number of epochs all scale with the data.
  • Chasing small differences on a tiny validation set. With a few dozen held-out conversations, a small gap is noise.

References and further reading

External sources open in a new tab.

  1. 01TrainerHugging Face Transformers docs · huggingface.coThe full list of training arguments and their defaults, from learning rate and epochs to warm-up and weight decay.
  2. 02Linear regression: HyperparametersGoogle Machine Learning Crash Course · developers.google.comLearning rate, batch size and epochs explained with interactive examples.
  3. 03Accurate, Large Minibatch SGD: Training ImageNet in 1 HourGoyal et al., 2017 · arXiv · arxiv.orgThe linear scaling rule linking batch size and learning rate, and gradual warm-up.
  4. 04Hyperparameter (machine learning)Wikipedia · en.wikipedia.org

Turn weeks of expert work into minutes

See how Scalata fits your team, your data, and your controls.