Explainer
How a neural network actually works
No brains and no magic, just adjustable numbers. An explanation without the mathematics, but without simplifying it into being wrong.

Contents (6)
The neural network is the part of AI that most often stays a black box. People say it "mimics the brain" and "learns by itself", and the explanation stops there. Neither sentence is wrong, but neither tells you anything.
In reality a neural network is simpler than it sounds. It is a formula with an enormous number of adjustable numbers in it. Everything else is repetition.
Start with one decision
Suppose you have one thing to decide: do I take an umbrella.
You have two pieces of information. The sky is cloudy, say 0.8 on a scale from zero to one. The rain forecast is 0.9.
Neither piece matters equally. The forecast tells you more than the cloud does. So give them weights: 0.4 for cloud and 0.6 for the forecast.
Now do the sum:
0.8 × 0.4 = 0.32
0.9 × 0.6 = 0.54
----
total 0.86
Agree a threshold as well: if the result is above 0.5, take the umbrella. 0.86 is above it, so the umbrella comes.
That is exactly what one artificial neuron does. It receives numbers, multiplies each by its own weight, adds them up, and decides on the strength of the result whether to pass a signal on.
Nothing more mysterious than that happens inside a single neuron.
Where do the weights come from?
Above, I made 0.4 and 0.6 up. This is what the whole of machine learning is about: the weights are not invented but found from examples.
Suppose you have a thousand days, and for each you know the weather and whether the person got wet. The network can start with completely random weights and see how it goes:
- It makes a guess: "no umbrella needed".
- Compare that with what actually happened: it poured.
- The guess was wrong, and the size of the miss is calculated. That number is called the error.
- Work out how much each weight contributed to the error.
- Nudge the weights a fraction in the direction that would have produced a better answer.
Then the same thing again with the next day. And the next. And a million more times.
Each individual adjustment is deliberately small. If the network changed its weights drastically after every error, it would swing from side to side and never settle. The size of the step is called the learning rate, and it is one of the most consequential settings in the whole of training.
Walking downhill in fog
There is a useful image for this. Imagine standing on a hillside in thick fog, and your task is to get down to the valley. You cannot see where to go, but you can feel with your foot which way the ground slopes. You take a small step that way. Then you feel again.
That is how a neural network is trained. "Height" is the error, and the valley is the combination of weights at which the network is wrong as rarely as possible. The network never sees the whole picture once. It just takes millions of small steps downhill.
Two things follow, and they explain a lot later on:
- Training is slow and expensive, because a vast number of steps is needed.
- The result is not the only possible one. Another valley, with slightly different weights, might have worked just as well.
One neuron is not enough
The umbrella decision was easy, because it had two inputs and a direct connection to the outcome. Most real tasks are not like that.
So neurons are placed side by side and one after another. Neurons side by side look at the same input from different angles. Successive layers take the previous layer's results as their input.
Image recognition is the clearest example. When a photograph is shown to the network:
- The first layers respond to very coarse things: where it is light, where it is dark, where the boundary between them runs.
- The next layers combine those boundaries into corners and curves.
- The ones after that recognise an eye, a nose or a wheel out of the corners and curves.
- The last layers make the decision: a face or a car.
The important part is that nobody had to tell the network what an eye is. The layers end up recognising things like that because it is the most efficient way to reduce the error. The number of layers is where the name deep learning comes from.
One technical detail is worth mentioning, because without it the whole structure would collapse: after each layer, a small non-linear kink is applied to the result: for example, negative values are clipped to zero. Without that kink, a hundred-layer network would collapse mathematically into a single multiplication and be of no use whatsoever. The kink is called the activation function.
The network does not memorise the examples
This is the part most often misunderstood.
After training, those thousand days of weather data are not sitting anywhere as a separate table. What is left is a set of numbers, the weights, adjusted so that the same formula produces sensible answers for days it has never seen.
That does not mean the material leaves no traces. Individual examples can be stored in the weights precisely enough that the model reproduces them almost word for word, and researchers have got large language models to output entire passages from their training data. So the network is not a search engine, but it is not clean of its material either.
This is exactly what makes a neural network useful. It does not look an answer up in a table; it computes it.
And this is exactly where neural networks' best-known problem comes from. A model does not keep a citation for what it learned and cannot reliably say where a piece of information came from. A source it offers you when asked may be invented outright.
The same thing explains hallucination. The model always produces what the computation says is the most plausible continuation. Plausible and true are usually the same thing, but not always. When they differ, the model chooses plausible and does not notice having done so.
Cramming is not the same as learning
A neural network can also fail in the other direction. If it has a great many weights and few training examples, it can effectively learn the examples by heart: it answers perfectly on everything it has seen and badly on everything else.
This is called overfitting. It is the same phenomenon as a student who crammed last year's exam questions but cannot answer one that has been reworded.
That is why a model's ability to generalise must not be judged on the training data alone. Some examples are set aside and brought out only at the end. Only those show whether the network learned the thing or just the examples.
How do you get from this to a language model?
The same structure, a bigger scale, and one additional invention.
First, text is turned into numbers. A neural network can only handle numbers, so text is chopped into small pieces called tokens, and each piece is represented by a set of numbers. Those numbers are not supplied by hand: the network adjusts them during training too, until words close in meaning end up close together.
The task is the same throughout. The language model is shown text with the continuation missing, and it has to guess the next piece. The guess is compared with the real continuation, the error is calculated, the weights are adjusted. Exactly the same loop as the umbrella, only with astronomically more repetitions.
The additional invention is attention. Older networks read text one word at a time and had forgotten the beginning by the end. The current structure, the transformer, lets the network weigh, as it processes each word, which other words are relevant to it. When a sentence says "it would not fit in the bag because it was too big", the network learns that the second "it" refers to the object and not to the bag.
One clarification is needed here. A model that produces text does not see all the words but only the preceding ones: future words are masked during training, because otherwise the model would see the very answer it is supposed to predict. In tasks like translation and classification the whole text can be visible at once. This invention of attention is widely regarded as the single biggest reason language models improved so fast in the 2020s.
You can try this yourself: there is a small language model on this site, built from this site's own texts, which shows the most likely continuations of a word.
The end result is not a sentence but a probability distribution: a list of all the possible next pieces and their probabilities. The system picks one, appends it to the text and starts again. The answer is produced one piece at a time, and the model does not know when a sentence begins how it will end.
What to take away
| The claim | How it actually is |
|---|---|
| A neural network mimics the brain | The name comes from a loose analogy. The structure is a formula, not a nerve cell. |
| The model knows things | The model is tuned to produce the most likely continuation. Knowing is a by-product of that. |
| The model remembers what it was told | The weights do not change during use. A conversation is forgotten unless it is stored separately. |
| The model knows where the information came from | The examples are not kept. The source has to be retrieved separately. |
| A bigger model is always better | More weights help only if there is correspondingly more data and compute. Otherwise it crams. |
The single most important insight is this: there is no point in the mechanism where understanding happens. There are only numbers, adjusted so that the output is useful. Whether adjusting numbers in sufficiently complicated ways amounts at some point to a kind of understanding is an open dispute that this article takes no position on. What can be said with certainty is that understanding has not been built in as a separate part.
That does not make neural networks lesser. It tells you what you can rely on them for and what you cannot, and that is the only question that matters in practice.
Sources
- Attention Is All You Need · Vaswani et al., arXivthe original transformer paper
- Extracting Training Data from Large Language Models · Carlini et al., arXivtraining material reappearing in a model's output
- Learning representations by back-propagating errors · Rumelhart, Hinton and Williams, Naturebackpropagation
Harri Salomaa · Forty years in software, twenty of them in the United States and Germany: from collecting process data and analysing network data to immersive computing, and most recently AI.