A logit is the raw, unnormalised score a model produces for each possible output before those scores are turned into probabilities. In an LLM, the final layer produces one logit for every token in the vocabulary at each step. Softmax then converts the full set of logits into a probability distribution. The terms “logit” and “logits” are used interchangeably; logits are simply the vector of all these scores.
Key takeaways
- Logits are scores, not probabilities: they can be negative and do not sum to 1.
- Only the relative differences between logits matter, not their absolute values.
- Softmax turns logits into probabilities; temperature divides logits first.
- Logit bias can push specific tokens up or down before sampling.
- Logprobs, returned by some APIs, are the logarithms of the resulting probabilities.
A logit explained in simple terms
Imagine judges scoring contestants with raw points: 8.2, 5.1, −1.4. These points are not percentages and do not add to 100. To express them as chances of winning, you convert them with a formula. Logits are the raw points; softmax is the conversion.
From logits to probabilities
Softmax exponentiates each logit and divides by the total:
Worked example with three candidate tokens:
| Token | Logit | e^logit | Probability |
|---|---|---|---|
| ” Mumbai” | 3.0 | 20.09 | 0.78 |
| ” Pune” | 1.5 | 4.48 | 0.17 |
| ” Delhi” | 0.2 | 1.22 | 0.05 |
The exponentials sum to 25.79, so the probabilities are about 0.78, 0.17 and 0.05. Note how a logit gap of 1.5 becomes a large probability gap: softmax strongly favours the highest scores.
Why models output logits rather than probabilities
- Numerical stability: loss functions such as cross-entropy are computed more stably directly from logits.
- Flexibility: temperature, top-k and top-p all operate on logits before the final conversion.
- Efficiency: softmax over a vocabulary of 100,000+ tokens is applied once, at the end.
Practical uses of logits
| Use | How it works |
|---|---|
| Logit bias | Add a positive or negative value to specific tokens to encourage or forbid them |
| Constrained decoding | Set logits of invalid tokens to negative infinity to enforce structured output |
| Confidence signals | Compare the top logits to see how decisive the model is |
| Classification with LLMs | Compare logits of label tokens such as “yes” and “no” |
| Speculative decoding | Verify a draft model’s tokens against the main model’s logits |
Logprobs
Many APIs expose logprobs: the natural logarithm of each token’s probability. A logprob of 0 means probability 1, and more negative values mean less likely. They are useful for measuring confidence, ranking alternatives and detecting uncertain answers. Note that low confidence does not guarantee an error, and high confidence does not guarantee correctness.
Logits in classification
Outside LLMs, the same term applies: a classifier’s final layer produces logits, which sigmoid or softmax converts into class probabilities. The word comes from the logit function in statistics, the log-odds, which is the inverse of the logistic function.
Limitations
- Raw logit values are not comparable across models or runs.
- Large vocabularies make logit processing costly at each step.
- Logits are often poorly calibrated: high confidence can still be wrong.
