E9Capstone: build a tiny GPT
6 lessons. Study in order; each one assumes the previous.
The capstone closes the pillar by building a working language model end to end, the way nanoGPT does: a small decoder-only Transformer trained on character-level text. Everything taught across A, C, D, and E reappears here as code that runs, so the abstractions become a model you can train on a laptop and sample from.
You will set up the training loop and data pipeline, reimplement the Transformer block from scratch, and train it on TinyShakespeare. Then you will modernize it with RoPE and RMSNorm, add a minimal preference-tuning pass (RLHF/DPO) on top of the pretrained base, and finish by re-reading 'Attention Is All You Need' with the implementation in hand.
This subsection is deliberately a synthesis: it has no new theory of its own. It exists so the reader can verify, by building, that the pieces fit together.
Before you start
- E3 Transformer LMs (the block, positional encodings, decoder-only).
- E4 Training LLMs (pretraining objective) and E4/E? alignment for the DPO pass.
- D1 Core building blocks (backprop, optimizers) and comfortable PyTorch.