---
title: "Temperature"
slug: "temperature"
category: "glossary"
tags: ["glossary", "ai-agents", "llm", "sampling", "determinism", "prompt-design"]
status: "stable"
last_updated: 2026-05-14
summary: "Temperature scales the probability distribution over next-token predictions; lower values produce more deterministic output, higher values increase variability."
related:
  [
    "[[glossary/top-p]]",
    "[[glossary/token]]",
    "[[glossary/context-window]]",
    "[[prompt-engineering/prompt-design]]",
    "[[ai-agents/structured-output]]",
    "[[glossary/structured-output]]",
  ]
---

## Overview

This page is the atomic definition. Sampling and inference configuration live at [[prompt-engineering/prompt-design]].

## Definition

Temperature is a scalar applied to the logits (raw token probability scores) before sampling the next token. Dividing logits by a temperature below 1.0 sharpens the distribution, making the highest-probability token more likely and reducing variance. Dividing by a temperature above 1.0 flattens the distribution, giving lower-probability tokens more opportunity to be sampled and increasing variance. At `temperature=0`, the model always picks the highest-probability token (greedy decoding), producing deterministic output for the same prompt and model state. At `temperature=1.0`, the model samples from the raw distribution. Typical recommendations: use `0` or `0.1` for structured extraction, code generation, and fact retrieval; use `0.7-1.0` for creative writing, brainstorming, and varied generation. Most providers cap temperature at `2.0`; values much above `1.0` produce incoherent output for most tasks.

## When it applies

Set temperature explicitly for any production use case. Default temperature varies by provider and model. Use `0` for deterministic pipelines (parsing, classification, extraction) where reproducibility matters. Use higher values for creative tasks where diversity is the goal.

## Example

A data extraction prompt with `temperature=0` returns the same JSON every run given the same input, enabling reliable testing. The same prompt at `temperature=1.0` may vary field capitalization or phrasing across runs.

## Related concepts

- [[glossary/top-p]] - the complementary sampling parameter that limits vocabulary size.
- [[glossary/token]] - temperature controls the distribution over the next token at each step.
- [[prompt-engineering/prompt-design]] - when to set temperature for different task types.
- [[glossary/structured-output]] - structured output schemas pair with low temperature for reliability.

## Citing this term

> See [[glossary/temperature|Temperature]] (llmbestpractices.com/glossary/temperature).

## Related

- [[glossary/top-p]]
- [[glossary/token]]
- [[glossary/context-window]]
- [[prompt-engineering/prompt-design]]
- [[glossary/structured-output]]
