liveBook · Manning

Gradient descent

As explained in How Large Language Models Work

Gradient descent is an iterative optimization algorithm that adjusts parameters in the direction that reduces a differentiable objective function.

Gradient descent is a repetitive training procedure, not human-like learning. It adjusts a neural network’s parameters so its predictions become less wrong according to a measurable loss function. section 4.0 section 4.1

The basic training loop works like this:

  • Use a loss function to assign one numeric score to how poorly the model performed. section 4.1
  • Compare the expected outputs with the network’s actual outputs. section 4.1.2
  • Calculate gradients that indicate the direction and amount for changing the parameters. section 4.1.2
  • Apply small updates repeatedly until the accumulated changes improve performance. section 4.1.2

Rolling a ball downhill

Imagine a ball on a hilly landscape. The ball’s position represents a parameter value, and the hill’s height represents loss. Each update nudges the ball downhill toward lower loss; many small nudges can transform the network into something useful. section 4.1.2

The procedure offers no guarantee of finding the best solution and can settle in a local minimum. For LLMs, it is repeated billions of times while training the network to predict the next token; that objective does not perfectly capture reasoning or other high-level goals. section 4.1.2 section 4.6

How How Large Language Models Work covers it

How deep it goes
Provides a high-level procedural explanation with analogies, while deliberately sparing mathematical derivation.
Examples
Uses a rolling-ball hill analogy and figures showing inputs, labels, parameter updates, global minima, and local minima.
What it assumes
Assumes familiarity with inputs, outputs, and neural-network parameters, while introducing loss functions as a prerequisite from the ground up.
What you can do after
Evaluate how iterative parameter updates train models and recognize why loss objectives do not guarantee optimal or broadly capable behavior.
How it connects
Connects gradient descent to loss functions, gradients, neural networks, machine learning, and next-token prediction.

Also explained in

Compare how 17 books explain gradient descent →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.