When you ask ChatGPT a question, what actually happens? Not the marketing version — the mechanism.
The Core Insight
A language model is a probability machine. Given a sequence of words, it predicts what word comes next (Jurafsky & Martin, 2024). That's it. Everything else — the conversations, the code generation, the apparent reasoning — emerges from doing this prediction extremely well across an enormous range of contexts.
This isn't a metaphor. When you type "The capital of France is," the model calculates a probability distribution over its entire vocabulary. "Paris" gets a high probability. "London" gets a lower one. "Banana" gets almost zero. The model samples from this distribution and outputs the next word.
Then it does it again, treating its own output as part of the input. Word by word, the response emerges.
What Training Actually Does
Training is where the probabilities come from. The model sees billions of text examples — books, websites, code, conversations — and adjusts its internal parameters to become better at predicting the next word.
The parameters are just numbers. A lot of them — modern models have hundreds of billions. These numbers encode patterns: that "Paris" often follows "capital of France," that code after def usually defines a function, that formal documents use different vocabulary than tweets.
The model doesn't "know" any of this the way you know your phone number. It has learned statistical associations that produce useful outputs. This distinction matters when we get to what the model can and cannot do — and it's the foundation for understanding debates about whether these systems learn like brains, whether they can improve themselves, and what it means when they appear autonomous.
The Transformer Architecture
The specific mechanism most language models use is called a transformer, introduced in the landmark paper "Attention Is All You Need" (Vaswani et al., 2017). The key innovation is "attention" — the model can learn which parts of the input matter most for predicting any given output.
When generating the word "Paris," the model attends heavily to "capital" and "France" while mostly ignoring earlier parts of the prompt. This attention is learned during training, not programmed.
Attention operates across a "context window" — the amount of text the model can consider at once. Early models had small windows (a few thousand words). Modern ones handle hundreds of thousands. But there's always a limit, and information at the edges of the window often gets less attention than information near the output.
What This Means in Practice
Understanding the mechanism reveals both capabilities and limits:
Why models are good at: Pattern completion, style imitation, synthesis across domains, generating plausible text. These are exactly what next-word prediction optimizes for.
Why models struggle with: Exact counting, precise arithmetic, novel reasoning without similar training examples, maintaining perfect consistency across long outputs. These require computation that prediction-by-prediction generation doesn't naturally provide.
Why models "hallucinate": They're not retrieving facts from a database — they're generating plausible continuations. If the most probable next word is wrong, the model has no way to know that. It's optimizing for plausibility, not truth. (This is one reason RAG systems exist — they ground model outputs in actual documents rather than relying solely on learned patterns.)
The Infrastructure Angle
This mechanism has infrastructure implications. A model that predicts one word at a time is fundamentally serial — you can't parallelize the generation of a single response. This means response time scales with length, and serving costs scale with usage.
More significantly, the training process requires massive compute resources. The corporations that can afford to train frontier models number in the single digits (training runs now cost upwards of $1 billion). The mechanism creates natural monopolies in a way that, say, web servers never did. But inference — running a trained model — is a different story. Local inference on consumer hardware is increasingly viable, creating a genuine counterweight to cloud dependency.
Understanding how language models work isn't just technical trivia. It's prerequisite to understanding who controls them, who benefits from them, and how they might be governed.
Related
- The Training Pipeline
- What Model Cards Tell You
- The Autonomy Illusion
- How Reasoning Models Actually Work
- How Retrieval-Augmented Generation Changes Who Needs What
- No AI Doesn't Learn Like a Brain
- Economics of Training a Frontier Model
- Stochastic Parrots