Self-Attention (or scaled dot-product attention) is an attention mechanism that relates different positions of a single sequence to compute a representation of the same sequence, allowing the model to calculate context dynamically.
Key to managing sequence memory and token weights during transformer encoder-decoder blocks, context calculations, and sequence modeling; optimizing Self-Attention prevents attention processing bottlenecks and keeps execution latencies low.
Self-attention is the mathematical mechanism in Transformers that computes relative importance scores between all tokens in a sequence simultaneously. By calculating Query, Key, and Value vector projections for each word and scoring their alignment, self-attention enables the model to capture complex, long-range dependencies and multi-layered relationships without relying on recurrent loops.
By projecting each word token into three vectors: Query (Q), Key (K), and Value (V). It multiplies Q and K to get a similarity score, scales the result, applies softmax to get attention weights, and multiplies by V.
It divides the dot products of Query and Key vectors by the square root of their dimension size. This prevents the dot products from growing extremely large in high dimensions, which could push the softmax function into regions with vanishing gradients.
We currently have no direct coverage articles matching "Self-Attention". Explore trending global AI topics below instead.