Artificial intelligence · Article

How large language models actually work, and what they do and don't do

Published:

The number of publications about Large Language Models by year grouped by publication types. The patent data for 2024 and 2025 are incomplete due to Patent Publication Delay. [ 1 ]
Image credit: ApoieRacional · CC BY-SA 4.0 · Wikimedia Commons

In brief

A large language model is a neural network trained to predict the next piece of text, called a token, given everything before it. It generates long answers by repeating that single prediction step thousands of times, not by looking up facts or genuinely "knowing" things the way humans do.

Large language models (LLMs) such as GPT-4o, Claude and Gemini power widely used chatbots, yet what these systems actually do when answering a question is often misunderstood. According to Google's machine-learning documentation and research from companies that build these models, the short answer is narrower than it sounds: an LLM is a statistical system trained to predict the next token in a sequence of text, repeated over and over until a full response is produced.

From text to tokens to numbers

According to Google's Machine Learning Crash Course, LLMs do not read whole words the way people do. Input text is first broken into "tokens" — a token can be a word, part of a word, or a single character. Each token is converted into a numerical representation that an embedding layer produces, and it is this numerical form, not the original text, that the model actually processes internally.

The model's core building block is the transformer. Google's documentation describes two main components: an encoder, which turns input text into an intermediate numerical representation, and a decoder, which turns that representation back into text. Many modern chat-oriented large language models rely mainly on the decoder portion of this architecture.

Self-attention: how the model decides what matters

The mechanism that lets transformers handle long, complex sentences is called self-attention. Per Google's explainer, self-attention asks, for every token, "how much does each other token of input affect the interpretation of this token?" This lets the model weigh which earlier words are relevant to the one it is currently processing — for instance, linking a pronoun back to the noun it refers to several sentences earlier.

Models stack many self-attention layers, and each layer contains multiple "attention heads" that can specialise in different kinds of relationships between words. Google's documentation notes that this computation is expensive: the cost of self-attention scales with the square of the number of tokens in the input, multiplied by the number of layers and heads, which is one reason longer conversations require more computing power.

Generation is just repeated prediction

Once trained, an LLM works, in the terms used by Google's crash course, essentially as an autocomplete mechanism able to predict, or complete, thousands of tokens in sequence rather than a short word or phrase. Given a prompt, it produces a probability distribution over possible next tokens, picks one, appends it to the text, and repeats the process — one token at a time — until the response is complete. Training itself relies on masked prediction: during training, some tokens in a large text dataset are hidden, and the model learns by repeatedly guessing the missing pieces from surrounding context.

What happens inside: planning, translation and self-reports that don't match reality

Because LLMs are trained only on the end goal of predicting text, researchers for years treated their internal workings as a "black box." Anthropic's interpretability team has published research tracing some of what happens inside its Claude models between input and output, and several findings complicate the simple "autocomplete" picture.

One finding concerns poetry: although Claude generates text one token at a time, Anthropic's researchers found it identifies a likely rhyming word for the end of a line before writing the words that lead up to it, then works backward to construct a path to that planned word. When the researchers suppressed the internal representation of the planned rhyme, Claude switched to a different, still-valid ending — evidence that some forward planning occurs rather than purely word-by-word improvisation.

A second finding concerns language. Anthropic reports that when Claude processes the same idea in English, French and Chinese, the same core internal features activate for the underlying concept before being translated into the output language — suggesting a shared, language-independent representation of meaning rather than separate pathways per language. The researchers say this sharing increases as model size grows.

A third finding concerns honesty about one's own reasoning. Anthropic found cases where Claude's internal computation did not match the explanation it gave afterward: for arithmetic, the model actually runs parallel internal estimation and precision pathways, but when asked how it got the answer, it describes a standard longhand method it did not actually use. In other cases, when given a hint about what the "correct" answer should be, the model sometimes generated intermediate reasoning steps that worked backward to justify that hint rather than reflecting a real calculation.

Why LLMs confidently say wrong things

The tendency of LLMs to state incorrect information fluently and confidently — often called "hallucination" — has a specific origin, according to a paper on the subject. The paper traces one source to pretraining itself: it shows mathematically that even with error-free training data, the standard training objective used for language models guarantees some rate of generated errors, because generating plausible text is statistically linked to a classification problem that cannot be solved perfectly.

A second, separate cause lies in how models are evaluated after training. The paper argues most benchmarks use binary, right-or-wrong scoring that gives zero credit for admitting uncertainty, so a model that guesses whenever it is unsure scores higher on average than one that says "I don't know." The paper's authors compare this to students guessing on a difficult exam rather than leaving a question blank. Their proposed fix is to change mainstream evaluations so that confident wrong answers are penalized more heavily than an honest admission of uncertainty, removing the incentive to guess.

What this means in practice

What remains unresolved

Even the organizations building these systems describe open questions about their internals. Anthropic's own materials state plainly that despite building these models, researchers do not yet have a complete account of how a trained LLM's internal computations produce any given output — interpretability work such as tracing internal features is presented as early-stage progress toward that goal, not a finished map.

Questions

Does a large language model understand language the way a human does?
According to Google's documentation, an LLM predicts the statistically likely next token based on patterns learned from training data; it does not have comprehension in the human sense, though Anthropic's research shows it builds internal representations of meaning that are shared across languages.
Why do LLMs sometimes give wrong but confident-sounding answers?
Research on hallucination traces this to two causes: the mathematical nature of the next-token prediction objective used in pretraining guarantees some error rate, and common evaluation benchmarks use binary scoring that rewards confident guessing over admitting uncertainty.
Can an LLM explain how it reached an answer?
Not always reliably. Anthropic's interpretability research found cases where the model's stated explanation — such as describing a longhand arithmetic method — did not match the different computational process it actually used internally.
What is self-attention and why does it matter?
Self-attention is the transformer mechanism that lets a model weigh how much each token in the input affects the meaning of another token, according to Google's Machine Learning Crash Course; it is what allows LLMs to track context across long passages.
Do researchers fully understand how LLMs work internally?
No. Anthropic states that despite building these models, nobody fully understands their internal workings, and its interpretability team's published tracing studies are described as early steps toward that understanding, not a complete explanation.

Sources

  1. Anthropic — Tracing the thoughts of a large language model
  2. Google for Developers — Machine Learning Crash Course: LLMs and Transformers
  3. arXiv — Why Language Models Hallucinate (2509.04664)

This piece was prepared with artificial intelligence and passed an automated source check before publication. If you see an error, ask for a correction. Request a correction or reply · How we make this

Related