Command Palette
Search for a command to run...
Linear Attention
The core computational rearrangement idea of linear attention can be traced back to the Efficient Attention preprint made public by Shen et al. in 2018; in 2020, Angelos Katharopoulos et al. from the Idiap Research Institute and EPFL systematically described and popularized this framework in “Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention” (ICML 2020). Standard attention requires first computing a score matrix quadratic in sequence length and applying softmax, so time and GPU memory costs grow quadratically with sequence length; linear attention, by contrast, usually uses a non-negative feature map to transform queries and keys, exploits the associativity of matrix multiplication to first aggregate the “key-value interaction state,” and then multiplies it with the query, thereby reducing computational complexity to linear growth with sequence length.
EPFL
In addition, in autoregressive settings, linear attention can be written in an incremental recurrence form, updating the state step by step and generating token by token like a recurrent neural network. The cost is that the sharpening weight allocation of softmax is removed, and the model usually performs worse than standard attention on long-distance exact retrieval; therefore, in practice it is often mixed with local attention or full attention, or applied to scenarios more sensitive to long-sequence throughput and memory efficiency.
Build AI with AI
From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.