Raphael Friedmann
← Understanding AI

What an LLM is, and how it produces words

A jargon-free explanation of large language models: what they are, why they're basically a very good autocomplete, and how they write one word at a time.

You type a question into ChatGPT or Claude, and a fluent answer appears. Behind that is a thing called an LLM. This post explains what an LLM is; no background needed.

That’s the whole thing. It’s not a search engine and it’s not a database of facts. It’s a pattern machine for language.

The core mechanism: guess the next word

Everything an LLM does comes down to a single, simple skill: given some text, guess what comes next.

Take a half-finished sentence. The model looks at it and scores every word it knows for how likely it is to come next.

"The cat sat on the ___" - the model's top guesses for the next word
mat62%floor14%couch9%table6%roof4%
The model scores every possible next word, then picks one. Numbers here are illustrative, but this guess-and-pick is exactly what happens, every single word.

It doesn’t know the answer is “mat”. It estimates that “mat” is the most likely continuation, and usually goes with it. Same as the autocomplete on your phone, except trained on a large slice of everything ever written, so its guesses are very good.

One word at a time, in a loop

One guess only gives you one word. To write a whole answer, the model takes the text including the word it just added and guesses again. And again. A sentence grows like this:

The cat
The cat sat
The cat sat on
The cat sat on the
The cat sat on the mat.

Each line is one trip through the guesser. The new word gets added, the whole thing goes back in, and it predicts the next one. That loop, running very fast, is the answer typing itself out on your screen. There’s no grand plan for the sentence; it’s built one believable step at a time.

Under the hood: a neural network

So far the guesser has been a black box. This section looks inside. The thing doing the guessing is a neural network.

Here is the shape of it:

A neural network: numbers in, patterns in the middle, next-word scores out
each line = one weightyour text(as numbers)hidden layerswhere the patterns livenext-wordscoressignal flows left to right →
Each dot is a simple unit; each line carries a weight. Real models have far more units and dozens to hundreds of layers, but the shape is exactly this.

Read it left to right. Your text, as numbers, enters on the left and flows through layer after layer. At each step, every unit adds up the signals reaching it, each one turned up or down by its connection’s weight, and passes the result on. Out the right side come the scores for the next word, the same ones you saw in the bar chart earlier.

The “deep” in “deep learning” just means many layers stacked up. Small networks have a few; the big language models have dozens to well over a hundred. And those weights, the dial on every connection, are exactly the “billions of numbers” I keep mentioning. A large model can have hundreds of billions of them. The next section covers how those dials get set.

Setting the dials: training

Nobody sets them by hand. A fresh network starts with random weights and guesses pure gibberish. Training is how it gets good.

So the model’s “knowledge” isn’t a list it looks things up in. It’s baked into those connection weights as patterns. “Paris” reliably follows “the capital of France is” because that pairing turned up countless times in training, and the weights settled into it.

Why it sometimes makes things up

This also explains a common complaint: invented facts.

If a convincing-sounding but wrong continuation is what the patterns suggest, the model will write it just as smoothly as a correct one. It isn’t lying; it genuinely has no separate notion of “true”. That’s worth remembering every time an answer sounds authoritative.

A dial for creativity

One last thing you may have heard of. When the model picks from its ranked guesses, there’s a setting that decides how much randomness it uses. Turn it down and it almost always takes the top guess: predictable, repeatable, a bit dry. Turn it up and it sometimes reaches for lower-ranked words: more surprising and creative, and more likely to wander off. That’s the “temperature” knob, and it’s the same guessing machine either way, just bolder or more cautious about which word it commits to.

From idea to something you can run

That’s an LLM: a next-word guesser, trained until its guesses are good, run in a loop. Doing all that guessing fast enough to feel instant takes serious engineering, which is a topic of its own. If you want to see how a real engine pulls it off, start with how an engine turns a model file into words, then the speed story on a single graphics card.