Model Parameters & Configuration / Sampling & Randomness

Temperature

Beginner [2/5]
Randomness control Creativity parameter

Definition

Temperature is a parameter that controls how random or deterministic the model's outputs are. At temperature 0, the model always picks the most likely next word, producing consistent but potentially predictable output. Higher temperatures introduce more randomness, leading to more creative but potentially less focused results.

Think of it like a dial between "play it safe" (0) and "take creative risks" (1+).

Key Concepts

  • Low temperature (0-0.3): Focused, deterministic, consistent outputs
  • Medium temperature (0.4-0.7): Balanced creativity and coherence
  • High temperature (0.8-1.0+): Creative, varied, sometimes unpredictable
  • Probability distribution: Temperature adjusts the likelihood curve

Examples

Temperature Comparison
Same Prompt, Different Temperatures
Prompt: "Write a creative name for a coffee shop" Temperature 0.2 (Low - Predictable): → "The Daily Grind" → "Morning Brew Café" → "The Coffee Corner" Temperature 0.9 (High - Creative): → "Midnight Percolations" → "The Caffeinated Dreamer" → "Beans & Bohemia"
Lower temperature gives common, predictable results; higher temperature produces more unique ideas.
Temperature Guide
Recommended Settings by Task
Temperature 0: ✓ Code generation ✓ Factual Q&A ✓ Data extraction ✓ Classification tasks Temperature 0.3-0.5: ✓ Business writing ✓ Summarization ✓ Explanation Temperature 0.7-1.0: ✓ Creative writing ✓ Brainstorming ✓ Poetry/fiction ✓ Marketing copy
Match temperature to your task's needs for creativity vs accuracy.

Interactive Exercise

🌡
Choose the Right Temperature

For each task below, choose an appropriate temperature (0, 0.3, 0.7, or 1.0) and explain why:

1. Generating Python code to sort a list

2. Writing taglines for a new sneaker brand

3. Answering customer support questions

4. Writing a short fantasy story

Pro Tips
  • Use temperature 0 for factual, consistent tasks
  • Use 0.7-1.0 for creative tasks like writing
  • For code, lower temperature (0-0.3) usually works best
  • Generate multiple outputs at higher temperature and pick the best

Related Terms