← AI glossary

AI glossary · Basic · Language models

Gradient descent

Gradient descent is a way for AI models to learn by adjusting their parameters little by little in the direction that reduces how wrong they are (the loss). Most deep learning models today are trained with this method or variations of it.

About this term
Level
Basic · Technical terms you often meet in AI news
Added
2026-10-08
In plain words It is like walking down a mountain in thick fog, feeling only the slope under your feet and stepping one step at a time in the steepest downhill direction. But a real model's 'terrain' is a space with millions to billions of directions, far more complex than the mountain people picture.

How it works

First, the model makes a prediction with its current parameters, and a loss function measures how far the prediction is from the correct answer. Next, it computes how much and in which direction the loss changes when each parameter is changed slightly, that is, the gradient. In neural networks, this gradient is computed efficiently with backpropagation. The parameters are then adjusted slightly in the opposite direction of the gradient, where the loss decreases. This process is repeated countless times until the loss is small enough.

The gradient descent loopParameters → Predict; Predict → Compute loss; Compute loss → Compute gradient; Compute gradient → Adjust parameters slightly; Adjust parameters slightly → Parameters(Repeat)ParametersThe model's numbersPredictCompute lossDifference from thecorrect answerCompute gradientComputed bybackpropagationAdjust parametersslightlyMove by the learningrateRepeat
The gradient descent loop From left to right, it goes through prediction → loss computation → gradient computation, then adjusts the parameters and returns to the start, repeating the process.

Why it matters

Gradient descent is the key tool that makes it practical to train huge neural networks. Without people defining rules one by one, a model can tune its own parameters given just data and a loss function. LLM pretraining and fine-tuning also ultimately run on this principle. That is why it is considered one of the first concepts to learn to understand deep learning.

Things to know

The value that sets how big each step is is called the learning rate. If the learning rate is too large, training overshoots the minimum and becomes unstable; if it is too small, training becomes too slow. In practice, stochastic gradient descent (SGD), which computes gradients on small batches (mini-batches) instead of the full dataset, and improved methods such as Adam are mainly used. There is also no guarantee of finding the point with the lowest loss, and training often stops at a point that is good enough.

Example

When training an LLM used in a chatbot, the model predicts the next token in a sentence and computes the loss by comparing it with the actual next token. It repeats adjusting the parameters to reduce that loss over enormous amounts of text, and this 'method of adjusting' is an optimization algorithm from the gradient descent family. The same principle is used when a company fine-tunes a model on its own data.

Related terms