Skip to main content
QUICK REVIEW

[Paper Review] Scaling Transformer to 1M tokens and beyond with RMT

Aydar Bulatov, Yuri Kuratov|arXiv (Cornell University)|Apr 19, 2023
Topic ModelingComputer Science19 citations
TL;DR

This paper presents Recurrent Memory Transformer (RMT), a memory-augmented, segment-level recurrent approach that enables Transformer models to process up to 2 million tokens with linear compute scaling, by attaching trainable memory tokens and using curriculum learning.

ABSTRACT

A major limitation for the broader scope of problems solvable by transformers is the quadratic scaling of computational complexity with input size. In this study, we investigate the recurrent memory augmentation of pre-trained transformer models to extend input context length while linearly scaling compute. Our approach demonstrates the capability to store information in memory for sequences of up to an unprecedented two million tokens while maintaining high retrieval accuracy. Experiments with language modeling tasks show perplexity improvement as the number of processed input segments increases. These results underscore the effectiveness of our method, which has significant potential to enhance long-term dependency handling in natural language understanding and generation tasks, as well as enable large-scale context processing for memory-intensive applications.

Motivation & Objective

  • Demonstrate memory-augmented segment-level recurrence (RMT) as a plug-in wrapper for encoder-only and decoder-only transformers.
  • Show that RMT enables processing of extremely long sequences (up to 2M tokens) with linear compute and constant memory during inference.
  • Develop and benchmark memory acquisition/retention tasks scalable to million-token contexts to assess generalization of memory operations.
  • Investigate the impact of RMT on long-range language modeling and formal reasoning tasks to evaluate practical benefits across domains.

Proposed method

  • Attach a token-based memory module to pre-trained transformers without changing their architecture.
  • Process long inputs by dividing into fixed-size segments and performing full attention only within segments, enabling linear scaling.
  • Train with recurrence of memory tokens across segments so memory outputs influence subsequent segments.
  • Use curriculum learning to progressively extend task length from single-segment to multi-segment contexts.
  • Evaluate memory operations via synthetic memorization tasks and extend experiments to long-range language modeling and theorem-proving style generation.

Experimental results

Research questions

  • RQ1Can RMT extend the effective context length of pre-trained transformers to multi-million-token scales with linear computational cost?
  • RQ2How well does a memory-augmented transformer memorize, retrieve, and reason over facts across extremely long sequences?
  • RQ3Do memory-augmented models generalize to longer sequence lengths when trained on progressively longer segment tasks?
  • RQ4What is the impact of RMT on perplexity and predictive quality in long-text language modeling and formal proof generation?

Key findings

  • RMT scales linearly with input length for a fixed segment size, reducing FLOPs compared to non-recurrent models for multi-segment inputs (up to 295× fewer FLOPs in some cases).
  • With memory, a pre-trained BERT backbone can store and retrieve information across up to 2,000,000 tokens (4,096 segments of 512 tokens).
  • Curriculum learning improves stability and generalization, allowing models trained on shorter tasks to solve substantially longer ones.
  • In long-range language modeling, RMT with memory yields perplexity improvements over baselines and stabilizes predictions at segment boundaries by carrying memory across segments.
  • RMT demonstrates attention-pattern–driven memory operations and can generalize memory retrieval across extremely long sequences, suggesting no intrinsic technical limitation to scaling beyond 2M tokens on suitable tasks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.