Self-Attention

Category: Neural Networks & Architectures

A mechanism that computes the relationship between all positions within a single sequence, allowing each element to attend to every other element.

Full Explanation

Self-attention (also called intra-attention) computes a weighted representation of each position in a sequence by considering all other positions in the same sequence. Each position produces query, key, and value vectors; attention weights are computed as the scaled dot product between queries and keys, then applied to values. This allows the model to dynamically focus on relevant parts of the input regardless of their distance. Self-attention captures long-range dependencies in O(1) sequential operations (though O(n^2) in computation), unlike RNNs which require O(n) sequential steps. Self-attention is the core mechanism of the transformer architecture and has revolutionized NLP, computer vision, and multi-modal AI. Its main limitation is quadratic memory and computation cost with sequence length, motivating research into efficient attention variants.

Related Terms

More in Neural Networks & Architectures

Explore More