Skip to content

Plain-language explainer

How LLMs work, without the math

How does a large language model actually work?

A large language model is a next-word predictor. It turns your text into numbers, runs them through billions of learned weights, and produces a probability for every possible next token. It picks one, adds it to the text, and repeats. There is no database of facts and no lookup step. The intelligence is a very good statistical guess about what comes next, learned from a huge amount of text. Everything else, chat, code, agents, is built on that one loop.

Last reviewed

Do not just read it. Operate the mechanism yourself in a short interactive lesson.

See it work: How does an AI think?

Free, no code, no signup.

The pipeline: what happens when you press send

Step one is tokenization. The model never sees letters or words. Your text is chopped into tokens, common fragments from a fixed vocabulary, so 'strawberry' might become two or three pieces, each with an id number. This is why models are billed per token and why counting letters inside a word is famously hard for them.

Step two is embedding. Each token id looks up a long list of numbers, its position on a learned map of meaning, where similar meanings sit near each other. From here on, everything is arithmetic on those number lists.

Step three is the transformer itself: dozens of stacked layers where attention lets every token look at the other tokens and pull in the ones that change its meaning, so 'bank' near 'river' ends up carrying a different vector than 'bank' near 'money'. Step four turns the final vector into a score for every token in the vocabulary, and a softmax turns scores into probabilities. Step five samples one token from that distribution, appends it, and the whole thing runs again. A 500-word answer is that loop executed a few hundred times, fast enough to look like typing.

Where the 'knowledge' comes from: training

All those weights start as random numbers. Pretraining fixes that with one brutally simple exercise, repeated trillions of times: show the model a slice of real text, hide the next token, let it guess, measure the miss, nudge the weights to miss less. Do this across trillions of tokens of web pages, books and code, and the weights are forced to absorb grammar, facts, style and code patterns, because absorbing them is the only way to keep guessing well.

A raw pretrained model is a continuation machine, not an assistant. Ask it a question and it might continue with three more questions, since that is a plausible continuation. Post-training turns it into a product: it is shown examples of helpful dialogue, then tuned on human (and increasingly AI) preference judgments, a process whose best-known ingredient is RLHF, reinforcement learning from human feedback. That is where 'predict text' becomes 'answer the user, decline harmful requests, admit uncertainty'.

The split matters for what you can expect. Training happened in the past, once, at enormous cost. When you chat, nothing is learning: the weights are frozen, and your conversation changes the model's behavior only while it sits in the context window. Tomorrow it starts blank again, unless the product deliberately saves memory for you.

How big are these models, in real numbers?

Exact figures for frontier models are trade secrets, but the public record gives honest anchors. The table mixes disclosed historical numbers with commonly reported figures as of mid-2026.

  • A parameter is one learned number. 'Billions of parameters' means billions of dials the training process tuned.
  • Context windows grew about a thousandfold in six years, which is why models can now read whole books or codebases in one prompt.
Representative scale anchors. Disclosed where public, reported estimates where not.
Model eraParametersTraining textContext window
GPT-2 (2019, disclosed)1.5 billion~8 billion tokens1,024 tokens
GPT-3 (2020, disclosed)175 billion~300 billion tokens2,048 tokens
Open-weight large (e.g. Llama 3.1, disclosed)405 billion~15 trillion tokens128k tokens
Frontier tier (2025-26, reported)undisclosed; estimates run to the trillions, often mixture-of-expertstens of trillions of tokens200k to 1M+ tokens

Why does it sometimes make things up?

Because nothing in the loop checks the sentence against reality. The model always emits the most likely next token, and fluent, confident prose is the likely shape of an answer whether or not the underlying fact was ever in the training data. When the fact is well represented, likely and true coincide. When it is rare or absent, the model fills the gap with the most plausible pattern, an invented citation, a wrong date, produced by exactly the same machinery as a correct one. This failure has a name, hallucination, and it is managed, not cured: products ground answers in retrieved documents and web search, cite sources, and train models to abstain more, but the prediction engine underneath has no built-in line between remembered and plausible.

This is also the honest way to read the model's confidence. Its tone is a property of the writing it predicts, not a measurement of certainty. The practical rule for anything that matters: ask what the answer is grounded in, and check the source it cites.

What did reasoning models change?

Since late 2024, most frontier systems can spend tokens thinking before they answer: they generate a private chain of intermediate steps, explore, backtrack, then write the reply. Nothing about the core loop changed, thinking tokens are still next-token prediction, but budgeting extra compute at answer time turned out to buy real gains on math, code and multi-step problems. It is the same trick you use when you work a problem on scratch paper instead of blurting the first thing.

The catch is cost and fit. Thinking multiplies tokens, so it multiplies latency and price, and on easy questions it buys nothing, occasionally even talks the model out of a right answer. That is why products ship fast and thinking modes, or route between them automatically. More thinking is not more knowing: a reasoning model still hallucinates facts it never learned, it is just better at working through the ones it has.

What an LLM is not

  • It is not a database. There is no table of facts inside, only weights that make good guesses likely. Deleting or editing one specific fact is an open research problem.
  • It is not searching the internet, unless the product wraps it in a search tool and pastes results into the prompt. The same model can be current in one app and stale in another.
  • It does not remember you between chats by itself. Continuity comes from the product re-sending history or storing memory, both of which live outside the model.
  • It does not run your code or check its arithmetic natively. When it gets math right at scale, a calculator or code tool is usually involved.
  • It is not conscious, and 'think' is a metaphor. What streams out is a probability distribution being sampled, one token at a time.

What people get wrong

  • It looks answers up in a stored database. It does not. It predicts likely text, which is exactly why it can be confidently wrong.
  • It understands the way a person does. It models patterns in language, not lived experience or meaning.
  • Bigger is always smarter. Scale helps, but training data quality and how you use the model matter just as much.
  • It learns from your conversation. The weights are frozen during chat; anything it 'picks up' lasts only as long as the context window.

Where you see it in real products

  • Chat assistants generate each reply one token at a time.
  • Writing and autocomplete tools rank the next word the same way.
  • Coding agents wrap the same predictor in a loop that can run tools.
  • The word-by-word streaming you watch in every chat app is the loop, live.

Common questions

Does an LLM search the internet for answers?
Not by itself. A model answers from the patterns in its weights, which stopped changing when training ended. Search only happens when the product wraps the model in a tool that fetches pages and pastes them into the prompt first. That is why the same model can be current in one app and out of date in another.
Why does it sound so confident when it is wrong?
Because confidence is not something it measures. It picks the most likely next token given everything so far, and assured, fluent text is the likely shape for an answer. Nothing in the loop compares the sentence to reality, so an invented citation is produced by exactly the same machinery as a correct one.
How much text has a model like this read?
Trillions of tokens of public web text, books and code, filtered and deduplicated. The mix and the cleaning matter more than the raw amount, and labs treat the exact recipe as a trade secret, so be skeptical of any precise public number.
Is ChatGPT the same thing as an LLM?
ChatGPT is a product built around LLMs. The model predicts tokens; the product adds the chat interface, conversation history, tools like web search and code execution, safety layers, and memory. Many behaviors people attribute to 'the model', remembering you, browsing, running code, are actually the product's wrapping.
What is a token exactly?
A common fragment of text from the model's fixed vocabulary, typically a word, part of a word, or punctuation. On average a token is about three quarters of an English word. Models read, generate and bill in tokens, which is why providers quote prices per million tokens.
If it only predicts the next word, how can it write code or reason?
Because predicting well on trillions of tokens of code and argument forces the weights to encode the patterns that generate them: syntax, logic, common algorithms, styles of proof. Prediction is the training objective, not the ceiling of what gets learned. Whether that amounts to 'real' reasoning is debated; what is measurable is that the predictions solve problems.
Do LLMs work the same in Spanish or other languages?
The mechanism is identical, and big models train on many languages at once. Quality tracks how much of each language was in the training mix, so major languages work very well while low-resource languages see more errors, and tokenizers often split non-English text into more tokens, which can make the same sentence slightly costlier.

Related explainers

More in Foundations

One idea at a time, in your inbox

New lessons and explainers, written the way these pages are. Now and then, not daily, and never a sales sequence.

We email you a confirmation link first. Unsubscribe in one click, any time. Privacy.

Part of See How AI Works, a free interactive course, where you learn how modern AI works by operating it, not watching videos.