Foundations
Probability you actually need
Conditional probability, softmax over 248,320 outcomes, log probabilities, and what temperature 1.0 versus 0.7 actually does to Qwen3.8-27B.
Updated
01 · Concept
Concept
Here is a concrete situation before any vocabulary. You have run Qwen3.8-27B on a prompt and the final layer has handed you 248,320 raw numbers, one per output-tensor row. They are not probabilities: some are negative, some are large, and they certainly do not sum to anything convenient. Somebody now has to turn that pile into an actual distribution, and then somebody has to choose a token from it. Almost all of the probability you need for this course is the machinery for those two steps.
Start with what a distribution is. A probability is a number between zero and one expressing uncertainty under a model. For mutually exclusive possibilities the probabilities add to one. After any runtime masking, softmax produces a categorical distribution: non-negative values summing to one over the candidates the decoder may select. Qwen’s raw output vector has length 248,320, while its tokenizer artifacts map 248,077 ids. Notice what this makes explicit. The distribution is the model’s answer. Picking a token from it is a separate decision made by code you configure, not by the network.
Probability is always conditioned on something. We write for the probability of , and for the probability of given that holds. Language modelling is conditional through and through: . The token Mercury is a fine continuation of the closest planet to the Sun is and a poor one after the liquid metal is. Conditioning is the whole game, and the history in lesson 0.2 is the history of how much of a model could afford to look at.
The chain rule assembles a sequence probability from those conditionals:
This identity is why repeated next-token prediction defines a probability for a whole passage. It also explains an immediate practical problem: multiply a few hundred numbers below one and the result underflows to zero in floating point. So implementations work in logarithms. Because , the product becomes a sum. The log of a probability is at most zero, closer to zero for likelier events, tending to minus infinity for impossible ones. Training minimizes negative log-likelihood, which flips the sign so that better predictions give a smaller number, and averaging over tokens makes sequences of different length comparable.
Now the bridge from raw scores to that distribution. Given logits , softmax computes
Exponentiating makes every value positive; dividing by the total makes them sum to one. One property is worth memorizing: adding the same constant to every logit leaves the probabilities unchanged, because the constant factors out of numerator and denominator. Softmax cares only about differences between logits.
Work the temperature example numerically, using three logits and ignoring the other 248,317 for legibility. Take . Exponentiating gives , , and , summing to , so the probabilities are about , , and . That is temperature 1.0, the preset Qwen3.8-27B uses in its thinking mode. Now apply temperature , the model’s instruct-mode preset. Temperature divides the logits before softmax: . Exponentiating gives roughly , , and , summing to , so the probabilities become about , , and . The leader gained nine points of probability and the tail lost most of what it had. Nothing about the model changed; only the sharpness of the reading.
There is a classic wrong turn here that is worth walking into deliberately. Suppose you had instead divided the probabilities by 0.7 and renormalized. You would get , , and , summing to ; dividing through by that total returns , , . Exactly the original distribution. Scaling every probability by a constant and renormalizing is a no-op, because the constant cancels in the same way an added constant cancels for logits. Temperature only does anything because it acts before the exponential, where a multiplicative change to the exponent becomes a nonlinear change to the result. If your sampler applies temperature to the wrong side of the softmax, the parameter will appear to do nothing at all, and this is a real bug people ship.
Two rules prevent most probabilistic reasoning errors. First, is not ; a symptom can be common among patients with a rare disease while the disease stays rare among people with the symptom. Second, expectation is not an outcome: the expected value of a fair die is 3.5, and no face shows 3.5. Expected loss, the quantity training minimizes, is an average over examples that no single example need resemble.
The working toolkit is small: normalize with softmax, condition on context, multiply conditionals with the chain rule, work in logs for stability, and keep the model’s distribution firmly distinct from the world it describes. With those five pieces, cross-entropy, entropy, perplexity, and every sampling method in track 7 are variations rather than new subjects.
02 · Analogy
Analogy
Picture a weather desk with a hundred chips spread across tomorrow: sixty on rain, thirty on cloud, ten on sun. New radar does not declare a future; it slides chips around the table. The forecast is the whole arrangement, not the label under the tallest pile. Temperature is a croupier who, before anyone reads the table, either rakes chips toward the tallest pile or spreads them outward. The croupier adds no information about tomorrow. It only changes how decisive the table looks.
03 · Teach it back
Teach it back
Explain conditional probability and log probability with a next-token example, then say precisely what temperature does and where in the pipeline it acts.
Compare with a model answer
A language model estimates P(next token | tokens so far); the same token can be likely after one prefix and negligible after another. A whole sequence probability is the product of those conditionals, which underflows quickly, so implementations sum log probabilities instead. Softmax turns raw scores into that distribution by exponentiating and normalizing. Temperature divides the logits before softmax, not the probabilities after it: dividing probabilities by a constant and renormalizing changes nothing, because the constant cancels. Lower temperature sharpens the distribution toward the top-scoring token, higher temperature flattens it, and neither supplies new evidence about which token is correct.
04 · Check your understanding
Check your understanding
Complete the teach-back and answer the quiz correctly to finish this lesson.
◎ · Evidence marker
Sources
- Claude E. Shannon (1948). A Mathematical Theory of Communication.
- Qwen Team (2026). Qwen3.8-27B Model Card.