Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain scaled dot-product attention as you would in an interview. Include why the scaling factor matters.
Scaled dot-product attention computes softmax of QK transposed divided by the square root of d_k, then weights V. The scaling keeps the softmax in a stable gradient regime.
Imagine a room full of labelled boxes, each holding some content. You walk in with a question written on a card. You compare your card to every label, decide how relevant each box is, and then take a mix of their contents weighted by how relevant they are. The query is your card, the keys are the labels, the values are the contents, and the mix is the attention output. The square root divisor is a temperature knob that keeps the comparison fair when the cards are very detailed: without it, one label can shout so loudly that all the others go silent, and you would never get a useful mix.
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.
Lead with the formula, name Q, K, and V as projections of the input, walk through the three steps (score, scale, softmax, multiply by V), give the variance argument for the scale factor, and close with the gradient flow consequence that ties it to training stability.
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.
Reciting the formula without justifying the scale factor. The square root of d_k is not cosmetic, it is the variance correction that keeps gradients from vanishing as dimensionality grows.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.