mej7.comHow AI Works

How do AI models learn?

Author: Mehdi Sadriu, independent educator. Last reviewed: 25 November 2026. How we check claims: methodology.

A model learns by seeing many examples: it guesses, measures how wrong it was (loss), and updates its parameters a little so the loss goes down. The chain-rule engine for those updates is backpropagation (Rumelhart, Hinton & Williams (1986)). Language models usually do this on the next-token task, without a human labelling every word.

In one paragraph. Training: θ ← θ − η ∇θ L, repeated. L is usually cross-entropy of the next token for language models.

Guess → loss → nudge. Teaching loop.
  1. Guess the next token
  2. Compare to the actual next token
  3. Move weights a little
  4. Repeat millions to billions of times

What is the puppy metaphor — and where does it break?

A treat when the guess is right is a metaphor for a loss that goes down. The model does not feel proud. It does not understand 'right' as you do. It changes numbers.

What is self-supervised learning here?

The 'label' is the next token in the text itself. That is why you can train on huge corpora without labelling each sentence by hand. The model still copies the corpus's gaps and biases.

What happens after pretraining?

Many assistants are then instruction-tuned and sometimes trained with human preference data (Ouyang et al. (2022)). That changes behaviour. It still does not install a truth oracle.

What is the math?

θ ← θ − η ∇θ L(θ)

η is the learning rate. ∇θ L comes from backpropagation through the network. You do not need to derive it to use the rest of this path.

Worked example

Target next token: 'meow'. The model put probability 0.05 on 'meow' and 0.4 on 'woof'. Cross-entropy is large. Gradients nudge embeddings and later layers so that next time, on similar context, 'meow' scores higher. One step is tiny; billions of steps add up.

Check your understanding

Five questions. Answers are in the disclosure under each item, so this page still works if JavaScript is off.

1. Loss is…
Show answer

B. Lower is better during training.

2. Backpropagation computes…
Show answer

B. Rumelhart, Hinton & Williams (1986).

3. Next-token training is called self-supervised because…
Show answer

B. Label comes from the input.

4. A tiny learning rate means…
Show answer

B. η in the update rule.

5. InstructGPT (Ouyang et al., 2022) is about…
Show answer

B. Post-training, not pretraining alone.

Further reading

  1. Learning Representations by Back-propagating Errors — Rumelhart, Hinton & Williams (1986). Nature.
  2. A Neural Probabilistic Language Model — Bengio et al. (2003). Journal of Machine Learning Research.
  3. Training Language Models to Follow Instructions with Human Feedback — Ouyang et al. (2022). NeurIPS.