Fine-Tuning, and When Not ToLesson 10 of 84

Module 2 · How training actually works

One training step, taken apart

In this lesson

  • 10 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 1 of 9 in this chapter

This chapter’s goalTrace one optimisation step from a batch of tokens to a changed weight, and predict which way loss, memory and stability move when you change the learning rate, the batch size, the precision or the number of epochs.

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
One training step, in four partsForwardIds of shape 4 by1,024 become logits ofshape 4 by 1,024 by128,256: 525 millionnumbers, often thelargest allocation inthe job.LossCross-entropy againstthe next token.Positions labelledminus one hundredcontribute nothing tothe loss and nothingto the gradient.BackwardOne gradient tensorper trainableparameter, the sameshape as theparameter, which iswhy freezing 99 percent removes 99 percent of that cost.UpdateAdamW turns gradientsinto a weight changeusing two runningaverages, then thegradients are zeroed.A batch of four sequences of 1,024 tokens on an 8B model. Every hyperparameter later in the course isa consequence of one of these four lines.
A batch of four sequences of 1,024 tokens on an 8B model. Every hyperparameter later in the course is a consequence of one of these four lines.

Figure 2.1

A little at a time

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

Step 1 of 7Free · no account needed
Lesson steps

Four things happen, in order

Everything in this course is a variation on one step, repeated a few thousand times. The step has four parts: a forward pass, a loss, a backward pass, and an update. If you can narrate these with real shapes, every hyperparameter later stops being folklore.

Take a concrete batch: 4 sequences of 1,024 tokens each, on an 8B model with a vocabulary of 128,256.

1. Forward

The token ids go in as a tensor of shape (4, 1024). The embedding table turns each id into a vector of 4,096 numbers, giving (4, 1024, 4096). That tensor passes through every transformer block (attention, then a feed-forward network) and comes out the same shape at the end.

The last layer projects it to vocabulary size: (4, 1024, 128256). These are the logits, one score per possible next token, at every position.

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 Running Models Yourself exam.

Stuck on something?Ask Rafael, your AI tutor

How to cite: Addaly (2026) ‘One training step, taken apart’, in Fine-Tuning, and When Not To. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/fine-tuning/one-training-step (Accessed: 29 November 2026).