How a model learns: training, in plain words
Every LLM starts as random noise and is shaped by one repeated loop: guess, measure the error, nudge billions of dials. Here's how that training actually works, and why it costs a fortune.
In what an LLM is I said the model’s knowledge is “baked into billions of connection weights” during training, and that each wrong guess “nudges every weight a little”. That sentence hides the single most important loop in all of AI. Let us open it up, no maths degree required.
A brand-new model is random. Ask it to continue “the capital of France is” and it produces gibberish, because its dials are set to nothing in particular. Training is how those dials get tuned, and it’s the same simple loop run an astronomical number of times.
The training loop
Take an ordinary sentence from the training data, hide the next word, and play the guessing game the model will play forever after.
Guess
Show the model a stretch of real text with the next word hidden. It produces its scores for what comes next, exactly as it does when you use it.
Measure the error
Compare its guess to the word that actually came next in the real text. The gap between "what it predicted" and "the truth" is turned into a single number: the loss. Confident and right is a low loss; confident and wrong is a high one.
Assign blame
Work backwards through the network to figure out, for every single weight, which way it should move to make that error smaller. This is the clever bit, and it has a name: backpropagation.
Nudge every dial
Move each weight a tiny step in the helpful direction. Then grab the next piece of text and do the whole thing again, billions of times.
Drawn out, those four steps form a single cycle that feeds back on itself.
Why “nudge downhill” is the whole trick
The part that sounds like magic, “figure out which way to move billions of dials”, is really just rolling downhill. Picture the loss as a landscape: hills where the model is wrong, valleys where it is right. At any point, the maths can tell you which direction is downhill. So you take a small step that way, land somewhere slightly better, and look again.
No one chooses the weights. Nobody could; there are hundreds of billions of them. They’re discovered, one downhill step at a time, by a process that only ever asks “was that guess too high or too low, and which way fixes it?” Repeat that for long enough over enough text, and grammar, facts, and style settle into the dials on their own. Nobody programmed “Paris follows the capital of France”; it’s just where the landscape bottomed out.
Why it costs a fortune
The loop is simple. The scale is not. A modern model is trained on something like trillions of words, and every step touches every weight. That’s why training, not using, is the expensive part.
Training (once)
- Trillions of words, seen repeatedly
- Thousands of [GPUs](/blog/what-is-a-gpu/) for weeks or months
- Costs millions; done a handful of times
Using it (every day)
- Runs the finished weights forward only
- Can fit on a single card
- Cheap, and the part [engines like imp](/blog/how-imp-works-model-to-token/) optimise
This split is worth holding onto. The giant compute bills you hear about are mostly the one-time training. Once the dials are set, running the model is comparatively cheap, which is the entire reason a 30-billion-parameter model can serve answers on a card you can buy.
What you get at the end
The output of all this is a base model: a thing that is brilliant at continuing text, because that is the only game it ever played. Useful, but not yet the helpful assistant you talk to. If you typed a question into a raw base model, it might just continue with more questions. Turning a text-continuer into something that answers you takes a few more stages, and that’s the next post: pretraining, fine-tuning, and RLHF.