Language models have moved from research curiosity to everyday infrastructure in a remarkably short time, and the explanations offered for how they work tend to fall into two unhelpful camps: mystical, or dismissive. The actual mechanism is comprehensible without mathematics, and understanding it explains both the capabilities and the characteristic failures.
Text becomes numbers
A model cannot process text directly. The first step is tokenisation, which splits input into units — roughly, common words become single tokens while rarer words split into fragments. A useful rule of thumb is that a token averages about three quarters of an English word.
Related: what “encrypted” really means
Each token is then mapped to a vector, a long list of numbers representing its position in a high-dimensional space. These embeddings are learned during training, and they encode relationships: tokens used in similar contexts end up near each other, and directions in the space correspond to meaningful transformations.
Attention: the key idea
The architecture underlying current models is the transformer, and its central innovation is the attention mechanism. For each token being processed, attention computes how relevant every other token in the context is, and builds a representation weighted accordingly.
The practical effect is that meaning becomes contextual. In “the bank of the river” and “the bank raised rates”, the token for bank starts identically but attention pulls in the surrounding context and produces different internal representations. Models run many attention operations in parallel, each learning to track different kinds of relationship — grammatical dependency, coreference, topical association — and stack dozens or hundreds of layers of this process.
Related: how inflation is actually measured
Training in two phases
Pre-training is conceptually simple and computationally enormous. The model is shown vast quantities of text and asked repeatedly to predict the next token. When it is wrong, the parameters adjust slightly. Repeated across trillions of tokens, this forces the model to encode grammar, factual associations, reasoning patterns and stylistic conventions, because all of those improve prediction accuracy.
Post-training shapes that raw capability into something useful. Supervised fine-tuning on curated examples teaches the model to follow instructions and adopt a helpful register. Reinforcement learning from human feedback then trains a reward model on human preferences between outputs and optimises the model against it. This phase does not add knowledge; it changes which of the model’s capabilities surface and how.
Generation is one token at a time
When producing output, the model computes a probability distribution over the entire vocabulary for the next token, selects one, appends it to the context, and repeats. Every token is generated with full knowledge of everything written so far and no knowledge of what comes next.
Selection is not simply taking the highest probability. A temperature parameter controls how much randomness is introduced; low values produce predictable, repetitive text, high values produce varied and less coherent text. This is why the same prompt can yield different answers, and why models are not deterministic by default.
Why models get things confidently wrong
The failure mode usually called hallucination follows directly from the mechanism. The model is producing statistically plausible continuations. A plausible continuation of a request for a citation is a citation-shaped string — correctly formatted, with a believable author and title — and nothing in the generation process distinguishes retrieving a real one from constructing a plausible one.
This is why the errors are characteristically confident and well-formed rather than hesitant. The model has no separate representation of certainty about facts that it consults before answering. Techniques such as retrieval augmentation, which supplies real source documents in the context, address this by changing what the model is completing from rather than by fixing the underlying mechanism.
Context windows and what they mean
The context window is how many tokens the model can attend to at once — the prompt plus everything generated so far. Anything outside it does not exist for the model. This is why long conversations lose earlier details and why a model has no memory between sessions unless a system explicitly stores and re-supplies information.
Larger context windows have expanded dramatically, but performance does not remain uniform across them. Retrieval accuracy tends to be strongest at the beginning and end of a long context and weaker in the middle, an effect that matters when placing important instructions in a long document.
What this predicts about use
The mechanism explains where these systems are strong and where they are not. They are strong at tasks where fluent, pattern-consistent output is the goal: drafting, summarising, reformatting, translating, explaining familiar concepts, and producing code in well-represented languages. They are weaker where the task requires guaranteed factual accuracy, arithmetic precision, or knowledge of anything after training concluded.
The practical implication is not that the output is unreliable in general, but that reliability varies systematically with task type — and that knowing which type you are in is most of the skill in using them well.
More from PressBBC
- What “Encrypted” Actually Means When an App Claims It
- Electric Vehicle Batteries: Chemistry, Range and What Degradation Really Looks Like
- Understanding Inflation: CPI, Core, and Why Your Experience Differs
- Browse everything in our Technology section.
Sources and further reading
- “Attention Is All You Need” — the 2017 paper that introduced the transformer
- NIST — Artificial Intelligence — the AI Risk Management Framework and related standards






