LLM & Transformer Fundamentals·Question 11 of 109Basic

What does the temperature parameter actually do? Give the formula.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Temperature rescales the logits before the softmax that converts them into a probability distribution over the vocabulary:

p_i = exp(z_i / T) / Σ_j exp(z_j / T)

Full worked answer

Temperature rescales the logits before the softmax that converts them into a probability distribution over the vocabulary:

p_i = exp(z_i / T) / Σ_j exp(z_j / T)

  • T = 1: the model's raw distribution.
  • T → 0: differences between logits are amplified; the distribution collapses toward the argmax - deterministic, greedy-like decoding. (T = 0 in APIs is implemented as argmax; true division by zero is undefined.)
  • T > 1: differences are compressed; the distribution flattens, low-probability tokens become likelier - more diverse, more error-prone output.

Key properties worth stating: temperature is a monotonic transform - it never reorders tokens, only sharpens or flattens the distribution, so greedy decoding is unaffected by it. It operates per generation step on the conditional distribution, and its effects compound over a long generation: small increases in per-token entropy produce noticeably more divergent completions.

Going further: follow-up territory

Practical guidance a strong candidate gives: use T = 0 (or near it) for extraction, classification, structured output, and code where there's a correct answer - you want the mode. Use T ≈ 0.7-1.0 for creative writing and brainstorming where diversity is the point. Note that T = 0 does not guarantee bit-identical outputs across API calls in practice (batching non-determinism, floating-point non-associativity across kernels, infrastructure changes), a common misconception worth flagging. And check whether you can set it at all: as of late 2026 the newest closed frontier models have removed sampling parameters (Anthropic's 5.x models reject or ignore them, GPT-6 Astra accepts no custom temperature, Gemini ignores them from 3.6 Flash and Google recommends system instructions for determinism). This guidance applies to self-hosted open-weight models and older API models; on current frontier APIs you steer behaviour through effort level, structured outputs and prompting instead. Also note temperature interacts with truncation samplers: it's applied with top-p/top-k/min-p, and the order of operations (typically temperature first, then truncation, though implementations vary) changes behaviour at high T - min-p in particular was designed to stay robust at T > 1.

One more useful framing: temperature trades off exploitation of the model's confidence against exploration of its uncertainty - the same knob as in softmax exploration in RL.

What a good answer covers

  • p_i = exp(z_i / T) / Σ_j exp(z_j / T)
  • T = 1: the model's raw distribution
  • T → 0: differences between logits are amplified; the distribution collapses toward the argmax -…
  • T > 1: differences are compressed; the distribution flattens, low-probability tokens become likelier -…
  • Key properties worth stating

Key terms: T = 1 · T → 0 · T > 1

Interviewer follow-ups to expect

  1. Why can T=0 still produce different outputs across identical API calls?

  2. If you increase temperature, why do you usually also want min-p or top-p?

  3. What temperature would you use for an LLM-as-judge evaluation and why?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep