Attention temperature divides QK^T; sampling temperature divides output logits, distinguishwhere each lives.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Attention temperature shapes mid-layer routing over keys; sampling temperature shapes final next-token selection over vocabulary. Different softmaxes, fully independent.
Imagine writing a story. First, you keep notes on every paragraph you have already written so you can refer back. The way you decide which old paragraph to look at when writing a new sentence is one knob, that is attention temperature. Set it low and you laser-focus on one prior paragraph; set it high and you blend many. Second, when you actually pick the next word to write, you have a long list of possible words and you sample one. That sampling knob is sampling temperature. Set it low and you pick the most likely word; set it high and you pick something unusual. Two completely separate decisions, two completely separate knobs.
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.
6-8 min: pipeline softmax count + T_attn location and effect + T_sample location and effect + sqrt(d_k) vs T_attn distinction + production API exposure + failure mode comparison.
| Property | Attention temperature | Sampling temperature |
|---|---|---|
| Where it acts | Pre-softmax scores in every attention layer | Final vocabulary logits before sampling |
| What it shapes | Key routing per head | Next-token discrete choice |
| Failure mode (high) | Uniform attention, routing collapse | Random vocabulary, nonsense output |
| Failure mode (low) | Single-key lock, hallucination | Greedy repetition |
| API exposure | Rarely exposed | Always exposed |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating the two temperatures as the same knob with different names. They act on different softmaxes at different stages of the pipeline and have completely different effects.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.