Along which axis of the QK^T score matrix is softmax applied inside attention?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Along the key axis (the last dimension). Each query gets a probability distribution over keys; each row sums to 1.
Imagine planning a meal where each chef has to decide how much of each ingredient to use. The chef does not normalize 'how much each ingredient gets used across all chefs'. The chef normalizes 'how much of my own meal each ingredient takes up', so for each chef's own dish, the ingredient percentages add up to 100%. Each query token in attention is like one chef: it decides for itself how attention mass is split across all available keys, and those splits add up to 100% for that query.
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.
Identify the key axis as the normalization axis, derive the choice from the downstream V matmul shape, contrast with wrong-axis options, and walk how masking, FlashAttention tiling, and cross-attention all align with the key-axis convention.
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.
Applying softmax along the query axis. That would give each key a distribution over queries, not each query a distribution over keys, and the downstream V matmul would be malformed.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.