Pick what happens to attention weights when pre-softmax scores are divided by a temperature T > 1
T > 1 flattens the distribution: gaps between scores shrink, attention spreads across more positions. In the limit T -> infinity the row becomes uniform.
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.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
State that T > 1 flattens the distribution, derive the two limits (T -> infinity uniform, T -> 0 argmax), explain shift-invariance vs scale-non-invariance, and connect to the sqrt(d_k) built-in temperature and LLM output sampling temperature.
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.
- Hinton et al. 2015 (Distilling the Knowledge in a Neural Network): teacher logits divided by T > 1 to produce softer distributions for student training; the dark-knowledge insight.
- OpenAI, Anthropic, and Google APIs all expose a temperature parameter for chat completions, applied to the final vocabulary softmax during decoding.
- Modern decoding strategies like nucleus sampling and top-k filtering operate alongside temperature, often with T in [0.5, 1.5] depending on use case.
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?
QWhat does the entropy of the attention weight distribution look like as a function of T?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
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.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.