Contents

How a Language Model Actually Works

Lesson 41 of 78. Sign in to keep your place.

Module 5 · Where the weights come from

What the training objective actually measures

8 min read

One number, minimised

The training objective is small enough to write in a line. At every position, the model produces a probability distribution over the vocabulary. Take the probability it assigned to the token that actually came next. Take the negative logarithm. Average over all positions.

Python
loss = -np.mean(np.log(probs[range(T), true_next_tokens]))

That is cross-entropy loss, and it is the whole objective of pretraining. Nothing in it mentions truth, helpfulness, reasoning or safety. All of those are downstream consequences of predicting text well.

Reading the number

The negative log of a probability. If the model gave the correct token a probability of 1.0, the loss at that position is 0. If 0.5, it is 0.69. If 0.01, it is 4.6.

Because the logarithm is steep near zero, being very wrong is punished hard. A model that assigns 0.001 to the true token takes a loss of 6.9 at that position, which will dominate the average over many confident-and-correct positions. This is why models learn to hedge: spreading a little probability across plausible alternatives is cheap insurance against a catastrophic single position.

Typical values give you a scale. A well-trained current model reaches a loss around 1.6 to 2.0 nats per token on general text. Random guessing over a 128,000-entry vocabulary would be about 11.8. Human-level performance on this task is not well defined, but the remaining gap is small in nats and large in what it buys.

Perplexity

Perplexity is the exponential of the loss. A loss of 2.0 is a perplexity of 7.4, and the interpretation is intuitive: the model is as uncertain as if it were choosing uniformly among 7.4 equally likely options at each step.

Two warnings that matter more than the definition.

Perplexity is not comparable across tokenizers. A model with a large vocabulary produces fewer tokens for the same text, so its per-token perplexity is measured on different units. Comparing perplexity across model families is meaningless unless you normalise: bits per byte or bits per character does this correctly, and is what careful papers report.

Perplexity is not comparable across datasets. A model that memorised your test set will have wonderful perplexity on it. Held-out data from the same distribution is the minimum requirement, and contamination is the constant threat.

What low loss does and does not imply

Driving this number down produces grammar, factual association, translation, arithmetic to a degree, and the appearance of reasoning, because all of these help predict text written by people who possessed them. That is the remarkable result at the centre of the field, and it was not obvious in advance.

What it does not produce is any preference for true statements over plausible ones. The loss rewards assigning high probability to the token that came next in the corpus. Where the corpus is wrong, predicting the wrong thing is exactly correct. Where the model is generating rather than predicting, nothing in this objective distinguishes a true continuation from a plausible one, which is the mechanism the hallucination lesson describes.

Where you meet it

You will see loss curves whenever you fine-tune. Three readings worth knowing:

  • Training loss falling, validation loss rising: overfitting. The model is memorising your examples. Stop earlier, use fewer epochs, or add data.
  • Both flat from the start: the learning rate is too low, or the data is not formatted the way the model expects. Check the chat template before you touch hyperparameters.
  • A sudden spike: the numerical instability from module two. Roll back and lower the learning rate.

And the practical caution: a lower fine-tuning loss does not mean a better model for your purpose. Loss measures agreement with your training examples. If those examples are mediocre, a lower loss means more faithfully mediocre. The number to trust is a held-out evaluation on the task you actually care about.

Every lesson here is open. Your progress is recorded once you pass the AI, Actually Explained exam.

Check your understanding

A fine-tune reaches a much lower training loss than a previous run, but users say the model is worse. What is the most likely explanation?

Pick the one you would defend. Your answer stays private.

Next lesson · 9 minHow a number inside the model gets changed

Stuck on something?Ask Anjali, your AI tutor

How to cite: Addaly (2026) ‘What the training objective actually measures’, in How a Language Model Actually Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/how-llms-work/the-loss-and-perplexity (Accessed: 13 October 2026).