Companion page
Large Language Models from the Ground Up
by Waseem Khan — everything the book links to, on one stable page. Bookmark this; the links below are kept current even as the material evolves.
▶ Run the book's code (free, nothing to install)
Every code chapter of the book is also a runnable notebook. Each “Open in Colab” link opens the notebook in Google Colab — press Copy to Drive, then run cells with Shift+Enter. (Free Google account required. Details: book Chapter 15 / Appendix A.)
- Part II · Ch 16 00 — Roadmap & reading Python Open in Colab
- Part II · Ch 17 01 — Math foundations Open in Colab
- Part III · Ch 18 02 — Tokenization Open in Colab
- Part III · Ch 19 03 — Your first language model (bigram) Open in Colab
- Part III · Ch 20 04 — Autograd from scratch (micrograd) Open in Colab
- Part III · Ch 21 05 — Self-attention Open in Colab
- Part III · Ch 22 06 — The Transformer block Open in Colab
- Part IV · Ch 23 07 — PyTorch & autograd Open in Colab
- Part IV · Ch 24 08 — Assembling the GPT Open in Colab
- Part IV · Ch 25 09 — Training the GPT Open in Colab
- Part IV · Ch 27 10 — Sampling & beyond Open in Colab
🚀 Advanced companion notebooks (Parts V–VII)
- Part V · Ch 28 Train your own BPE tokenizer Open in Colab
- Part VI · Ch 34 Fine-tune a real model with LoRA/QLoRA (needs the free T4 GPU runtime) Open in Colab
- Part VII · Ch 41 RAG from scratch Open in Colab
- Part VII · Ch 42 Build a tool-using agent (needs a local model — Ollama, Chapter 39; not pure Colab) Open in Colab
✨ Interactive animations (Part I of the book)
The book's Part I topics — tokens, embeddings, attention, training, sampling — have animated, playable demos in the free web course: How LLMs Work (18 short lessons).
🧪 Interactive labs (the whole book)
Twenty-four small in-browser demos animate the book's trickiest mechanisms, from Part I's fundamentals to Part VIII's frontier scale — the book's "Watch it move" boxes point at these. Six highlights below; all 24 labs on one page →
- Ch 25 Attention learns to look — scrub 3,000 training steps and watch sixteen heads sharpen into specialists Open lab
- Ch 27 Watch it speak — the book's own 825K-parameter GPT, generating live in your browser Open lab
- Ch 36 Reward hacking — the judge's score climbs while true quality collapses, until the KL leash catches Open lab
- Ch 41 The RAG retrieval playground — score a question against every document and see what's retrieved Open lab
- Ch 42 Prompt injection — one poisoned email hijacks an inbox assistant, until the guardrails switch on Open lab
- Ch 45 The Chinchilla allocator — split a FLOPs budget between size and tokens and find the valley floor Open lab
🧪 Run Part III's code in the browser — no account at all
Chapters 17–22's NumPy code also runs directly on this site (Pyodide, in your browser): Build an LLM from Scratch — interactive course.
📦 All the source code
GitHub: github.com/wazeemlabs/llm-book-code
— notebooks in llm-from-scratch/, one per code chapter. Download ZIP or
git clone; local setup instructions are in the book's Appendix A.
🎓 For instructors
The book is written to support four quite different courses, and Appendix G sets out which chapters belong in each, what compute a department has to provide, and how to handle the fact that every ★ and ★★ answer is printed in Appendix B. The materials that can't ship inside a book are here:
- Course-fit table — all 47 chapters with prerequisite tier, lecture-or-lab, compute needed, dependencies, and track membership
- Week-by-week calendars — for the non-majors, undergraduate CS, senior/MS, and graduate-seminar tracks
- Rubrics — a shared four-dimension scale plus a criterion for every one of the 59 ★★★ exercises, and for the Appendix H capstone
- Problem bank — a generator, not a document: fresh numeric problems with a computed answer key, a new set per seed, so nothing leaks and no two terms sit the same paper
- Slides — per-chapter decks built from the book's figures and key takeaways
Everything except the answer keys is a direct download. For those, email ceo@wazeem.com from an institutional address with a link to your course listing — the keys stay unpublished for the obvious reason. Reports of what worked and what didn't in your classroom are genuinely welcome, and shape the next edition.
✍️ About the author
Waseem Khan is a US Fulbright Scholar with a master's in public policy and data analytics from Carnegie Mellon University — where he made the Heinz College Dean's List — and a master's in computer science from NUST. In nearly two decades as a software and machine-learning engineer he has shipped Android apps with over a million downloads, and as a Deputy Commissioner in Pakistan's Inland Revenue Service built the fraud-detection and analytics systems that raised audit capacity twenty-fold. Today he works inside the LLM industry itself: leading a thirty-person team that creates and audits the training data used to teach frontier AI models to code and reason, and writing the PhD-level research problems used to train their deep-research modes — the very techniques the book explains.
Reach him at linkedin.com/in/wasxxm or ceo@wazeem.com — reader questions and corrections are genuinely welcome.
🐛 Errata & updates
Corrections and updates to the book are listed here as they're found. Spotted a problem? Open an issue: github.com/wazeemlabs/llm-book-code/issues.
No errata yet — this page was last updated for the first edition.