Intelligent Interfaces · Information · a lab

It only ever
says numbers.

What a large language model is, without the architecture: a machine that computes probability distributions and emits integers. Everything else, including meaning, lives in how we read them.

What the model sent

Scroll ↓

Ask a language model a question and it answers with a list of whole numbers. Nothing else ever leaves it.

This page skips the machinery inside the model, the transformer, and looks at what goes in and what comes out, using the language of information theory: probabilities, surprise and bits. Each section works the same way. First a claim, then a picture that shows it, then something you can try yourself.

Every number here is computed from texts bundled with the page: public-domain books from Project Gutenberg, Korean short stories from Wikisource, and Python source code. Token IDs are real IDs from o200k_base, the tokenizer of OpenAI’s GPT-4o family. The “model” on this page is a small trigram model trained on four novels. It is tiny compared with an LLM, but it is the same kind of object. Nothing here calls an AI service.

The whole loop

Two moving parts: odds, and a lookup table.

Everything a chatbot has ever said to you came out of this loop, one number at a time. The model turns the numbers so far into odds for every possible next number. One number is drawn, a codebook turns it into text, and the loop repeats. The rest of the page takes the loop apart.

Figure 0. Real numbers throughout. The IDs are o200k_base. The odds come from this page’s trigram model, trained on four novels including Moby-Dick, which saw “on the” times. Here it drew “sea”.

A language model does two things: it computes odds, and a codebook turns the chosen number into text.

Act I

Numbers

What leaves the model, and the codebook that turns it into language.

1 · The tokenizer

A sentence is a short list of row numbers.

Models never see letters. A tokenizer cuts text into common pieces, called tokens, and swaps each piece for its row number in one fixed table of about 200,000 entries. We’ll call that table the codebook. The model reads and writes only the row numbers.

Figure 1. Read top to bottom: text, pieces, row numbers. The codebook on the right is the real table around row 6,439 (“ language”). Rows next to each other have nothing to do with each other.
Try this
  1. Press Only IDs. This is everything the model ever sees.
  2. Switch to 한국어 or 中文: the same idea, cut into different pieces.
  3. Hover over a chip to see its number of bytes.

Text goes in as a list of integers, and integers come out.

2 · The shift

Same numbers. Different codebook.

Suppose the model’s numbers reach you perfectly, but your copy of the codebook is printed one row off. The message hasn’t changed, not by a single bit. Only your agreement with the sender about the table is gone. Watch what you read.

Figure 2. Both readers receive identical numbers. Reader B’s table is shifted by one row, so row 976 now holds “set”, which used to be row 977.
Try this
  1. Drag the slider to +1, then press +10,050.
  2. Click any received word to see the codebook rows around it.
  3. Choose 中文 and shift it: it turns into fragments of other languages and code.
Read every ID as ID + k
k = 0
On the wire · never changes
What the reader sees
Token by token · click one
The codebook around

The numbers carry no meaning. The meaning is in the codebook that sender and reader share.

Act II

Odds

Behind every number is a distribution over all of them.

3 · The next number

A model is a function from context to odds.

At every step the model gives each of the 200,000 numbers a probability. Writing is rolling a weighted die, adding the result to the context, and rolling again. Temperature sharpens or flattens the die before each roll.

Figure 3. Left: the odds after “It was a”, computed by this page’s trigram model. Right: the same odds at temperature 0.3, where the favourite takes over, and at 1.5, where everything evens out. The model is small, trained on tokens of four novels. An LLM does the same thing with far more context and data.
Try this
  1. Press Draw one a few times and watch the odds change with each new word.
  2. Drag temperature down to 0.2: it starts repeating itself.
  3. Drag it up to 2: it falls apart.
Text so far
Odds for the next ID · click one to choose it

Generation is a weighted die rolled again and again. The model has counts, not ideas.

4 · Surprise

Surprise has a unit: the bit.

If the model gave the token that actually came next a probability p, it was surprised by −log₂ p bits. A coin flip is 1 bit. A one-in-a-million event is about 20 bits. Average surprise is how language models are scored.

Figure 4. Top: probability converted to bits. Bottom: surprise for every token of a sentence from Sherlock Holmes, a book the model never trained on, and for the same numbers shifted by one. The model can’t read either sentence, but it can tell which one is wrong.
Try this
  1. Click the four cards in order and watch the average go from about 10 to about 20 bits per token.
  2. Hover over a bar to see the token and its surprise.

A model without understanding can still detect a wrong codebook, because wrong text is improbable.

Act III

Clouds

A book is a distribution. So is a language, and so is a model.

5 · Clouds

Every text is a cloud over the same numbers.

Count how often each token appears in a book and you get its fingerprint, a probability distribution, which we’ll call a cloud. Two books in the same language share most of their mass. Two languages barely touch, even though both use the same 200,000 numbers. The gap between two clouds can be measured in bits.

Figure 5. Each panel compares the 7 most common tokens in Alice (blue, above the line) with the other book’s use of the same tokens (red, below). On the right are the other book’s own favourites. The ruler measures the distance between clouds with the Jensen–Shannon divergence (JSD): 0 bits means identical, 1 bit means nothing in common. Each sample is 30,000 tokens.
Try this
  1. Leave A = Alice and set B = Sherlock: the dots overlap.
  2. Switch B to 紅樓夢: nothing overlaps.
  3. Press Shift A by +1: on screen the cloud moves by one pixel, but the divergence jumps.
  4. Open All texts and drag a point.

The whole codebook as a square: ID 0 is at the top left and 199,997 at the bottom right, read row by row. Common pieces got low IDs, so the top rows are crowded.

● A
● B
Divergence, A to B
0.00
0 · identical1 bit · nothing shared

Languages are different clouds on the same numbers, and the distance between two clouds can be measured.

6 · The same shape

Different clouds, same shape.

The clouds share almost nothing, yet they have the same shape. Rank each text’s tokens from most to least common and plot count against rank on logarithmic axes. Every language gives roughly the same straight slope, and so does Python. This is Zipf’s law: a few tokens do most of the work.Zipf

Figure 6. Token rank against count, both on log scales, for 30,000-token samples. The dashed line is the slope −1 that Zipf’s law predicts.

Every language spends its tokens in the same lopsided way.

Act IV

Compression

To predict is to compress.

7 · Shannon’s game

Most of every sentence is predictable.

In 1951 Claude Shannon had people guess hidden text one letter at a time.Shannon 1951 A letter you guess on the first try tells you almost nothing new. A letter that needs many guesses carries real information. Counting guesses measures how much information text carries.

Figure 7. A worked example. The small numbers are how many guesses this page’s letter model needed for each letter of a sentence it never saw, using the 26 letters plus space. Most letters take one guess. If every letter were a blind guess among 27 symbols, each would cost 4.75 bits.
Try this
  1. Type your guesses for about ten letters (keys a–z and space).
  2. Press Let the model play the rest and compare the two histograms.
Guesses needed per letter
–you, bits per letter
–model, bits per letter

Most of every sentence is predictable. A letter could carry 4.75 bits, but the model needs about .

8 · Probabilities become bits

A good predictor is a good compressor.

Prediction turns directly into compression. Start with the interval from 0 to 1, and for each letter keep only the slice the model gave to the letter that actually came. A confident, correct guess keeps a wide slice. The narrower the final slice, the more bits it takes to write down. This technique is called arithmetic coding.

Figure 8. Left: coding “i had ” with the letter model’s real probabilities; each row zooms into the slice chosen above it. Right: what a general-purpose compressor (xz) needs per character for each text. A Chinese character carries far more than an English letter because each one does more work. LLMs used as compressors beat tools like this on text.Delétang et al. 2023

Lower surprise means a shorter code. Training a model is minimizing bits.

9 · Information is not meaning

Shift a text and it keeps every bit.

A compressor doesn’t know English; it only finds patterns. So what happens to a text whose letters are all moved one step along the alphabet? This brings back the shift from Act I. In algorithmic information theory, the information in a text is the length of the shortest program that prints it, its Kolmogorov complexity.Kolmogorov “Shift by one” is a tiny program.

Figure 9. The opening of A Scandal in Bohemia and the same text with every letter shifted by one, both compressed by your browser with DEFLATE. The sizes are nearly identical. Only one of them is readable.
Try this
  1. Click English, then English, every letter +1: the compressed size barely moves.
  2. Click Random letters: no patterns, so very little saving.
  3. Type anything in the box.

Shifting destroys meaning but not information. The codebook was the meaning.

Coda

So what is language?

01

Meaning lives in the codebook, not the numbers.

A model emits integers. Shift the table by one row and the same message becomes noise. Meaning is an agreement between whoever writes and whoever reads.

02

Language is a distribution, and a redundant one.

A letter could carry 4.75 bits. Our four-novel letter model needs , and Shannon’s human guessers needed about one. Most of every sentence is predictable from what came before it.

03

Languages are different clouds on the same numbers.

English and Chinese differ by bits of Jensen–Shannon divergence, out of a possible 1. Yet their rank-frequency curves have the same shape.

04

A model is a distribution fit to distributions.

The trigram model’s output lands bits from the books it learned from, about as close as those books are to each other (0.24–0.33). It reproduces a cloud; it does not consult a meaning.

05

To predict is to compress, and information is not meaning.

Lower surprise means a shorter code, and training a model minimizes exactly that. A shifted text keeps all its bits () and loses all its sense.