# Temperature

- **Canonical URL:** https://getaimath.com/dictionary/temperature/
- **Topics:** [LLM Fundamentals](https://getaimath.com/dictionary/category/llm-fundamentals/)
- **Last updated:** 2026-11-25

## What is Temperature?

**In one sentence:** Temperature is a setting that controls how random or creative a model's answers are.

When choosing the next token, the model has a list of options with different chances. Low temperature makes it almost always pick the most likely option, so answers are focused and predictable. High temperature makes it more willing to pick less likely options, so answers are more varied and creative, but sometimes weird.

![How ChatGPT & Claude Talk: Super-Powered Autocomplete — Simple cartoon diagram showing a sentence chopped into Lego word blocks (tokens), an AI brain weighing the odds of the next word ("mat" 75%, "couch" 18%, "roof" 5%), and snapping "mat" onto the end of the sentence.](https://getaimath.com/diagrams/llm-fundamentals.png)
*Napkin Diagram (LLM Fundamentals): Language models don’t plan whole essays at once—they play a super-smart game of "guess the very next word" over and over.*

### Quick Math / Rule of Thumb

T = 0 picks the single highest-probability token (greedy); T = 0.2–0.4 stays focused for code/facts; T = 0.8–1.0 flattens probabilities for creative variety.

## What is an example of Temperature?

Temperature 0 is good for math or facts, while temperature 0.9 is better for brainstorming story ideas.

## Why does Temperature matter?

Adjusting temperature lets you trade reliability for creativity.

## Temperature vs. Top-P Sampling

Temperature rescales how flat or sharp all token probabilities are, while Top-P (nucleus sampling) cuts off the unlikely tail once top choices add up to probability P.

| Dimension | Temperature | [Top-P Sampling](https://getaimath.com/dictionary/top-p-sampling/) |
| --- | --- | --- |
| Mechanism | Sharpens (<1) or flattens (>1) logits | Keeps smallest top set summing to P (e.g., 0.9) |
| Effect on long tail | Lowers tail odds but keeps rare words possible | Hard-truncates low-probability tail tokens |
| Practical advice | Tune one primarily (e.g., T=0.2 for code, 0.8 for writing) | Keep near 0.9–0.95 as a safety net |

## Related Concepts

- [Chain of Thought (CoT)](https://getaimath.com/dictionary/chain-of-thought-cot/): Chain of Thought is when an AI works through a problem step by step in writing before giving its final answer.
- [Top-K Sampling](https://getaimath.com/dictionary/top-k-sampling/): Top-K sampling means the model only chooses the next token from its K most likely options.
- [Few-shot Prompting](https://getaimath.com/dictionary/few-shot-prompting/): Few-shot prompting is giving an AI a handful of examples in the prompt before asking it to do the task.
- [Top-P Sampling](https://getaimath.com/dictionary/top-p-sampling/): Top-P sampling means the model picks from the smallest group of likely tokens whose chances add up to P, such as 90%.
- [One-shot Prompting](https://getaimath.com/dictionary/one-shot-prompting/): One-shot prompting is asking an AI to do a task after showing it exactly one example.
- [Repetition Penalty](https://getaimath.com/dictionary/repetition-penalty/): A repetition penalty is a setting that makes a model less likely to repeat the same words or phrases over and over.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/temperature/)
