HyperAIHyperAI

Command Palette

Search for a command to run...

The temperature coefficient (Temperature) is a parameter that controls sampling randomness during the decoding phase of large language models. At each step, the model outputs a probability distribution over the next token. The temperature T alters the steepness of this distribution by scaling the logits (first dividing by T, then applying softmax): when T < 1, the distribution becomes sharper, resulting in more deterministic and conservative outputs; when T > 1, the distribution flattens, leading to more diverse outputs that are also more prone to deviation; as T approaches 0, it is equivalent to greedy decoding, almost always selecting the token with the highest probability; when T = 1, the distribution remains unchanged.

The concept of the temperature coefficient originates from the Boltzmann distribution and simulated annealing in statistical physics. In 1983, Kirkpatrick et al., in their paper Optimization by Simulated Annealing, used "temperature" as a parameter to control search randomness: high temperatures allow escaping local optima, while gradually lowering the temperature over time leads to convergence. This notation was later adopted by sampling methods and softmax, becoming a general technique for adjusting distributions in generative models.

Typical usage of the temperature coefficient involves combining it with top-k and top-p (nucleus) sampling: first adjust the distribution according to the temperature, then truncate the long tail to balance diversity and coherence. In practice, higher temperatures are suitable for creative writing and brainstorming, while lower temperatures are preferred for code generation, mathematical reasoning, and factual question answering.

The effects of the temperature coefficient can be quantified. In 2026, Parupudi et al., in their paper Before and After Temperature: A Distributional View of Creative LLM Generation, used Llama-3.1-8B to generate 500 open-ended creative prompts at T = 0.3/0.8/1.5. They found that the single feature of "how temperature reshapes the distribution" could predict creativity rankings with a Spearman ρ of 0.918, significantly outperforming traditional metrics such as perplexity. This demonstrates that temperature is not merely a knob adjusted by intuition, but a key interface for regulating creativity and stability.

Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing

HyperAI Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp