AI GLOSSARY · AI CONCEPTS

Temperature (LLM sampling)

Markdown version

Definition

In language-model token sampling, temperature adjusts the probability distribution used to select tokens. A lower value concentrates probability on the most likely tokens; a higher value spreads probability more evenly. It affects generation only when the decoding method uses it.

Also called: LLM temperature, temperature AI, temperature setting LLM, temperature parameter, sampling temperature.

In plain language

An autoregressive text generator predicts the next token according to a probability distribution. When temperature is used for sampling, lowering it concentrates probability on the most likely tokens, while raising it spreads probability more evenly. A decoder that does not use temperature will ignore that setting. IBM notes that temperature is often conflated with creativity, but this is not always the case.

Technical definition

IBM describes how each token is assigned a logit, and the set of tokens is normalized into a softmax probability distribution. The temperature parameter modifies this distribution. In the OpenAI chat completions reference, temperature is a number between 0 and 2 with a default of 1; higher values like 0.8 make output more random and lower values like 0.2 make it more focused and deterministic. OpenAI generally recommends altering temperature or top_p but not both. In Hugging Face Transformers, GenerationConfig temperature modulates next-token probabilities and defaults to 1.0 if not set. Its temperature warper requires do_sample=True to affect generate. For the standard decoding strategies, num_beams=1 gives greedy decoding with do_sample=False or multinomial sampling with do_sample=True; num_beams>1 gives beam-search decoding or beam-search multinomial sampling respectively.

Worked examples in this catalogue

Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.

  1. Skill by Skill Almanac · Illustrative, not executed

    llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    Builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
    Why it exercises the concept
    Prepare the same cases for comparing temperature settings in a separate evaluation harness. This skill checks the dataset; it does not run or score the model.

How it shows up when you use agents

In the OpenAI chat completions reference, temperature is an optional request parameter. In Hugging Face Transformers, it is a field of GenerationConfig. For the standard strategies, do_sample controls whether to sample: with num_beams=1, False selects greedy decoding and True selects multinomial sampling. With num_beams>1, the corresponding methods are beam-search decoding and beam-search multinomial sampling.

When sampling uses temperature, it changes the probability distribution used to select the next token during inference. Hugging Face's TemperatureLogitsWarper documentation explicitly requires do_sample=True; otherwise temperature has no effect on generate. OpenAI's reference describes top-p as an alternative to sampling with temperature, and generally recommends altering one of the two but not both.

Common confusions

  • Temperature versus top-p. OpenAI's reference describes top-p as nucleus sampling, an alternative to sampling with temperature, in which the model considers the tokens comprising the top probability mass.
  • Temperature versus creativity. IBM says temperature is often conflated with creativity, but this is not always the case, and suggests thinking of it as how broadly the model uses text from its training data.
  • Temperature versus focus. OpenAI's reference says lower values like 0.2 make output more focused and deterministic, and higher values like 0.8 make it more random.

Terms that mention Temperature (LLM sampling)

2 terms mention this one

More in AI concepts

Next steps

  1. llm-eval-test-sets A skill that exercises it.
  2. Softmax Related term.
  3. Token Related term.
  4. All glossary terms A to Z and by family.

Sources

Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-24. Wikipedia is never the only source.

Review record

Last verified

Drafted by Claude and Codex (automated drafting); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-24. Last verified .

Change log (7)
  • : US Google Ads query estimate aligned to cached receipt; close variants may overlap and no traffic is promised.
  • : Independent automated factual and example-source review completed; exact-version technical and demand checks recorded separately. Publication remains disabled.
  • : Codex scope correction after independent source review; peer acceptance pending, not indexable.
  • : First version.
  • : Stage-3 accuracy pass: removed unsourced claims (falsehood at any setting, identical output, agent tool advice, provider variance); narrowed examples to skill and guide text; attributed creativity point to IBM.
  • : Revision author scoped temperature to decoding that uses it, corrected sampling/beam conditions, and retained only the relevant eval-dataset example; independent re-review pending.
  • : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.