Learn AI Layer by Layer
A hands-on guide to how modern AI actually works, built up from scratch one idea at a time. No math or coding background needed. Every chapter is full of widgets you can poke, drag, and break.
Teaching a class? See the guide for educators
- Part 1
The building blocks
How a machine made of numbers can learn to do things nobody told it how to do.
- Part 2
Meaning as numbers
How words become something a computer can reason about, and why predicting the next word requires understanding.
- Part 3
The transformer
The architecture behind every modern chatbot, built from the pieces you already have.
- Part 4
From model to assistant
How a document-continuing machine becomes something that chats, reasons, and gets things done.
- Part 5
AI in the world
What AI is doing to the society around it, and the realistic ways it could go badly wrong.
Every chapter comes with real PyTorch code
Each chapter ends with an optional notebook you can run in Google Colab, with nothing to install. New to PyTorch? The PyTorch from Scratch appendix teaches you enough to follow along.
Coming soon
16 more chapters are planned, covering the ideas behind today's cutting-edge models.
- Matrix MathThinking by rotating
- Making Training WorkWhy training almost doesn't work
- Mixture of ExpertsOnly wake the specialists you need
- Long ContextRemembering a million words
- Inference and HardwareRunning models fast
- InterpretabilityLooking inside the mind
- Reinforcement LearningLearning from experience
- Self-PlayGetting better by beating yourself
- AlignmentTeaching AI right from wrong
- Distillation and Synthetic DataModels teaching models
- Image ComprehensionTeaching machines to see
- Image GenerationDrawing pictures
- World ModelsSimulating reality
- AudioListening, speaking, and singing
- Hallucination and GroundingMaking stuff up
- Context ManagementGetting the right information
Want to know when more chapters are written?
I announce each new chapter on my blog, Messy Progress. Subscribe and you'll get an email when the next one is out.