Skip to content
analysis18 min read

How Do Large Language Models Actually Work? (Plain English)

A large language model writes text by repeatedly predicting the most likely next word, one token at a time. This plain-English guide explains next-token prediction, tokens, embeddings, the transformer and attention, two-phase training, and why LLMs hallucinate.

Author
Anthony M.
18 min readVerified July 6, 2026Tested hands-on
How large language models work — predicting the next word, one token at a time
A large language model works by predicting the most likely next word, adding it, and repeating. Illustration.

A large language model (LLM) is a computer program that writes text by repeatedly predicting the most likely next word, one small piece at a time. It learned to do this by reading an enormous amount of text and slowly adjusting billions of internal numbers, called parameters, until its guesses matched real writing. An LLM does not look facts up in a database and does not truly understand meaning the way a person does; it predicts patterns in language. That single idea, next-word prediction, explains almost everything about how these models behave, including why they are fluent, why they are creative, and why they sometimes state false things with total confidence. Models like Claude Sonnet 5, GPT-5.5, Gemini 3.1 Pro, and DeepSeek V4 are all built on this same core mechanism.

Large language models can feel like magic. You type a question and a thoughtful, well-written answer appears, as if a knowledgeable person were on the other side. The reality is stranger and, once you see it, far more useful to understand. Underneath the polish, a model is doing one simple thing over and over: guessing the next chunk of text. This guide explains, in plain English and with zero math, how that one trick becomes something that can draft an email, explain a legal clause, or write working code. We will build the picture piece by piece: how a model reads text as tokens, how it stores meaning as numbers, how the transformer lets every word pay attention to every other word, how the whole thing is trained in two phases, and why it sometimes makes things up. By the end you will have a clear mental model that makes these tools far easier to use well.

The one idea behind every LLM: predicting the next word

Here is the whole engine in a sentence: a large language model takes the text so far and predicts what word most likely comes next. Then it adds that word to the text and predicts again. And again. This loop, running at superhuman speed, is how every answer you have ever seen from a chatbot was produced, one small step at a time.

Think of the autocomplete on your phone. You type "I'll be there in five," and it suggests "minutes." An LLM is that same idea taken to an extreme. Instead of guessing the next word from your last few messages, it draws on patterns absorbed from a huge slice of human writing, and instead of offering one weak suggestion, it produces a ranked sense of every possible next word and how likely each one is. The model does not pick a word at random and it does not always pick the single most likely one; it samples from the top candidates, which is part of why the same prompt can yield slightly different answers.

Because the model only ever predicts the next piece, it builds its reply left to right, never knowing the end of its own sentence when it starts it. This is called being autoregressive, which just means each new word is fed back in as part of the input for the next prediction. It is also why you often see answers stream onto the screen word by word: you are literally watching the loop run.

The autocomplete that read a library

The reason this humble mechanism produces essays and code rather than gibberish is scale. To predict the next word well across recipes, contracts, Python, poetry, and casual chat, a model has to pick up an astonishing amount along the way: grammar, facts, tone, formatting, common reasoning steps, and the rhythm of how ideas usually follow one another. Prediction, done well enough over enough text, forces the model to encode a working impression of how the world is described in writing. That is the quiet trick at the heart of the field: teach a system to predict text, and to get good at it, it has to learn a great deal about the content of that text too.

Why "one word at a time" matters in practice

The step-by-step nature has real consequences for you as a user. A model cannot revise a paragraph it has not written yet, so asking it to "think first" by outlining before answering often improves the result, because its own outline becomes part of the input it predicts from. It also means longer answers take longer to produce, since every single word is a fresh prediction. And it explains why a model can paint itself into a corner: once it has committed to an opening, it tends to continue in a way that is consistent with what it already wrote, even if a better path existed.

Tokens: how a model chops up language

Tokens — how a language model splits text into sub-word pieces
Before a model can process text, it splits it into tokens, which are often sub-word fragments rather than whole words. Illustration.

We keep saying a model predicts the next "word," but that is a friendly simplification. What it actually predicts is the next token. A token is the unit of text a model reads and writes, and it is usually a chunk of a word rather than a whole word. Common words like "the" or "cat" are typically a single token, while a longer or rarer word such as "unbelievable" may split into several pieces like "un," "believ," and "able." In English, one token averages about four characters, or roughly three quarters of a word, so a thousand tokens is around 750 words.

Why not just use whole words, or individual letters? Whole words would need an impossibly large vocabulary and would choke on typos, names, and new coinages. Individual letters would make every prediction tiny and force the model to reassemble everything from scratch. Sub-word tokens are the practical middle ground: a manageable vocabulary that can still spell out anything, including words the model has never seen, by combining familiar pieces.

Why tokens explain some strange failures

Tokens are also behind a class of failures that puzzle people. When a model struggles to count the letters in a word, or to reverse a string, or to do exact character-level manipulation, the token is often the culprit: the model never saw individual letters, it saw a single chunk, so letter-by-letter tasks are genuinely awkward for it. Understanding tokens turns these quirks from spooky into obvious. It also connects directly to cost and speed, because providers measure and bill usage in tokens rather than words, a topic we unpack in our explainer on AI model pricing and how tokens are billed.

Embeddings: turning words into coordinates of meaning

Embeddings — a language model stores word meaning as coordinates in space
A model turns each token into a long list of numbers, so that words with similar meanings end up near each other in a vast space of coordinates. Illustration.

A computer cannot do anything with the raw letters of a token, so the first thing a model does is convert each token into a list of numbers called an embedding. You can picture an embedding as a set of coordinates that places the token at a specific point in a vast, many-dimensional space of meaning. This sounds abstract, but the intuition is simple and powerful: words with similar meanings end up near each other, while unrelated words sit far apart.

In this space of meaning, "dog," "puppy," and "hound" cluster together in one neighborhood, while "invoice," "spreadsheet," and "quarterly" gather in another. The famous illustration is that directions in the space can capture relationships: the step from "king" to "queen" is similar to the step from "man" to "woman," so the model has effectively learned the idea of gender as a consistent direction, without anyone ever programming that rule. It discovered these arrangements purely from the company each word keeps across billions of examples.

Meaning comes from context

Embeddings are why a model can handle paraphrases, synonyms, and vague phrasing so gracefully. It is not matching exact keywords; it is working with positions in meaning-space, so "How do I get my money back?" and "What is your refund policy?" land close together even though they share almost no words. Crucially, a token's representation is not frozen. As the model reads a sentence, the meaning it assigns to each word shifts based on the words around it, so "bank" near "river" is understood differently from "bank" near "loan." That reshaping of meaning by context is exactly what the next piece, the transformer, makes possible.

The transformer and attention: how a model weighs every word

Self-attention — every word in a sentence weighs every other word
Self-attention lets the model connect "it" to "the trophy," resolving what each word refers to by weighing every other word. Illustration.

The engine that turns embeddings into predictions is a design called the transformer, introduced by Google researchers in a 2017 paper memorably titled "Attention Is All You Need." Nearly every major model today, including Claude, GPT, and Gemini families, is a transformer of some kind. Its key ingredient, and the reason it works so well, is a mechanism called self-attention.

Self-attention is easier to grasp with an example than a definition. Consider the sentence, "The trophy did not fit in the case because it was too big." What does "it" refer to, the trophy or the case? You know instantly that "it" means the trophy, because a trophy being too big is what would stop it from fitting. Self-attention is how the model does the same thing: when it processes the word "it," it looks back at every other word in the sentence and decides how much each one matters for understanding "it" right now. The word "trophy" gets a lot of attention, "case" gets some, "the" gets almost none. The model is, in effect, drawing lines of relevance between words.

A simple analogy for attention

Imagine every word in the sentence is a person at a meeting, and each one gets to ask the others, "How relevant are you to me right now?" Everyone answers, the loudest and most relevant voices are weighted most heavily, and each word updates its own understanding based on what it heard. Do this for every word at once, then repeat the whole process through dozens of stacked layers, and simple word representations gradually become rich, context-aware understandings of the sentence. Early layers might sort out grammar; deeper layers handle meaning, references, and logic. Nothing here is hand-coded. The model learned which words should attend to which purely from predicting text.

Why attention was the breakthrough

Before transformers, models read text strictly in order, one word after another, which made it hard to connect words far apart and slow to train. Self-attention lets a model consider all the words in a passage together and in parallel, so it can link a pronoun to a noun twenty words earlier as easily as to its neighbor, and it can be trained on huge datasets efficiently. That combination, long-range understanding plus parallel training, is what unlocked the leap from clumsy autocomplete to the capable models we use now. The number of these attention-and-processing layers, along with the count of internal parameters, is a big part of what people mean when they call a model "large."

How a model is trained, in two phases

The two phases of training a large language model — pretraining then post-training with RLHF
A model first learns raw prediction from a mountain of text (pretraining), then learns to be helpful and safe from human feedback (post-training). Illustration.

A model is not programmed with rules; it is trained. Training means starting with billions of internal numbers set to random values and nudging them, over and over, until the model gets good at its job. Those numbers are the parameters, sometimes called weights, and you can think of them as billions of tiny dials that together encode everything the model has learned. Frontier models have hundreds of billions of these dials. Training happens in two very different phases, and the distinction matters.

Phase 1: Pretraining, where it learns language

In pretraining, the model is shown a colossal amount of text, drawn from books, websites, code, and more, and given one relentless task: predict the next token. It reads a passage with the next word hidden, guesses, and is corrected against the real word. Each correction adjusts the dials a hair in the direction that would have produced a better guess. Repeat this across trillions of tokens and the model gradually absorbs grammar, facts, writing styles, and reasoning patterns, all as a side effect of getting better at prediction. This phase is enormously expensive and produces a "base model" that is a brilliant text predictor but an awkward assistant: ask it a question and it might reply with more questions, because on the open web a question is often followed by more questions.

Phase 2: Post-training, where it learns to be helpful

The second phase, post-training, turns that raw predictor into the polite, helpful assistant you actually talk to. It has two common parts. First, instruction tuning: the model is trained on many examples of a request paired with a good response, teaching it to answer rather than ramble. Second, learning from human feedback, often called RLHF (reinforcement learning from human feedback): people compare pairs of model answers and mark which is better, and those preferences are used to steer the model toward responses that are helpful, honest, and harmless. This is the phase that gives a model its manners, its refusal to help with dangerous requests, and much of its house style. If pretraining is reading the whole library, post-training is the apprenticeship that teaches the model how to be useful with what it read.

Parameters, and who can see them

Those trained parameters are the model. Whether a company publishes them is the line between a closed model, where you can only reach it through an API, and an open-weight model, where the parameters are downloadable and you can run the model yourself. That choice shapes cost, privacy, and control, which we cover in closed vs open-weight AI models, and if you want to run an open model on your own hardware, our guide to self-hosting an open-weight model walks through it. Open-weight families such as DeepSeek V4 and Kimi K2.7 sit on one side of this line, while Claude Opus 4.8 and GPT-5.5 sit on the other.

Why LLMs hallucinate (and what that word really means)

Why large language models hallucinate — they predict plausible text without verifying facts
A model optimizes for text that sounds right, not text it has checked, which is why confident, fluent errors slip through. Illustration.

Now the mechanism pays off, because it explains the single most important limitation of these tools. A hallucination is when a model states something false as if it were true: an invented citation, a fake statistic, a plausible but wrong answer. People often assume this is a bug to be patched. It is better understood as a direct consequence of how the model works.

Remember the core loop: the model predicts the most plausible next token given everything so far. It is optimizing for text that sounds right, not text that has been checked against reality. It has no built-in fact database to consult and no separate step where it verifies a claim before saying it. When you ask for a source and the model has genuinely seen the right one many times, it will likely produce it correctly. When it has not, it does not go blank; it generates the most plausible-looking citation, which may be entirely fictional, because a plausible citation is exactly what usually follows that kind of request in its training data. The model is not lying, because lying requires knowing the truth. It is doing what it always does, filling in the most likely continuation, and sometimes the most likely-sounding continuation is false.

What actually reduces it

This is why the fixes that work all involve giving the model something real to lean on rather than asking it to try harder. Grounding the model in retrieved documents, so it answers from provided text rather than memory, cuts fabrication sharply. Giving it tools, such as a search engine, a calculator, or a database, lets it look things up instead of guessing. And prompting it to show its reasoning or to say when it is unsure nudges it toward more honest output. But no amount of cleverness removes the underlying truth: an LLM predicts, it does not know, so anything important it tells you should be verified. Newer reasoning-focused models are noticeably better at catching their own mistakes, but "better" is not "immune."

The context window: the model's short-term memory

One more concept ties the practical experience together: the context window. This is the amount of text, measured in tokens, that a model can consider at once. Everything in a single interaction, your instructions, the documents you paste, the running back-and-forth, and the model's own reply, has to fit inside this window. Modern models have large windows, often hundreds of thousands of tokens, enough for a small book, but the limit is always there.

The context window is the model's entire working memory for a conversation. It has no memory of you between separate chats unless an application is deliberately built to store and re-supply that history. When a long conversation starts to "forget" what you said at the beginning, you are usually seeing the oldest tokens fall out of the window, or being crowded out, rather than the model changing its mind. Understanding this reframes prompting as a memory-management task: the useful skill is deciding what to put in the window, and what to leave out, so the model has exactly the context it needs and no distracting clutter.

The knowledge cutoff

Separate from the context window is the knowledge cutoff: a model only "knows," from training, about text created up to a certain date. Anything that happened after that point is invisible to it unless you supply it in the prompt or the model can search the web with a tool. A model confidently answering a question about last week's events, without a search tool, is often just predicting a plausible answer from stale training data. When freshness matters, either give the model current information directly or use a version wired to a live search tool.

What this all means when you use one

Put the pieces together and a practical picture emerges. A large language model is a next-token predictor, trained first to model language and then to be a helpful assistant, that reads and writes in tokens, represents meaning as coordinates, and uses attention to understand how words relate. That is not a limitation to apologize for; it is a description of a genuinely powerful tool, as long as you use it for what it is.

Three habits follow directly. First, treat it as a brilliant drafter and reasoner, not an oracle: it is superb at transforming, summarizing, explaining, and generating, and it needs a fact-check for anything consequential. Second, expect variability: because the model samples from likely next tokens, the same prompt can produce different answers, so a single output is a sample, not a verdict. Third, manage the context: give it the relevant material, be explicit about the format you want, and remember it only knows what is in the window plus what it learned before its cutoff.

The same core mechanism now spans a whole spectrum of tools. A conversational assistant and an autonomous coding agent are the same kind of predictor wired up differently, a distinction we draw out in agentic coding models vs chatbots. And because every model runs this loop with different training, sizes, and prices, the practical differences between them are real: our side-by-side breakdowns of Claude Sonnet 5 vs GPT-5.5, Claude Sonnet 5 vs DeepSeek V4, GPT-5.5 vs DeepSeek V4, and Claude Opus 4.8 vs GPT-5.5 show how the same underlying idea produces very different tools. You can also read our individual reviews of Claude Sonnet 5, GPT-5.5, and Gemini 3.1 Pro to see how each one behaves in daily use.

The mental model to keep

If you remember one thing, make it this: a large language model predicts the next word, then does it again. Everything else, the tokens, the embeddings, the attention, the two training phases, the hallucinations, the context window, is detail hanging off that single idea. Hold that picture and these tools stop being mysterious. You stop expecting a search engine and start using a remarkably capable pattern-completion machine: quick to draft, strong at reasoning through a problem you set up well, and always in need of a human to verify the facts that matter. Understand the loop, and you understand the tool.

Frequently Asked Questions

What is a large language model in simple terms?

A large language model is a computer program that generates text by repeatedly predicting the most likely next word, one small piece at a time. It learned this by reading an enormous amount of text and adjusting billions of internal numbers, called parameters, until its guesses matched real writing. It does not look facts up or understand meaning the way a person does; it predicts patterns in language, which is why it is fluent, creative, and occasionally confidently wrong.

How does an LLM actually generate text?

It reads the text so far, predicts the most likely next token, adds that token to the text, and predicts again, looping until the answer is complete. This is called being autoregressive, because each new word becomes part of the input for the next prediction. It is also why answers often stream onto the screen word by word: you are watching the prediction loop run in real time.

What is a token in a large language model?

A token is the unit of text a model reads and writes, usually a sub-word fragment rather than a whole word. Common words are often a single token, while longer or rarer words split into several pieces, such as "un," "believ," and "able." In English, one token averages about four characters or roughly three quarters of a word, so a thousand tokens is around 750 words. Models predict and are billed in tokens, not words.

What are embeddings in an LLM?

An embedding is a list of numbers that represents a token as a point in a vast space of meaning, so that words with similar meanings sit near each other and unrelated words sit far apart. This lets a model handle synonyms and paraphrases gracefully, because it works with positions in meaning-space rather than exact keywords. The model discovered these arrangements on its own, from the company each word keeps across billions of examples.

What is the transformer and self-attention?

The transformer is the model design behind nearly every modern LLM, introduced by Google researchers in 2017. Its key mechanism, self-attention, lets each word look at every other word in the passage and decide how much each one matters for understanding it. That is how a model figures out that "it" refers to "the trophy" rather than "the case." Attention gives models long-range understanding and lets them train efficiently in parallel.

What does it mean to train a large language model?

Training means starting with billions of internal numbers set to random values and nudging them, over and over, until the model gets good at predicting text. Those numbers, the parameters or weights, are billions of tiny dials that together encode what the model has learned. Training happens in two phases: pretraining, where it learns language from a mountain of text, and post-training, where it learns to be a helpful assistant.

What is RLHF and why does it matter?

RLHF stands for reinforcement learning from human feedback, a key part of post-training. People compare pairs of model answers and mark which is better, and those preferences are used to steer the model toward responses that are helpful, honest, and harmless. RLHF is what gives a model its manners, its house style, and its refusal to assist with dangerous requests, turning a raw text predictor into the assistant you actually talk to.

Why do large language models hallucinate?

Because the model predicts the most plausible next token, optimizing for text that sounds right rather than text it has checked. It has no built-in fact database and no separate verification step, so when it has not reliably seen the right answer, it still produces the most plausible-looking continuation, which can be entirely fictional. It is not lying, because lying requires knowing the truth; it is filling in a likely continuation that happens to be false. Grounding it in documents or tools reduces this.

What is a context window?

The context window is the amount of text, measured in tokens, that a model can consider at once. Everything in a single interaction, your instructions, pasted documents, the running conversation, and the model's reply, must fit inside it. It is the model's working memory, and it has no memory between separate chats unless an application deliberately stores and re-supplies that history. When a long chat starts to forget the beginning, the oldest tokens are falling out of the window.

Do LLMs understand what they are saying?

Not in the human sense. A model has no beliefs, intentions, or awareness; it manipulates patterns in language extremely well. It behaves as if it understands, because predicting text accurately requires encoding a great deal about grammar, facts, and reasoning, but there is no inner experience or genuine comprehension behind the words. Treating it as a capable pattern-completion machine, rather than a mind, leads to far better use of it.

What is a knowledge cutoff?

A knowledge cutoff is the date up to which a model learned from training text. Anything that happened after that point is invisible to the model unless you supply it in the prompt or the model can look it up with a search tool. A model answering a question about recent events without a search tool is often just predicting a plausible answer from stale data, so when freshness matters, provide current information or use a version wired to live search.

Why do LLMs give different answers to the same question?

Because the model does not always pick the single most likely next token; it samples from the top candidates, and that randomness produces variety. A setting often called temperature controls how adventurous this sampling is: lower values make answers more predictable and repetitive, higher values make them more varied and creative. This is why a single output should be treated as one sample rather than the model's definitive verdict.

Related Articles

Was this review helpful?
Anthony M. — Founder & Lead Reviewer
Anthony M.Verified Builder

We're developers and SaaS builders who use these tools daily in production. Every review comes from hands-on experience building real products — DealPropFirm, ThePlanetIndicator, PropFirmsCodes, and many more. We don't just review tools — we build and ship with them every day.

Written and tested by developers who build with these tools daily.