Introduction: The Memory Bottleneck in Transformers
Standard Transformer architectures have revolutionized natural language processing, yet they remain constrained by a fundamental limitation: finite memory capacity. The self-attention mechanism's computational complexity scales quadratically ($O(L^2)$) with sequence length $L$. While "efficient" variants like the Longformer or Reformer achieve linear complexity, they still operate within a fixed context window. Once this window is full, older information must be discarded, preventing the model from capturing truly long-range dependencies.
The ∞-former (infinite-former) addresses this gap by introducing an unbounded long-term memory (LTM). Inspired by human cognition, which selectively updates and compresses memories rather than exhaustively querying every past event, the ∞-former trades off memory resolution for length. This allows it to maintain context over arbitrarily long sequences without a corresponding increase in computational cost.
The ∞-former Architecture
The core innovation of the ∞-former is the transition from discrete to continuous attention. Instead of treating the LTM as a collection of individual tokens, the model represents it as a continuous signal $\bar{X}(t)$ over a time interval $[0, 1]$.
As shown in Figure 1, the model maintains a standard short-term memory (STM) for recent tokens while attending to the LTM for distant context. The continuous signal in the LTM is approximated using a fixed number $N$ of Radial Basis Functions (RBFs). Because the attention mechanism queries these basis functions rather than individual tokens, the complexity of attending to the LTM becomes $O(L^2 + L \times N)$. Since $N$ is constant, the cost of accessing the distant past remains fixed, regardless of whether the sequence contains thousands or millions of tokens.
Maintaining Unbounded Memory
To ensure the memory never "fills up," the ∞-former employs an unbounded update mechanism. When new tokens arrive, the existing continuous signal is "contracted"—effectively squashed into a smaller portion of the $[0, 1]$ interval—to make room for the new data.
To prevent the loss of critical information during this compression, the authors introduce "sticky memories." This technique, inspired by synaptic plasticity, uses a histogram of past attention weights to allocate more "space" (and thus higher resolution) to regions of the memory that the model frequently accesses. This ensures that important concepts remain sharp even as the overall context grows toward infinity.
Experimental Results
The ∞-former was evaluated across synthetic and real-world long-range tasks, demonstrating significant advantages over state-of-the-art baselines.
Synthetic Sorting
In a task requiring models to sort tokens by frequency in long sequences, the ∞-former showed remarkable stability. While the accuracy of Transformer-XL plummeted as sequence length increased from 4,000 to 16,000 tokens, the ∞-former maintained high performance.
Language Modeling and Dialogue
On the PG-19 dataset (Project Gutenberg books), the ∞-former achieved a perplexity of 32.48, outperforming both the vanilla GPT-2 (33.44) and the Compressive Transformer (33.09). Furthermore, in document-grounded dialogue tasks (CMU-DoG), the model consistently surpassed baselines in F1, Rouge-L, and Meteor scores, proving its ability to effectively leverage long auxiliary contexts for grounding.
Discussion and Future Work
The ∞-former represents a paradigm shift from capacity-constrained memory to resolution-constrained memory. While this approach allows for infinite context, it introduces a precision trade-off: as sequences grow extremely long, the RBF approximation may become too "blurry" for fine-grained retrieval of very old information.
Future research directions include implementing multimodal attention densities (e.g., mixtures of Gaussians) to allow heads to attend to multiple disparate memory regions simultaneously. Additionally, combining the ∞-former’s continuous "gist" of the past with discrete retrieval-augmented generation (RAG) could provide the best of both worlds: a long-term thematic understanding coupled with precise factual recall.
Summary updated