25 November 2026 · 4 min readInteractive 3D
What is gradient descent? How AI learns downhill
Every modern AI model learns the same way: by taking small steps downhill on a landscape of mistakes. Drop a ball and watch.
Imagine standing on a hill in thick fog. You want to reach the bottom, but you can only feel the ground under your feet. The sensible plan: feel which way slopes down most steeply, take a step that way, and repeat. That plan is gradient descent.
The landscape is the mistake
For an AI model, the height of the landscape is its loss: a single number for how wrong its answers are. Each position on the floor is one setting of the model’s numbers. Low ground means a good model. Training means walking downhill.
The rule for each step
- Measure the slope where you are: this is the gradient.
- Step in the opposite direction, because the gradient points uphill.
- Make the step a fixed fraction of the slope: that fraction is the learning rate.
- Repeat until the ground is flat.
Real models have millions or billions of numbers, so their landscape has millions of directions, not two. The rule is exactly the same.
Set the step size to the maximum on the bowl. The ball overshoots and bounces from side to side. Too big a learning rate is one of the most common reasons training fails.
One step, worked out
Suppose the loss is L(w) = (w − 3)², smallest at w = 3. Start at w = 0 with a learning rate of 0.1. The slope is L′(w) = 2(w − 3).
- At w = 0 the slope is 2 × (0 − 3) = −6
- Step: w = 0 − 0.1 × (−6) = 0.6
- At w = 0.6 the slope is −4.8
- Next step: w = 0.6 + 0.48 = 1.08, closer to 3
Each step moves against the slope, and the steps shrink as the ground flattens near the bottom. After about 30 steps w is within 0.01 of 3.
With millions of numbers
A real model has millions or billions of weights, so the landscape has that many directions. The gradient is the list of slopes in every direction at once, and one step changes every weight together. The picture of a ball rolling downhill in 3D is the same idea with only two weights, so you can see it.
Stochastic gradient descent
Computing the exact slope over all the training data is slow, so models use a small random batch each step. The slope is a bit noisy, which sounds bad but helps: the noise can shake the ball out of shallow dips and saddle points.
Momentum lets the ball keep some of its previous speed, so it rolls through small bumps instead of stopping.
A real training loop
- Take a batch of examples
- Run them through the model and compute the loss
- Use backpropagation to find the gradient for every weight
- Subtract learning rate × gradient from each weight
- Repeat with the next batch
One pass through the whole dataset is called an epoch. Small models might train for tens of epochs; large language models often see most of their data only once or twice because there is so much of it.
Glossary
- Loss function: the number being made smaller.
- Gradient: the list of slopes for every weight.
- Learning rate: how big each step is.
- Epoch: one full pass through the training data.
Try these yourself
- Q1. L(w) = w², w = 2, rate 0.25: slope 4, new w = 2 − 1 = 1
- Q2. Same again: slope 2, new w = 0.5
- Q3. L(w) = (w + 1)², w = 0, rate 0.5: slope 2, new w = −1, the minimum in one step
- Q4. What happens with rate 1 on L(w) = w² from w = 1? It jumps to −1 and back for ever
Where it came from
The French mathematician Augustin-Louis Cauchy described the method in 1847 to solve equations in astronomy. More than a century later, it became the engine of machine learning when combined with backpropagation, an efficient way to compute every slope in a network.
In short
Find the slope, step a little the other way, repeat. With many weights the slope becomes the gradient, and the same rule trains almost every modern AI model.
Keep going
Questions people ask
What is gradient descent in simple words?
A way to find the lowest point of a function by repeatedly taking a small step downhill, in the direction where the function decreases fastest.
Why is it called the gradient?
The gradient is the list of slopes in every direction. Moving against it is the fastest way down.
Does gradient descent always find the best answer?
Not always: it can stop in a local minimum or slow down near a saddle point. In large neural networks this is usually good enough.