Technology

How does ChatGPT work?

ChatGPT is a language model, and so are Gemini and Claude. It doesn't know things and doesn't look them up. It guesses the next word, one at a time, from billions of numbers tuned by a guessing game played trillions of times.

· 2 min read· Watch the full answer, 3:00

The full answer, with diagrams. 3:00. Watch on YouTube

The mechanism, in three steps

  1. A guessing game. The model reads an enormous pile of text with the next word covered, guesses it, and every wrong guess nudges one of its dials a little. That is repeated a few trillion times.

  2. Billions of dials, no sentences. Nothing it read is stored. What remains is billions of tiny numbers, tuned until the guesses come out right: patterns, not a library.

  3. One word at a time. You type a question. It guesses the next word, adds it on, and guesses again, thousands of times. On its own it never looks anything up, which is why it can be brilliant and sometimes confidently wrong.

Check yourself

Does the model keep a copy of the text it was trained on?

No. Training adjusts its numbers; the text itself is not stored. That is why it cannot quote a source the way a search engine can.

Why can it be confidently wrong?

Because it is producing the most likely next word, not checking a fact. A fluent, likely-sounding sentence and a true one are not always the same sentence.

What does "word" really mean here?

A token: a word or a piece of one. "Unbelievable" might be three tokens. The mechanism is the same either way.

ChatGPT is a language model, and so are Gemini, Claude and the assistants built on them; everything below applies to all of them. Image recognisers, recommendation feeds and self-driving cars are different machines with different mechanisms, and they get their own answers.

Your phone’s keyboard already does a small version of this. Type “I’m on my” and it offers “way”. It learned that from a lot of text, not from knowing where you are going. A large language model is the same idea at a scale that is hard to picture.

Step one is a guessing game. Take a huge pile of text, cover the next word, and ask the model to guess it. When the guess is wrong, nudge the model’s internal numbers a little so it would have done better. Then move to the next word and do it again. Meta’s Llama 3 models were trained on about 15 trillion tokens this way, and the nudging is the ordinary maths of gradient descent, applied an unimaginable number of times.

Step two is what is left afterwards. Not the text. The model does not keep a copy of anything it read. What it keeps is its numbers, the parameters, billions of them: GPT-3 had 175 billion. They are the dials, tuned until the guesses come out right. It is not a library with a lookup. It is a very well-tuned hunch machine.

Step three is what happens when you type. Your question becomes the start of a text. The model guesses one word, adds it to the text, and guesses the next, over and over, until it guesses that the answer should stop. That loop is the whole trick. Nothing is fetched. Nothing is checked, unless the app around the model is connected to a search tool and does that first.

This is also why it can be confidently wrong. The model is producing the most likely next word given everything so far, and the most likely sentence is usually true, but not always. A confident, fluent, wrong answer is not a glitch. It is what next-word guessing does when the likely words and the true words come apart, which is exactly what OpenAI’s own analysis of hallucination describes.

Say it back: it doesn’t know. It guesses the next word, really well.

Sources

Questions this also answers

Is that all ChatGPT does, guess the next word?

That is the core of the model. The product around it adds things: a system prompt, a memory of the conversation, and often a search tool, so the app can look things up before the model guesses. The model on its own does not.

Is all AI like this?

No. This is the language kind. A face recogniser, a recommendation feed or a self-driving car is trained by a related guessing game, but on pictures, clicks or sensor data rather than text, and produces a label, a ranking or a steering angle rather than the next word. Same family, different machines.

So does it understand what it says?

This article only describes the mechanism. Whether guessing the next word extremely well counts as understanding is a real debate, and not one a one-minute answer should settle.