๐งฉ Puzzle Piece: A transformer doesn't output "the next
word." It outputs a
probability distribution over 50,000+ possible next tokens. When GPT says "I'm 73% sure the next word is 'the'," that's not a
metaphor โ it's a literal probability, computed through the softmax
function. To understand what a transformer actually produces, you need to
understand probability.
AI systems deal with uncertainty. Which token comes next?
Is this image a cat or a dog? Will this user click? Probability is the
mathematical framework for reasoning about uncertainty โ and it's the
native language of every generative AI system.
The Three Axioms of Probability
All of probability theory rests on three axioms (Kolmogorov, 1933):
Non-negativity: P(A) โฅ 0 for any event A. Probabilities
can't be negative.
Unit measure: P(ฮฉ) = 1. The probability of
something happening is 1.
Additivity: If A and B are mutually exclusive, P(A โช B)
= P(A) + P(B).
That's it. Everything else โ Bayes' theorem, expectation, distributions,
entropy โ follows from these three rules.
Sample Space and Events
The sample space ฮฉ is the set of all possible outcomes.
For a language model, ฮฉ is the vocabulary โ every token the model can
produce. An event is any subset of ฮฉ. P(event) is the
total probability mass assigned to outcomes in that event.
Why Probability for AI?
AI systems face three kinds of uncertainty that probability handles
naturally:
Aleatoric uncertainty โ genuine randomness in the
world. Which word comes next in a sentence is inherently uncertain; many
continuations are valid. Probability quantifies this.
Epistemic uncertainty โ what the model doesn't know. A
model trained on limited data should express lower confidence on
unfamiliar inputs. Probability provides calibrated confidence scores.
Learning from data โ the core of machine learning.
"Find the parameters that make the training data most probable" is the
maximum likelihood principle behind virtually all generative AI
training.
AI without probability is just pattern matching.
Probability is what turns "this looks similar to things I've seen" into "I
am 73% confident that the next token is 'the', 11% that it's 'a', and
0.01% that it's 'pterodactyl'." The numbers are meaningful โ they're
calibrated statements about uncertainty.
Two Types of Probability
Frequentist: Probability = long-run frequency. "If I
rolled this die infinitely many times, how often would I get a 6?"
Bayesian: Probability = degree of belief. "Given what I
know, how confident am I that this email is spam?" Bayesian probability
updates beliefs with evidence โ it's the framework behind modern AI.
AI uses both views. The training objective is frequentist
(maximize likelihood across the dataset). But the model's output โ "I'm
73% confident in 'the'" โ is a Bayesian statement of belief conditioned on
the input. The mathematics handles both seamlessly.
Check Your Understanding
Q1: A language model outputs probabilities for the next token. The
probabilities across all possible tokens must satisfy which condition?
A. They must all be equalB. They must be non-negative and sum to exactly 1C. The highest must be at least 0.5D. They can be any real numbers
Q2: A model assigns P("the" | context) = 0.73 and P("a" | context) =
0.11. What is P(not "the" and not "a" | context)?
A. 0.16B. 0.84C. Cannot determine from this information aloneD. 0.08 (the product, since tokens are independent)
Q3: Why is probability the right language for AI output, rather than
just picking the single most likely answer?
A. Picking the single most likely answer gives identical results and
is simplerB. The probability distribution captures the model's uncertainty โ it
tells you not just what's most likely, but how much more likely it is
than alternativesC. It's required by the GPU hardwareD. It makes the output human-readable
๐ Recommended Reading
Blitzstein & Hwang, Introduction to Probability โ Chapter 1
(Probability and Counting)
If the axioms feel abstract, think concretely: every time you see a
probability bar in a ChatGPT response alternative, that's the model's
probability distribution made visible. The math behind that bar is exactly
what we're learning here.