1. Surprise is the score
Training shows the model some text and asks, at every position: what comes next? The model answers with a probability for every token in its vocabulary. We then look at the probability p it gave to the token that really came next, and turn it into a penalty called the loss:
loss = −ln(p)
If the model was sure and right (p near 1) the loss is near 0. If it gave the right token only a one in a thousand chance, the loss is large. A model that knows nothing spreads its probability evenly, so with a vocabulary of 512 tokens it scores ln 512 ≈ 6.24 everywhere. That number is the starting line.
| Probability given to the right token | Loss |
|---|---|
| 0.9 (confident, right) | 0.11 |
| 0.5 (a coin flip) | 0.69 |
| 0.1 | 2.30 |
| 1 in 512 (pure guessing) | 6.24 |
| 0.0001 (confident, wrong) | 9.21 |
The loss punishes confident mistakes hard, which is exactly what you want. Training is the search for numbers that make the average loss over lots of text as small as possible.
5. What to take from this, and what not to
One number drives everything. Pre-training, fine-tuning and preference tuning all use this same loop: measure the loss, compute the gradient, take a small step. They differ only in which loss they measure.
Lower loss is not always better behaviour. The loss only measures how well the model predicts text like its training data. A model can predict well and still say untrue or unhelpful things.
The curve flattens. A tiny model has a limit on what it can capture, set by its size and the amount of text it saw. More steps past that point buy little. Bigger models and more data are what move the floor.
Next chapter: how the model turns those probabilities into words, and why a setting called temperature changes whether it plays safe or gets creative.