Build a Tiny GPT from Scratch

Generative & Agentic AI · Advanced: Inside the Model · Advanced · 30 min

Build a character-level language model in plain Python: tokenize, count bigrams, generate with greedy and temperature sampling, then see exactly what a transformer block and a training loop add on top.

This lesson is part of TuringPath Pro. See plans.

What you will learn

  • Step 1: turn text into numbers
  • Step 2: a bigram model is a table of counts
  • Step 3: generate with greedy and temperature sampling
  • Step 4: what a transformer block adds
  • Step 5: the training loop in words

More in Advanced: Inside the Model

Previous: Mixture of Experts (MoE) · Next: Interpretability: Looking Inside the Model