← My notebook

04 · Models

How an LLM writes

A language model does not look up an answer. It predicts the next token from the ones already there, one token at a time.

Tokens, not words

Text is split into tokens: whole words, pieces of words, punctuation. "The number has to" is a handful of tokens, and that is all the model has to go on.

Score, pick, append

For the next position the model scores every token it knows. "hold" gets 42 percent, "be" 21, "stay" 11, and a long tail gets almost nothing. One token is picked, usually a likely one.

That token is appended to the context and the scores are thrown away. The line is now "The number has to hold", and the whole prediction runs again for the next position.

Why this matters

There is no stored sentence called "The number has to hold up." It was built one choice at a time. That is why the same prompt can give different answers, and why a confident sentence is not the same as a checked fact.

What to watch for

Long answers compound small choices. If you need a fact, give it to the model in the context or let it call a tool, rather than hoping the right tokens come out.