EMZETT.
Login

Temperature and sampling

In short: Temperature controls how randomly a language model picks the next token. Low is predictable, high is more creative and riskier.

In more detail: The model computes a probability for each possible token. At temperature 0 the most likely is always chosen. Higher values flatten the distribution. Top-p and top-k restrict the choice to the most likely candidates.

In Depth

  • Factual tasks, code: low (0 to 0.3).
  • Creative writing: medium to high (0.7 to 1.0).
  • Top-p (nucleus): Only tokens whose probabilities add up to p count.
  • Repetition penalty: prevents loops.
  • Seed: The same seed and temperature 0 usually give reproducible results.

See also: Hallucination (AI), Prompt engineering