Associative Recurrent Memory Transformer

Ivan Rodkin, Yuri Kuratov, Aydar Bulatov, Mikhail BurtsevarXiv 2024 · DOI

Introduction

Standard Transformers face a significant challenge: their self-attention mechanism scales quadratically with sequence length, making them computationally expensive for long contexts. While linear transformers and recurrent models like State Space Models (SSMs) or the Recurrent Memory Transformer (RMT) offer improvements, they often encounter a memory bottleneck. RMT, for instance, relies on a limited set of "memory tokens" to pass information between segments, creating a narrow channel for long-term data flow.

The Associative Recurrent Memory Transformer (ARMT) addresses this by augmenting the RMT framework with layerwise associative memory (fast weights). This architecture maintains constant time and space complexity per step while providing the high-capacity storage necessary for complex, multi-hop reasoning over sequences of unprecedented length—up to 50 million tokens.

Methods and Architecture

ARMT builds upon the RMT framework, which processes text in discrete segments and passes memory tokens sequentially. The defining feature of ARMT is the integration of an Associative Block (AssocBlock) into every transformer layer.

Comparison of (a) Recurrent Memory Transformer, (b) Associative Recurrent Memory Transformer, and (c) the internal logic of the Associative Block.

Key Technical Components

  • Layerwise Associative Memory: Instead of relying solely on token passing, ARMT maintains an association matrix ($A$) at each layer. This matrix acts as a "fast-weight" memory that stores key-value pairs derived from the memory tokens.
  • The Update Rule: The model employs a quasi-linear attention mechanism to update the association matrix as it moves through segments. This allows the model to "write" new information, "erase" outdated associations, and "read" relevant facts based on the current context.
  • Gamma-Correction: A critical mathematical refinement introduced by the authors to prevent "catastrophic forgetting." They found that standard fast-weight updates fail because the normalization vector doesn't account for erased information. Gamma-correction ensures the model can perform hundreds of erase-insert operations while maintaining a stable memory state.
  • DPFP-3 Non-linearity: The model utilizes a specific non-linear mapping to project keys and queries, which enhances the stability of associations over long durations.

Experimental Evaluation

The authors evaluated ARMT across several challenging benchmarks:

  1. BABILong: An extreme long-context benchmark where models must answer questions hidden within massive amounts of distractor text. ARMT was tested on sequences up to 50 million tokens.
  2. Associative Retrieval: Synthetic tasks ("Remember & Rewrite") designed to measure raw memory capacity and the ability to update stored values.
  3. Wikitext-103: A standard language modeling dataset used to evaluate general text prediction capabilities.

Key Results and Insights

ARMT demonstrated a 3000x increase in context length generalization, successfully performing tasks on 50 million tokens after being trained on only 16,000 tokens. This level of generalization is largely attributed to the associative nature of its memory, which allows for more efficient linking of specific keys to values compared to simple recurrence.

Performance of ARMT on BABILong tasks across context lengths up to 50 million tokens compared to baselines.

On the BABILong QA1 task (single supporting fact), ARMT achieved 79.9% accuracy at 50 million tokens. In contrast, performance for GPT-4 and RAG-based systems typically collapses well before reaching the 1-million-token mark. Furthermore, ARMT showed significantly higher memory capacity than Mamba, demonstrating 60x length generalization on complex multi-hop tasks compared to Mamba's 8x.

Limitations and Future Work

Despite its strengths, ARMT currently lacks a "parallel form" for training, meaning segments must be processed sequentially. This makes it slower to train on short-to-medium sequences compared to fully parallelizable models like Mamba or standard Transformers. Additionally, while ARMT dominates in retrieval and QA, its performance on standard language modeling (Wikitext-103) remains similar to the base RMT, suggesting the model may over-focus on recent segments during training.

Future research will focus on scaling ARMT to multi-billion parameter models to determine if these associative benefits persist at the scale of modern Large Language Models (LLMs).

Summary updated

BibTeX
@misc{rodkin2024associative,
  author = {Ivan Rodkin and Yuri Kuratov and Aydar Bulatov and Mikhail Burtsev},
  title = {{Associative Recurrent Memory Transformer}},
  year = {2024},
  eprint = {2407.04841},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.04841},
}
Figure