Logits and Model Output
Logits are the raw output of a model before probability conversion; larger logits correspond to higher probabilities, but the logits themselves are not probabilities.
A Prediction Before the Conversion
A language model does not finish its work when it produces its raw output. That output is a list of numbers, one for each token in the model's vocabulary. It is tempting to read those numbers as the model's confidence about each token. Many learners assume that a bigger number means a more likely token, and that the numbers are already percentages that add up to a whole. This article tests that belief, shows where it breaks, and then shows the standard tool used to turn raw output into something that can be treated as a probability.
What do you think happens?
A model with three tokens produces the logit vector [2, 1, 0]. Which token should receive the highest probability, and would you expect the three probabilities to add up to exactly one? Commit to an answer before you continue.
Reveal answer
The token with logit 2 receives the highest probability, and the three probabilities produced by softmax add up to exactly one. The raw logits themselves do not add to one; they add to 3.
The largest logit ranks its token highest, which is the part of the belief that holds. The sum-to-one property does not come from the logits; it comes from the conversion step that follows. Notice that the raw logits sum to 3, which shows they are not yet probabilities.
Tracing What the Model Actually Outputs
The belief usually goes like this: the model outputs a vector of scores, the largest score wins, and so the scores must be the model's probability estimates. The first half is partly true. Larger logits do correspond to higher probabilities. The second half is where the reasoning goes wrong. A larger logit ranks a token higher, but the logit itself is not a probability. The scores are raw outputs, and they have not yet been arranged into a form that probability rules require.
Think of the raw output as a vector with one entry per token. Each entry is called a logit. The vector might look like [2, 1, 0] for a three-token vocabulary, or [-1, -2] for a two-token one. Each position stands for one token, and the value at that position is the model's raw score for that token. Nothing in the vector guarantees that the entries are non-negative or that they add up to one.
Three Gaps Between Logits and Probabilities
The source lists three properties that separate logits from probabilities. Each one is a property a probability must have, and logits do not automatically have it. Logits do not represent probabilities. They do not add up to one. And they can be negative, whereas probabilities have to be non-negative. Because of these three gaps, a raw logit vector cannot be used directly as a probability distribution, even though its largest entry still points at the most favored token.
| Property | Raw logits | Probabilities |
|---|---|---|
| Meaning | Raw model scores before conversion | Likelihood that each token is chosen |
| Sum across tokens | Not required to be one (for [2, 1, 0] the sum is 3) | Must sum to exactly one |
| Sign | Can be negative | Must be non-negative |
| Ordering | Larger logit means higher probability | Larger probability means more favored token |
Logits and probabilities share an ordering but differ in the rules they follow.
The Softmax Conversion Recipe
A softmax layer is the component that converts a logit vector into probabilities. Suppose the model's vocabulary has N tokens, and the logit vector is written as x_1, x_2, up to x_N. The probability assigned to token i is given by the formula below, where the sum in the denominator runs over every token j from 1 to N. Read the formula as a recipe: take each logit, transform it with the exponential, and divide by the total of all the transformed values.
Notice what the formula guarantees. Each exponential is a positive number, so every numerator is positive, and so is the denominator. Each probability is therefore non-negative. The denominator is exactly the sum of all the numerators, so when you add the probabilities for every token, the numerators cancel the denominator and the total is one. These are the two properties that the raw logits lacked, and the formula produces them by construction.
Tracing the Vector [2, 1, 0] Through Softmax
Converting the logit vector [2, 1, 0]
A model with three tokens produces the logits 2, 1, and 0 for tokens A, B, and C. Compute the softmax probability for each token and check that they sum to one.
- 1Exponentiate each logit
Compute $e^{2} \approx 7.389$, $e^{1} \approx 2.718$, and $e^{0} = 1$.
- 2Sum the exponentials
The denominator is $7.389 + 2.718 + 1 \approx 11.107$.
- 3Divide for token A
$7.389 / 11.107 \approx 0.665$.
- 4Divide for token B
$2.718 / 11.107 \approx 0.245$.
- 5Divide for token C
$1 / 11.107 \approx 0.090$.
- 6Check the total
$0.665 + 0.245 + 0.090 = 1.000$, so the output is a valid distribution.
Token A gets about 0.665, token B about 0.245, and token C about 0.090. The largest logit still gives the largest probability, but the values are now a valid distribution.
Negative Logits After Softmax
A common surprise is that logits can be negative, while probabilities cannot. Softmax resolves this without any special rule. Because the exponential of any real number is positive, a negative logit becomes a small positive number in the numerator. A logit that is negative therefore receives a small but nonzero probability, and the normalization step still makes the total equal one.
Softmax on an all-negative vector
Apply softmax to the logit vector [-1, -2], where both entries are negative.
- 1Exponentiate
$e^{-1} \approx 0.368$ and $e^{-2} \approx 0.135$. Both are positive even though the inputs are negative.
- 2Sum
The denominator is $0.368 + 0.135 \approx 0.503$.
- 3Divide for the first token
$0.368 / 0.503 \approx 0.731$.
- 4Divide for the second token
$0.135 / 0.503 \approx 0.269$.
- 5Check the total
$0.731 + 0.269 = 1.000$.
The output is roughly 0.731 and 0.269. Both logits were negative, yet the result is a valid pair of probabilities. The sign of a logit does not decide whether it can be converted; the conversion always produces non-negative values.
Where Sampling Enters the Pipeline
Once a softmax layer has produced a probability for every token, the model still has to choose which token to output. This choice is where sampling strategies operate. The source explains that the right sampling strategy can make a model's responses better suited to a given application. One strategy can make responses more creative, while another can make them more predictable. Many strategies have been introduced to nudge the model toward responses with specific attributes, and you can also design your own, though doing so typically requires access to the model's logits.
The flowchart makes the ordering clear. Sampling strategies do not operate on raw logits in the ordinary description; they receive the probabilities that softmax has already produced. That is why the probability distribution has to be valid first: a strategy that picks among options weighted by these values relies on them being non-negative and summing to one.
Mistakes Learners Make with Logits
Common mistake Treating the largest logit as a percentage confidence
What it looks likeReading the logit vector [2, 1, 0] as saying token A is 200 percent likely.
Why it failsLogits are unnormalized scores. Their size only ranks tokens; it does not express a probability.
Do this insteadApply softmax first. The probability for token A is about 0.665.
Common mistake Assuming raw logits sum to one
What it looks likeAssuming [2, 1, 0] is already a distribution because the values look like weights.
Why it failsThese logits sum to 3, and they are not required to sum to one.
Do this insteadCompute the softmax denominator to normalize the values.
Common mistake Dropping tokens with negative logits
What it looks likeIgnoring a token whose logit is -2 because a negative number cannot be a probability.
Why it failsExponentiation turns every real logit into a positive number, so the token still receives a small nonzero probability.
Do this insteadKeep every token in the softmax computation; for [-1, -2] the outputs are about 0.731 and 0.269.
Common mistake Confusing the ordering of tokens with their probability values, so that a close pair of logits is assumed to have equal probabilities
Checking Your Understanding
A model with three tokens produces the logit vector [0, 0, 0]. Without fully computing, what should each probability be, and why? Then confirm your answer by applying softmax.
Hints
- Every logit is the same, so every exponential is the same value.
- Three equal numerators divided by their sum must each be one third.
- The sum of three equal probabilities must equal one.
Key Takeaways
- Raw logits are the model's output before conversion; larger logits point to higher probabilities, but the logits themselves are not probabilities.
- Logits can be negative and need not sum to one, so they fail the two properties a probability distribution must have.
- A softmax layer applies p_i = e^{x_i} divided by the sum of e^{x_j} over all N tokens, producing non-negative values that sum to one by construction.
- Negative logits become small positive numbers after exponentiation, so softmax handles them without any special rule.
- Sampling strategies act after softmax, choosing a token from the probability distribution the layer has produced.