The architecture, block by block
The reference model is decoder-only, and the chapter walks it from the bottom up, one station at a time. The whole stack is this:
- token embeddings
- position embeddings
- N identical blocks: causal attention, feed-forward, layer norm, residual connections
- a final layer norm
- a linear projection onto the vocabulary
- softmax: the probabilities of the next token
GPT-2 small's numbers show what each stage weighs. The position embeddings are learned, one row per position, and weight tying makes the embedding matrix and the final projection the same tensor: it removes 50 257 × 768 ≈ 38.6 million parameters, nearly a third of the 124 million total. The last stage also gives the first sanity check: a freshly initialised model has to start from a loss of ln 50 257 ≈ 10.82, and if the first training step reports anything else, the bug is in the code.
Chapter 6, page 102.


