- Key idea
- Outcomes, probabilities, distributions, and conditional probability
- Real world
- A weather forecast: 70% rain, 25% cloudy, 5% sun. Three outcomes, each with a probability, adding up to 100%.
- In an LLM
- After "The cat sat on the", the model gives every word in its vocabulary, about 100,000 of them, a probability. " mat" might get 40%, " floor" 15%, and so on, all adding up to 1.
The basics
- An outcome is one thing that can happen: a die shows 4, it rains, the next word is " mat".
- A probability is a number from 0 to 1 saying how likely an outcome is. 0 means never, 1 means certain, 0.25 means one time in four.
- A probability distribution lists every possible outcome with its probability. The probabilities always add up to exactly 1, because something has to happen.
Try it
Six outcomes, each with probability . Add them up: . If you roll it 600 times, you expect about 100 of each face, but not exactly 100: real samples are noisy.
| Next word | Probability |
|---|---|
mat | 0.40 |
floor | 0.15 |
sofa | 0.08 |
bed | 0.06 |
| … 99,996 others | 0.31 in total |
The model doesn't "choose" a word. It produces this whole distribution, and a separate step samples one word from it: " mat" 40% of the time, " floor" 15%, and occasionally something rare.
Conditional probability
Most interesting probabilities depend on what you already know. The chance of rain given dark clouds is higher than the chance of rain on a random day. This is written , read "probability of rain given clouds".
A language model is entirely conditional probabilities: .
The probability of a whole sentence
To get the probability of a sequence, multiply the conditional probabilities of each step. This is the chain rule of probability.
Every extra word multiplies by another number below 1, so the probability of a long answer gets very small, very fast. The next pages deal with that.
The chance of rain on Monday is 0.3. If it rained Monday, the chance it rains Tuesday is 0.6. If it rained both days, Wednesday is 0.7. The chance of three rainy days in a row is .
Where this shows up
- In RL, the policy is a probability distribution over actions: the RL loop.
- Sampling several answers per prompt is how RL explores: exploration.
- pass@k, the chance at least one of k samples is right, is built from these rules: Does RL teach new skills?.
- The full story, from conditional probability and Bayes to the estimators in RL papers: the Probability for LLMs course.
Notation
For outcomes with probabilities :
Conditional probability and the chain rule:
A language model computes each factor of that product; it is called autoregressive because each word is conditioned on all the words before it.