Temperature

Temperature is a parameter that controls the randomness and creativity of AI-generated output. Lower temperatures (0-0.3) produce more focused, deterministic responses ideal for coding, while higher temperatures (0.7-1.0) enable more creative and varied outputs.

Example

For generating production code, you'd use temperature 0.1 for consistent, predictable results. For brainstorming feature ideas, temperature 0.8 gives more creative suggestions.

Temperature is one of the few AI parameters you can directly control, and it significantly impacts the code you get.

How Temperature Works

At each step, AI predicts probable next tokens:

  • Low temperature (0.1) — Almost always picks the most likely token
  • Medium temperature (0.5) — Sometimes explores less likely options
  • High temperature (0.9) — Frequently picks surprising tokens

Temperature for Different Tasks

TaskRecommended Temperature
Code completion0.1 - 0.3
Bug fixes0.1 - 0.2
Documentation0.3 - 0.5
Brainstorming0.7 - 0.9
Creative writing0.8 - 1.0

Why Low Temperature for Code

Code needs to be:

  • Syntactically correct
  • Logically consistent
  • Following established patterns

High temperature introduces randomness that can break these requirements.

When to Increase Temperature

  • Exploring alternatives — "Give me 5 different approaches"
  • Naming things — Variable, function, project names
  • Creative features — Unusual UI patterns, novel solutions
  • Brainstorming — Feature ideas, architecture options

Accessing Temperature

Most AI tools have defaults:

  • Cursor — Optimized automatically, limited control
  • Claude API — Direct parameter access
  • ChatGPT — Hidden, uses reasonable defaults

If you have control, start low for code and only increase when you want variety.

Ad
Favicon