How a model guesses the next word

One example, start to finish. The model reads four tokens and has to fill the gap:

wheredidthecat?
Our corpus: the only text in the whole course. Module 1 cleans and tokenizes it, module 6 trains on it, module 7 tests the trained model on it.
Where did the cat sat?
The cat sat on the  mat.
the Dog  sat on the mat .
WHERE did the dog sat ?

Tiny sizes, so every number fits on screen: 10 tokens in the vocabulary, 3 numbers per token, one attention head. Every number is computed in code. Read the modules in order.

The big picture
The big picture: text, tokens, vectors, attention, chances, then training or inference

Whole course on one page (one file, works offline, good for printing or saving).

Part A · The forward pass: from text to a guess (used by training and inference)
Part B · Training: the weights change
Part C · Inference: the weights are frozen