﻿# Temperature changes a probability distribution before sampling

Temperature rescales token logits before normalization. Understand probability ratios, entropy, greedy limits and why temperature does not add knowledge.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/temperature-probability-entropy/
Language: en

Temperature is a numerical operation on a next-token distribution. Describing it only as creativity hides what actually changes: the relative weight of candidate tokens after the model has computed scores. A small distribution makes this mechanism visible without relying on a subjective judgment about the generated answer.

## Divide logits before softmax

For positive temperature, divide candidate logits by that temperature before softmax normalization. This preserves their ordering while changing their separation. Raising temperature compresses score differences; lowering it expands them. The resulting probabilities still sum to one. This is a decoding transformation applied to an already computed vector, so it does not change the model weights, the prompt tokens or the evidence available at that step. A separate token filter may subsequently remove candidates, depending on the generation pipeline.

## Probability ratios reveal the operation

For two candidate logits, the ratio of their softmax probabilities is the exponential of their score difference divided by temperature. Consider scores with a fixed positive gap. Increasing temperature reduces the ratio toward equal weighting; decreasing temperature makes the favored candidate more dominant. The relationship is about ratios, not simply adding a fixed probability to every unusual word. Normalization couples all candidates, so a probability changes in relation to the complete surviving distribution, including tokens outside the most visible shortlist.

## Entropy concerns the conditional distribution

For a fixed finite score vector, increasing positive temperature flattens the softmax distribution and generally increases its entropy toward a uniform distribution. This is local conditional uncertainty at the current position. A full sampled sequence changes later contexts, so a local entropy comparison cannot predict every property of finished text. Diverse continuations may include mistakes as well as useful alternatives. Increasing entropy supplies no new factual source and cannot guarantee that a rare candidate is more insightful than a common one.

## Keep the implementation boundary explicit

A zero-temperature setting is often implemented as a greedy special case rather than literal division by zero. Check the documented generation behavior. For a reproducible illustration, save one logit vector and compare transformed distributions before drawing samples. Then hold filtering rules and random seed policy explicit when studying complete outputs. A different answer can result from randomness even with identical probabilities. This distinction prevents model changes, probability transformations and random draws from being combined into one vague explanation about creativity.

## Primary research and implementation references

- [Hugging Face: Generation Strategies](https://huggingface.co/docs/transformers/generation_strategies).

- [The Curious Case of Neural Text Degeneration](https://arxiv.org/abs/1904.09751).

- [Attention Is All You Need](https://arxiv.org/abs/1706.03762).

## Related engineering context

[Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/).
