🧬
🧬 Hands-on companion

Build Your Own LLM in Python

8 lessons: tokenizer, bigram table, weighted die with temperature, loss, gradient training, n-grams and overfitting — on all of Shakespeare's plays, in pure Python right in the browser. The hands-on companion to "How AI Works".

What you'll build
🔤Your own tokenizer
🎲A text generator with temperature
📉Loss 4.17 → 2.5 with your own eyes
🧪Overfitting caught live
📘 8 lessons⏱ 1-2 evenings🎓 Intermediate
🎯 Mission
Build and train a language model with your own hands
⚡+130XP
🏆CertificatePDF
📜Your model writes Shakespeare
Progress0 / 8 · 0%
Next up: The book in memory: counting symbols

Course program

  1. 01

    The book in memory: counting symbols

    Loading text•set and sorted•A 65-symbol vocabulary⚡ +10
    ▶ Now
  2. 02

    Tokenizer: letters to numbers and back

    stoi and itos•enumerate•encode / decode•Round-trip check⚡ +10
    Open
  3. 03

    Questions and answers: splitting the book

    Encoding the whole book•(context, answer) pairs•train / val 90 / 10⚡ +10
    Open
  4. 04

    The first model: a "who follows whom" table

    A 65 × 65 table•zip over neighbours•The probability pie•Bigrams⚡ +10
    🔒 Pro
  5. 05

    The die and the temperature: the model writes

    random.choices•The generation loop•Temperature•random.seed⚡ +10
    🔒 Pro
  6. 06

    Measuring surprise: the loss

    −log p•Average surprise•Add-one smoothing•train vs val⚡ +10
    🔒 Pro
  7. 07

    Turning the knobs: training by gradient

    logits and softmax•Batches•The p − y gradient•Learning rate⚡ +10
    🔒 Pro
  8. 08

    Looking further back: context and overfitting

    n-grams•tuple as a key•Overfitting live•What attention adds
    Your model writes Shakespeare
    🔒 Pro
Build Your Own LLM in Python — online coding course — CodeDala