Zenaique

Pick what happens to attention weights when pre-softmax scores are divided by a temperature T > 1

MCQ·Easy·4.0 · 0·~1 min·Asked atIBMMckinseyRunway·Relevant atMicrosoft
Attempt it
TL;DR

T > 1 flattens the distribution: gaps between scores shrink, attention spreads across more positions. In the limit T -> infinity the row becomes uniform.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a vote where everyone shouts a number out of 100 for each candidate. If you shrink everyone's volume to a whisper, the loudest shouter no longer drowns out the others and the final vote spreads out instead of going to a single landslide winner. Dividing the model's raw scores by a temperature greater than 1 is exactly that volume knob: it shrinks every number toward zero, so the final share of attention across all the items in the row evens out instead of being captured by one peak. Turn the knob the other way and the loudest voice wins everything.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Temperature T in softmax controls how peaked or flat the output distribution is. Dividing scores by T > 1 shrinks them toward zero, narrows the ratios between exponentials, and produces a flatter post-softmax distribution. The two limits are interpretable: T -> infinity gives a uniform distribution (maximum entropy), and T -> 0 gives a one-hot argmax (minimum entropy). For any finite T > 1, the distribution sits monotonically between the two extremes.

This deep dive walks the temperature-softmax formula and its limits, distinguishes shift-invariance from scale-non-invariance, explains the sqrt(d_k) divisor as a built-in attention temperature, and traces where temperature manipulation actually shows up in production (LLM output sampling, knowledge distillation, not per-layer attention).

Mental model: temperature is a one-parameter family interpolating between argmax and uniform. The sqrt(d_k) scaling in attention is a fixed temperature; the LLM's output temperature is the tunable knob you actually adjust at decoding.

The temperature-softmax formula and its limits

Softmax with temperature T applies the formula:

wj(T)=esj/Tkesk/Tw_j(T) = \frac{e^{s_j / T}}{\sum_k e^{s_k / T}}

The two limits

  • T -> infinity: every s_j / T -> 0, every e^{0} = 1, the denominator is T_k, so every entry is 1/T_k. The row is uniform. Maximum entropy log(T_k).
  • T -> 0+: gaps between scores explode ((s_j - s_max) / T -> -infinity for all non-max j), so non-max exponentials vanish and only the max survives. The row is one-hot at argmax_j s_j. Minimum entropy 0.

The intermediate regime

For any finite T > 1, the distribution is monotonically softer than T = 1: the ranking of entries is preserved, but the relative magnitudes are compressed. The entropy H(w(T)) is a monotonically increasing function of T.

For any finite T < 1, the distribution is monotonically sharper than T = 1: ranking preserved, magnitudes amplified, one entry dominates more aggressively.

The display form

T0:wone-hot(argmaxs),T:wuniformT \to 0: w \to \text{one-hot}(\arg\max s), \quad T \to \infty: w \to \text{uniform}

Key insight: temperature is not a binary switch. It is a smooth interpolation parameter between the two extremes, with the entropy of the distribution as a monotone function of T.

Shift invariance vs scale non-invariance
The sqrt(d_k) divisor as built-in attention temperature
Where temperature is actually tuned: LLM sampling and distillation
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Vaswani et al. 2017: section 3.2.1 explains the sqrt(d_k) divisor as a built-in temperature chosen to keep pre-softmax variance near 1.
  • LLM sampling at inference time: T = 0.7 (slightly sharper than default) is a common chat-model setting; T > 1 produces more diverse text; T -> 0 approaches greedy decoding.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy is softmax shift-invariant but not scale-invariant, and what is the practical implication?
A

Shift invariance: softmax(x + c) = softmax(x) because the additive constant cancels from numerator and denominator (e^{x_i + c} = e^{x_i} e^c). The e^c factor is the same in every entry, so it drops out. Scale non-invariance: softmax(x / T) != softmax(x) because dividing by T scales the gap between any two inputs by 1/T, and the exponential function is non-linear in ratios. Practical implication: the row-max stabilization trick softmax(x - max(x)) is mathematically free (shift-invariant), so production code uses it everywhere. Temperature scaling, on the other hand, genuinely reshapes the distribution.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Claiming softmax is scale-invariant. It is shift-invariant (subtract a constant from every input and weights are unchanged), not scale-invariant; dividing by T > 1 reshapes the distribution.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • The temperature-softmax formula softmax(x / T)

  • Behavior at T > 1 (flatter), T < 1 (sharper), T -> infinity (uniform), T -> 0 (argmax)

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Explain scaled dot product attention.
Short answer·Medium