
How Large Language Models Actually Work (Without the Math)
In May 2023, a federal judge in New York sanctioned two lawyers for filing a legal brief full of court cases that didn’t exist. Six of them, complete with quotes, docket numbers, and judicial reasoning. The lawyers hadn’t invented the cases themselves. They’d asked ChatGPT to find supporting precedent, it had confidently supplied six, and nobody checked before filing. When the opposing counsel couldn’t locate a single one, the case, Mata v. Avianca, became the cautionary tale that gets told every time someone asks whether it’s safe to trust an AI chatbot with something that matters.
The interesting part isn’t that the lawyers got caught. It’s why the chatbot did that in the first place. It didn’t glitch. It didn’t lie in the way a person lies. It did exactly what it was built to do: produce the most plausible-sounding continuation of a legal brief, sentence by sentence. It just so happened that “plausible-sounding” and “true” aren’t the same thing, and nothing in how the system works forces them to line up.
Once you understand the actual mechanism, that outcome stops being a mystery and starts being predictable. That’s the goal of this article: to open the hood on how large language models work, in plain language, with no equations and no computer science degree required.
Quick answer: A large language model is a computer program trained on enormous amounts of text to do one thing extremely well: predict the next likely word (technically, the next “token”) given everything written so far. It builds an answer one small piece at a time, guided by patterns it learned during training, not by looking facts up or reasoning the way a person does. Everything else, including how convincingly human it sounds, follows from that one core mechanism.
Here’s what you’ll walk away knowing:
- The core trick behind every LLM is next-token prediction, done billions of times during training and once per word when it answers you.
- Words get broken into pieces called tokens before the model ever sees them, which explains some genuinely odd LLM behavior, like struggling to count letters in a word.
- “Attention,” the breakthrough idea from 2017, is what lets the model figure out which earlier words actually matter to the one it’s about to write.
- Training happens in stages: first the model learns language patterns from a huge pile of text, then it’s taught to follow instructions and hold a conversation.
- Hallucination isn’t a rare malfunction. It’s a direct, structural consequence of a system whose only goal is plausibility, not truth.
What a large language model actually is
Strip away the branding and a large language model is a piece of software trained to do one narrow job: given some text, predict what text is most likely to come next. That’s the entire mandate. Not “understand the world,” not “reason like a person,” not “know things” in the way a librarian knows things. Predict the next likely chunk of text, based on statistical patterns learned from an enormous amount of writing.
“Large” refers to the sheer scale involved, both in how much text the model was trained on and in how many internal parameters (the adjustable numeric settings that store what it learned) it has. Modern frontier models have on the order of hundreds of billions of these parameters. The 2020 GPT-3 model, one of the first to make the wider world sit up and pay attention, had 175 billion of them, a jump of more than 100 times over its own predecessor two years earlier. Later models have grown in different, less publicly disclosed ways, but the underlying idea hasn’t changed: more parameters, trained on more text, tend to produce a model that captures more subtle patterns in language.
“Language model” is the accurate part of the name, and it’s worth taking literally. It’s a model of language, of how words and ideas tend to follow one another in human writing, not a model of facts, and not a database of verified information. That distinction explains almost everything confusing about how these tools behave, so it’s worth sitting with before we go any further.
None of this started with ChatGPT. Predicting the next word in a sentence is a decades-old idea in computational linguistics, going back to simple statistical models that just counted how often one word followed another. Those early approaches could only “remember” a word or two of context, which made them useless for anything beyond short, generic phrases. Later architectures, recurrent neural networks in particular, extended that memory but still processed text strictly in order, one word affecting the next in a chain, and still lost track of anything said too far back. What changed everything wasn’t a bigger version of those older ideas. It was a genuinely different architecture, which we’ll get to shortly, that let a model weigh the full context at once instead of one word at a time.
The one job it does, over and over: predicting the next piece of text
Here’s the whole trick, stated plainly: an LLM looks at the text so far and asks, “given everything I’ve seen written like this before, what’s the most likely thing to come next?” Then it writes that. Then it looks at the slightly longer text, including what it just wrote, and asks the same question again. And again. And again, one small step at a time, until it decides the response is complete.
That’s genuinely it. There’s no separate “thinking module” bolted onto the side, deliberating about truth or checking a fact database before each word. The prediction step is the entire mechanism.
To make this concrete: if you feed a model the start of the sentence “The capital of France is,” it doesn’t retrieve a stored geography fact from a table somewhere. It has, during training, seen that specific pattern (or extremely similar ones) so many times, associated so strongly with the word “Paris,” that predicting “Paris” next is simply the overwhelmingly likely continuation. The model produces the correct answer, but through pattern strength, not lookup.
This is also why the popular comparison to your phone’s autocomplete isn’t lazy or dismissive, it’s structurally accurate. Both systems do the same core job: predict a likely next piece of text given what came before. The difference is one of scale and refinement so large it changes what the tool is capable of, the way comparing a paper airplane to a jet undersells the jet by pointing out they’re both technically gliders. Same principle, staggeringly different execution.
Step one: breaking your words into tokens
Before a model can predict anything, your text has to be converted into a form it can work with. Models don’t process raw letters or whole words directly, they process tokens, chunks of text that are often smaller than a word and sometimes exactly one word, depending on how common that word is.
This chunking happens through an algorithm called byte pair encoding (BPE), originally invented as a data compression technique long before anyone used it for AI. The idea: start with individual characters, then repeatedly merge whichever pair of characters or character-chunks appears most often in a huge body of text, building up a vocabulary of common pieces. Common English words like “the” or “is” typically end up as single tokens, because they’re everywhere. Rarer words, unusual names, or non-English text often get split into two, three, or more subword pieces, because the model never saw them often enough as whole units to justify giving them their own token.
This is a good moment to link this back to a concept you may have already run into: our plain-English AI glossary covers tokens as one of the core terms worth knowing, since pricing, context limits, and a lot of odd model behavior all trace back to them.
Tokenization also explains a genuinely funny category of LLM mistakes. Ask a model to count the letters in a word, and it sometimes gets it wrong in a way that seems almost embarrassing for something this sophisticated. The reason: the model isn’t seeing “s-t-r-a-w-b-e-r-r-y” as nine individual letters the way you are reading this sentence. It’s seeing two or three token chunks, and counting individual letters inside a token is a task it was never directly trained to do well, because its entire world is built out of tokens, not characters. The model isn’t bad at spelling. It’s working with a different unit of representation than you’d assume, and the mismatch shows up as an odd, specific blind spot.

Step two: turning tokens into meaning
Tokens are still just symbols. Before the model can do anything useful with them, each token gets converted into a long list of numbers called an embedding. You don’t need the math here, just the intuition: think of an embedding as a set of coordinates that place a word’s meaning in space, such that words used in similar contexts end up near each other.
“King” and “queen” end up close together in this space. So do “doctor” and “physician.” Meanwhile “king” and “banana” land nowhere near one another, because they essentially never show up in similar contexts across the model’s training data. The model never explicitly learns a dictionary definition for any word. It learns these coordinates purely from noticing which words tend to appear around which other words, across a staggering volume of text, and that turns out to be enough to capture a remarkable amount of real meaning and relationship.
This is the step that lets a model handle synonyms, analogies, and context sensibly, even for words it’s never seen used in that exact combination before. It has a coordinate-space sense of what the word is “like,” and that’s often enough to generalize correctly.
Step three: attention, deciding what actually matters
Here’s the part that actually made modern LLMs possible, and it has a specific birthdate: June 2017, when eight researchers at Google published a paper with an almost cocky title, “Attention Is All You Need.” It introduced an architecture called the Transformer, and it is, without much exaggeration, the single idea underneath every major LLM you’ve used. By 2026 that paper had been cited more than 250,000 times, placing it among the most-cited scientific papers of the century.
The problem it solved: earlier language models processed text strictly in order, one word affecting the next in a chain, which made it hard for information from early in a sentence (or paragraph, or document) to still be influencing the model’s decisions much later on. Long-range relationships between words kept getting lost.
Attention fixes this by letting the model directly weigh every other word in its current context against the word it’s about to predict, no matter how far apart they are. Take the sentence: “The trophy didn’t fit in the suitcase because it was too big.” What does “it” refer to, the trophy or the suitcase? A human resolves this instantly using world knowledge (trophies don’t shrink to fit; oversized things don’t fit in undersized containers). An attention mechanism does something structurally similar: it learns, from patterns across enormous amounts of text, to weigh “trophy” much more heavily than “suitcase” when predicting what comes after “it” in a sentence shaped like this one. It’s assigning a kind of relevance score between every pair of words in the passage, then using those scores to decide what to focus on.
The other reason attention mattered so much is almost boring by comparison, but arguably more important in practice: unlike the older word-by-word architectures, Transformer-style attention could be computed in parallel across huge chunks of text at once, rather than strictly one step after another. That made it dramatically faster to train on the scale of hardware available, which is a big part of why model capability accelerated so quickly once this architecture took over.
Step four: predicting one piece at a time, then doing it again
With tokens converted to meaningful coordinates and attention figuring out which parts of the text matter to which other parts, the model finally does its actual job: it produces a probability for every possible next token, essentially a ranked list of “here’s how likely each possible next word is, given everything so far.” Then it picks one, appends it to the growing text, and repeats the entire process to pick the next one.
This loop, predict, pick, append, repeat, is called autoregressive generation, and it’s why watching a chatbot respond word-by-word (or in small bursts) isn’t a cosmetic animation, it’s often a fairly literal look at the mechanism actually running.
It’s also worth knowing that the model usually doesn’t just pick the single highest-probability token every time. Most systems sample from that probability distribution, weighted toward likely options but with some controlled randomness, often adjustable through a setting called “temperature.” Lower temperature makes output more predictable and repetitive; higher temperature makes it more varied and occasionally more surprising. This is the direct answer to a question a lot of people ask without knowing why it happens: why does the same prompt sometimes produce a noticeably different answer the second time? Because the model isn’t retrieving a fixed answer. It’s re-rolling a weighted set of probabilities and landing on a slightly different path through them.

Why the same model can write a sonnet and still fumble simple arithmetic
This one confuses people more than almost anything else about LLMs, and the mechanism explains it cleanly. A model that can draft a legal contract, explain a tax rule, or write convincing poetry will sometimes get a basic multi-digit multiplication problem wrong, in a way that feels bizarre for something that sophisticated. It isn’t a contradiction. It’s a direct consequence of what the model was actually trained to do.
Writing a sonnet is, structurally, exactly the kind of task next-token prediction excels at: there’s an enormous amount of poetry in the training data, clear patterns of rhythm and rhyme to draw on, and no single “correct” output to match exactly. Multiplying two large numbers is the opposite kind of task. It has exactly one correct answer, reached through a fixed procedure, and the model isn’t running that procedure. It’s predicting what a plausible-looking answer to a multiplication problem tends to look like, based on patterns in text, the same mechanism it uses for everything else. For small, frequently-seen calculations (like 7 times 8) that pattern is reinforced enough times during training that it’s essentially memorized and reliable. For a novel calculation with larger numbers, there’s no memorized pattern to fall back on, and the model is left generating a number that merely resembles a correct answer in form.
This is exactly why the more capable modern AI products don’t rely on the base model to do arithmetic at all. Many chat assistants detect a math or coding question and quietly hand it off to an actual calculator or code interpreter running in the background, then bring the real, computed result back into the conversation. That’s not a workaround for a flaw so much as an acknowledgment of what the underlying mechanism is and isn’t good at: language and pattern completion, not precise, step-by-step computation.
Where does the “knowledge” actually come from? How training happens
Everything described so far is the mechanism, the machinery that runs every single time a model produces a response. But that machinery starts out knowing nothing. It has to learn its patterns somewhere, and that happens in stages, well before you ever type a message to it.
Phase one: pretraining, reading almost everything
The first and by far most computationally expensive stage is pretraining. The model is shown a colossal amount of text, drawn from books, websites, articles, code, forums, and more, and given exactly one exercise, over and over, across that entire dataset: predict the next token. Get it right, adjust the model’s internal parameters slightly to reinforce that pattern. Get it wrong, adjust them slightly the other way. Repeat this billions upon billions of times.
GPT-3, again a useful reference point simply because OpenAI published detailed numbers about it back in 2020, was trained on several hundred billion tokens of text. This single stage is where a model absorbs grammar, facts stated often enough in its training data, writing styles, coding patterns, and an enormous range of general knowledge, all as a side effect of getting extremely good at one repetitive exercise: guess the next piece of text.
It’s worth being precise about what this produces. A freshly pretrained model isn’t yet a helpful assistant. It’s something closer to an extremely well-read autocomplete engine with no particular interest in being useful, following instructions, or giving you a clean, direct answer. Ask it a question and it might continue your question with more questions, because that’s a pattern it’s also seen plenty of times on the internet. That gap is what the next stage closes.
Phase two: supervised fine-tuning, learning to follow instructions
In this stage, the model is trained further on a smaller, carefully constructed set of examples that specifically look like the behavior you actually want: a user’s question followed by a genuinely helpful, well-formatted answer. This teaches the model the shape of the conversation you expect, question in, direct and useful answer out, rather than the more meandering, unstructured patterns it absorbed from general internet text.
Phase three: reinforcement learning from human feedback, learning what “good” looks like
The final major stage is where things got genuinely interesting for how usable these models became, and it has a specific name and origin worth knowing: Reinforcement Learning from Human Feedback, or RLHF. OpenAI’s 2022 InstructGPT paper is the landmark demonstration of this approach. The process: have the model produce several candidate answers to the same prompt, have human reviewers rank those answers from best to worst, then use those rankings to train a separate “reward model” that learns to predict which kinds of answers humans prefer. The language model is then further adjusted to produce more of the answers the reward model scores highly.
The result reported in that research was striking enough to be worth repeating: human evaluators preferred outputs from a much smaller, 1.3-billion-parameter InstructGPT model over the outputs of the original 175-billion-parameter GPT-3 it was built from, and the fine-tuned version also produced meaningfully fewer fabricated facts and toxic responses. Raw scale, in other words, wasn’t what made GPT-3 hard to use well. The absence of this alignment stage was.
Put the three stages together and you get the shorthand version worth remembering: pretraining teaches the model language and general knowledge, supervised fine-tuning teaches it the shape of a helpful conversation, and RLHF teaches it, approximately, what a human being actually considers a good answer.
Why it sometimes just makes things up
Now the Mata v. Avianca story from the opening makes complete mechanical sense. When those lawyers asked ChatGPT to find supporting case law, the model wasn’t searching a legal database, it doesn’t have one built in. It was doing the one thing it was built to do: predicting a plausible continuation of a request that looked like “give me case citations that support this legal argument.” Legal citations have an extremely recognizable format, case name, volume number, reporter, page, year, and the model had absorbed that format thoroughly during training. So it generated text in exactly that format. It just wasn’t anchored to anything real, because nothing in the mechanism requires it to be.
When one of the lawyers directly asked the chatbot to confirm the cases were real, it reportedly assured him they could be found in “reputable legal databases such as LexisNexis and Westlaw.” That confirmation was itself just another plausible-sounding continuation, generated the exact same way as the fake cases it was vouching for. There was no internal fact-checking step available to catch the error, because there’s no internal fact-checking step in this architecture at all. Judge P. Kevin Castel, presiding over the case, described one of the fabricated opinions as reading like “gibberish” on closer inspection, and sanctioned the attorneys $5,000 for what he called acting in bad faith by filing it.
This is what people in AI call a hallucination, and once you understand next-token prediction, the term stops sounding mysterious. It’s not the model glitching or lying. It’s the model doing its actual job, generating the statistically likely next piece of text, in a situation where “statistically likely” and “factually true” have quietly come apart. The model has no separate mechanism that says “I don’t actually know this, I should stop.” Silence was never one of the patterns it was strongly trained to produce; a confident, complete-sounding answer almost always was.
We go deeper on exactly why this keeps happening even in the newest, most capable models, and on the concrete habits that catch it, in our dedicated breakdown of AI hallucinations.
Five common misconceptions about how LLMs work
“It looks facts up in a database somewhere.” Not by default. A plain LLM only has what it absorbed into its parameters during training. Some AI products bolt a genuine search step onto the model, an approach called retrieval-augmented generation, or RAG, so the model can read real, current documents before answering. But that’s an added system, not something a base language model does on its own.
“Bigger models just memorize more of the internet.” Mostly no. With far more training examples than parameters, brute memorization wouldn’t generalize to the huge range of novel questions people actually ask, and generalizing to new situations is precisely what these models are good at. What gets built during training functions more like a compressed map of patterns and relationships in language than a stored copy of specific text, though some verbatim memorization of frequently repeated passages does happen and is an active area of research and concern.
“It understands language the way a person does.” It has learned, with extraordinary precision, which words and ideas statistically follow which other words and ideas. That’s a genuinely different thing from comprehension, intent, or awareness, even when the output is indistinguishable from something a thoughtful person would write.
“The same prompt should always get the same answer.” Only if the sampling randomness is turned all the way down, which most consumer chatbots don’t do by default. Normal behavior involves controlled randomness at each prediction step, so re-running an identical prompt can land on a different, equally plausible path through the model’s probabilities.
“It’s connected to the internet and checking things as it answers.” By default, no. A base language model only knows what got baked into its parameters during training, which stops at a fixed cutoff date. Some AI products add a genuine browsing tool on top, which lets the model issue a real search and read real, current pages before answering, but that’s a separate system bolted onto the model, not something the underlying mechanism does automatically. If a tool doesn’t clearly show you a search step or cited sources, assume it’s answering from memorized training patterns, not a live check.
“A longer, more articulate answer is a more accurate one.” Length and confidence are stylistic patterns the model learned from confident, articulate writing in its training data. Neither is a signal the model uses to represent how certain it actually is, mostly because it doesn’t have a reliable internal signal for that at all.
What this means for how you actually use AI tools
None of this is trivia. It changes how you should actually use tools like ChatGPT, Claude, and Gemini day to day.
Treat fluency as a style, not a truth signal. A model that writes a beautifully structured, confident paragraph about something false will read exactly like a model writing a beautifully structured, confident paragraph about something true. The writing quality tells you nothing about accuracy, because both are produced by the same mechanism. Verify anything you plan to rely on, especially names, dates, citations, statistics, and anything with real consequences if it’s wrong.
Give the model a strong pattern to complete, and it will generally complete it well. This is most of what good prompting actually is: instead of a vague request, hand the model the shape of the answer you want, context, format, constraints, examples, because you’re not commanding a reasoning engine, you’re steering a very capable pattern-completion engine toward the specific pattern you need.
Remember that everything the model “knows” is frozen at training time, unless the specific tool you’re using has a retrieval or browsing feature layered on top. Ask a plain LLM about something that happened after its training cutoff and you’re asking it to guess based on the closest patterns it has, which is a fundamentally different situation from asking it about something well-documented across its training data.
It also helps to know that a model only ever “sees” a limited amount of text at once, called its context window, which includes your entire conversation history plus any documents you’ve pasted in. Once a conversation runs long enough to spill past that limit, earlier parts quietly fall out of view, which is why a chatbot can appear to “forget” something you told it ten minutes ago. That’s a large enough topic on its own to deserve its own explanation, but the short practical version is: for anything that really matters, restate the key facts rather than assuming the model still has them in view.
And take hallucination seriously as a design feature of the mechanism, not an occasional bug you might get unlucky with. The more specific, obscure, or high-stakes your question, the more worth double-checking the answer becomes, exactly like those two lawyers wish they had.
A one-paragraph mental model to keep
If you remember nothing else from this article, remember this sequence: your text gets chopped into tokens, each token gets converted into coordinates that capture meaning, an attention mechanism figures out which of those tokens matter most to each other, and the model uses all of that to predict the single most probable next token, then repeats the whole process on the slightly longer text, one token at a time, until it decides it’s done. Everything it “knows” was baked into its parameters beforehand, first through predicting text across a vast training set, then through further training that shaped it into a helpful, instruction-following conversationalist. There is no separate fact-checker, no built-in truth detector, and no awareness. Just an extraordinarily well-tuned pattern-completion machine, which happens to be good enough to be genuinely, enormously useful, provided you understand exactly what you’re actually talking to.
The bottom line
A large language model isn’t a digital brain and it isn’t a search engine with a friendly voice. It’s a next-token predictor, trained on a staggering amount of human writing, refined to follow instructions and hold a conversation, and running the exact same mechanical loop whether it’s explaining a recipe or, as two unlucky lawyers found out, fabricating six court cases with total conviction.
That’s not a reason to distrust these tools wholesale. It’s a reason to use them with your eyes open: as remarkably capable pattern-completion engines that reward good prompting, save enormous amounts of time, and still need a human checking the parts that matter. Now you know exactly what’s happening between your question and its answer. That alone puts you ahead of most people using these tools every day.
Frequently asked questions
Does a large language model actually understand what it's saying?
Not in the way a person does. An LLM has no beliefs, goals, or awareness. It has learned extremely detailed statistical patterns in how humans use language, and it applies those patterns to predict plausible next words. The output can be so coherent that it feels like understanding, but there's no comprehension happening behind it, just very sophisticated pattern completion.
Is ChatGPT just a really advanced autocomplete?
Mechanically, yes, that's a fair description of the core mechanism: both predict the next likely piece of text based on what came before. The difference is scale and training. Your phone's autocomplete is trained on a small model and a narrow dataset. An LLM is trained on a huge slice of the internet and then further trained to follow instructions and hold a conversation, which is why the comparison undersells how capable the result is, even though the underlying trick is the same.
Why does an LLM give a different answer if I ask the same question twice?
Most LLMs don't always pick the single most likely next word. They sample from a probability distribution, weighted toward likely options but not locked to the top one. This controlled randomness, often adjustable as a 'temperature' setting, is why answers vary slightly between runs even when nothing else has changed.
If LLMs just predict likely words, why do they sometimes make up facts that sound completely real?
Because the model's only job is producing plausible-sounding text, not verified text. When it doesn't have a strong pattern to draw on, it doesn't stay silent, it generates the most statistically plausible continuation anyway, which can be a fabricated fact stated in a perfectly confident tone. This is called a hallucination, and it's a direct consequence of how the model works, not a bug that shows up occasionally.
Do bigger language models just memorize the internet?
Mostly no. A model with far more parameters than training examples would need to memorize to score well on training data, but memorization doesn't generalize to new questions it's never seen, and generalizing is exactly what these models do. What they build during training is closer to a compressed map of patterns, relationships, and structure in language than a lookup table of stored sentences, though limited verbatim memorization of frequently repeated text does happen.
What's the difference between a large language model and 'AI' in general?
AI is the broad field of making machines perform tasks that normally require human intelligence. A large language model is one specific kind of AI: a neural network trained on text to predict and generate language. Image generators, recommendation systems, and self-driving perception systems are all AI too, but they aren't LLMs, they're built and trained completely differently.


