Temperature (Parameter)
A setting that controls how random or creative an AI model's responses are β low temperature gives focused, predictable output while high temperature gives varied, creative output.
Temperature is a parameter that controls the randomness of an AI model's output. At low temperatures, the model picks the most likely next token almost every time, producing focused and predictable responses. At high temperatures, the model spreads probability more evenly across options, producing more varied and creative β but potentially less coherent β output.
How temperature works
When an AI model generates each token, it calculates a probability distribution over its entire vocabulary. "The cat sat on the ___" might assign: "mat" (40%), "floor" (20%), "chair" (15%), "table" (10%), and thousands of other words with small probabilities.
Temperature adjusts this distribution:
- Temperature 0 (or near 0): The model almost always picks the highest-probability token. Output is deterministic and repetitive.
- Temperature 0.3-0.7: A moderate range. The model mostly follows high-probability options but occasionally introduces variety.
- Temperature 1.0: The default for many models. Natural diversity in output.
- Temperature above 1.0: Probabilities flatten. Less likely tokens get chosen more often. Output becomes more creative but may lose coherence.
Choosing the right temperature
- Factual questions and data extraction: Low temperature (0-0.3). You want the most accurate, consistent answer.
- Business writing and emails: Medium temperature (0.3-0.7). Professional but not robotic.
- Creative writing and brainstorming: Higher temperature (0.7-1.0). More variety and unexpected combinations.
- Code generation: Low temperature (0-0.3). Correctness matters more than creativity.
- Classification: Temperature 0. You want the most confident, consistent label.
Temperature vs top-p
Temperature and top-p (nucleus sampling) both control randomness but in different ways. Temperature adjusts the probability distribution directly. Top-p restricts the set of tokens considered to those covering a cumulative probability threshold. Many practitioners adjust one and leave the other at default.
Temperature in practice
Most AI APIs accept temperature as a parameter in the request. If you are using a chat interface, you may find temperature controls in the settings. Some providers default to temperature 1.0; others default to lower values.
A common mistake
Setting temperature to 0 does not guarantee identical outputs for the same prompt. Minor computational differences (floating-point arithmetic, batching) can still introduce variation. For truly deterministic outputs, some providers offer a seed parameter alongside temperature 0.
Why This Matters
Temperature is one of the few controls you have over AI output characteristics. Setting it appropriately for each use case is a simple change that can significantly improve results. Data extraction with high temperature wastes accuracy; brainstorming with low temperature wastes creativity. Matching temperature to task is basic AI hygiene.
Related Terms
Continue learning in Essentials
This topic is covered in our lesson: Prompt Engineering Fundamentals