E5 ELI5.LabVisual explainers
AI & FRONTIER / 30 MINELI5

Learning is nudging numbers

A language model is billions of numbers, and Parts 1 and 2 showed what it does with them. But nobody types those numbers in. They start out random, and a process called training nudges each one, a tiny bit at a time, until the model’s guesses get good. This part builds that process from a single knob, and then trains a small model right here in your browser.

It builds on Part 2’s idea of grading a guess, and on Part 5’s GPUs, which do the heavy lifting. Facts carry a tag: public means a published paper, model card or plain arithmetic, example means a made-up or rounded number used to show how something works, and not public means the company has not said. Go deeper boxes are optional.

data and examples the learned numbers (knobs) error and arithmetic the path downhill the wrong intuition, going wrong

The problem

Billions of numbers, and nobody wrote them

Part 1 showed each token’s list of numbers, and Part 2 showed the model turning numbers into scores for the next word. A large model has billions of these learned numbers. They are called weights or parameters. No engineer chose any of them. If you filled them with random values, the model would write random gibberish. Training is how random numbers become a model that writes.

BEFORE TRAINING “qz the vmple oo xkk banana gr” training AFTER TRAINING “The cat sat on the mat.” Same model, same number of knobs. Only their settings changed.

The analogy

Getting a shower to the right temperature

You step into a shower that is too cold. You do not calculate anything. You feel how wrong it is, turn the tap a little towards hot, feel again, and repeat. If it overshoots and gets too hot, you turn back a little. After a few nudges it is right. Training is exactly this loop, done by arithmetic.

Mapping it back: the tap is one learned number, the water temperature is the model’s answer, “too cold by this much” is the error, and the nudge is a small change to the number. Where the analogy breaks: a shower has one or two taps. A language model has billions, all affecting each other, and you get to nudge all of them at once. The rest of this part is about how that is possible.

The smallest model

A model with one knob

Start tiny. You have the distance and fare of ten taxi rides, and you want a model that guesses the fare from the distance. The simplest model is one number, the price per kilometre: fare = price × distance. That price is the model’s only knob. Turn it and watch how wrong the guesses are:

PRICE PER KM (THE KNOB)
average miss, squared (the loss)
how it is doing

Too low, and every guess falls short. Too high, and every guess overshoots. Somewhere in between, the misses are as small as they can be. Finding that spot by hand is easy with one knob. The question is how to find it with a rule a computer can follow, because that same rule will then work for a billion knobs.

Go deeper: the fares are made up

The ten rides are example data, made from a true price of about ₹2.6 per kilometre plus some random wobble, the way real fares wobble with traffic. A model never sees the true price; it only sees the rides.

Measuring wrongness

One number that says how wrong the model is

To improve, the model needs one number that says how bad it is right now. Take each ride’s miss (guess minus real fare), square it, and average them all. That is the loss. Part 2, chapter 19, used a different recipe for grading next-word guesses, but the job is the same: one number, lower is better.

Why square the miss?A miss of −5 and a miss of +5 should not cancel out to “perfect”. Squaring makes every miss count as bad.
Why not just the size?Squaring also makes big misses count much more than small ones: one miss of 10 costs as much as 100 misses of 1.
Why one number?With one number you can always ask the only question training needs: did that nudge make things better or worse?

The landscape

Every knob setting has a height: the loss

Try every possible price and plot the loss for each. You get a valley. Each position across is a setting of the knob; the height is how wrong that setting is. Training means walking to the bottom of the valley. The trouble is that the model cannot see the whole valley: working out the loss everywhere is far too expensive for a real model. It can only feel the ground where it is standing.

PRICE PER KM (WHERE YOU STAND)

Feeling the ground means one thing: which way does it slope, and how steeply? That is the slope, drawn as the purple line. Here is the key fact of all machine learning: the slope can be worked out exactly, with arithmetic, from where you stand. And it points uphill. So you step the other way.

Walking downhill

Step against the slope, again and again

The rule is short: work out the slope, take a step downhill whose size is the slope times a small number called the learning rate, and repeat. Steep ground gives a big step; nearly flat ground near the bottom gives a tiny one. Start at a bad guess and watch the steps. Then try different learning rates:

LEARNING RATE
0steps taken
current price per km
current loss

A tiny learning rate creeps and wastes time. A good one gets close in a handful of steps. Too big, and each step jumps past the bottom and lands higher up the other side; far too big, and it climbs out of the valley altogether. This walk is called gradient descent (gradient is another word for slope), and picking the learning rate is one of the most important choices in training any model.

Go deeper: the slope, as a formula

With one knob w, the loss is the average of (w × distance − fare)². Its slope is the average of 2 × (w × distance − fare) × distance. Each ride pushes w up if it was under-charged and down if it was over-charged, more strongly for long rides. Every step is just w ← w − learning rate × slope.

Two knobs

Two knobs make a bowl

Real taxi fares also have a fixed starting charge. Now the model has two knobs: fare = start charge + price × distance. Every pair of settings has a loss, so the landscape is a bowl seen from above, with darker meaning lower. The slope now has two parts, one per knob, and together they point straight uphill. Click anywhere to start there, then walk:

LEARNING RATE

Notice the valley is a long, narrow trench, not a round bowl. The first step drops into the trench, then the walk creeps along its nearly flat floor. Raise the learning rate to hurry it and the steps start bouncing between the trench walls instead. Real loss landscapes are full of trenches like this, which is why training uses cleverer step rules than the plain one here (see Go deeper).

Go deeper: better ways to step

Momentum. Keep part of the previous step, like a ball rolling downhill. Bounces across the trench cancel out, and progress along it builds up speed.

Adam. The most common rule for language models public. It keeps a running average of each knob’s slope and of its size, and gives every knob its own step size, so steep knobs take careful steps and flat ones take bigger ones.

Schedules. Training usually starts with a small learning rate, warms up, then slowly lowers it towards the end so the final steps settle gently into the bottom.

Scaling up

A billion knobs: same walk, no pictures

One knob made a curve. Two made a bowl. A model with 8 billion knobs makes a landscape with 8 billion directions, which nobody can picture. But the rule does not care. Work out the slope for every knob, nudge every knob a little against its own slope, and repeat. Imagine a hiker in thick fog on a mountain range with a billion directions, who can only feel the ground under their feet. They keep stepping downhill, millions of times.

Two things are surprising. First, that this works at all in so many directions, rather than getting stuck in some small dip. With billions of directions there is nearly always some direction that still leads down. Second, that the slope for every one of billions of knobs can be worked out at once, for only about twice the cost of the guess itself. That is the next chapter.

Sharing the blame

Work backwards to find each knob’s share of the blame

A model is a chain: the input goes through one step, then another, then another, each with its own knobs, and out comes a guess. When the guess is wrong, each knob deserves some share of the blame. The trick is to work backwards from the error. The last step’s knobs get blamed first. Then that blame is passed back to the step before, scaled by how much that step affected the next, and so on, all the way to the start.

Think of a relay team that lost a race: you look at the final runner first, then pass the question back down the line, asking each runner how much they changed the result. This backwards pass is called backpropagation, published in its modern form in 1986 public. It hands every knob its exact slope, all in one sweep.

Go deeper: the rule behind it

Each step’s effect on the final error is the product of the effects of every step after it. If nudging knob A by a little changes step 1’s output by 3 times as much, and that changes the guess by 2 times as much, then nudging A changes the guess by 3 × 2 = 6 times as much. Multiplying these effects backwards along the chain is called the chain rule, from calculus. Backpropagation is the chain rule, done efficiently for every knob at once.

The price of learning

Learning costs three times as much as guessing

Part 3, chapter 18, showed that one guess (one token) costs about 2 sums per learned number. Training needs the guess, then the backwards pass, which costs about twice as much again. So training on one token costs about 6 sums per learned number public.

the guess2 sums per number sharing the blame, backwardsabout 4 sums per number = 6 sumsper number, per token Training is about three times the arithmetic of using the model, for every token of text read. Plus the nudge itself, which is cheap: one small update per knob per step.

Batches

Don’t read the whole library before each step

The true slope would use every example in the training data. For a language model that is trillions of tokens, so one step would take months. Instead, each step looks at a random handful, called a batch, and uses its slope as an estimate of the real one. The estimate is a bit noisy, but steps become millions of times cheaper, so the walk wobbles its way down far faster.

Language models typically use batches of a few million tokens per step public. The wobble even helps a little: it shakes the walk out of small, shallow dips that a perfectly smooth walk could settle into.

The language version

Every word in every sentence is a quiz

For a language model, the guess is Part 2’s next-token guess, and the loss is Part 2’s penalty: how small a chance the model gave the token that really came next. The beauty is that any text at all is training data, with no labelling needed. Every position in a sentence is a free quiz: hide the next token, let the model guess, check the answer.

One sentence of seven tokens is six quizzes. A trillion tokens of books, websites and code is about a trillion quizzes, and after each batch every knob is nudged to do a little better next time. Nobody teaches the model grammar, facts or reasoning. Whatever helps it pass the quizzes is what its numbers drift towards.

Try it

Train a 729-knob model, right here

This is a real language model, just a very small one. It guesses the next letter from the current letter only, using a grid of 27 × 27 = 729 knobs (26 letters plus space). It starts with random knobs and learns from this page’s own text, a few thousand letters, using exactly the walk from chapter 6: compute the loss, find every knob’s slope, nudge, repeat.

Average penalty while training (lower is better)
After the letter “t”, it now expects
It writes, letter by letter (rolling the die from Part 2)
0training steps
average penalty (Part 2, chapter 19)
729knobs, versus billions in a real model

At first it writes noise, and after “t” every letter is about equally likely. After a hundred or so steps it has learned, on its own, that “h” often follows “t”, that “q” is followed by “u”, and roughly how long words are. It cannot learn more than that, because it only sees one letter back. A real model sees thousands of tokens back and has billions of knobs, but the walk is the same.

Go deeper: what exactly is being trained

Each of the 27 rows of knobs holds a score for every possible next letter, given the current letter. Scores become chances through softmax (Part 2, chapter 4). The loss is the average penalty for the letters that really came next. The slope for each knob is simply (chance the model gave − 1 if that letter really came next, else 0), averaged over every place the current letter appears, so each row learns at its own pace. Each step nudges every knob against its slope.

Learning versus memorising

Getting the quiz right is not the same as understanding

A model with enough knobs can memorise its training data: give perfect answers on text it has seen, and poor ones on anything new. That is called overfitting, like a student who memorises last year’s exam answers. To catch it, some text is held back and never trained on. If the loss on that held-back text stops falling while the training loss keeps dropping, the model has started memorising.

Large language models are trained on so much text that they see most of it only about once, so classic overfitting is less of a problem for them. But they still memorise passages that appear many times, such as famous quotes or common code, which is a known issue public.

The gotcha

It does not learn while you chat

Because a chatbot remembers what you said earlier in the conversation, it is natural to think it is learning from you. It is not. Once training ends, the numbers are frozen. Your chat only adds text to what the model reads (Part 2, chapter 15). Close the chat and that text is gone from the model’s view; its numbers were never touched.

TRAINING · months, beforehand reads trillions of tokens nudges every number, millions of times CHATTING · afterwards numbers are frozen, read-only your words are input, not lessons Wrong intuition: “it is learning from our conversation”. Companies may use some conversations to train future models, under their own policies, but that is a separate, later training run.

This is also why a model does not know about events after its training data was collected, unless a tool like web search hands it fresh text to read (part 16).

How big

The bill for training a large model

Six sums per number per token, times the number of knobs, times the number of tokens read. Pick a model and see what it takes:

LEARNED NUMBERS
TOKENS OF TEXT TRAINED ON
H100 GPUS WORKING TOGETHER
sums in total
of training, at 40% of each GPU’s peak example
of electricity for the GPUs alone, at 700 W each

For a real check, Meta trained Llama 3’s 405-billion-number model on about 15 trillion tokens using up to 16,384 H100 GPUs, and reported about 38 trillion trillion sums in total public, matching the rule above. That is why training frontier models costs tens to hundreds of millions of dollars, and why it happens rarely, while using them happens billions of times a day.

Many GPUs

Thousands of GPUs, one walk downhill

No single GPU could do this in a lifetime, so training is split. The simplest split: give each GPU its own share of the batch, let each work out the slopes from its share, then average all the slopes together so every GPU takes the same step. The model stays identical everywhere; only the reading is shared out.

Averaging means every GPU must talk to every other GPU after every step, which is why AI data centres need very fast connections between chips. For the largest models even one copy is too big for one GPU, so the model itself is split up as well. That is part 12, “Many chips as one”.

The whole picture

Guess, grade, share the blame, nudge, repeat

repeat for millions of batches

Training is a walk downhill in fog. The model guesses, the loss says how wrong it was, backpropagation hands every number its share of the blame, and each number takes a tiny step to be a little less wrong. Do that millions of times over trillions of quizzes and random numbers become a model that writes. What exactly those numbers compute, inside, is the subject of part 7 (attention) and part 9 (the transformer).

Field guide

What you notice from the outside

“Knowledge cutoff” datesThe model only knows text it was trained on, collected before training began.chapter 15
It forgets you after a chatChatting never changes its numbers; earlier messages are just text it reads.chapter 15
Training runs cost millionsSix sums per number per token, times trillions of tokens, on thousands of GPUs.chapters 10, 16
New model versions, not updatesLearning means a new training run that produces a new set of numbers.chapters 6, 15
It can recite famous textPassages seen many times in training get memorised.chapter 14
“Parameters” in model namesThe count of knobs, as in an “8B” model with 8 billion.chapter 1

Field guide

The words, in plain language

Weights, parametersThe learned numbers: the model’s knobs.
TrainingNudging the numbers, step by step, to make the guesses better.
LossOne number saying how wrong the model is right now. Lower is better.
Slope, gradientWhich way, and how steeply, the loss changes as a knob turns.
Gradient descentRepeatedly stepping each knob against its slope: walking downhill.
Learning rateHow big each step is. Too small is slow, too big overshoots.
BackpropagationWorking backwards from the error to give every knob its slope.
BatchThe handful of examples used for one step.
OverfittingMemorising the training data instead of learning patterns.
Held-out dataText kept out of training, used to check for memorising.
AdamA popular step rule that gives every knob its own step size.
Pre-trainingThe first, huge training run on next-token quizzes. Part 13 covers what comes after.

Field guide

What is known and what is not

PublicGradient descent, backpropagation (1986), Adam, the 6-sums-per-number-per-token rule, batch sizes in published papers, and Llama 3’s training size and total sums from Meta’s report.papers, model cards
ExampleThe taxi rides, the learning rates in the demos, the overfitting curves, and the 40% GPU efficiency in the calculator.made up to show the idea
Not publicHow Claude models are trained in detail: their size, data, batch sizes, step rules and compute.Anthropic has not said
AN IDEA TO TAKE WITH YOU
Nobody writes a model’s numbers. They start random and are nudged downhill, a tiny step at a time, until the guesses get good.