How language models predict text
It is next-word prediction, done at a scale that makes the result look like more than it is, and sometimes be more useful than it sounds.
One job, many appearances
A language model does one core job: given some text, it assigns probabilities to what might come next. To write, it samples from those probabilities, adds the new piece to the text, and repeats. To answer a question, it is still doing that job. The question and the instructions are the given text. The answer is the continuation.
That is why the same kind of model can translate, summarize, write code, or hold a conversation. Those are not separate built-in modules in the simple case. They are patterns that showed up often enough in the training text, or in later tuning, that "the most likely continuation" often looks like the task you asked for.
Tokens, not always whole words
The model usually does not eat text a word at a time. It eats tokens, which are common pieces of text: a short word, a part of a longer word, a punctuation mark, or a bit of code. The vocabulary is finite. Any passage you type is broken into that vocabulary, run through the network, and turned back into text.
This is bookkeeping, but it has consequences. A word the model has never seen as a whole can still be handled if its pieces are known. A typo can become a strange token sequence and throw the prediction off. When a model "struggles with spelling" or with a rare name, you are often looking at this tokenization step, not at a tiny person who forgot how to spell.
Why fluent text can still be wrong
The training goal is to be good at continuing text, not to be good at checking the world. If a confident, well-written sentence was a common way to finish a similar prompt in the data, the model may produce that sentence even when it is false. This is why a language model can invent a citation, a date, or a legal clause that looks right and is not.
You can reduce that problem with later training, with tools that look things up, and with the habit of checking anything that matters. You cannot wish it away by saying the model is "smart." The system is strong at patterns in language. It is weak at being an authority. What these systems cannot do is the longer version of that warning.
Context, and the edge of the window
The model only "sees" a limited stretch of text at once, called the context window. If you past that limit, earlier parts of the conversation are no longer in view unless some other system summarizes or retrieves them. A model that contradicts itself after a long chat is often not lying. It may simply no longer have the earlier turn in its input.
That is also why these systems can feel sharp on a short, well-posed question and vague on a long, messy one. You can help by putting the facts the answer depends on inside the prompt, clearly, rather than assuming the model will remember a document you mentioned an hour ago. For the difference between the expensive process that built the weights and the cheaper process that produces the next token, see Training versus inference.
Common questions
Is a language model just a very large autocomplete?
In mechanism, yes: it predicts likely continuations of text. The scale, the training, and the way people wrap it in tools can make that mechanism useful for tasks that do not look like autocomplete. The mechanism is still prediction.
Why can a model write working code and still invent a book title?
Code that runs has a tight pattern, and errors often show up when you try it. A book title can look stylistically right and still refer to no book. The model is scoring likely text, not checking a catalog, unless you have added a tool that does that check.
Does adding a search tool make the model truthful?
It can help, when the tool is used and when the retrieved source is good. It does not turn the model into a guaranteed witness. You still have to read the source.