How Does AI Learn From Mistakes? Loss, Backpropagation, and Gradient Descent Explained

How AI models learn from mistakes during training: what loss measures, how backpropagation traces errors, and how gradient descent adjusts weights.

An AI model learns from its mistakes in a narrow, mechanical sense. During training, the model makes a prediction, a formula scores how far off it was, a procedure called backpropagation works out how each of the model’s internal numbers contributed to the miss, and a method called gradient descent shifts those numbers a small amount in the direction that should shrink the error [1, 2]. Then the whole cycle runs again, across an enormous number of examples.

Nothing in that loop involves the model noticing or understanding an error. It is arithmetic at very large scale, and it normally finishes before anyone uses the model.

The previous guide explained what a model's parameters and weights are: the learned numbers that shape every output. This guide explains how those numbers get their values. The next guide, on training versus inference, picks up at the point where this loop is switched off.

TL;DR

  • Training is a loop. Guess, score the miss, work out what to change, change it slightly, repeat [2].
  • Loss is the score. One number measures the gap between outputs and correct answers; people decide how it is calculated [3].
  • Backpropagation finds the direction. It sends the error signal backward to compute how each parameter should move, but changes nothing itself [1].
  • Gradient descent takes the step. It moves the parameters a little way downhill on the loss, and the learning rate sets the size of that step [4, 5].
  • A lower training score is not the whole goal. Developers also check the model on examples it never trained on [6].
  • A corrected reply does not prove the model retrained. A correction can shape the next reply through conversation text without triggering an immediate weight update [7].

The Loop in Plain Words

Think of a routine, not a moment of insight: try, compare the result with the right answer, decide what to adjust, adjust a little, try again. Training follows that routine with numbers in place of judgment.

Training often begins with randomized parameter values, so early predictions are poor [2]. The landmark 1986 backpropagation paper started its networks from small random weights for a technical reason, too: to break the symmetry that would otherwise leave different parts of the network making identical changes [8].

Everyday stepTechnical nameWhat it produces
Make a guessForward passA prediction
Score the missLoss functionA single number, the loss
Trace responsibilityBackpropagationThe gradient: a direction of change for every parameter
Adjust a littleGradient descentSlightly updated parameters

The layers the error signal passes through are covered in how neural networks recognize patterns; here the focus is the numbers.

Step 1: Measure the Miss With a Loss Function

Training can only reduce an error it can measure. A loss function converts the gap between the model’s prediction and the correct value into one number, the loss, and the aim of training is to push that number as low as it will go [3].

What counts as a bad mistake is a human design decision. A squared-error loss punishes one large miss far more heavily than an absolute-error loss does, pulling the model toward unusual cases [3]. Neither is right for every task; the choice tells training which errors matter most.

For a large language model, the correct answer during pretraining is simply the next token in a passage of real text, so the text acts as its own answer key [9]. The loss at each position depends on how much probability the model gave to the token that actually came next: high probability means a small loss, and low probability means a large one [9].

The model does not experience the loss; training software calculates it and acts on it.

Step 2: Work Out Which Settings to Change With Backpropagation

Knowing the size of the miss is not enough. A large model has billions of parameters, and training needs to know which way each should move and how much each matters. Backpropagation is the standard way to work that out.

Backpropagation starts at the output, where the loss is calculated, and passes information about the error backward through the network toward the input, layer by layer [1, 8]. What comes out is the gradient: for every parameter, an indication of which direction of change would raise the loss and how sensitive the loss is to that parameter [4].

The step that makes this affordable is the chain rule from calculus. Each small piece of the network only has to know how its own output responds to its own inputs. When the backward signal reaches a piece, it combines that signal with its local information and sends a message to the pieces feeding into it: should their outputs go up or down, and how strongly, to improve the result [10]. No single part has to see the whole network.

One clarification prevents a common mix-up: backpropagation only computes the gradient, and a separate optimization method, such as stochastic gradient descent, uses it to change the weights [1]. Because the two always run together, Google’s machine-learning course simply calls backpropagation the most common training algorithm for neural networks, and notes that libraries perform it automatically [11].

In a 1986 Nature paper, David Rumelhart, Geoffrey Hinton and Ronald Williams showed that repeatedly adjusting connection weights to shrink the gap between actual and desired outputs could lead a network’s hidden units to represent useful features of a task [8]. The same authors wrote that their procedure, in its form at the time, was not a plausible account of how brains learn [8].

Step 3: Take a Small Step With Gradient Descent

The gradient points uphill, toward a larger loss. Gradient descent moves the parameters a small distance in the opposite direction, downhill, so the loss should come out a little lower [4]. The loss is then recalculated with the new values, and the cycle repeats until a chosen stopping condition is reached [2]. The technique long predates AI; a standard deep-learning textbook attributes gradient descent to the mathematician Cauchy in 1847 [4].

The size of each step is controlled by the learning rate, a training setting chosen before or during the run; adaptive optimizers can adjust the effective step size as training proceeds [5, 4, 12]. Settings of this kind are called hyperparameters, which separates them from the parameters that training calculates [5].

A shower with a single mixing handle gives a feel for the trade-off. If the water is too cold, you turn the handle toward hot. Tiny turns get there slowly; big turns overshoot into scalding, then overcorrect into cold. Training behaves in a similar way: a learning rate that is too small makes progress slow, while one that is too large can make the loss bounce around or even climb [5, 13]. Stanford’s deep-learning course notes call the step size one of the most important settings to tune [13].

The analogy breaks down in one respect: a model has millions or billions of handles, and each step adjusts all of them at once, each by its own amount.

An Illustrative Example: One Missed Delivery Estimate

This example is invented and stripped down so the steps are visible.

Picture a tiny model that estimates courier delivery times. It has two learned settings: minutes per kilometer and minutes per stop. For a trip of 10 kilometers with 3 stops, it predicts 25 minutes. The delivery actually takes 34.

  • Loss: the loss function turns the nine-minute shortfall into a single score.
  • Backpropagation: the gradient indicates that raising either setting would shrink this miss. In this simple setup, the per-kilometer setting gets the larger push, because it is multiplied by the larger number in this trip.
  • Gradient descent: both settings rise slightly, not all the way to make this one prediction perfect, because the next trip might hit unusual traffic.

Repeated over thousands of trips, small steps let the settings drift toward values that work reasonably well on average. Real models do this with far more settings and many layers, which is where backpropagation becomes essential [11].

Many Examples, Many Rounds: Batches and Epochs

Calculating the loss over an entire dataset before every update is impractical with millions of examples [5]. Instead, training usually draws a random batch of examples, averages their gradients and updates the parameters once per batch [5]. The direction estimated from a batch is a good approximation of the direction for the whole dataset, and it allows far more frequent updates [13]. One complete pass through all the training examples is an epoch, and many training setups run for several or many epochs [5].

The scale ranges widely. In the 1986 paper, a small network learning to detect mirror symmetry needed 1,425 sweeps through its 64 possible inputs [8]. A large language model, by contrast, predicts the next token at every position across vast amounts of text, and all of its weights are adjusted through backpropagation with gradient descent [9]. The largest GPT-3 model used batches of 3.2 million tokens [9].

Stochastic gradient descent and its variants are the most widely used optimization methods in deep learning [12]. Some variants, such as Adam, adapt the step size automatically as training proceeds [12].

Does Training Find the Perfect Settings?

Not necessarily. For a simple linear model, the loss surface is shaped like a bowl, so gradient descent reliably reaches the bottom [2]. Neural networks are different. Their loss surfaces contain many dips, and gradient descent carries no guarantee of finding the lowest one [8, 12]. In practice, deep-learning engineers settle for settings that make the loss very low rather than provably minimal [4].

The backward signal can also misbehave in deep networks: gradients reaching early layers can shrink toward zero, so those layers barely learn, or grow so large that training cannot settle [11].

A Lower Score Is Not the Whole Goal

Training lowers the loss on training examples, but what people want is good performance on new data, so training loss is only a stand-in [12]. Developers therefore hold back a validation set the model never trains on. When a model has plenty of capacity, its training error often keeps falling while its validation error starts to rise, a sign that it is fitting quirks of the training data rather than patterns that carry over [6].

That is overfitting. One common response, early stopping, keeps the parameters from the point where validation error was lowest [6]. A training loss of exactly zero can be a warning sign of overfitting rather than a triumph [2].

Is a Chatbot Learning When You Correct It?

Suppose you tell a chatbot its answer was wrong, and the next reply is better. It looks like learning from a mistake, but the better reply does not by itself show that the model retrained during the conversation. Text in a model’s input can change its next output without a weight update [7].

The GPT-3 researchers demonstrated this distinction by testing their model on tasks specified purely through text, with no gradient updates [7].

Lasting changes come from separate training runs, and some providers use conversations for them, depending on the product and settings. OpenAI says it may use content from ChatGPT’s plans for individuals to train its models unless users opt out, and that temporary chats are not used [14]. Anthropic says it uses chats from its consumer Claude plans to improve its models when users choose to allow it, and excludes incognito chats [15]. Google says that, depending on a user’s settings, Gemini Apps data is used to improve Google services, including Gemini models [16]. These policies were checked in November 2026 and can change [14, 15, 16].

When permitted conversation data is later used for model training, any resulting weight changes occur in that later training—not as an immediate update within the corrected conversation [9, 7, 14, 15, 16]. What Happens During Training—and What Happens When You Use the Model? Training vs. Inference explains the two stages in full.

What We Know, What We Don’t, and Where Experts Disagree

What We Know

The core loop of loss, backpropagation and gradient-based updates is standard and thoroughly documented in textbooks and university courses [1, 12], and large language models are pretrained with the same machinery [9].

What We Don’t Know

This guide stays general rather than attributing a single optimizer or learning-rate schedule to every model. It is also hard to know in advance whether a particular run will settle on settings that hold up on new data, which is why validation checks exist [6]. How specific model families are built and trained is the subject of BuildAIQ’s AI Models + Systems chapter.

What Experts Disagree About

Confidence: Expert Debate

Who deserves credit for backpropagation. The 1986 Nature paper stated the method, and the same authors’ work that year helped make it widely used, but textbook histories also credit earlier chain-rule work, Werbos’s 1981 proposal and independent rediscoveries by Yann LeCun and David Parker in 1985 [1]. The 1986 paper itself acknowledged Parker’s and LeCun’s versions [8].

How much imperfect stopping points matter. Gradient descent can settle on settings that are good but not the best available, yet the 1986 authors reported their networks very rarely got stuck in poor solutions, and a later textbook calls the many dips not necessarily a major problem [8, 12].

Practical Takeaways

  • Translate “the AI learned” into “training changed the model’s numbers to lower a score.” That keeps the mechanism and its limits in view.
  • Ask what the loss rewarded. A model is pushed toward whatever its loss function measures, which may differ from what users care about.
  • Be wary of training-set results. Look for performance on data the model did not train on.
  • Don’t assume a correction sticks. A chatbot’s improvement after you correct it normally comes from the conversation itself, so restate important corrections in a new chat.
  • Check your data settings if it matters to you. Whether chats feed future training depends on the provider and your settings [14, 15, 16].

Sources

  1. Deep Learning, Chapter 6: Deep Feedforward Networks. MIT Press / deeplearningbook.org, 2016, accessed 2026-11-10.
  2. Linear regression: Gradient descent (Machine Learning Crash Course). Google for Developers (Machine Learning Crash Course), 2026-02-03, accessed 2026-11-10.
  3. Linear regression: Loss (Machine Learning Crash Course). Google for Developers (Machine Learning Crash Course), 2026-01-05, accessed 2026-11-10.
  4. Deep Learning, Chapter 4: Numerical Computation. MIT Press / deeplearningbook.org, 2016, accessed 2026-11-10.
  5. Linear regression: Hyperparameters (Machine Learning Crash Course). Google for Developers (Machine Learning Crash Course), 2025-12-03, accessed 2026-11-10.
  6. Deep Learning, Chapter 7: Regularization for Deep Learning. MIT Press / deeplearningbook.org, 2016, accessed 2026-11-10.
  7. Language Models are Few-Shot Learners. arXiv, 2020-05-28, accessed 2026-11-10.
  8. Learning representations by back-propagating errors. Nature (author-hosted copy, University of Toronto), 1986-10-09, accessed 2026-11-10.
  9. Speech and Language Processing, Chapter 7: Transformers and Pretraining (draft). Stanford University (author-hosted textbook draft), 2026-08-19, accessed 2026-11-10.
  10. CS231n Deep Learning for Computer Vision (course notes: Backpropagation, intuitions). Stanford University (CS231n course notes), accessed 2026-11-10.
  11. Neural Networks: Training using backpropagation (Machine Learning Crash Course). Google for Developers (Machine Learning Crash Course), 2025-12-15, accessed 2026-11-10.
  12. Deep Learning, Chapter 8: Optimization for Training Deep Models. MIT Press / deeplearningbook.org, 2016, accessed 2026-11-10.
  13. CS231n Deep Learning for Computer Vision (course notes: Optimization, stochastic gradient descent). Stanford University (CS231n course notes), accessed 2026-11-10.
  14. How your data is used to improve model performance. OpenAI Help Center (Internet Archive capture of 2026-11-01), accessed 2026-11-10.
  15. Is my data used for model training?. Anthropic Privacy Center, 2026-03-16, accessed 2026-11-10.
  16. Gemini Apps Privacy Hub. Google (Gemini Apps Help), 2026-10-26, accessed 2026-11-10.