How does the temperature parameter reshape the sampling distribution?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Temperature divides the logits before softmax; `T<1` sharpens toward the top token, `T>1` flattens toward the tail, `T=0` is greedy argmax.
Imagine the model's raw output as a row of heights, one per possible next word. The highest height is the model's favorite token. Temperature is a knob that scales those heights before they get turned into probabilities. Turn the knob below 1 and the gaps between heights grow, so the favorite towers over everyone else and almost always wins; the output gets predictable, sometimes repetitive. Turn it above 1 and the gaps shrink, so unlikely tokens get a real chance and the output gets more diverse, sometimes off the rails. Set it to 1 and nothing changes; you sample from the trained distribution as-is. Set it to 0 and you skip sampling entirely, just pick the tallest, every time.
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.
5 min: write the formula `p = softmax(logits / T)`, explain low / equal to one / high regimes, describe the T = 0 special case (greedy argmax), state that the effect is non-linear because softmax is non-linear, and give a typical default plus one production pin-low use case.
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.
Describing temperature as scaling probabilities directly. It scales logits before softmax, which is non-linear in token probability and far more aggressive than a linear rescale.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.