Academy · Lesson 01 · Start here

How does ChatGPT work? It guesses the next word, one token at a time

Everything ChatGPT does comes from one move repeated thousands of times: look at the text so far, score every possible next piece, pick one, repeat. Once you have operated that move with your own hands, most of the mystery goes.

Rohan KumarSansser
18 min2 labs
By the end you can
  • Say what a token is and why Hindi costs five times more of them than English
  • Read a probability bar chart from a real model and say what it means
  • Explain what the temperature setting does, and why high temperature invents things
  • Answer 'is it just predicting the next word?' properly: yes, and that is not a small thing
Part 1

The one move

Here is the whole of ChatGPT in one sentence. Given the text so far, score every possible next piece of text, pick one, add it to the text, and do it again.

That is it. There is no plan for the paragraph. There is no lookup of facts in a database. There is no understanding in the way you understand this sentence, and also no trickery: just a very good guess about what comes next, made again and again, fast enough that it looks like typing.

People hear this and say "so it's just autocomplete". Hold that thought until the end of the lesson. You will operate the move yourself, on a real model, and then decide whether "just" is the right word.

Lab

Text is not words to a model. It is tokens.

Before any guessing, the text is chopped into tokens: pieces that are sometimes a word, sometimes part of a word, sometimes a single character or a piece of punctuation. The chopping rules were learned from a mountain of mostly English text, so English gets efficient pieces. Everything else gets chopped finer.

OpenAI's own rule of thumb is that one token is about four characters of English, so 100 tokens is roughly 75 words. That rule breaks the moment you leave English. Try the Hindi example in the lab and compare it with the English one above it. Same sentence, same meaning, more than five times the tokens. You pay per token, the model's memory is counted in tokens, and its "attention" is spread across tokens. So a Hindi speaker gets less of everything for the same price. This is the single most important thing about AI that nobody in India is told.

Lab 01How text becomes tokensReady

These splits come from GPT-2's tokenizer, the ancestor of the one ChatGPT uses. Pick a text and watch it break into pieces. The model never sees letters or words, only these pieces.

Lab

Every token gets a score

Now the guess. The model takes all the tokens so far and produces one number for every token in its vocabulary. GPT-2, the model in our labs, has 50,257 of them. Those numbers are turned into probabilities that add up to 100 percent. The bar chart you are about to see is the real output of a real model, not a drawing.

Three things to notice. First, the model is rarely sure: after "The capital of France is", the top guess is "the", not "Paris", because in the text it learned from, that phrase is followed by all kinds of things. Second, the probabilities are spread over thousands of tokens; the eight bars we show hold most of the bets but never all of them. Third, the model is small and old. GPT-2 was released in 2019 and has 124 million parameters; today's models have a thousand times more and are much better at this. The move is identical.

Lab 02A real model picks its next wordReady

Real GPT-2 output. Choose a start, read the odds, then take the top word or roll the dice. Slide the temperature and watch the same odds reshape. Each start has been run three words deep.

Part 4

Temperature: the dial between boring and unhinged

You just used the most misunderstood setting in AI. Temperature does not make the model smarter or dumber. It reshapes the odds before the dice are rolled. At low temperature the top choice gets nearly all the probability, so you get the same safe answer every time. At high temperature the odds flatten and the long tail of unlikely tokens gets real weight.

Watch the percentages in the lab as you slide it. At 0.1 the top word is close to certain. At 2.0 the eight bars together hold much less, and "roll the dice" lands on something strange. That is not a bug. It is the same model with a different dial. And it is the honest explanation of one kind of hallucination: a low-probability token got picked, and then every token after it had to make sense of it.

Chat apps hide this dial and set it somewhere in the middle. Developers can set it. When someone says a model "got creative", often they mean the dial was up.

Part 5

Why it rarely says the same thing twice

People are surprised that the same question gives different answers. Now you know why: the pick is a dice roll weighted by the odds. Press "roll the dice" a few times from the same start and you get different sentences, each one plausible. Only at the very lowest temperature does it become deterministic, and even then small differences in the text so far change the odds.

This is also why "regenerate" works. You are not asking the model to think harder. You are rolling again.

Check yourself

So is it just autocomplete?

Yes, mechanically. Every token comes from the move you just operated. And no, in the way people mean it. On the r/singularity thread that argues this out every few months, the top answer puts it well: next-word prediction describes the mechanism, not what the mechanism can do. To predict the next token of a chess game well, you have to model chess. To predict the next token of a legal argument, you have to model the argument. Scale the move up a thousand times and train it on most of the written internet, and the guesses start to contain a working model of the world the text describes.

What the move cannot do is also now clear. It cannot check a fact against a source, because there is no source, only odds. It cannot know that it does not know, because a low-confidence guess still produces a confident-looking sentence. Both of those get their own lesson.

Q1After 'The capital of France is', why is the model's top guess 'the' rather than 'Paris'?

Q2What does turning the temperature up do?

Q3Why does a Hindi sentence cost more tokens than the same sentence in English?

Remember

What to take with you

  1. ChatGPT is one move repeated: score every next token, pick one, repeat. There is no plan and no fact store.
  2. Tokens are pieces, not words. Non-English text costs several times more, which means less memory and more cost for the same meaning.
  3. Temperature reshapes the odds before the pick. Low is repetitive, high is inventive, and inventive includes invented.
  4. 'Just predicting the next word' is true of the mechanism and says nothing about the ceiling. What the move cannot do is check or know.
Questions

Questions people are asking

How does ChatGPT actually work? It turns your text into tokens, scores every possible next token, picks one by a weighted dice roll, adds it, and repeats. The scores come from a neural network trained on a huge amount of text. That loop is all it does.

Is ChatGPT just predicting the next word? Mechanically yes. But predicting the next word well on the whole internet forces the model to learn a lot about the world the text describes, which is why the results go far beyond autocomplete.

What is a token in AI? A piece of text the model works with: often a word, sometimes part of a word or a single character. OpenAI's rule of thumb is one token for about four English characters; other languages need more tokens for the same text.

What does temperature do in ChatGPT? It reshapes the probabilities before the next token is picked. Low temperature makes the top choice nearly certain; high temperature spreads the odds so unlikely tokens appear. Chat apps set it for you; the API lets you choose.

Does ChatGPT actually understand what it says? It has no checker and no source of truth, only learned odds. Whether a very good model of those odds counts as understanding is a real debate. What is not debatable is that it cannot verify a claim the way you can.

Sources

  1. OpenAI Help Center, What are tokens and how to count them help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them
  2. Radford et al., Language Models are Unsupervised Multitask Learners (GPT-2), OpenAI, 2019 cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf
  3. 3Blue1Brown, Large Language Models explained briefly, Nov 2024 youtube.com/watch?v=LPZh9BOjkQs
  4. r/singularity, What are the best arguments against 'it's just a next word predictor', Jul 2026 reddit.com/r/singularity/comments/1v9i9e5
  5. Simon Willison, Think of language models like ChatGPT as a calculator for words, Apr 2023 simonwillison.net/2023/Apr/2/calculator-for-words
Newsletter

One email a week. Written by people.

New lessons and how-tos, the tools we tested and what we think, in one short email.

Free · Unsubscribe anytime