How Large Language Models Actually Work

Every AI chatbot, coding assistant, and agent you have used is built on a large language model, or LLM. They can feel like they understand you, reason with you, and know things. Underneath, they are doing something far simpler than that impression suggests, and understanding what it is explains most of their strange behavior.

The one-sentence version #

An LLM predicts the next chunk of text, given everything before it, over and over.

That is genuinely most of it. You give it some text (your question, the conversation so far), and it produces the most likely next chunk, then the next, then the next, one piece at a time, until it has built a full response. It is autocomplete, scaled up almost beyond recognition.

What it learned, and how #

An LLM is trained by being shown an enormous amount of text (books, code, websites, conversations) and made to play one game billions of times: predict the next word in a passage, then get corrected when it is wrong. Do that at a large enough scale and something surprising happens. To predict text well, the model has to absorb the patterns underneath it: grammar, facts, styles of argument, how code is structured, how a recipe is written, how a polite reply sounds.

Nobody programmed it with rules for any of that. It picked up the patterns because they help it predict the next chunk. The “intelligence” you experience is those absorbed patterns being replayed to continue whatever text you started.

Why something so simple works so well #

It is fair to be skeptical that “fancy autocomplete” could write a working function or explain a concept. The reason it can is that predicting text well, across a huge range of text, turns out to require a lot. To reliably continue a math explanation, you have to have absorbed how the math works. To continue a piece of code, you have to have absorbed the structure of the language. Prediction at scale forces the model to internalize the patterns behind the words, and those patterns are powerful enough to be genuinely useful.

Why it sounds confident even when it is wrong #

Here is the part that trips everyone up. An LLM is not looking anything up. It is not consulting a database, and it has no built-in sense of whether what it is saying is true. It is producing the most plausible continuation of the text.

Plausible and true are usually the same thing, which is why it works so often. But when they come apart (an obscure fact, a made-up citation, a detail it never really absorbed), the model still produces a fluent, confident-sounding answer, because fluent and confident is what it was trained to produce. It does not hesitate, because it has no mechanism for hesitation. This is why LLMs hallucinate, and why the confidence in the writing tells you nothing about its accuracy.

What an LLM is not #

Clearing up a few common misconceptions makes the behavior much easier to predict:

  • It is not a search engine. It does not look up current information. On its own, it only knows the patterns it absorbed during training, frozen at some point in the past. (Giving it live access to information is a separate trick, called RAG or tool use.)
  • It is not a database. It does not store facts in neat rows it can retrieve exactly. It stores patterns, which is why it can paraphrase a concept perfectly and still get a specific number wrong.
  • It does not think the way you do between messages. It produces its answer, and that is the whole of its “thought.” (Newer reasoning models add a working-out step before the answer, but that is a deliberate addition, not the default.)

Why this frame is worth keeping #

Once you hold onto “it predicts plausible text,” a lot of AI behavior stops being mysterious. It explains why prompting well matters so much: you are steering the prediction. It explains why the model needs to be handed facts to be reliable on specifics. It explains the confident wrongness. And it explains why the same model can be brilliant and useless in the same session, depending on whether the plausible continuation happens to be the correct one.

Everything else in AI (agents, tools, memory, reasoning) is built on top of this one prediction engine. It all starts with a model guessing the next chunk of text, and doing it well enough to be worth building on. A good next step from here is understanding what those “chunks” actually are: tokens.