1 of 4

Your RightSignal

How LLMs work · 3 of 141 / 3

Backpropagation

The concept

How a network knows which of its billions of weights to blame

Backpropagation works out, for every weight, how much it contributed to the network's error. That number is the gradient: how much the loss (the error score) would change if you nudged the weight, and in which direction.

It uses the chain rule: if a weight changes the output, and the output changes the loss, the two effects multiply. For y = w·x with x = 2, w = 3 and target 4, the output is 6, the loss is 4, and the gradient is 8.

A positive 8 means "raising w makes things worse, quickly", so gradient descent, from the last lesson, lowers w. Backprop does the blaming; gradient descent does the nudging.

What it’s forWorks out how much one weight is to blame for the loss by chaining two simpler effects together.

∂L/∂w = ∂L/∂y · ∂y/∂w

L
the loss, a single number scoring how wrong the output is
w
one weight inside the network
y
the value that the weight directly affects, e.g. a neuron's output
∂a/∂b
how much a changes per tiny change in b (a derivative, or slope)

What it givesThe gradient for w: the size and direction of its effect on the error.

  1. y = w·x = 3·2 = 6, L = (y − t)² = (6 − 4)² = 4
  2. ∂L/∂y = 2(y − t) = 2·2 = 4, and ∂y/∂w = x = 2
  3. ∂L/∂w = 4 · 2 = 8