Availit World How AI really works, in your language

Lesson 6 of 4615 minFacts checked October 20, 2026

Learning is walking downhill

Every model, from a spam filter to DeepSeek, learns the same way: measure how wrong it is, find which way is less wrong, and take a small step. Then do it again, billions of times.

In this lesson you will

  • Say what a loss is, and why learning means making it smaller
  • Read a slope as “which way is downhill, and how steep”
  • Run gradient descent by hand, and see what the learning rate does
  • Recognise the words in training papers: gradient, learning rate, batch, optimizer, Adam, Muon
On this page
  1. Measuring how wrong: the loss
  2. Slopes: which way is downhill
  3. Gradient descent: step, check, repeat
  4. Billions of dials at once
  5. How it is done for real
  6. Remember
  7. Check yourself

Measuring how wrong: the loss

Before a model can improve, it needs a way to measure how badly it is doing. That measure is a single number called the loss. High loss means many mistakes; zero would mean none. All of learning comes down to one goal: change the weights so the loss goes down.

For a language model the idea is the same, with a different loss. At every position in its training text, the model gives a chance to each possible next token. The loss is high when it gave the token that really came next a low chance, and low when it saw it coming. You will meet this loss, called cross-entropy, in the next lesson.

Slopes: which way is downhill

The slope (mathematicians say derivative) answers one question: if I nudge this number up a tiny bit, does the loss go up or down, and by how much? A positive slope means “uphill to the right, so go left”. A negative slope means go right. A slope of zero means you are at the bottom of a valley (or the top of a hill).

The slope of a simple curve
loss(x) = x²

A simple valley with its lowest point at x = 0.

slope(x) = 2x

The rule for its slope. You do not need to work these out yourself: software does it for every weight automatically.

at x = 3: slope = 6

Positive and steep: the loss rises quickly to the right, so step left.

Gradient descent: step, check, repeat

Put the pieces together and you get the method that trains nearly every model in this course, gradient descent:

new x = x − learning rate × slope

Step against the slope. The learning rate sets how big the step is.

Five steps down loss(x) = x², learning rate 0.1, starting at x = 3
StepxSlope (2x)New x
1363 − 0.1 × 6 = 2.4
22.44.82.4 − 0.48 = 1.92
31.923.841.92 − 0.384 = 1.536
41.5363.0721.536 − 0.307 = 1.229
51.2292.4581.229 − 0.246 = 0.983

Each step shrinks x by a fifth. The steps get smaller by themselves as the slope flattens near the bottom.

Try itRoll the ball downhill

This curve has two valleys: a deep one on the left and a shallower one on the right. The ball starts at −3. Run it with each learning rate, then move the starting point to the right-hand side and run it again.

This interactive part needs JavaScript.

What you should have seen:

  • 0.01: far too timid. After 20 steps the ball has barely moved.
  • 0.05 and 0.2: it settles neatly in the deep valley; the bigger rate gets there in about 3 steps.
  • 0.6: too bold. It jumps right over the valley and bounces from side to side, never settling.
  • Starting on the right: it settles in the shallow valley, a local minimum, and stays there. From where it stands, every direction is uphill, so it cannot know a deeper valley exists.

A team is training a model. What does each loss curve tell you about the learning rate?

0 of 5 sorted
  • After a day of training the loss has hardly changed

    Answer: Too small

  • The loss jumps up and down and then shoots up to huge numbers

    Answer: Too big

  • The loss falls fast at first, then keeps falling slowly and smoothly

    Answer: About right

  • The loss falls, but so slowly that training would take years

    Answer: Too small

  • The loss suddenly spikes upward in the middle of training

    Answer: Too big

Billions of dials at once

The demo had one number to adjust. A real model has billions of weights, and the loss depends on all of them. The idea does not change: for every weight, work out its slope (how the loss would change if that one weight were nudged), and nudge every weight a little against its own slope, all at the same time.

All those slopes together form a vector with one entry per weight, called the gradient. That is where the name comes from: gradient descent means stepping down the gradient. You no longer have a curve but a landscape with billions of directions, and nobody can picture it, but the rule is the same simple one you just used.

How do you find billions of slopes quickly? With a clever bookkeeping method called backpropagation, which works out all of them in about twice the time it takes to run the model once. It has its own lesson in part 3.

Quick check

A weight’s slope is −4 and the learning rate is 0.01. What happens to the weight?

Show the answer

Answer: It goes up by 0.04 new = old − 0.01 × (−4) = old + 0.04. A negative slope means the loss falls as the weight rises, so the weight goes up.

How it is done for real

Training a large language model is gradient descent with a few practical additions you will see in every paper.

  • Batches. Computing the loss over all the training text before every step would take forever. Instead each step uses a small random sample, a batch (often millions of tokens for big models). The slope is a little noisy, but steps are cheap, so you can take many. This is stochastic gradient descent; stochastic means random.
  • Learning-rate schedules. Training starts with a gentle warm-up (tiny steps while things settle), then uses its largest rate, then lowers it slowly towards the end so the model settles into a good valley.
  • Optimizers. Smarter versions of the update rule. Momentum lets the steps build up speed like a ball rolling downhill. Adam (2014) and its variant AdamW give every weight its own step size, based on how its slopes have behaved; AdamW has been the standard for years.
  • Muon. A newer optimizer that adjusts each weight matrix as a whole rather than weight by weight. Moonshot’s 2025 study found it about twice as compute-efficient as AdamW. Kimi K2 and DeepSeek-V4 were trained with it.

Remember

  • The loss is one number measuring how wrong a model is. Learning means changing the weights to make it smaller.
  • A slope (derivative) says how the loss changes when you nudge a number. Step against it to go downhill.
  • Gradient descent: new weight = weight − learning rate × slope, repeated many times. All the slopes together are the gradient.
  • Too small a learning rate is slow; too big overshoots or blows up. You can also get stuck in a local minimum.
  • Real training uses random batches, a warm-up and decay schedule, and optimizers such as AdamW and Muon.

Words to know

Loss
One number that measures how wrong a model’s answers are. Training tries to make it smaller.
Slope (derivative)
How fast the loss changes when you nudge one number. Its sign tells you which way is downhill.
Gradient
The slopes for all the weights at once, as one long vector.
Gradient descent
Learning by repeatedly nudging every weight a little against its slope.
Learning rate
How big each step is. One of the most important settings in training.
Local minimum
A valley that is not the deepest one, but where every direction looks uphill.
Batch
The small random sample of training examples used for one step.
Optimizer
The exact rule for turning slopes into weight updates: plain gradient descent, momentum, AdamW, Muon.
Loss spike
A sudden jump in the loss during training, a sign that something went unstable.

Go to the source

This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.

Check yourself

5 questions. Tap the answer you think is right.

0 of 5 answered

What does training try to do to the loss?

Show the answer

Answer: Make it smaller The loss measures how wrong the model is, so training changes the weights to push it down.

At some point the slope of the loss is positive. Which way should the weight move?

Show the answer

Answer: Down A positive slope means the loss rises as the weight rises, so lowering the weight lowers the loss.

x = 2, the slope is 4 and the learning rate is 0.25. What is the new x?

Show the answer

Answer: 1 new x = 2 − 0.25 × 4 = 2 − 1 = 1.

The loss bounces up and down and then explodes. What is the most likely cause?

Show the answer

Answer: The learning rate is too big Steps that are too big jump over the valley and can make things worse with every step.

What is the gradient?

Show the answer

Answer: The slopes for all the weights together, as one vector The gradient collects every weight’s slope into one vector. Gradient descent steps against it.

Lesson complete

Answer every question above to complete this lesson.

Your progress is saved on this device only.

Next lessonProbability: how models express doubt
Previous lesson All lessons

Choose your language