Back to LLMs Mind Map
中文·English
LLMsID: attention-scaled-dot

Scaled Dot-Product Attention

缩放点积注意力
🎯Core Definition
Scaled Dot-Product Attention is the core attention operator of the Transformer: Attention(Q,K,V)=softmax(QKTdk)VAttention(Q,K,V) = softmax(\frac{Q K^T}{\sqrt{d_k}}) V. Dividing by dk\sqrt{d_k} normalizes the dot-product variance: if Q and K have per-dimension variance 1, the variance of a dkd_k-dim dot product grows linearly with dkd_k; without scaling, softmax inputs saturate as dimensionality grows (e.g. dk=128d_k = 128, 12811.3\sqrt{128} \approx 11.3) and gradients vanish.
💡Use Cases
every head softly matches all tokens in the sequence — the foundation for MHA/GQA/MLA, FlashAttention and RoPE; interviews typically start with "why divide by dk\sqrt{d_k}" and then probe complexity, masks and head splitting.
Key Problems Solved
unlike unscaled dot products, scaling keeps softmax entropy and gradients stable at any dimensionality so deep networks train reliably; but time and memory stay O(n2)O(n^2), which becomes the main bottleneck for long sequences and motivates IO-aware implementations like FlashAttention.
🎯5 High-Frequency Exam Points
1
Why divide by dk\sqrt{d_k}? What breaks without it (variance analysis, softmax saturation)?
2
Time and space complexity of scaled dot-product attention? Why is O(n2)O(n^2) the long-context bottleneck?
3
Shapes of the Q/K/V projections? How are heads split and concatenated?
4
Difference and implementation of padding mask vs causal mask?
5
Single vs multi-head: why h heads rather than one wide dd-dim head?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Scaled Dot-Product Attention"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardKV Cache ManagementNext CardAttention Variants MHA/MQA/GQA

🔗 More LLMs Knowledge Cards

Agent & Tool CallingAlignment Tax & Preference DataBenchmarks MMLU/GSM8KTokenization: BPE / WordPiece