Papers › Recurrent Memory Transformer

Recurrent Memory Transformer

14 Jul 2022arXiv:2207.06881archive 2025-07-28

Aydar Bulatov, Yuri Kuratov, Mikhail S. Burtsev

Transformer-based models show their effectiveness across multiple domains and tasks. The self-attention allows to combine information from all sequence elements into context-aware representations. However, global and local information has to be stored mostly in the same element-wise representations. Moreover, the length of an input sequence is limited by quadratic computational complexity of self-attention. In this work, we propose and study a memory-augmented segment-level recurrent Transformer (RMT). Memory allows to store and process local and global information as well as to pass information between segments of the long sequence with the help of recurrence. We implement a memory mechanism with no changes to Transformer model by adding special memory tokens to the input or output sequence. Then the model is trained to control both memory operations and sequence representations processing. Results of experiments show that RMT performs on par with the Transformer-XL on language modeling for smaller memory sizes and outperforms it for tasks that require longer sequence processing. We show that adding memory tokens to Tr-XL is able to improve its performance. This makes Recurrent Memory Transformer a promising architecture for applications that require learning of long-term dependencies and general purpose in memory processing, such as algorithmic tasks and reasoning.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2207.06881")

Code

Syntology Ran 6 of 13 code samples harvested from 3 repositories linked to this paper; 7 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · violated contract; 1 ran · our draft was wrong; 3 ran with no contract checked.

By repository: official repository: 9 samples from 1 repository, 3 ran; community (archive-listed): 1 sample from 1 repository, 0 ran; community: 2 samples from 1 repository, 2 ran; 1 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

booydar/lm-rmt officialmentioned in papermentioned on GitHubpytorch report
booydar/transformer-xl officialmentioned in papermentioned on GitHubpytorchApache-2.0 report
booydar/t5-experiments mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

13 samples harvested; 6 ran; 1 honoured the contract we drafted; 7 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran · violated contract
1ran · our draft was wrong
3ran
7unverified

Licence: 2 of the 13 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 3 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

AdaptiveEmbedding booydar/lm-rmt/pytorch/mem_transformer.py official repository ran Apache-2.0 (permissive) · 4fbd1dc67be817f3 · report
DecoderLayer booydar/lm-rmt/pytorch/mem_transformer.py official repository ran Apache-2.0 (permissive) · 460c2ddd444dbae3 · report
MultiHeadAttn booydar/lm-rmt/pytorch/mem_transformer.py official repository ran Apache-2.0 (permissive) · 17b3ba52d31a4f22 · report
MemTransformerLM booydar/lm-rmt/pytorch/mem_transformer.py official repository unverified Apache-2.0 (permissive) · d6f7759cbb53633c · report
ProjectedAdaptiveLogSoftmax booydar/lm-rmt/pytorch/mem_transformer.py official repository unverified Apache-2.0 (permissive) · da461b6fa9c6c2a2 · report
RelLearnableDecoderLayer booydar/lm-rmt/pytorch/mem_transformer.py official repository unverified Apache-2.0 (permissive) · 1a40c2f95182a074 · report
RelLearnableMultiHeadAttn booydar/lm-rmt/pytorch/mem_transformer.py official repository unverified Apache-2.0 (permissive) · fd30acd200176f09 · report
RelPartialLearnableDecoderLayer booydar/lm-rmt/pytorch/mem_transformer.py official repository unverified Apache-2.0 (permissive) · 4bd79fa041136c60 · report
RelPartialLearnableMultiHeadAttn booydar/lm-rmt/pytorch/mem_transformer.py official repository unverified Apache-2.0 (permissive) · 027c122b94fbe192 · report
RMTBaseModel booydar/t5-experiments/modeling_rmt/base.py community (archive-listed) unverified no licence file found · pointer only · 36ad33d145150380 · report
identity lucidrains/recurrent-memory-transformer-pytorch/recurrent_memory_transformer_pytorch/recurrent_memory_transformer.py community ran · honoured contract MIT (permissive) · 7f1040f5e3991d5e · report
eval_decorator lucidrains/recurrent-memory-transformer-pytorch/recurrent_memory_transformer_pytorch/recurrent_memory_transformer.py community ran · our draft was wrong MIT (permissive) · 5444a7d75d38878d · report
exists identical code first harvested elsewhere ran · violated contract licence of this copy not recorded · aa5486a3650902d8 · report

Tasks

Language ModelingLanguage Modelling

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAdaptive Input RepresentationsAdaptive SoftmaxAttentionBPECosine AnnealingDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerLinear Warmup With Cosine AnnealingMulti-Head AttentionPosition-Wise Feed-Forward LayerReLUResidual ConnectionSoftmaxTransformerTransformer-XLVariational Dropout

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections