AI from Zero · Lesson 4 of 6

How ChatGPT works

The clearest plain-language explanation of large language models you will read. No maths, just the one simple thing they actually do.

Beginner12 minute read

ChatGPT can write essays, explain quantum physics, and crack jokes. It feels like it understands you. So the honest truth is surprising: underneath, it is doing one strikingly simple thing, over and over. It is guessing the next word. That is not a simplification hiding the real magic. It genuinely is the whole trick, and this lesson shows you exactly how it turns into something that feels intelligent.

It predicts the next word

A large language model, the kind of AI behind ChatGPT, has one job: given some text, predict what word most likely comes next. Type "The capital of France is" and it predicts "Paris". Then it adds that word, looks at the whole thing again, and predicts the next word. And the next. One word at a time, it writes a whole reply.

That repeated guess-the-next-word, using its own output as it goes, is how a machine that only predicts words ends up writing paragraphs, poems, and code.

Try it: be the language model

Below is a tiny version of the same idea. Start with a few words, and it offers the most likely next words with their odds, just like the real thing (only much, much smaller). Keep clicking to build a sentence one word at a time.

Interactive

Next-word predictor

Click a predicted word to add it. The bars show how likely the model thinks each one is.
The real ChatGPT does exactly this, but with a vocabulary of tens of thousands of word-pieces and billions of learned patterns instead of a handful.

How did it learn the odds?

Remember lesson 2: AI learns from examples. A language model is trained by reading a staggering amount of text, much of the public internet, books, and articles, and playing a simple game billions of times: cover the next word and try to guess it. Every wrong guess nudges it to do better. After enough practice, it has absorbed the patterns of language: grammar, facts, styles, and the way ideas tend to follow one another.

It also breaks text into pieces called tokens (roughly, word-fragments) and it is really predicting the next token. That detail lets it handle any word, even ones it has never seen, but the idea is the same: predict what comes next.

Why it sounds smart but does not "know"

Here is the crucial catch. The model is predicting likely words, not true ones. Usually likely and true line up, because truthful text is common. But not always. When the model does not have the pattern, it will still confidently produce plausible-sounding words, which may be completely made up. This is called a hallucination, and it is not a bug it will simply grow out of; it is a direct result of how the machine works.

The most important takeaway
ChatGPT does not look anything up and does not know whether it is right. It generates the most plausible continuation. That is why it can be brilliant and confidently wrong in the same breath, and why you should always check anything that matters.

So what is a transformer?

You will hear that these models are built on a transformer. In one line: a transformer is the particular design that lets the model weigh which earlier words matter most when predicting the next one, its way of paying attention to context. That is what made these models so good. How it works in detail is a topic in itself, and if this lesson has you hooked, that is exactly where to go next.

You now understand the big one
Every chatbot, from ChatGPT to the rest, is at heart a next-word predictor trained on enormous text. Hold onto that and you understand modern AI better than most.
Scroll to Top