Self-Attention
An attention mechanism in which each position in a sequence computes similarity with other positions, enabling the model to establish global dependencies within the same sequence. It is a core component of Transformer encoders and decoders.
Core Facts
The computational complexity of the self-attention mechanism grows approximately quadratically with sequence length, with the attention matrix computation being proportional to n² for a sequence of length n.
The computational complexity of the standard Self-Attention mechanism has a quadratic relationship with sequence length (O(n²)).
When resolution doubles, the attention computation the model must handle often grows fourfold or more, causing elapsed time to increase non-linearly.
Timeline (last 90 days)
In a standard Transformer decoder, attention when computing the current token's output aggregates information from all historical positions, constituting full-prefix conditioning rather than a strict first-order Markov autoregressive dependency.
Self-attention has quadratic complexity, so researchers have proposed a variety of alternatives, including state space models (such as Mamba and S4), long convolutions (such as Hyena), linear attention, and gated recurrent units, among others.
Standard self-attention has O(n²) computation and memory cost in sequence length n.
In the prefill stage, for a prompt of length L, the self-attention computation grows with L^2, the matrix multiplications are large in scale and highly parallel, and GPU compute utilization (MFU) is usually high, making it compute-bound.
In language models, visual tokens are concatenated with text tokens and jointly participate in self-attention computation, whose computational overhead grows quadratically with the number of tokens.
Hybrid language models alternate or combine full-attention layers with efficient layers such as linear attention and state space models (e.g., Mamba); full-attention layers must store key-value vectors for every historical token, with overhead growing linearly with sequence length, while linear attention layers replace the KV cache with a fixed-size recurrent state.
The Transformer is an architecture built entirely on self-attention.
Self-attention itself is permutation-invariant, so the model cannot directly learn the input order from the attention output.
Transformers access past trajectories through the attention mechanism, at the cost of quadratic memory and computation overhead.
Each Transformer block contains a self-attention layer and a position-wise feed-forward network, both surrounded by residual connections and layer normalization.
7 more timeline events
All Facts (20)
The computational complexity of the self-attention mechanism grows approximately quadratically with sequence length, with the attention matrix computation being proportional to n² for a sequence of length n.
90%VerifiedThe computational complexity of the standard Self-Attention mechanism has a quadratic relationship with sequence length (O(n²)).
90%VerifiedWhen resolution doubles, the attention computation the model must handle often grows fourfold or more, causing elapsed time to increase non-linearly.
75%VerifiedExpanding the context window from 8K to 128K increases computational cost by 256 times.
75%VerifiedThe self-attention mechanism allows the model to simultaneously see the information of all other tokens in the input sequence when processing each token, and the computational complexity of the attention matrix is O(n²)
75%VerifiedThe core idea of ViT is to divide an image into fixed-size patches, flatten each patch and treat it as a token in a sequence, and then model global dependencies through a multi-head self-attention mechanism.
75%VerifiedEach Transformer block contains a self-attention layer and a position-wise feed-forward network, both surrounded by residual connections and layer normalization.
65%UnverifiedWhen sequence length n grows from 2K to 128K, the attention computation volume increases approximately 4,000-fold.
70%UnverifiedThe study finds that hallucinations manifest as three types of information flow distortion patterns: over-reliance on self-attention, diffuse contextual retrieval, and excessive information compression.
70%UnverifiedThe scaled dot-product attention formula is Attention(Q,K,V) = softmax(QK^T/√d_k)V, where dividing by √d_k prevents dot products in high-dimensional space from becoming too large and causing softmax to enter a saturation region.
60%UnverifiedIn a standard Transformer decoder, attention when computing the current token's output aggregates information from all historical positions, constituting full-prefix conditioning rather than a strict first-order Markov autoregressive dependency.
50%UnverifiedSelf-attention has quadratic complexity, so researchers have proposed a variety of alternatives, including state space models (such as Mamba and S4), long convolutions (such as Hyena), linear attention, and gated recurrent units, among others.
50%UnverifiedStandard self-attention has O(n²) computation and memory cost in sequence length n.
50%UnverifiedIn the prefill stage, for a prompt of length L, the self-attention computation grows with L^2, the matrix multiplications are large in scale and highly parallel, and GPU compute utilization (MFU) is usually high, making it compute-bound.
50%UnverifiedIn language models, visual tokens are concatenated with text tokens and jointly participate in self-attention computation, whose computational overhead grows quadratically with the number of tokens.
50%UnverifiedHybrid language models alternate or combine full-attention layers with efficient layers such as linear attention and state space models (e.g., Mamba); full-attention layers must store key-value vectors for every historical token, with overhead growing linearly with sequence length, while linear attention layers replace the KV cache with a fixed-size recurrent state.
50%UnverifiedThe Transformer is an architecture built entirely on self-attention.
50%UnverifiedSelf-attention itself is permutation-invariant, so the model cannot directly learn the input order from the attention output.
50%UnverifiedTransformers access past trajectories through the attention mechanism, at the cost of quadratic memory and computation overhead.
50%UnverifiedSelf-Attention means that each position within a sequence computes similarity with all other positions, allowing the model to establish global dependencies within the same sequence, and it is the core of the Transformer encoder and decoder.
50%