AI and Probability: Meaning and Selective Use of Temperature, top-p, top-k

AI Navigate Original / 4/27/2026

💬 OpinionIdeas & Deep AnalysisTools & Practical Usage
共有:

Key Points

  • LLMs sample from a probability distribution; temp/top-p/top-k control it
  • Low temp = deterministic (classify); high = creative (story)
  • Move only one of temperature/top-p; fix seed for reproducibility
  • Settings differ per model; check API defaults

The LLM Rolls Dice

An LLM may return different output every time for the same input. This is because the LLM, after computing "the probability distribution of the next word," samples (draws lots) from that distribution. Parameters like temperature, top-p, top-k control how probability is rolled.

Temperature

A value 0 to 2. Controls how much to "sharpen / flatten" the probability distribution.

Example: The Word After "Japan's capital is"

CandidateRaw probAfter T=0.5After T=2.0
Tokyo0.950.990.7
Kyoto0.030.0050.15
Osaka0.010.0010.10
Other0.010.0010.05

Temperature Guide

  • 0.0: fully deterministic (same every time). For tests/classification.
  • 0.0-0.3: nearly deterministic. Fact-check, extraction, summary.
  • 0.5-0.7: standard. Chat, Q&A, coding.
  • 0.8-1.0: creative. Novels, poetry, brainstorm, ad copy.
  • 1.0+: very diverse, quality-degradation risk.

top-p (Nucleus Sampling)

Sign up to read the full article

Create a free account to access the full content of our original articles.

AI and Probability: Meaning and Selective Use of Temperature, top-p, top-k | AI Navigate