Model

Temperature

Why You Need to Understand Temperature

The same Prompt, each time you call the model, the generated content can vary — sometimes slightly, sometimes dramatically.

This is because when generating each word, the model isn't "choosing the most correct one" but "sampling according to probability." Temperature is the parameter that controls how "conservative or aggressive" this "sampling" is.

Understanding Temperature helps you tune output to match expectations — stable code, or creative copy, precise extraction, or free brainstorming.


What Is Temperature

One-line definition: Temperature controls the randomness of model output. Lower values mean more stable, higher values mean more varied.

Analogy: Temperature is like a "conservative/aggressive" dial:

  • Turn it low = model chooses the safest words, like writing standard answers on an exam
  • Turn it high = model is willing to take risks, like bold improvisation during creative writing

Practical effects:

  • 0.0 - 0.3: very stable, suitable for code, extraction, rule-based responses
  • 0.4 - 0.6: stable with variation, suitable for daily Q&A, summarization, customer service
  • 0.7 - 1.0: more varied, suitable for creative writing, brainstorming, copywriting

How to Do It: When to Turn Up / Down

Turn down for scenarios (pursuing stability):

  • Code generation: the same function should produce essentially consistent code
  • Information extraction: extracting fields from text, needs accuracy, can't deviate
  • Math, logic, normative answers: answers should be unique
  • Needing reproducible results: testing and tuning need stable output

Turn up for scenarios (pursuing variation):

  • Creative writing: needs diverse expression
  • Ad copy: paraphrase variations, multiple versions
  • Brainstorming: wanting unexpected ideas
  • Generating multiple different expression versions

For another sampling control parameter, see the Top-p entry — both control randomness but in different ways.

Common pitfalls:

  • High Temperature doesn't mean smarter: just more random, not necessarily more accurate
  • Complex reasoning usually needs low Temperature: reasoning needs stability, not randomness
  • Using the same value for all tasks: different task types vary greatly, best configured per scenario

Remember this: Temperature is the "conservative/aggressive" dial — lower is more stable, higher is more varied — but higher isn't necessarily better.

Related terms: Top-p · Token