Lune

ICLR2025Top-tier venue

Understanding Factual Recall in Transformers via Associative Memories

Eshaan Nichani, Jason D. Lee, Alberto Bietti

Abstract

Large language models have demonstrated an impressive ability to perform factual recall. Prior work has found that transformers trained on factual recall tasks can store information at a rate proportional to their parameter count. In our work, we show that shallow transformers can use a combination of associative memories to obtain such near optimal storage capacity. We begin by proving that the storage capacities of both linear and MLP associative memories scale linearly with parameter count. We next introduce a synthetic factual recall task, and prove that a transformer with a single layer of self-attention followed by an MLP can obtain 100% accuracy on the task whenever either the total number of self-attention parameters or MLP parameters scales (up to log factors) linearly with the number of facts. In particular, the transformer can trade off between using the value matrices or the MLP as an associative memory to store the dataset of facts. We complement these expressivity results with an analysis of the gradient flow trajectory of a simplified linear attention model trained on our factual recall task, where we show that the model exhibits sequential learning behavior.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

23 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Transformers learn to implement preconditioned gradient descent for in-context learning cites Transformers Learn In-Context by Gradient Descent
  • Transformers learn to implement preconditioned gradient descent for in-context learning cites Linear Transformers Are Secretly Fast Weight Programmers
  • Why and How LLMs Hallucinate: Connecting the Dots with Subsequence Associations cites Transformers learn to implement preconditioned gradient descent for in-context learning
  • Why and How LLMs Hallucinate: Connecting the Dots with Subsequence Associations cites Transformers Learn In-Context by Gradient Descent
  • Muon Outperforms Adam in Tail-End Associative Memory Learning cites Locating and Editing Factual Associations in GPT
  • Transformers Learn In-Context by Gradient Descent cites Hopfield Networks is All You Need
  • Transformers Learn In-Context by Gradient Descent cites Linear Transformers Are Secretly Fast Weight Programmers
  • Linear Transformers Are Secretly Fast Weight Programmers cites Hopfield Networks is All You Need
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers23

  1. Muon Outperforms Adam in Tail-End Associative Memory LearningShuche Wang, Fengzhuo Zhang, Jiaxiang Li, Cunxiao Du et al.ICLR 2026 · 40 citations
  2. Emergence and scaling laws in SGD learning of shallow neural networksYunwei Ren, Eshaan Nichani, Denny Wu, Jason D. LeeNeurIPS 2025 · 33 citations
  3. Emergence of Superposition: Unveiling the Training Dynamics of Chain of Continuous ThoughtHanlin Zhu, Shibo Hao, Zhiting Hu, Jiantao Jiao et al.ICLR 2026 · 21 citations
  4. Why and How LLMs Hallucinate: Connecting the Dots with Subsequence AssociationsYiyou Sun, Yu Gai, Lijie Chen, Abhilasha Ravichander et al.NeurIPS 2025 · 20 citations
  5. Data Mixing Can Induce Phase Transitions in Knowledge AcquisitionXinran Gu, Kaifeng Lyu, Jiazheng Li, Jingzhao ZhangNeurIPS 2025 · 16 citations

Builds on23

  1. Locating and Editing Factual Associations in GPTKevin Meng, David Bau, Alex Andonian, Yonatan BelinkovNeurIPS 2022 · 3,415 citations
  2. Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations
  3. Hopfield Networks is All You NeedHubert Ramsauer, Bernhard Schäfl, Johannes Lehner, Philipp Seidl et al.ICLR 2021 · 620 citations
  4. Linear Transformers Are Secretly Fast Weight ProgrammersImanol Schlag, Kazuki Irie, Jürgen SchmidhuberICML 2021 · 394 citations
  5. Transformers learn to implement preconditioned gradient descent for in-context learningKwangjun Ahn, Xiang Cheng, Hadi Daneshmand, Suvrit SraNeurIPS 2023 · 324 citations

Related papers

  1. Do LLMs dream of elephants (when told not to)? Latent concept association and associative memory in transformersYibo Jiang, Goutham Rajendran, Pradeep Ravikumar, Bryon AragamNeurIPS 2024 · 19 citations
  2. Learning to Recall with Transformers Beyond Orthogonal EmbeddingsNuri Mert Vural, Alberto Bietti, Mahdi Soltanolkotabi, Denny WuICLR 2026 · 1 citation
  3. Memory Layers at ScaleVincent-Pierre Berges, Barlas Oguz, Daniel Haziza, Wen-tau Yih et al.ICML 2025
  4. Do All Autoregressive Transformers Remember Facts the Same Way? A Cross-Architecture Analysis of Recall MechanismsMinyeong Choe, Haehyun Cho, Changho Seo, Hyunil KimEMNLP 2025
  5. Birth of a Transformer: A Memory ViewpointAlberto Bietti, Vivien Cabannes, Diane Bouchacourt, Hervé Jégou et al.NeurIPS 2023 · 182 citations
Dusk over the sea between two cliffs drawn in fine vertical lines