How Large Language Models Actually Work
A clear, non-technical explanation of what happens inside a large language model — from tokens to transformers to next-word prediction.
Large language models are, at their core, very good at one thing: predicting the next word. Everything else — writing, reasoning, coding — emerges from that simple objective scaled up enormously.
Tokens: the atoms of text
Models do not read words; they read tokens. A token is a chunk of text — often a word, part of a word, or a punctuation mark. "Artificial" might be one token; "artificial intelligence" might be two. This tokenisation lets the model handle any language and any length of text.
The transformer
The transformer is the architecture behind modern models. Its key innovation is attention: the ability to weigh how much each token should pay attention to every other token in the input. This lets the model understand context — that "it" in a sentence refers to something mentioned earlier.
Training: predicting, over and over
Training is simple in description and enormous in scale. The model reads vast amounts of text and repeatedly predicts the next token, adjusting its internal parameters each time it is wrong. Over trillions of tokens, it learns grammar, facts, reasoning patterns and style.
Fine-tuning and alignment
After pre-training, models are fine-tuned — trained further on specific tasks or human preferences — to follow instructions and behave helpfully and safely. This is why a base model and a chat model behave so differently.
What this means in practice
Understanding the basics explains a lot: why models sometimes hallucinate (they predict plausibly, not truthfully), why context length matters (attention is expensive), and why prompts matter (the model is always predicting what comes next).