liveBook · Manning

Gradient

As explained in How Large Language Models Work

A gradient is a vector of derivatives indicating how an objective function changes as its parameters change.

A gradient is a set of measurements showing the direction and amount to change a neural network’s parameters to reduce error. It connects a loss function, which scores how poorly the model performs, with gradient descent, the repeated process that adjusts the model. section 4.1 section 4.1.2

A training step follows this pattern:

  • Compare the model’s actual outputs with the expected outputs. section 4.1.2
  • Use the loss function to turn the error into a single numeric score. section 4.1
  • Use the gradient to make many parameters slightly better, then repeat the process. section 4.1.2

Rolling a ball downhill

Imagine a ball on a hilly landscape. The ball’s position represents a parameter value, while the hill’s height represents loss. The gradient indicates which direction and how far to move; repeated small moves aim for a valley with lower loss. The method can still settle in a local valley rather than the best one, and it offers no guarantee of a good solution. section 4.1.2

Figure 4.3 Inputs and labels (the known correct answers for each input) are used to tweak the neural network during gradient descent. A network is made of parameters that are altered a small amount each time gradient descent is applied. We eventually transform the network into something useful by applying gradient descent millions or billions of times.
figure

Follow the figure to see how inputs and known labels produce small parameter updates that gradually transform a neural network. section 4.1.2

How How Large Language Models Work covers it

How deep it goes
Defines direction and amount of parameter change, then traces repeated updates while stopping short of mathematical derivation.
Examples
Uses a ball rolling downhill, loss landscapes, training inputs, expected outputs, and parameter-update diagrams.
What it assumes
Introduces loss functions and parameter adjustment together, assuming no advanced machine-learning background.
What you can do after
Evaluate how gradients guide neural-network training and why repeated updates may still miss the best solution.
How it connects
Connects gradients with loss functions, gradient descent, neural networks, parameters, training data, and local minima.

Also explained in

Compare how 20 books explain gradient →

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.