Name the two properties softmax guarantees for every row of the attention weight matrix
Every entry lies in [0, 1] and each row sums to exactly 1. Softmax produces a row-stochastic matrix, a valid probability distribution over keys.
Picture cutting a single pizza into slices to share among friends. No friend can get a slice of negative size, no friend can get more than the whole pizza, and the total amount of pizza handed out has to add up to exactly one pizza, no more, no less. The step that turns raw model scores into attention works the same way. Each item on the menu gets a fraction of the model's focus that is at least 0 and at most 1, and the fractions across the whole row always sum to exactly one pizza's worth. That tidy 'no negatives, no overweights, total of one' rule is what makes the row behave like a clean share-out.
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 the two properties (entries in [0, 1], row sums to 1), prove each from the softmax formula, give the probability-simplex interpretation, and walk the downstream consequences (convex-combination output, mask renormalization, attention sinks).
Real products, models, and research that use this idea.
- Vaswani et al. 2017: the canonical attention formula softmax(QK^T / sqrt(d_k)) V produces row-stochastic weight matrices, the [0, 1] entries and row-sum-to-1 are why the output is a convex combination of values.
- Attention visualizations (BertViz, exBERT) display the post-softmax weight matrix as a heatmap where each row's cells visually add up to 1.
- Causal masking in every modern LLM (GPT-5.5, Llama 4 Maverick, Claude Opus 4.7, Gemini 3.1 Pro) is applied at the score level (set masked positions to -inf), the [0, 1] and sum-to-1 constraints are preserved automatically.
- Softmax-1 (Evan Miller 2023, used in some Gemma variants) relaxes the row-sum-to-1 constraint to allow rows summing to less than 1, eliminating the attention-sink consequence.
- FlashAttention v2 and v3 maintain running max and sum statistics to compute softmax tile by tile, the [0, 1] and sum-to-1 properties hold for the final output even though the full weight matrix is never materialized.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhat changes about the [0, 1] and sum-to-1 properties when softmax-1 is used in place of standard softmax?
QHow does the simplex constraint enable masking to work without explicit renormalization?
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.
Forgetting that weights must be NON-NEGATIVE and at most 1. Softmax cannot produce negative weights or weights larger than 1, regardless of the score values.
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.