Hi, I'm Sean Egan, a Navy information warfare officer and research scientist. I built this book for colleagues and friends who want to know how a language model works.
We'll follow the real equations and check some by hand. You need no math background. Part I builds the tools, starting with an arrow on a page. Then we follow text into the model, watch attention combine information, and see how training changes its numbers.
New to this? Start with Chapter 1 and take your time. Already know linear algebra? Start at Part II; the prerequisite links bring you back whenever you need a refresher. Watch the videos, drag the interactives, get a pencil. We'll work through this together.
How to read
| Tool | Use it to |
|---|---|
| Videos | Watch the idea move. |
| Interactives | Change one thing and see what follows. |
| Worked examples | Check the arithmetic with a pencil. |
Part I
The Math You Need
-
1Numbers That PointVectors: arrows, coordinates, and why direction is information6 min
2Measuring SimilarityThe dot product: one number that says how much two arrows agree7 min
3Grids That TransformMatrices: machines that turn one vector into another8 min
4Functions and Curvesf(x), exponentials and logarithms: the shapes the math is made of7 min
5Slopes and DescentDerivatives: which way is downhill, and how steep?8 min
6Chance and ChoiceProbability: spreading belief across possibilities7 min
Part II
Inside an LLM
-
7Text Becomes NumbersTokens: chopping language into countable pieces6 min
8Meaning as DirectionEmbeddings: every token becomes an arrow, and nearby arrows mean similar things6 min
9The Prediction GameOne job: guess the next token7 min
10AttentionHow words look at each other9 min
11The TransformerStacking attention into a thinking machine7 min
Part III
How It Learns
-
12Measuring WrongnessLoss: turning 'bad guess' into a single number7 min
13Rolling DownhillGradient descent: learning as finding low ground6 min
14Blame Flows BackwardBackpropagation: how millions of weights each learn their share6 min
15The Training RunTrillions of tokens, thousands of GPUs, one falling curve5 min
16From Parrot to PartnerFine-tuning, RLHF, and how a text predictor becomes an assistant6 min
17Why It Makes Things UpHallucination: no credit for silence, and recall is generation9 min
Part IV