Nyströmformer is an efficient Transformer architecture that approximates the full softmax attention matrix using the Nyström method—a classical technique for approximating large kernel matrices by sampling a subset of landmark points and reconstructing the full matrix from this subset. Nyströmformer selects $m$ landmark tokens (via segment-means or learned selection) and uses them to approximate the $N\times N$ attention matrix as a product of three smaller matrices, achieving $O(N\cdot m)$ complexity.
Why Nyströmformer Matters in AI/ML:
Nyströmformer provides high-quality attention approximation that preserves the softmax attention's properties more faithfully than linear attention or random feature methods, achieving near-exact attention quality with significantly reduced computational cost.
• Nyström approximation — The full attention matrix A $= \operatorname{softmax}(\mathrm{QK}^T/\sqrt{d})$ is approximated as à $= A_{\mathrm{NM}} \cdot A_{\mathrm{MM}}^{-1} \cdot A_{\mathrm{MN}}$, where $M$ is the set of $m$ landmark tokens, $A_{\mathrm{NM}}$ is the $N\times m$ attention between all tokens and landmarks, and $A_{\mathrm{MM}}$ is the $m\times m$ attention among landmarks
• Landmark selection — The $m$ landmark tokens are selected by averaging consecutive segments of the sequence: each landmark represents the mean of $N/m$ consecutive tokens, providing a uniform coverage of the sequence; this is simpler than random sampling and provides consistent quality
• Pseudo-inverse stability — Computing $A_{\mathrm{MM}}^{-1}$ requires inverting an $m\times m$ matrix, which can be numerically unstable; Nyströmformer uses iterative methods (Newton's method for matrix inverse) to compute a stable pseudo-inverse without explicit matrix inversion
• Approximation quality — With $m=64-256$ landmarks, Nyströmformer achieves 99%+ of full attention quality on standard NLP benchmarks, outperforming Performer, Linformer, and other efficient attention methods on long-range tasks
• Complexity analysis — Computing $A_{\mathrm{NM}}$ costs $O(N\cdot m\cdot d), A_{\mathrm{MM}}^{-1}$ costs $O(m^3)$, and the full approximation costs $O(N\cdot m\cdot d + m^3); \text{for} m \ll N$, this is effectively $O(N\cdot m\cdot d)$, linear in sequence length
| Component | Dimension | Computation |
|---|---|---|
| $A_{\mathrm{NM}}$ | $N \times m$ | All-to-landmark attention |
| $A_{\mathrm{MM}}$ | $m \times m$ | Landmark-to-landmark attention |
| $A_{\mathrm{MM}}^{-1}$ | $m \times m$ | Nyström reconstruction kernel |
| Ã $= A_{\mathrm{NM}}\cdot A_{\mathrm{MM}}^{-1}\cdot A_{\mathrm{MN}}$ | $N \times N$ (implicit) | Full attention approximation |
| Landmarks $(m)$ | 32-256 | Segment means of input |
| Total Complexity | $O(N\cdot m\cdot d + m^3)$ | Linear in $N$ for fixed $m$ |
Nyströmformer brings the classical Nyström matrix approximation method to Transformers, providing one of the highest-quality efficient attention approximations through landmark-based reconstruction that faithfully preserves softmax attention patterns while reducing quadratic complexity to linear, achieving the best quality-efficiency tradeoff among efficient attention methods.