How large language models work
A language model puts a probability on every possible next word, picks one, and runs the calculation again. Everything else follows from that loop.
A language model puts a probability on every possible next word, picks one, and runs the calculation again. Everything else follows from that loop.
This piece first appeared in German. The English version is a rewrite rather than a line-by-line translation, and the German original stays online in the archive: Wie funktionieren eigentlich Large Language Models?.
Type half a sentence into a chatbot and only one thing actually happens. The model puts a probability on every word that could come next, picks one, adds it to the text, then runs the whole calculation again from the top. A paragraph of fluent prose is that loop a few hundred times over, and nothing in it resembles understanding.
What comes back is a statistical estimate of what usually follows. Worth knowing, before you hand one of these systems a question whose answer you cannot check for yourself.
Before a model can estimate anything, someone has to show it an enormous amount of text: books, articles, websites, forum posts. The scale is the part that resists intuition. Reading without a single pause, you would need more than 2,600 years to get through what went into the training of GPT-3.
What happens to all that text is modest by comparison. You show the model an example, hide the final word and let it guess what belongs there. An algorithm called backpropagation then nudges the internal parameters, the weights, so that the right answer becomes a little more likely next time. Run that cycle a few billion times and the patterns settle into the weights, which is why a model can respond plausibly to a sentence nobody has ever written before.
A machine has no way of handling words, only numbers, so every word gets a vector: a list of numbers whose positions stand for dimensions of meaning and context. Those numbers are not a fixed definition, though. They shift with the sentence around them, which is why bank in a paragraph about interest rates gets described by different numbers than bank in a paragraph about a river.

That movement is what lets a model do more than grammar. Distances between vectors measure how close two meanings sit, and relations between them carry semantic structure. That is where the familiar example comes from: king minus man plus woman landing somewhere near queen. And because the numbers travel with the sentence, a model picks up implication instead of only syntax.
Underneath all of it, then, a language model is a comparison engine, checking continuously which word and sentence patterns have turned up in similar contexts before.
Progress arrived in 2017 with the transformer architecture out of Google. Earlier models worked through a text word by word, holding what came before in a kind of running memory. A transformer takes the whole sequence in parallel, every word and every vector at the same time.
Two components carry that. Self-attention lets the model register which words in a sentence condition each other. In Lisa put her book down, attention is what settles whether her attaches to Lisa or to somebody else in the paragraph, and the answer changes every vector downstream. Feedforward networks then work through whatever attention has surfaced and hold on to the patterns it found. Stack enough layers of both and the representations get genuinely complex, carrying syntax, meaning and even style.
Pretraining optimizes for one thing, finishing text, so making an assistant out of that takes a second phase: reinforcement learning from human feedback, or RLHF. People rate the model's answers on whether they are useful, neutral or problematic, and the model learns to prefer the kind of answer that scored well. That is the point where a system predicting words starts behaving like a system answering questions, even though the underlying operation has not changed.
A large language model is a high-dimensional probability machine: it compares familiar word structures, estimates which continuation is statistically plausible, and produces something that reads as sense. The apparent intelligence comes out of the precision and the depth of that pattern recognition, at a scale the human brain has real trouble picturing.
My own view is that these systems are not intelligent at all. They are an enormous database, and the skill lies in querying it deliberately. That has a practical edge — supplying the judgment is still your job, and the question worth asking is which of your own questions an estimate can actually answer.
Grouped by the section they support.
Opening
Training is one prediction, repeated a few billion times
Words become coordinates, and the coordinates move
The transformer let the model read a sentence at once
Human ratings turn a text completer into an assistant
Where this leaves you
Your link has expired. Please request a new one.
Your link has expired. Please request a new one.
Your link has expired. Please request a new one.
Great! You've successfully signed up.
Great! You've successfully signed up.
Welcome back! You've successfully signed in.
Success! You now have access to additional content.