Linformer is a method that compresses keys and values along the sequence axis from to , shrinking the attention weight matrix from to . Wang et al. at Facebook AI proposed it in 2020 in the paper "Linformer: Self-Attention with Linear Complexity."
Standard multi-head attention computes weights for every pair of tokens, so computation and memory grow with the square of the sequence length . Linformer starts from the observation that the attention weight matrix of a trained model can in fact be represented almost entirely with little information (it is low-rank).
It therefore adds two learnable matrices (of size ) to each head, compresses keys and values into "representatives," and then computes standard scaled dot-product attention. If is fixed much smaller than , computation and memory are , that is, linear in .
In meeting terms, instead of listening to every one of the participants one by one, their remarks are summarized into memo sheets, and anyone with a question looks only at the memos. What goes into which memo is determined by learning.
The right side of the figure at the top of the article shows this difference. Standard attention forms an matrix, whereas Linformer forms only an matrix.

