How a Neural Network Learns
Weights, errors and many small corrections: the basic way almost every modern AI system learns, explained without a single formula.
Almost every modern AI system, from photo recognition to chat assistants, learns in the same basic way. The idea fits in a few paragraphs, and once it is clear, much of what AI does — and gets wrong — becomes easier to understand.
Units, connections and weights
A neural network is a program built from many simple calculating units arranged in layers. Each unit receives numbers from the units before it, multiplies each incoming number by a weight — a setting that says how much that connection matters — adds the results together and passes a new number on. The first layer receives the input, such as the brightness of each pixel in an image. The last layer produces the answer, such as “cat” or “dog”.
The network’s knowledge is stored entirely in its weights. A large modern network has billions of them. Before training they are set at random, so the network’s answers are meaningless.
Learning from examples
Training starts with a large set of examples for which the right answer is known: images labelled with what they show, sentences followed by their next word. The network is shown an example, gives its answer, and a separate measure — often called the loss — scores how far that answer is from the correct one.
The aim of training is to make the loss as small as possible across all the examples. Nobody sets the weights by hand; they are adjusted automatically, a little at a time.
Finding which weights to blame
The hard part is deciding which of millions of weights to change, and in which direction. The standard answer is back-propagation, described in an influential 1986 paper in Nature. After each answer, the error is traced backwards through the network, layer by layer, to work out how much each weight contributed to it. Every weight is then nudged slightly in the direction that would have made the error smaller.
A helpful picture is a walker in fog trying to reach the bottom of a valley. They cannot see the whole landscape, but they can feel which way the ground slopes under their feet and take a small step downhill. Repeating this step millions of times, over millions of examples, gradually leads the network to weights that give good answers. This step-by-step downhill method is known as gradient descent.
Learning versus memorising
A network that has simply memorised its training examples is of little use. What matters is generalisation: giving good answers on examples it has never seen. When a network fits its training data too closely — including its accidents and noise — and then performs worse on new data, this is called over-fitting.
To detect it, part of the data is set aside and never used for training. The network’s performance on this held-out test set is a fairer estimate of how it will behave in practice — but only if the test data resemble the situations where the system will really be used.
What this explains
- Data shape behaviour. A network can only learn patterns present in its examples, including unwanted ones such as historical bias.
- Knowledge is spread out. No single weight holds a fact, which is one reason it is hard to explain why a network gave a particular answer.
- Unfamiliar inputs are risky. Performance measured on test data says little about situations unlike anything in training.
Language models are trained in essentially this way, with one particular task: predicting the next piece of text. How that produces a conversational assistant is explained in What a Large Language Model Actually Does.
Sources
- Rumelhart, D. E., Hinton, G. E., Williams, R. J. “Learning representations by back-propagating errors”. Nature, 323, 533–536, 1986. doi:10.1038/323533a0
- LeCun, Y., Bengio, Y., Hinton, G. “Deep learning”. Nature, 521, 436–444, 2015. doi:10.1038/nature14539
- National Institute of Standards and Technology. Artificial Intelligence Risk Management Framework (AI RMF 1.0), NIST AI 100-1, 2023.