Abstract
Transformer architectures have achieved state-of-the-art results on a variety of sequence modeling tasks. However, their attention mechanism comes with a quadratic complexity in sequence lengths, making the computational overhead prohibitive, especially for long sequences. Attention context can be seen as a random-access memory with each token taking a slot. Under this perspective, the memory size grows linearly with the sequence length, and so does the overhead of reading from it. One way to improve the efficiency is to bound the memory size. We show that disparate approaches can be subsumed into one abstraction, attention with bounded-memory control (ABC), and they vary in their organization of the memory. ABC reveals new, unexplored possibilities. First, it connects several efficient attention variants that would otherwise seem apart. Second, this abstraction gives new insights—an established approach (Wang et al., 2020b) previously thought to be not applicable in causal attention, actually is. Last, we present a new instance of ABC, which draws inspiration from existing ABC approaches, but replaces their heuristic memory-organizing functions with a learned, contextualized one. Our experiments on language modeling, machine translation, and masked language model finetuning show that our approach outperforms previous efficient attention models; compared to the strong transformer baselines, it significantly improves the inference time and space efficiency with no or negligible accuracy loss.
Introduction
The standard Transformer architecture faces a significant scaling challenge: its attention mechanism scales quadratically ($O(N^2)$) with sequence length. This computational bottleneck makes processing long documents or generating extensive sequences prohibitively expensive. While various "efficient" attention variants have been proposed, they often rely on context-agnostic heuristic patterns. This research introduces ABC (Attention with Bounded-memory Control), a unified framework that transforms this quadratic complexity into linear complexity by bounding the memory size.
The ABC Framework and $\text{ABC}_{\text{MLP}}$
The core contribution of this work is the ABC abstraction, which demonstrates that many efficient attention models—including Linformer, clustering-based attention, and sliding-window attention—can be unified under a single lens. These models can be viewed as reading from a constant-sized memory ($n$ slots) using specific control vectors ($\phi_i$).
By fixing the memory size $n$ so that it does not grow with the sequence length $N$, the total complexity drops to $O(Nn)$, achieving linear scaling. Building on this framework, the authors propose $\text{ABC}_{\text{MLP}}$, a novel instance where control vectors are learned rather than fixed. Using a simple Multi-Layer Perceptron (MLP), the model dynamically decides which information to store in memory based on the content of the current token, making memory management context-aware.
Key Insights
- Causal Linformer: The ABC framework reveals that the Linformer—previously thought to be incompatible with causal (autoregressive) decoding—can indeed be adapted for text generation tasks.
- Context-Awareness: Experiments show that learned control vectors ($\text{ABC}_{\text{MLP}}$) significantly outperform heuristic or random memory placement ($\text{ABC}_{\text{RD}}$), proving that content-based memory management is vital for performance.
- Recurrent Compatibility: Because ABC utilizes a bounded memory, it can be implemented as a recurrent neural network during decoding, maintaining a constant-sized hidden state regardless of sequence length.
Experimental Results
The authors evaluated $\text{ABC}_{\text{MLP}}$ across several benchmarks, including WikiText-103 for language modeling and WMT14 for machine translation.
Performance and Efficiency
- Language Modeling: On WikiText-103, $\text{ABC}_{\text{MLP}}$ outperformed other linear-complexity models like Linformer by over 2.9 perplexity points, coming within 0.5 points of the standard quadratic Transformer.
- Translation: In WMT14 EN-DE, $\text{ABC}_{\text{MLP}}$ achieved a BLEU score of 27.3, slightly exceeding the standard Transformer baseline (27.2).
- Inference Speed: During decoding, $\text{ABC}_{\text{MLP}}$ maintained consistent speed regardless of sequence length, whereas the standard Transformer slowed down drastically. $\text{ABC}_{\text{MLP}}$ was approximately 1.25x faster than other competitive efficient models like RFA.
Conclusion
ABC provides a powerful abstraction for understanding and improving attention mechanisms. By moving from heuristic to learned memory control, $\text{ABC}_{\text{MLP}}$ offers a path toward Transformers that are both highly efficient and contextually sensitive, making them better suited for long-sequence tasks without the typical quadratic cost.
Summary updated