Papers › Memorizing Transformers

Memorizing Transformers

16 Mar 2022ICLR 2022 4arXiv:2203.08913archive 2025-07-28

Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins, Christian Szegedy

Language models typically need to be trained or finetuned in order to acquire new knowledge, which involves updating their weights. We instead envision language models that can simply read and memorize new data at inference time, thus acquiring new knowledge immediately. In this work, we extend language models with the ability to memorize the internal representations of past inputs. We demonstrate that an approximate kNN lookup into a non-differentiable memory of recent (key, value) pairs improves language modeling across various benchmarks and tasks, including generic webtext (C4), math papers (arXiv), books (PG-19), code (Github), as well as formal theorems (Isabelle). We show that the performance steadily improves when we increase the size of memory up to 262K tokens. On benchmarks including code and mathematics, we find that the model is capable of making use of newly defined functions and theorems during test time.

PaperPDFConference PDFCodeCode 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="2203.08913")

Code

Syntology Ran 20 of 34 code samples harvested from 4 repositories linked to this paper; 14 have no recorded run. Of those that ran: 3 ran · honoured contract; 1 ran · violated contract; 2 ran · our draft was wrong; 3 ran · fixture could not drive it; 11 ran with no contract checked.

By repository: official repository: 15 samples from 1 repository, 12 ran; community (archive-listed): 17 samples from 3 repositories, 6 ran; 2 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.

lucidrains/memorizing-transformers-pytorch officialmentioned on GitHubpytorch report
google-research/meliad mentioned on GitHubjaxApache-2.0 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

34 samples harvested; 20 ran; 3 honoured the contract we drafted; 14 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.

3ran · honoured contract
1ran · violated contract
2ran · our draft was wrong
3ran · fixture could not drive it
11ran
14unverified

Licence: 2 of the 34 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 4 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.

Attention lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 4673cf1999dcca6b · report
KNNAttention lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 2832f7cf743c7f86 · report
KNNMemory lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran MIT (permissive) · 246054b031dda4de · report
PreNormResidual lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 25d9116c53cb8eb2 · report
T5RelativePositionBias lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 9304ca35acfd717d · report
all_el_unique lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · dd330ab84432cbc2 · report
cast_list lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · honoured contract fingerprinted MIT (permissive) · 76123fa16b69b8d4 · report
check_shape lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · fixture could not drive it MIT (permissive) · 1bdfb9459bbcd869 · report
count_intersect lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · 5844bf2b191c00ed · report
identity lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · honoured contract fingerprinted MIT (permissive) · f3232418205f7cbd · report
unique lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 2aa06e7db15eb39b · report
KNNMemoryList lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository unverified MIT (permissive) · 3cb1714e61d5fad7 · report
MemorizingTransformer lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository unverified MIT (permissive) · c25e09cec3306193 · report
multi_context lucidrains/memorizing-transformers-pytorch/memorizing_transformers_pytorch/memorizing_transformers_pytorch.py official repository unverified MIT (permissive) · 2ef0e2f355bf12a6 · report
LlamaDynamicNTKScalingRotaryEmbedding normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) ran fingerprinted Apache-2.0 (permissive) · b90643346c166065 · report
LlamaLinearScalingRotaryEmbedding normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · b704c9a5be0a15d7 · report
LlamaMLP normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · 0765abcf04c608f6 · report
LlamaRMSNorm normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) ran · metamorphic tier: invariant Apache-2.0 (permissive) · 90915865fd797169 · report
LlamaRotaryEmbedding normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · 580c588511c469d9 · report
apply_rotary_pos_emb normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) ran · fixture could not drive it Apache-2.0 (permissive) · 49d79a24934a30e3 · report
AttentionLayer AIResearchHub/transformergallery/transformer/memorizingtransformer.py community (archive-listed) unverified MIT (permissive) · 7fd92c090cad8a75 · report
ExtendedLlamaAttention normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) unverified Apache-2.0 (permissive) · 4039fb9f24228670 · report
ExtendedLlamaConfig normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) unverified Apache-2.0 (permissive) · a7a01f367b6da9da · report
ExtendedLlamaDecoderLayer normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) unverified Apache-2.0 (permissive) · 7419a094e9f98c3a · report
ExtendedLlamaForCausalLM normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) unverified Apache-2.0 (permissive) · ecccb74da133bd6a · report
ExtendedLlamaModel normal-computing/extended-mind-transformers/src/llama/modeling.py community (archive-listed) unverified Apache-2.0 (permissive) · 29b4a33fabd0b32e · report
MemorizingLayer AIResearchHub/transformergallery/transformer/memorizingtransformer.py community (archive-listed) unverified MIT (permissive) · cbf31de811fec75e · report
MemorizingTransformer AIResearchHub/transformergallery/transformer/memorizingtransformer.py community (archive-listed) unverified MIT (permissive) · c25efb685f36ecd3 · report
flatten_dict_string_keys google-research/meliad/model_info.py community (archive-listed) unverified Apache-2.0 (permissive) · d92db56afc61ab11 · report
initial_kvi google-research/meliad/transformer/attention.py community (archive-listed) unverified Apache-2.0 (permissive) · 7deb74a26342f2d3 · report
should_run google-research/meliad/training_task.py community (archive-listed) unverified Apache-2.0 (permissive) · 1f2be62797cfccf1 · report
cast_tuple identical code first harvested elsewhere ran · honoured contract fingerprinted licence of this copy not recorded · f70dcb896366697c · report
exists identical code first harvested elsewhere ran · violated contract licence of this copy not recorded · aa5486a3650902d8 · report

Tasks

Language ModelingLanguage ModellingMath

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

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