Scaled Dot-Product Attention
where , , and .
Each query token scores its similarity against every key token via a dot product, divides by so large head dimensions do not push softmax into tiny-gradient saturation, normalizes scores into weights summing to , and takes a weighted average of the value vectors .
Every Transformer self-attention and cross-attention head executes this equation to route context between tokens.
Let , (so ), with:
Row raw dot products are . Dividing by yields , and .
CODE RUNS ONLY IN YOUR BROWSER VIA PYODIDE WEBASSEMBLY — NOTHING IS SENT TO ANY SERVER.
QUESTION 1 / 3
0 / 3 ANSWEREDQ1 · MCQ
Why are query-key dot products divided by sqrt(d_k) before applying softmax?
NO DOWNSTREAM FORMULAS YET
Nothing downstream lists Scaled Dot-Product Attention as a prerequisite yet. Open all 20 curriculum sections to pick what to prove next.
BROWSE ALL 20 SECTIONS →