P

Temperature (AI): Definition and Examples

Temperature is a parameter of AI models that controls the degree of randomness in generated responses. A low value (0-0.3) produces predictable responses, a high value (0.7-1.0) fosters creativity.

Full definition

Temperature is one of the most important parameters to master in prompt engineering. This setting directly influences the probability distribution when selecting the next token to generate.

Concretely, when you set the temperature to 0, the model systematically chooses the most likely token, giving deterministic responses. Conversely, a temperature of 1.0 allows exploring less likely options.

In practice, the ideal temperature depends on the use case. For factual writing or code, prefer 0-0.3. For brainstorming or creation, go up to 0.7-1.0.

Caution: too high a temperature (>1.0) can lead to incoherent responses or even hallucinations.

Etymology

The term comes from statistical physics. In physics, temperature determines the agitation of particles. The analogy was adopted in machine learning.

Concrete examples

Writing a professional email — low temperature

You are a professional assistant. Write a follow-up email for a client.

[temperature = 0.2]

Creative brainstorming — high temperature

Generate 20 original brand names for a healthy meal delivery startup.

[temperature = 0.9]

Code generation — very low temperature

Write a Python function that sorts a list by date in descending order.

[temperature = 0.1]

Practical usage

Start with a temperature of 0.3 and adjust. For creative tasks, increase gradually. For code, stay below 0.2.

Related concepts

Top-p (nucleus sampling)Top-kFrequency penaltyPresence penalty

FAQ

What is the best temperature for ChatGPT?
There is no universal value. For factual text/code: 0-0.3. For creative: 0.7-0.9. For general use: 0.4-0.6.
What is the difference between temperature and top-p?
Temperature modifies the entire probability distribution, while top-p cuts off the least likely options. Adjust one and leave the other at default.
Does temperature 0 always give the same response?
Almost. The model is quasi-deterministic, but slight variations can appear. Combine temperature=0 with a fixed seed for full reproducibility.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.