LLM Kitchen
Explanations

Part I · Prediction

Ch 0. The guessing game

Finish this sentence

The cat sat on the ___

You probably thought of a word straight away. Maybe mat, maybe floor. Before reading on, try it below, and see how your guess compares with a real .

Try it

Guess the next word

Recorded · GPT-2 small

Type a word, then see how likely GPT-2 small thought it was.

The cat sat on the ___·floor 7.6%·bed 6.5%·couch 5.4%·ground 5.2%·edge 4.8%·bench 3.2%·table 3.1%·sofa 2.9%

The 8 most likely continuations shown here add up to 39%. The model chooses from 50,257 possible pieces of text, so the other 50,249 share the rest.

Type the start of your own sentence, and GPT-2 small guesses the next word live. Choose a model tier to run a real model in your browser.

A machine that plays the guessing game

In 1951, Claude Shannon played this game with people, one letter at a time, to measure how predictable English is. Very, it turned out.[1]

In 1951, Claude Shannon ran an experiment that looks a lot like this one. He showed people the start of a passage and asked them to guess the next letter, again and again, and used how well they did to measure how predictable written English is. The answer: very.[1][1]

The model above, GPT-2 small, plays the same game. It doesn’t commit to one answer: it gives every possible next word a chance, and spreads its bets across floor, bed, couch, and many more.

A large language model plays the same game. The model above is GPT-2 small, which OpenAI released in 2019.[2][2][3][3] It read the words The cat sat on the and gave every possible continuation a chance. Notice that it doesn’t commit to one answer. It spreads its bets: floor, bed, and couch are all likely, and no single option gets even one chance in ten.

Chances, written down

The game has an exact form. Write a text as tokens x1,x2,…,xn: the chunks GPT-2 really reads, which Ch 4 explains. For each place i, the model gives the chance of token xi given every token before it, written P(xi|x1,…,xi−1). The chance of a whole text is those chances multiplied together:

P(x1,…,xn)=∏i=1nP(xi|x1,…,xi−1)

where ∏ means multiplying, for every place i from 1 to n.[2] The product shrinks fast. After The cat sat on the, floor gets 7.6%, and a comma after floor gets 26%, so the model’s favorite two-token continuation has a chance of only about 2%.

Spreading its bets is normal. Here the 50 likeliest next tokens add up to only about 64%; the other 50,207 share the rest. Shannon measured that spread as entropy, in bits:

H=−∑ipilog2⁡pi

where pi is the chance of outcome i. One bit is one fair yes-or-no question; a choice between eight equally likely outcomes is 3 bits.[4] From his guessing experiments, Shannon estimated that printed English carries about one bit per letter, given the 100 letters before it.[1]

Over and over

One guess is only one word. To write a sentence, the model adds its pick to the end of the text and plays the game again with the longer text. Step through the first few rounds:

Step through

The guessing game, repeated

Recorded · GPT-2 small
The 464·cat 3797·sat 3332·on 319·the 262
Probabilities for what comes next
Next tokenProbability
·floor 7.6%
·bed 6.5%
·couch 5.4%
·ground 5.2%
·edge 4.8%
·bench 3.2%
·table 3.1%
·sofa 2.9%
other
  1. ·floor 7.6%
  2. ·bed 6.5%
  3. ·couch 5.4%
  4. ·ground 5.2%
  5. ·edge 4.8%
  6. ·bench 3.2%
  7. ·table 3.1%
  8. ·sofa 2.9%
  9. other 61%

The model gives every possible next piece of text a probability. The top 8 are shown.

Step 1 of 12 or use ← → keys

The model gives every possible next piece of text a probability. The top 8 are shown.

That’s the whole trick, repeated: guess, pick, add, repeat. Everything else in this site explains how the guessing works, and how much can be built on top of it.

Recipe card

Recap

  • A large language model is a machine that predicts the next piece of text.
  • It doesn’t pick one answer. It gives every possible continuation a probability.
  • To write more, it adds a pick to the text and predicts again, over and over.
  • The chance of a whole text is each token’s chance, given the ones before it, multiplied together.

Next question: you used everything you know about English to make your guess. What’s the simplest way a program could make the same guess?

Sources

  1. Claude E. Shannon (1951). Prediction and Entropy of Printed English. Bell System Technical Journal 30(1).

Sources

  1. Claude E. Shannon (1951). Prediction and Entropy of Printed English. Bell System Technical Journal 30(1).
  2. Alec Radford et al. (2019). Language Models are Unsupervised Multitask Learners. OpenAI.
  3. OpenAI and Hugging Face (2019). GPT-2 model card (openai-community/gpt2). Hugging Face. Accessed October 23, 2026.

Sources

  1. Claude E. Shannon (1951). Prediction and Entropy of Printed English. Bell System Technical Journal 30(1).
  2. Alec Radford et al. (2019). Language Models are Unsupervised Multitask Learners. OpenAI.
  3. OpenAI and Hugging Face (2019). GPT-2 model card (openai-community/gpt2). Hugging Face. Accessed October 23, 2026.
  4. Claude E. Shannon (1948). A Mathematical Theory of Communication. Bell System Technical Journal 27(3).