Build LLMs from scratch.

From backpropagation by hand to transformers, reasoning, agents and MCP. Each step is a small exercise in plain Python and NumPy, solved and tested right in your browser.

15 sections · 2 problems

  1. 0

    NumPy & Math Foundations

    0/1

    Vectorized thinking, broadcasting and numerically stable primitives every later block relies on.

  2. 1

    Backpropagation by Hand

    0/1

    Derive and code gradients yourself, then prove them right with gradient checking.

  3. 2

    Loss Functions

    Coming soon

    MSE, cross-entropy from logits and their gradients.

  4. 3

    Optimizers & Schedules

    Coming soon

    SGD, momentum, Adam/AdamW, warmup + cosine decay, gradient clipping.

  5. 4

    Neural Network Layers

    Coming soon

    Embedding, LayerNorm, RMSNorm, dropout and weight initialization.

  6. 5

    Language Modeling Basics

    Coming soon

    Bigram and MLP language models, temperature, top-k and top-p sampling.

  7. 6

    Tokenization

    Coming soon

    Train a byte-pair encoding tokenizer, then encode and decode with it.

  8. 7

    Attention & Transformers

    Coming soon

    Scaled dot-product attention, causal masking, multi-head, RoPE, GQA, the full block.

  9. 8

    Training LLMs

    Coming soon

    Training loops, batching, mixed precision ideas and scaling-law arithmetic.

  10. 9

    Efficient Inference

    Coming soon

    KV cache, beam search, speculative decoding and int8 quantization.

  11. 10

    Post-Training & Alignment

    Coming soon

    SFT loss masking, LoRA, reward models, DPO, PPO-clip and GRPO.

  12. 11

    Reasoning

    Coming soon

    Self-consistency, pass@k, best-of-N with verifiers.

  13. 12

    Retrieval-Augmented Generation

    Coming soon

    Embeddings, cosine similarity, BM25, chunking and retrieval.

  14. 13

    Agents

    Coming soon

    Tool-call parsing, the ReAct loop and agent memory, driven by a scripted fake LLM.

  15. 14

    Model Context Protocol

    Coming soon

    JSON-RPC 2.0, the MCP handshake and a minimal tool server.