How does softmax turn an attention score into an attention weight?
Score is the pre-softmax raw dot product (any real number). Weight is the post-softmax probability in [0, 1] that rows sum to 1. Softmax is the bridge.
Think of judges at a talent show. First, each judge writes a raw score for every act on a piece of paper. The numbers can be anything: positive, negative, all over the place, and there is no rule that they have to add up to anything. Then the host runs through the room collecting those scores, runs them through a calculator, and converts them so each act lands as a clean percentage between 0% and 100%, with all the percentages across acts adding up to exactly 100%. The raw paper numbers are what the model calls 'scores'. The final percentages are what it calls 'weights'. The host with the calculator in between is the single step that converts one into the other.
Detailed answer & concept explanation~5 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.
Define score as the pre-softmax dot product and weight as the post-softmax probability, list which operations live at each level (masking, temperature, biases), and explain why the distinction matters for stable softmax and FlashAttention.
Real products, models, and research that use this idea.
- Vaswani et al. 2017: the canonical attention diagram explicitly separates 'MatMul + Scale' (score) from 'SoftMax' (weight) as distinct boxes.
- Attention visualization tools (BertViz, exBERT) plot the weight matrix, not the score matrix; that is why the heatmap rows sum to 1.
- Causal masking in every modern LLM (GPT-5.5, Llama 4 Maverick, Claude Opus 4.7, Gemini 3.1 Pro) is implemented at the score level by adding -inf to future positions before softmax.
- ALiBi (BLOOM, MPT) adds a per-head linear bias to scores before softmax; doing it post-softmax would break the probability constraint.
- FlashAttention v2 and v3 compute scores tile by tile, maintain running softmax statistics, and never materialize the full weight matrix in HBM.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy are causal masks applied at the score level rather than the weight level?
QHow does the row max trick for numerically stable softmax work, and does it change the weights?
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.
Using 'score' and 'weight' interchangeably. They are different objects living in different spaces; softmax is the operator that converts one to the other.
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.