3.4 Language models and how they predict text
Language models and how they predict text
The AI systems that have captured the public imagination — ChatGPT and its relatives — are large language models (LLMs). Their underlying task is startlingly simple to state, which makes their fluency all the more surprising.
The one task: predict the next token
A language model is trained to do exactly one thing: given some text, predict what comes next. It reads a sequence of words (more precisely, pieces of words called tokens) and outputs a probability for every possible next token. "The capital of France is" → very high probability for "Paris." That is the entire training objective. Crucially, this needs no human labels — the next word in ordinary text is the answer — which is why models can be trained on enormous amounts of raw internet text.
How prediction becomes conversation
If the model can predict the next token, it can generate text: predict one token, append it, predict the next, and repeat. A chatbot answering your question is just this loop, having learned from vast text that the tokens which plausibly follow a question are its answer. Astonishingly, learning to predict text well forces the model to absorb grammar, facts, styles, and a surprising amount of reasoning — all as a side effect of getting better at "what comes next."
Context window
A model can only "see" a limited amount of text at once — its context window. Everything it uses to make its next prediction (your question, the conversation so far, any documents you paste) must fit inside that window. It has no memory beyond it unless that text is supplied again.
It predicts plausibility, not truth
The deepest thing to internalize: the model is optimizing for plausible continuation, not for truth. It outputs what statistically tends to follow, which is usually correct because true text is common — but not always. This single fact explains hallucination, which we cover in 3.7.
A worked example
Type "Once upon a" into a phone keyboard and it suggests "time." That predictive keyboard is a tiny language model. An LLM is the same idea scaled up by a staggering factor — billions of parameters trained on a large fraction of the written internet — until "predict the next token" produces essays, code, and translations. Same principle, vastly more scale.
