Temperature (Sampling)

Category: NLP / Language Processing

A parameter that controls the randomness of text generation by scaling the model output logits before applying softmax, with higher values producing more diverse output.

Full Explanation

Temperature is a hyperparameter applied during text generation that modifies the probability distribution over the vocabulary before sampling. The logits (raw model outputs) are divided by the temperature value before the softmax function is applied. A temperature of 1.0 leaves the distribution unchanged; values below 1.0 sharpen the distribution, making high-probability tokens even more likely (more deterministic); values above 1.0 flatten the distribution, making low-probability tokens more likely (more creative/random). At temperature 0, generation becomes equivalent to greedy decoding. Temperature is commonly used alongside top-K or top-P sampling to fine-tune the balance between coherence and creativity. Typical values range from 0.1 for factual tasks to 1.0 or higher for creative writing. Choosing the right temperature is essential for controlling the behavior of language model applications.

Related Terms

More in NLP / Language Processing

Explore More

  • AI Tools Library — Discover AI tools related to Temperature (Sampling)
  • AI Education — Courses to learn about NLP / Language Processing
  • AI News — Latest news and updates