Back to the index
48/ 55

USING MODELS

Temperature.

A sampling setting that changes how strongly a model favors its most likely next outputs.

In plain words

Temperature adjusts the probability distribution used to sample outputs. In language generation, lower values usually concentrate probability on likely next tokens; higher values spread probability more broadly.

A closer look

A model first produces scores for candidate tokens. In a common implementation, these scores are divided by a positive temperature before being converted into probabilities. The system then samples from that distribution, potentially applying other settings such as top-p as well. A zero setting is often implemented as choosing the highest-scoring token.

The effect depends on the model, task, and other serving settings. A lower value may help with consistency; a higher one can create more variation. Providers differ in which settings they expose, and some models do not support an adjustable temperature at all.

In practice

AN EXAMPLE

For brainstorming story titles, more varied sampling may produce a wider selection. For extracting a reference number, consistency matters more, but the output still needs validation.

A useful distinction

Temperature is not a truthfulness or intelligence dial. Lowering it can make a model repeat the same wrong answer. Even a nominally deterministic setting does not guarantee identical outputs across every serving environment.

Sources & further reading

Hugging Face — Generation strategies (opens in a new tab)