Skip to main content

What is Temperature?

How temperature affects randomness and predictability, how logits and softmax work, and some examples with real numbers.

N
Written by Niko McCarty
Updated this week

Overview

When you adjust a model’s temperature, you’re controlling how predictable or random its outputs are. A lower temperature makes the model stick to the safest, most likely answers, while a higher temperature encourages it to be a bit more unpredictable. Temperature doesn’t make the model smarter or more creative—it simply reshapes the probabilities it assigns to possible outputs.

You can change a model's "temperature" setting while chatting with it on the model's Details page.

How to Use

Step 1: Understand how models generate text

  • Language models generate text one token at a time. A token might be a whole word (“cat”), part of a word (“ing”), or punctuation.

  • For each token, the model assigns scores (called logits) to every possible next token. Larger logits mean the token is more likely.

  • To convert logits into probabilities, the model applies a softmax function, which ensures they all sum to 1.

Step 2: See what temperature does

  • Before applying softmax, the model divides logits by the temperature value you set.

  • If temperature < 1: the gap between tokens grows. The model becomes more conservative, favoring the most likely token.

  • If temperature > 1: the gap shrinks. The model becomes more exploratory, spreading probability across more tokens.

Step 3: Try it with an example
Imagine the model has three possible next tokens with logits:

  • “cat” → 2.0, “dog” → 1.0, “banana” → 0.1

Now, if the temperature is set to...

  • 1.0 → Probabilities: cat 66%, dog 24%, banana 10%

  • 0.5 → Probabilities: cat 86%, dog 12%, banana 2% (much more predictable)

  • 2.0 → Probabilities: cat 50%, dog 30%, banana 20% (more varied, less predictable)

Step 4: Apply this in practice

  • Use low temperatures (0.2–0.7) for deterministic tasks like classification, code generation, or structured Q&A.

  • Use higher temperatures (0.8–1.5) for open-ended tasks like brainstorming, storytelling, or creative writing.

Tips & Best Practices

  • Match the task: Structured tasks work better with low temperatures, while creative ones benefit from higher settings.

  • Experiment: Small changes (e.g., 0.7 → 0.9) can noticeably affect outputs.

  • Don’t overdo it: Very high temperatures (>2.0) often lead to incoherent or nonsensical outputs.

  • Remember the principle: Temperature isn’t a creativity dial—it’s a way of reshaping probabilities.

Troubleshooting

The model is too random

Lower the temperature (e.g., 0.3–0.5). This sharpens probabilities and reduces unexpected tokens.

The model is too repetitive or boring

Raise the temperature (e.g., 0.9–1.2). This flattens probabilities and makes it more exploratory.

Outputs don’t change much when I adjust temperature

For some tasks (like binary classification), the token space is small. Temperature won’t have a big effect. Try tasks with more diverse outputs.

Did this answer your question?