Gradient
In machine learning, a gradient is the set of numbers saying how a model's error would change if each of its parameters were nudged, which training uses to decide how to adjust them.
In mathematics, the gradient of a function is a vector of partial derivatives: one number for each input, saying how fast the output changes as that input changes. Taken together, the gradient points in the direction in which the function increases most steeply, and its size says how steep that increase is. Picture standing on a hillside. The gradient is an arrow along the ground pointing straight uphill, and the steeper the slope, the longer the arrow.
In machine learning the hill is the model's error, called the loss, and the ground is made of the model's parameters. The gradient of the loss has one entry for every parameter, so for a large language model it has billions of entries. Each one answers a simple question: if this parameter went up slightly, would the error rise or fall, and by how much? A technique called backpropagation computes all of these numbers efficiently in a single backward pass through the network.
Training then moves each parameter a small step in the opposite direction to the gradient, downhill, which is gradient descent. If raising one weight would increase the error, the training step lowers it; if raising it would reduce the error, the step raises it. Repeated over many batches of data, these small corrections are how a model learns.
Gradients also explain some practical problems. If they become extremely large, a single update can throw a model off course, so developers cap them: Meta's Llama 2 training in 2023 used gradient clipping at a value of 1.0. Gradients can also carry information about the data they came from, which matters for privacy. A 2019 paper, Deep Leakage from Gradients, showed that training images and text could be reconstructed from gradients shared between machines.
When AI news mentions gradients, it is usually describing the machinery of training rather than anything a user sees. The word signals that a model's parameters are being adjusted in response to its errors.
It is a list of numbers, one per model parameter, showing how the model's error would change if each parameter were increased slightly. Training uses the gradient to work out which way to adjust every parameter to reduce the error. The gradient points in the direction in which the error increases fastest. Training wants the error to fall, so it steps the other way. That is why the method is called gradient descent. With backpropagation. After the network makes predictions on a batch of data and the error is measured, backpropagation works backwards through the layers, using the chain rule of calculus to find each parameter's contribution to the error. It is a safeguard that caps the size of the gradient before an update is applied, so one unusual batch cannot produce a huge, destabilising change. Meta's Llama 2 models, for example, were trained with gradient clipping at 1.0.Common questions
What is a gradient in machine learning?
Why does training move against the gradient?
How are gradients calculated for a neural network?
What is gradient clipping?
Search for "gradient machine learning", "gradient of the loss function" or "backpropagation gradients" to learn more. Maths references explain the gradient itself; Google's machine learning glossary and Crash Course and the documentation for frameworks such as PyTorch explain how it is used in training. Introductory videos that visualise loss surfaces can help, but check their claims against a written reference.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.