An interactive explainer
How models learn
Machine learning tends to be explained twice over: once in metaphors that leave nothing behind, once in equations that assume you already agree. This is the third way.
The whole of it, in order
Every step below is one chapter of the series. Read down the left and you have built a model; read down the right and you are using one. Almost nothing on the right is doing any learning.
While it is learning
Repeated a few thousand times, on examples whose answers are known.
- Start with a machine full of knobs, set at random.01What a model is
- Turn every example into numbers it can actually take in.10Embeddings
- Keep a tenth of the examples back, and shuffle the rest into batches.05Batches
- Run one batch forward, layer by layer, and get an answer.06Neural network
- Compare the answers with the truth: one number, the loss.02The loss
- Ask how much that number moves when each knob moves.03The slope, and the gradient
- Multiply the sensitivities along each path through the machine.07The chain rule
- One pass backwards hands every knob its share of the blame.08Backpropagation
- Step every knob the other way to its slope, by a chosen amount.04Gradient descent
- Go back four steps, a few thousand times, and watch the curve.09The training loop
When it answers you
Once per piece of a word, on something it has never seen.
- Freeze the knobs. Nothing below this line ever moves them again.12Inference
- Turn what was asked into numbers, the same way as before.10Embeddings
- Read all of it, deciding which parts matter for what comes next.11Encoder and decoder
- One pass forward through the layers, and no pass back.06Neural network
- Out comes one piece of a word: the one it finds most likely.12Inference
- Add the piece to what was written, keep what was already read, go round.12Inference