Module 5 · Where the weights come from

What the training objective actually measures

In this lesson

  • 8 min read
  • 5 reading sections
  • Knowledge check
  • Lesson 3 of 10 in this chapter

This chapter’s goalExplain what each training stage optimises and what it cannot fix, estimate the compute cost of a training run from parameter and token counts, and choose between prompting, retrieval and fine-tuning by what each one actually changes.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 6Free · no account needed
Lesson steps

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.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

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

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: 29 November 2026).