Build a Large Language Model (From Scratch)
No magic left once you write tokenization, causal multi-head attention, pretraining, and instruction fine-tuning line by line in PyTorch.
- 1Byte-pair encoding and token embedding geometry
- 2Causal self-attention and multi-head projections
- 3Residual streams, LayerNorm, and GELU feed-forward blocks
- 4Pretraining loop, cross-entropy loss, and perplexity
- 5Temperature, top-k, and nucleus sampling
- 6Loading pretrained weights into a clean architecture
- 7Supervised fine-tuning for classification and chat
- 8Preference alignment and LLM-as-a-judge evaluation
