How one number controls whether the AI is a robot or a poet.
temperature = 0.0 โ 2.0
"The capital of France is ___"
Model outputs probabilities for every possible next word:
Temperature decides HOW to pick from these probabilities
The Math: Softmax Scaling
T = 0.1
Extremely peaked
T = 2.0
Much flatter
Lower T โ sharper peaks. Higher T โ flatter distribution. (Illustrative scores; the formula is real.)
The Robot
Temp = 0
"The capital of France is ___" โ selection chances:
Always picks the #1 word. 100 runs โ 100 identical answers.
Top word "Paris" gets picked about 100% of the time here (illustrative chances, real formula).
The Sweet Spot
Temp = 0.7
"The capital of France is ___" โ selection chances:
Usually picks top words but sometimes surprises. A common choice for chat.
Top word "Paris" gets picked about 98% of the time here (illustrative chances, real formula).
The Wild Card
Temp = 1.5
"The capital of France is ___" โ selection chances:
Wild and unpredictable. Low-probability words get a real chance.
Top word "Paris" gets picked about 76% of the time here (illustrative chances, real formula).
Prompt: "How do I sort a list in Python?"
Same model, same prompt โ three temperatures (illustrative responses):
Same output every time. Perfect for code.
Helpful, varied phrasing. Good for explanations.
Wild tangent. Fun for stories, bad for code.
Top-P (Nucleus) Sampling
top_p = 0.9 โ keep the fewest top words whose chances add up to at least 90%
Temperature
Flatten the curve
Top-P
Cut the tail
Alternative to temperature: cut off low-probability tokens entirely.
Temperature โ Quality
Low Temp (0)
High Temp (1.5)
Good Prompt
Correct, concise answer
โCreative, still useful
โBad Prompt
Confidently wrong
โCreatively wrong
โPrompt quality matters MORE than temperature
Guess the Temperature
Prompt: "Write a haiku about coding"
Response A
Response B
Response C
API Differences
Provider
Range
Default
OpenAI
0 โ 2
1.0
Anthropic
0 โ 1
1.0
Gemini
0 โ 2
(varies)
Same concept, different scales. Always check the docs.
Match temperature to your task
Precise
0 โ 0.3
Balanced
0.5 โ 0.8
Creative
1.0 โ 1.5