LEARNING PATH · Foundations

Build an LLM From Scratch

For engineers who want to understand a language model down to the matrix multiply.

Advanced ~6h 15m20 lessons20 steps

No black boxes. Start at raw bytes and end at an aligned assistant — tokenization, embeddings, attention, the full forward pass, the training loss, and RLHF — each idea paired with a runnable challenge or lab that makes you build the piece by hand.

  • Explain every stage from tokens to a trained, aligned model
  • Implement attention, softmax, layer-norm and cross-entropy by hand
  • Reason about scaling laws and why pretraining works
  • Understand how RLHF turns a raw LM into an assistant
0 / 20 done · 0%
  1. LabNext up

    The Tokenizer

    Text becomes tokens: watch BPE build a vocabulary from raw bytes.

  2. Challenge

    BPE Merge Step

    Implement the merge step every BPE tokenizer is built on.

  3. Handbook

    The Embeddings Handbook

    Tokens become vectors — what an embedding actually is.

  4. Paper Breakdown

    Word2Vec

    The paper that made “king − man + woman ≈ queen” real.

  5. Lab

    The Meaning Map: Embeddings

    Fly through an embedding space and see meaning as geometry.

  6. Paper Breakdown

    Seq2Seq

    Before attention: encoder→decoder and its bottleneck.

  7. Paper Breakdown

    Attention Is All You Need

    The Transformer — the architecture every LLM inherits.

  8. Challenge

    Single-Head Attention

    Implement scaled dot-product attention from scratch.

  9. Lab

    The Spotlight: Attention

    Watch attention weights light up token to token.

  10. Challenge

    Softmax

    The function at every attention and output head.

  11. Challenge

    Layer Normalization

    The normalization that keeps deep stacks trainable.

  12. Lab

    Inside a Transformer: Self-Attention

    Push a sequence through a full forward pass, layer by layer.

  13. Handbook

    The Transformers Handbook

    Consolidate: the whole architecture in one handbook.

  14. Paper Breakdown

    RoPE (RoFormer)

    How modern models encode position — rotary embeddings.

  15. Paper Breakdown

    GPT-3

    Scale it up: few-shot learning emerges.

  16. Paper Breakdown

    Scaling Laws

    Why more parameters and data predictably help.

  17. Challenge

    Cross-Entropy Loss

    The loss you train a language model against.

  18. Handbook

    The Fine-Tuning Handbook

    Adapt a pretrained model to your task.

  19. Paper Breakdown

    InstructGPT

    Turn a raw LM into an assistant — RLHF.

  20. Lab

    The Taste Trainer: RLHF & DPO

    Practice the preference-tuning loop by hand.

← All learning paths