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.


Training is one prediction, repeated a few billion times

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.


Words become coordinates, and the coordinates move

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.

Grafik Vektoren in einem LLM
Quelle: https://www.youtube.com/watch?v=LPZh9BOjkQs&t=307s

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.


The transformer let the model read a sentence at once

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.


Human ratings turn a text completer into an assistant

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.


Where this leaves you

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.


Sources

Grouped by the section they support.

Opening

  • 3Blue1Brown (2024), Large Language Models explained briefly, video and lesson page, 20 November 2024, youtube.com, 3blue1brown.com. The main source for the whole article. Supports the model as a function that assigns a probability to every possible next word and repeats the step.
  • Brown et al. (2020), Language Models are Few-Shot Learners, NeurIPS 2020, arXiv:2005.14165. Supports GPT-3 as an autoregressive language model.

Training is one prediction, repeated a few billion times

  • 3Blue1Brown (2024). Supports the more than 2,600 years of non-stop reading for the GPT-3 training text, and training by hiding the last word and adjusting the parameters.
  • Rumelhart, Hinton and Williams (1986), Learning representations by back-propagating errors, Nature 323, 533–536, nature.com. Supports backpropagation as the procedure that adjusts the weights.

Words become coordinates, and the coordinates move

  • Mikolov, Yih and Zweig (2013), Linguistic Regularities in Continuous Space Word Representations, NAACL 2013, 746–751, aclanthology.org. Supports the example in which "King – Man + Woman" lands very close to "Queen". The example comes from static word vectors, before today's language models.
  • Peters et al. (2018), Deep contextualized word representations, NAACL 2018, arXiv:1802.05365. Supports word vectors that change with the surrounding sentence, as with bank.

The transformer let the model read a sentence at once

  • Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser and Polosukhin (2017), Attention Is All You Need, NeurIPS 2017, arXiv:1706.03762. Supports the transformer, self-attention and parallel processing of a sequence.
  • Geva, Schuster, Berant and Levy (2021), Transformer Feed-Forward Layers Are Key-Value Memories, EMNLP 2021, arXiv:2012.14913. Supports feedforward layers holding patterns from the training data. The Lisa example is an illustration.

Human ratings turn a text completer into an assistant

  • Ouyang et al. (2022), Training language models to follow instructions with human feedback, NeurIPS 2022, arXiv:2203.02155. Supports reinforcement learning from human feedback, in which people rank model answers and the model is tuned toward the preferred ones.

Where this leaves you

  • No external source. The view that these systems are not intelligent is the author's own.
The link has been copied!