How does the model give a probability to a phrase, or a meaning?

Question

How does the model give a probability to a phrase, or a meaning?

Every phrase already has a probability: multiply the faces you took. “Which meaning” is where the mass lands, and context moves it


The short answer

Taylor, this is the right follow-up, and I have been waiting for someone to ask it. In the first question we built one die: the model reads the text so far, produces a score for every entry in its vocabulary, and turns those scores into shares that add to one. You are asking what happens when the thing we want a probability for is a whole phrase rather than one token, and whether a meaning can have a probability the same way.

The answer comes in two halves. The first is that yes, the model gives a probability to every phrase, and it does it by multiplying: roll the die once per token, keep the share of the face you took each time, and multiply those shares together. That product is the probability of the whole phrase, and nothing else is going on. The second half is worth slowing down for. There is no stored variable called "the meaning," and no separate die that picks "physical" or "disposition" before the words start. What exists is where the probability mass lands, meaning the total probability sitting on a set of continuations. After "He is so cold." the continuations describing a shivering body carry one amount of probability, the continuations describing a cold personality carry another, and the ratio between those amounts is the closest thing to a belief about which reading is in play. Context shifts that ratio, and the numbers below are small enough to check by hand.

From one die to a sentence: the chain rule

Two definitions first, both short. A conditional probability is the probability of something given that something else is fixed. We write it $p(\text{next} \mid \text{context})$ and read the bar as "given." Everything a language model produces is conditional: never the probability of shivered in the abstract, only its probability given the exact text in front of it. The second is the chain rule, which is the whole of the answer to your first half:

$$p(t_1 t_2 \ldots t_n) = p(t_1)\cdot p(t_2 \mid t_1) \cdot p(t_3 \mid t_1 t_2) \cdots p(t_n \mid t_1 \ldots t_{n-1})$$

In words: the probability of a sequence is the probability of its first token, times the probability of its second token given the first, times the probability of its third given the first two, and so on to the end. Every factor on the right is one face of one die of the kind we built in question one. The model was never given a phrase probability. It was given a way to manufacture one.

Run it on your sentence. Pretend the die after "He is so cold." has five faces: He at 0.30, His at 0.20, Even at 0.10, I at 0.10, and everything else sharing 0.30. These numbers are made up. A real vocabulary has tens of thousands of faces, and only the arithmetic gets longer.

Worked example: the probability of "He shivered."

Three tokens, so three dice. Take the face He at 0.30. The model now reads "He is so cold. He" and builds a fresh die, on which shivered has share 0.20; it reads "He is so cold. He shivered" and builds a third, on which the period has share 0.90.

$$p(\text{He shivered.}) = 0.30 \times 0.20 \times 0.90 = 0.054$$

In words: multiply the three shares taken and the sentence has probability 0.054, a little over 5 chances in 100. No die was ever asked about the sentence. Three ordinary next-token dice were rolled, and the sentence's probability is the product of the faces.

Three panels in a row, each a small table of candidate tokens with a bar and a share. The first panel, after He is so cold, lists He at zero point three zero, His at zero point two zero, Even at zero point one zero, I at zero point one zero and else at zero point three zero, with He highlighted. The second, after He, lists shivered at zero point two zero, never at zero point zero five and else at zero point seven five, with shivered highlighted. The third, after He shivered, lists a period at zero point nine zero and else at zero point one zero, with the period highlighted. An arrow drops from each panel to a single line reading zero point three zero times zero point two zero times zero point nine zero equals zero point zero five four.
One die per token. Each panel is a complete die in its own right. The sentence's probability is assembled from the three faces taken, and never computed in one place.

Now a sentence that means something else entirely. "He never smiles." is four tokens: He at 0.30 from the same first die, then never at 0.05, smiles at 0.60, and the period at 0.95.

$$p(\text{He never smiles.}) = 0.30 \times 0.05 \times 0.60 \times 0.95 = 0.00855$$

In words: the same first face, then three more, and the product is 0.00855, about 8 chances in 1,000. The two sentences share their first factor and separate at the second, which is where the two readings of your phrase separate.

Why products get tiny, and bits get added instead

A product of numbers below one shrinks fast. Three factors gave 0.054; thirty tokens would give something near a billionth of a billionth, and a paragraph would drop below the smallest number the computer can hold before you finished reading it. So nobody who works with these models multiplies phrase probabilities. They take logarithms and add.

The logarithm base two of a number answers one question: two raised to what power gives this number? It also carries the property that turns a product into a sum, because the log of a product is the sum of the logs. Take the negative log base two of a probability and you get its surprise in bits, small when the model expected the token and large when it did not.

Worked example: 0.054 in bits

Take each factor on its own. Minus the log base two of 0.30 is 1.74 bits. Minus the log base two of 0.20 is 2.32 bits. Minus the log base two of 0.90 is 0.15 bits. The period was nearly certain, so it was barely news.

$$-\log_2 (0.054) = 1.74 + 2.32 + 0.15 = 4.21 \text{ bits}$$

In words: the three surprises add to 4.21 bits, and 4.21 bits is the same statement as a probability of 0.054. The multiplication became an addition with nothing approximated. Running the same arithmetic on the other sentence, 0.00855 is 6.87 bits: the less likely sentence costs more bits, which is what "less likely" means once you are counting in bits.

Three rows, each naming a token with its probability on the left and a horizontal bar on the right whose length is its surprise in bits: He at zero point three zero is one point seven four bits, shivered at zero point two zero is two point three two bits, and the period at zero point nine zero is zero point one five bits. Below, the three bars are laid end to end into one bar labeled four point two one bits, against a probability of zero point zero five four, with two summary lines reading multiplying and adding.
The product, laid end to end. The nearly certain period contributes almost no length. A factor of 0.90 is barely any news, and in bits that is visible at a glance.

This is not a separate theory bolted on. Cross-entropy grades the bits the model charged for the token that actually came next, summed across a sentence, so adding bits along a phrase is the training objective read forward. One habit follows: divide total bits by the number of tokens before comparing phrases of different lengths, or the shorter phrase wins for being shorter.

Watch part one (16:23): what to notice — the dice standing up one per token, the three taken faces sliding together into a single product, the same three faces restacking as bars that add to 4.21 bits, and the product shrinking off the bottom of the scale while the bar chart keeps its footing.

Two readings, one die

Now your real question. "He is so cold." can be about a body or about a person, and you want to know how the model holds both. It holds neither as a label. It holds a die at every position, and the two readings show up as two families of continuations that those dice treat differently.

One family holds the continuations that describe a body, such as "He shivered." and "His hands were shaking." That is the physical reading, and I will call it the body family. The other holds the ones that describe a character, such as "He never smiles.": the disposition reading, the personality family. Both are our categories, drawn by us over sentences the model gave probabilities to. Add up the mass on the members and you have a number that behaves like a belief:

$$\frac{p(\text{He shivered.})}{p(\text{He never smiles.})} = \frac{0.054}{0.00855} \approx 6.3$$

In words: with no other context, this model puts about 6.3 times as much probability on the body continuation as on the personality one. That ratio is the readout. It is not stored anywhere in the network; we computed it by choosing two sentences and dividing.

Do it with families rather than single sentences and the picture sharpens. "His hands were shaking." is $0.20 \times 0.50 \times 0.60 \times 0.80 \times 0.95 = 0.0456$, so a partial body-family sum of these two members is $0.054 + 0.0456 = 0.0996$ against a personality-family sum of 0.00855, a ratio near 11.6 to 1. Say "partial" every time: the real families have thousands of members and we listed three, so every family number on this page is a floor, and where we draw the boundary changes the answer.

A continuation tree growing rightward from a box labeled He is so cold. The first split shows the faces He at zero point three zero and His at zero point two zero. From He, one branch runs through shivered at zero point two zero and a period at zero point nine zero to a leaf reading He shivered, zero point zero five four; another runs through never, smiles and a period to a leaf reading He never smiles, zero point zero zero eight five five. From His, a branch runs through hands, were, shaking and a period to a leaf reading His hands were shaking, zero point zero four five six. The two body leaves are drawn in one accent and the personality leaf in another, and a line at the lower left reads zero point zero five four to zero point zero zero eight five five, about six point three to one.
Two families, one tree. Nothing splits at the top. The same first face, He, leads into both readings, and they only separate at the second die.

Context moves the mass

This part answers "the rest of my prompt." Put a sentence in front of the phrase and every die downstream changes, because each is conditioned on the whole text. The mechanism is attention: at the position where the next token is chosen, attention lets that position reach back to "snowing" or to "mother" and mix what it finds into the representation the scores are computed from. The weights are the same; what changes is what that position reaches back to, and so the die changes.

Run the same two sentences under three contexts. Only two factors move: the share of shivered after "He", and the share of never after "He".

Worked example: three contexts, three ratios

With no lead-in, shivered sits at 0.20 and never at 0.05: a ratio near 6.3 to 1 for the body. Put "It is snowing." in front and shivered rises to 0.45 while never falls to 0.01. Put "He never calls his mother." in front instead and shivered collapses to 0.03 while never climbs to 0.25.

$$\text{snowing: } \frac{0.30 \times 0.45 \times 0.90}{0.30 \times 0.01 \times 0.60 \times 0.95} = \frac{0.1215}{0.00171} \approx 71$$

and the other context pushes the same arithmetic the other way:

$$\text{mother: } \frac{0.30 \times 0.03 \times 0.90}{0.30 \times 0.25 \times 0.60 \times 0.95} = \frac{0.0081}{0.04275} \approx \frac{1}{5.3}$$

In words: one sentence of lead-in moved the model from about 6 to 1 in favor of the body, to about 71 to 1 in favor of the body, to about 5.3 to 1 against it. Nothing in the model was switched. Two factors in a product changed, and the product changed with them.

Three stacked panels, each showing the same small continuation tree after He is so cold. In the top panel, labeled no lead-in, the body branch carries zero point zero five four and the personality branch zero point zero zero eight five five, with a ratio bar reading six point three to one toward the body. In the middle panel, labeled It is snowing, the body branch carries zero point one two one five and the personality branch zero point zero zero one seven one, with a ratio bar reading seventy-one to one toward the body. In the bottom panel, labeled He never calls his mother, the body branch carries zero point zero zero eight one and the personality branch zero point zero four two seven five, with the ratio bar reversed to one to five point three.
The same tree, three times. The branches never change shape. Only the thickness of the two edges after He changes, and the ratio bar at the right follows them all the way across and past the midpoint.

This is what happens to a word's representation inside the model, which we took apart in the embeddings question: the row looked up for cold is identical in all three cases, and a few layers of attention later it is not. The lookup is fixed; what the model holds at that position is not.

Inside the network, both readings at once

It is fair to ask what happens in the weights while that ratio moves, and here I have to separate what is established from what is inference. The best current picture: concepts live as directions in the model's internal stream of numbers, one position carries many directions at once with different strengths, and attention moves a direction between positions. So "cold as temperature" and "cold as disposition" are not two boxes with one selected. They are two directions, both present after "cold," with weights the surrounding text pushes up and down.

We know this is roughly right because people have looked: small probes trained to read a named property off the numbers flowing through the network, its activations, do work. But a probe is our instrument, not the model's report. The model never emits "I have decided this is the body reading"; it emits scores over tokens. All of it is a measurement taken from outside. The reasoning question goes through what is known and what is not, with the papers named.

Picking a phrase: sampling, greedy, and beam

Everything so far has been about scoring phrases. Choosing one is a separate job, and the gap between them is where a lot of confusion lives. Greedy decoding takes the largest face on each die in turn. Beam search keeps a handful of partial phrases alive, a count called the beam width, extends each by one token, and keeps the best few by running total, so a bad-looking step can be paid back later. Sampling, the default in the first question, rolls each die honestly. Greedy takes the best token; beam reaches for the best phrase; and a product is where those targets come apart.

Worked example: when the biggest first face wins, and when it loses

The first die has He at 0.30 and His at 0.20, so greedy takes He and lands on "He shivered." at 0.054. Follow His instead: "His hands were shaking." runs $0.20 \times 0.50 \times 0.60 \times 0.80 \times 0.95 = 0.0456$, below 0.054. Greedy was right here. Now change one factor, as if the lead-in had mentioned a cold room: let the die after His put 0.80 on hands instead of 0.50.

$$0.20 \times 0.80 \times 0.60 \times 0.80 \times 0.95 = 0.073 \;>\; 0.054$$

In words: the second path now totals 0.073 against the greedy path's 0.054, and greedy never sees it, because greedy threw the path away at the first step on the strength of one face. A smaller first face on a much better remainder beats a larger first face on a worse one. Only something that looks ahead, such as beam search or scoring whole candidates, can find it.

Two stacked blocks sharing one vertical rule. In the upper block, labeled as the numbers stand, the greedy path He then shivered then a period carries the factors zero point three zero, zero point two zero and zero point nine zero and ends in a bar of zero point zero five four, while the discarded path His then hands then were then shaking then a period ends in a shorter bar of zero point zero four five six, and the verdict reads greedy wins here. In the lower block the second factor of the discarded path is changed from zero point five zero to zero point eight zero, its bar grows to zero point zero seven three and overtakes the greedy bar, and the verdict reads greedy loses here.
One factor decides it. The greedy path is the same in both halves. What changes is a single edge on the path greedy already discarded, and that is enough to reverse which sentence is most probable.

Temperature acts on every factor, so it acts on the product

Temperature is a per-token dial, and that is the point rather than a limitation: it is applied at every die in the product, so its effect compounds along the phrase. Take the first die at temperature one half. Under the rule from question one, every score is divided by the temperature before softmax, and dividing by one half doubles it; raising $e$ to twice a score is the square of raising $e$ to the score, so every share is squared before the shares are renormalized, on each die separately. The four named faces square to 0.09, 0.04, 0.01 and 0.01. The "everything else" bucket is not one face. Call it three hundred tokens of 0.001 each, and squaring sends each to a millionth, so the tail nearly vanishes.

$$p(\text{He}) : 0.30 \rightarrow \frac{0.09}{0.1503} = 0.60, \qquad p(\text{His}) : 0.20 \rightarrow \frac{0.04}{0.1503} = 0.27$$

In words: the leading face went from thirty percent to sixty percent, the runner-up from twenty to twenty-seven, and the long tail of rare tokens went from thirty percent down to about two-tenths of one percent. The die did not change which face leads; it changed how much daylight the leader has.

Now watch what that does to a phrase. On any one die, the ratio between two faces is squared: He against His was 1.5 to 1 and is now 2.25 to 1, which is 1.5 multiplied by itself. Along a phrase that squaring happens at every die, each with its own renormalization, so the effect compounds step by step and small temperature changes turn into large differences in which whole sentences are reachable. Raise the temperature instead and the tail fattens at every position, so the set of phrases with a real chance of appearing grows multiplicatively.

Watch part two (19:14): what to notice — the tree growing one die at a time, the two families lighting separately, the ratio bar sliding from 6.3 to 1 all the way across to 1 to 5.3 as the lead-in changes, the greedy path being thrown away before the better sentence appears, and every edge in the tree sharpening together when the dial moves.

Phrases, thoughts, and concepts: the same machinery, longer

You asked about phrases, thoughts and concepts together, and the machine does not distinguish them. A paragraph's probability is a product with more factors in it; an argument's has more still. Whatever length you care about, the chain rule covers it and the bits add along the way.

A "thought," in the sense you mean, is a continuation family at longer range: the continuations that develop one idea rather than another. You measure it the same way, and it never stops being a measurement we impose. What it does say is real: the model puts more probability on text that follows the thread of the prompt than on text that abandons it, which is no small thing for a machine trained only to fill in the next token. What it does not say is that the model has a representation of the idea in the sense you have one when you follow an argument. The next question along defines reasoning, thinking and understanding before using them, which is the only way to keep this paragraph straight.

What this does not explain

Four limits, because each is a place where the picture above can be stretched past what it supports.

First, the reading is our probe. Nothing in the model reports a sense of cold; we picked two sets of sentences and divided. Pick different sentences and you get a different number, with no fact of the matter about which set was right.

Second, a family sum is a definition, and ours are partial: every ratio on this page comes from two or three listed sentences out of families with no natural boundary. The direction of the effect is solid; the exact number is an artifact of what we listed.

Third, these probabilities are the model's, not the world's. A probable phrase is text the model expects, a statement about the training data and the objective, and that is the point behind recall being generation. A false sentence can be highly probable and a true one rare.

Fourth, the numbers here are pretend. Real dice have tens of thousands of faces, and real long-phrase probabilities are vanishingly small. That is why the work is done in bits.

What you now know

  • A language model gives a probability to every phrase, not just the next token, by the chain rule: multiply the share of the face taken at each position.
  • Products shrink toward nothing, so the work is done in bits. The surprises 1.74, 2.32 and 0.15 add to 4.21 bits, the same statement as a probability of 0.054.
  • "Which meaning" is where the mass lands across families of continuations rather than a stored switch, and the ratio between families is a readout we compute rather than something the model reports.
  • Context moves that mass through attention: the same two sentences go from about 6.3 to 1 for the body reading, to 71 to 1, to 1 against 5.3, as only the lead-in changes.
  • Greedy takes the largest face at each step while beam search reaches for the best whole phrase, and one better factor downstream makes the most likely first token the wrong one.
  • Temperature is applied at every die in the product, so sharpening compounds: a ratio of 1.5 to 1 between two faces becomes 2.25 to 1 at half temperature.

Where we're headed

Taylor, your first question ended with a die and a roll; this one ends with a product of them. For the die itself, go back to question one. For the bits taken seriously, including why the training loss is a file size, that is the entropy question. For the position where the two readings sit as directions rather than labels, start with the embeddings question and then go to the reasoning one. Thanks for asking the second question.