How Large Language Models Actually Work, Explained Without the Hype
Tokens, probabilities and context — the real mechanics behind the magic trick.

Tokens, probabilities and context — the real mechanics behind the magic trick.

Ask most people how a language model works and you get one of two answers: it is a very fast search engine, or it is a digital brain. Both are wrong, and both lead to bad decisions about where to use one.
The truth is stranger and much simpler. A large language model is a next-token predictor. Give it a stretch of text, and it produces a probability distribution over what comes next. Then it picks one, appends it, and does the whole thing again. Every capability you have seen — summarising, translating, writing code, arguing about philosophy — is that loop, repeated.
This article walks through the machinery one layer at a time. No equations, no hand-waving. By the end you should be able to predict what these systems are good at, and, more usefully, where they will quietly let you down.

A model never sees letters or words. Before anything happens, text is chopped into tokens — chunks that are usually somewhere between a character and a word. Common words like the are a single token; an unusual name might be split into four or five pieces.

Tokenisation explains a surprising amount of odd behaviour. Ask a model to count the letters in a word and it often fumbles, because it is not looking at letters at all; it is looking at chunks. Arithmetic on long numbers is unreliable for the same reason — the digits get grouped in ways that have nothing to do with place value.
For ordinary English prose, one token is roughly four characters, or about three quarters of a word. A 1,000-word article is somewhere near 1,300 tokens. Code, non-Latin scripts and unusual names all use more tokens per character.
Each token is mapped to a long list of numbers called an embedding. The point of an embedding is that similar meanings end up near each other in that numeric space. The vectors for doctor and surgeon sit closer together than the vectors for doctor and doorknob.
Nobody hand-writes those coordinates. They are learned, purely by observing which tokens tend to appear in similar contexts across an enormous amount of text. Meaning, in this system, is entirely a matter of company kept.
This is the piece that made modern models possible. In a sentence like the trophy did not fit in the suitcase because it was too small, the word it refers to the suitcase. Nothing about the word it tells you that; you have to look at the rest of the sentence.
The attention mechanism does exactly that. For every token, the model computes how much each other token in the context should influence its interpretation. Stack that operation dozens of times, and you get a system that can carry meaning across paragraphs.
Attention is not the model understanding your sentence. It is the model deciding, numerically, which parts of your sentence to weight most heavily when guessing the next chunk of text.
— The one-line summary

After all that processing, the model outputs a score for every token in its vocabulary. Those scores become probabilities. Then a sampler picks one — not always the most likely one, which is why you get different answers to the same question.
The temperature setting controls that choice. At temperature zero the model always takes the top-scoring token, giving repeatable, conservative output. Turn it up and lower-probability tokens get a look in, which reads as more creative and, past a point, as nonsense.
Training happens in stages, and the distinction between them matters more than most explanations admit.
The model reads a vast corpus of text and does one thing: predict the next token, over and over, adjusting its weights whenever it is wrong. This is where nearly all the raw knowledge and linguistic ability comes from. It is also enormously expensive and happens exactly once per model version.
A freshly pre-trained model is an unruly text continuer, not an assistant. A second, much smaller training phase teaches it to follow instructions, keep a helpful tone, and refuse certain requests. This shapes behaviour; it adds very little new factual knowledge.
If a model does not know something, fine-tuning is usually the wrong fix. Fine-tuning changes style and behaviour reliably and facts unreliably. To add knowledge, put the facts in the context window instead — that is what retrieval-augmented generation is for.
The context window is the total amount of text the model can consider at once — your prompt, any documents you paste in, the conversation so far, and the response it is generating. When people say a model has a 128,000-token context, that is the whole budget.
Two practical consequences follow. First, the model has no memory between separate conversations unless something in your application deliberately puts earlier material back into the prompt. Second, filling a huge context with marginally relevant text usually makes answers worse, not better. Relevance beats volume.
| Symptom | Common cause | What actually fixes it |
|---|---|---|
| Confidently invented facts | The answer was not reliably in training data | Supply the source text in the prompt |
| Forgets earlier instructions | Instructions fell outside the context window | Re-state key constraints near the end of the prompt |
| Miscounts letters or does bad arithmetic | Tokenisation hides character and digit structure | Hand the job to code, not the model |
| Answers differ every run | Sampling temperature above zero | Set temperature to 0 for deterministic tasks |
| Ignores part of a long document | Relevant passage buried in a long context | Retrieve and pass only the relevant sections |
Here is the uncomfortable part. A model producing a citation that does not exist is not malfunctioning. It is doing precisely what it always does: generating text that is statistically plausible given the context. A fake citation looks exactly like a real one — same shape, same rhythm, same author-year pattern.

The model has no separate mechanism for checking whether the thing it just produced is true. Truth and plausibility are the same signal to it. That is why a system that is right 95% of the time is not 95% trustworthy — the 5% arrives with identical confidence.
A small team used a model to summarise weekly support tickets into a digest for their managers. It worked beautifully for two months. Then someone checked a figure — the digest reported 214 tickets in a week when the real number was 186.
Nothing had broken. The prompt asked for a summary that included a total, the raw tickets were pasted in as unstructured text, and the model produced a plausible-looking number rather than counting rows.
The fix was not a better prompt. They computed the count in code, passed it in as a labelled figure, and asked the model only to write the prose around it. Numbers came from software; language came from the model. Each did what it is actually good at.
Fluency is not evidence. These systems produce well-formed, confident, grammatically perfect text whether or not the content is correct. Any workflow where a wrong answer carries real cost needs a verification step that is not itself a language model.

A large language model turns text into tokens, tokens into vectors, and then uses attention to weigh context before predicting the next token — repeatedly, until it stops. Knowledge is baked into weights during pre-training; behaviour is shaped afterwards; working memory is the context window and nothing else.
Every strength and every failure mode falls out of that design. It writes fluently because fluency is what it optimised for. It invents citations for exactly the same reason.
The most useful mental model is not a brain or a search engine. It is an extraordinarily well-read improviser: fast, articulate, widely informed, and entirely willing to make something up rather than admit a gap.
Work with that, not against it. Supply the facts, constrain the output, verify what matters, and you will get remarkable results. Expect a mind, and you will eventually get caught out. If you are building on top of one, our guide to prompts that survive real use is the natural next read.
Tap a star to share what you thought.
No ratings yet
Not in the way people do. They model statistical relationships between tokens extremely well, which produces text that reads as understanding. There is no separate representation of truth or belief behind it, which is exactly why a confident answer and a fabricated one look identical.
A chunk of text the model treats as a single unit — usually part of a word. In English, one token averages about four characters. Models never see raw letters, which is why letter-counting and long arithmetic are unreliable.
Because generating plausible text is the only thing they do. When the training data did not firmly establish a fact, the model still produces something statistically reasonable in its place. There is no internal check that separates recalled facts from invented ones.
Have a story, idea, or something valuable to share? Join The Blog Story for free, publish your content, reach more readers, and earn a share of advertising revenue from eligible content.
Create quality content. Grow your audience. Grow your earning potential.
The maximum amount of text a model can consider at once, covering your prompt, any supplied documents, the conversation history and the answer being generated. Anything outside it is invisible to the model.
Not by itself. Any apparent memory comes from the application re-sending earlier messages or stored notes as part of the new prompt. Start a fresh conversation with no such mechanism and the model knows nothing about you.
It controls how adventurously the model samples from its predicted probabilities. Zero always picks the highest-scoring token, giving consistent and conservative output. Higher values allow less likely tokens through, which reads as more creative and eventually as incoherent.
Usually not. Fine-tuning reliably changes style, format and behaviour, but is an expensive and unreliable way to install facts. Putting the relevant material directly into the prompt — retrieval-augmented generation — works far better for knowledge.
Supply the source material rather than relying on recall, set temperature to zero for factual work, ask for specific output formats, break complex tasks into steps, and verify anything consequential with code or a human review.