Generative models · the from-scratch course
CS336 — Language Modeling from Scratch
A linearized rebuild of Stanford's CS336: how a modern large language model is built end to end — tokenizer, architecture, kernels, parallelism, running the run, scaling laws, data, alignment, long context, inference — derived as one chain of decisions under a fixed compute budget.
This is the rigorous, full-stack sibling of the six-lesson Mini GPT track. Mini GPT is the compact tour of post-training; this course builds the whole thing from scratch, the way Stanford's CS336 does — and reorganizes the five course units (basics → systems → scaling → data → alignment & inference) into a single derivation where every lesson is forced by the wall the previous one hit.
The spine — one forced chain
Read the diagram left to right, top row then bottom. Each box is a wall; the arrow into the next box is the idea it is forced to introduce. Nothing is here "because LLMs have it" — each link exists because, without it, the chain breaks.
The lessons
How to use this
- Read it linearly. Each lesson assumes the last. Lesson 08 only makes sense as the answer to the wall lesson 05 hits; lesson 17 (preferences) only as the thing lesson 16 (SFT) cannot do.
- Touch every knob. Each widget has a configuration that breaks — a run that diverges, a model that overflows the GPU, a leak that fakes a benchmark, a context that collapses. Find it. The failure is the lesson.
- Follow the cross-links. This track is a hub. Where another series goes deeper — kernels, RL, serving — it links out instead of repeating.