Skip to content

Stage 13AI1st EditionRead

Build a Large Language Model (From Scratch)

Demystifying modern LLMs line by line in PyTorch: BPE tokenization, causal self-attention, GPT blocks, pretraining loops, and instruction tuning.

Sebastian Raschka · Manning (2024) · ISBN 978-1-63-343716-6

  1. 113Byte-pair encoding (BPE) tokenization & embeddings
  2. 114Scaled dot-product & causal multi-head self-attention
  3. 115Transformer blocks: LayerNorm, GELU & residual streams
  4. 116Autoregressive pretraining, cross-entropy & weight loading
  5. 117Supervised fine-tuning for classification & instructions
  6. 118Preference alignment (DPO/RLHF) & LoRA adapters
Build a Large Language Model (From Scratch) by Sebastian Raschka