mlsanityData to 14 Oct 2026

Generalization or Hallucination? Understanding Out-of-Context Reasoning in Transformers

arXiv 2506.10887 ↗First posted 12 Jun 2025cs.CL cs.LGcited by 10

On the map: LLM reasoning → Reasoning benchmarks and evaluation

Abstract (arXiv)

Large language models (LLMs) can acquire new knowledge through fine-tuning, but this process exhibits a puzzling duality: models can generalize remarkably from new facts, yet are also prone to hallucinating incorrect information. However, the reasons for this phenomenon remain poorly understood. In this work, we argue that both behaviors stem from a single mechanism known as out-of-context reasoning (OCR): the ability to deduce implications by associating concepts, even those without a causal link. Our experiments across five prominent LLMs confirm that OCR indeed drives both generalization and hallucination, depending on whether the associated concepts are causally related. To build a rigorous theoretical understanding of this phenomenon, we then formalize OCR as a synthetic factual recall task. We empirically show that a one-layer single-head attention-only transformer with factorized output and value matrices can learn to solve this task, while a model with combined weights cannot, highlighting the crucial role of matrix factorization. Our theoretical analysis shows that the OCR capability can be attributed to the implicit bias of gradient descent, which favors solutions that minimize the nuclear norm of the combined output-value matrix. This mathematical structure explains why the model learns to associate facts and implications with high sample efficiency, regardless of whether the correlation is causal or merely spurious. Ultimately, our work provides a theoretical foundation for understanding the OCR phenomenon, offering a new lens for analyzing and mitigating undesirable behaviors from knowledge injection.

Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Placed in Reasoning benchmarks and evaluation, one of 17 directions in LLM reasoning. Builds on 52 of its 65 references that are in the map. First posted on arXiv 12 Jun 2025.

Builds on

52 of 65 references.

References · 52

  1. 2014Adam: A Method for Stochastic Optimizationcited by 37,240
  2. 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,128
  3. 2017The Implicit Bias of Gradient Descent on Separable Datacited by 655
  4. 2016CVXPY: A Python-Embedded Modeling Language for Convex Optimizationcited by 641
  5. 2023The Reversal Curse: LLMs trained on "A is B" fail to learn "B is A"cited by 407
  6. 2019Implicit Regularization in Deep Matrix Factorizationcited by 405
  7. 2023Trained Transformers Learn Linear Models In-Contextcited by 337
  8. 2017Implicit Regularization in Matrix Factorizationcited by 322
  9. 2019Gradient Descent Maximizes the Margin of Homogeneous Neural Networkscited by 320
  10. 2018Characterizing Implicit Bias in Terms of Optimization Geometrycited by 266
  11. 2018Implicit Bias of Gradient Descent on Linear Convolutional Networkscited by 251
  12. 2023Evaluating the Ripple Effects of Knowledge Editing in Language Modelscited by 242
38 more
  1. 2024Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?cited by 232
  2. 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 170
  3. 2024Do Large Language Models Latently Perform Multi-Hop Reasoning?cited by 169
  4. 2023Birth of a Transformer: A Memory Viewpointcited by 161
  5. 2020Towards Resolving the Implicit Bias of Gradient Descent for Matrix Factorization: Greedy Low-Rank Learningcited by 150
  6. 2023Taken out of context: On measuring situational awareness in LLMscited by 143
  7. 2023Physics of Language Models: Part 3.2, Knowledge Manipulationcited by 143
  8. 2020Implicit Regularization in Deep Learning May Not Be Explainable by Normscited by 119
  9. 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
  10. 2023In-Context Convergence of Transformerscited by 115
  11. 2018Convergence of Gradient Descent on Separable Datacited by 110
  12. 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 102
  13. 2022Vision Transformers provably learn spatial structurecited by 93
  14. 2024Unfamiliar Finetuning Examples Control How Language Models Hallucinatecited by 87
  15. 2024Transformers, parallel computation, and logarithmic depthcited by 79
  16. 2021Small random initialization is akin to spectral learning: Optimization and generalization guarantees for overparameterized low-rank matrix reconstructioncited by 78
  17. 2024Hopping Too Late: Exploring the Limitations of Large Language Models on Multi-Hop Queriescited by 78
  18. 2023Transformers as Support Vector Machinescited by 74
  19. 2023Generalization on the Unseen, Logic Reasoning and Degree Curriculumcited by 73
  20. 2023Max-Margin Token Selection in Attention Mechanismcited by 58
  21. 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMscited by 56
  22. 2019Lexicographic and Depth-Sensitive Margins in Homogeneous and Non-Homogeneous Deep Modelscited by 53
  23. 2023Transformers learn through gradual rank increasecited by 52
  24. 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
  25. 2024Understanding Factual Recall in Transformers via Associative Memoriescited by 51
  26. 2025Training Dynamics of In-Context Learning in Linear Attentioncited by 46
  27. 2023What can a Single Attention Layer Learn? A Study Through the Random Features Lenscited by 40
  28. 2021On Margin Maximization in Linear and ReLU Networkscited by 34
  29. 2024From Self-Attention to Markov Models: Unveiling the Dynamics of Generative Transformerscited by 34
  30. 2024Mechanics of Next Token Prediction with Self-Attentioncited by 34
  31. 2024One-layer transformers fail to solve the induction heads taskcited by 32
  32. 2024Implicit Bias and Fast Convergence Rates for Self-attentioncited by 31
  33. 2024From Sparse Dependence to Sparse Attention: Unveiling How Chain-of-Thought Enhances Transformer Sample Efficiencycited by 29
  34. 2024Towards a Theoretical Understanding of the 'Reversal Curse' via Training Dynamicscited by 27
  35. 2025How Do LLMs Perform Two-Hop Reasoning in Context?cited by 20
  36. 2024Implicit Regularization of Gradient Flow on One-Layer Softmax Attentioncited by 19
  37. 2022Learning to Reason with Neural Networks: Generalization, Unseen Data and Boolean Measurescited by 17
  38. 2024Extractive Structures Learned in Pretraining Enable Generalization on Finetuned Factscited by 14

50 most cited of 52 All 52 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 3; 2026: 7.

10 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Why LLMs Hallucinate on Structured Knowledge: A Mechanistic Analysis of Reasoning over Linearized Representations
  2. 2024Out-of-distribution generalization via composition: a lens through induction heads in Transformers
  3. 2022Achieving and Understanding Out-of-Distribution Generalization in Systematic Reasoning in Small-Scale Transformers
  4. 2024Grokked Transformers are Implicit Reasoners: A Mechanistic Journey to the Edge of Generalization
  5. 2026Loop, Think, & Generalize: Implicit Reasoning in Recurrent-Depth Transformers
  6. 2026When Do Hallucinations Arise? A Graph Perspective on the Evolution of Path Reuse and Path Compression
  7. 2025More Thinking, Less Seeing? Assessing Amplified Hallucination in Multimodal Reasoning Models
  8. 2025Disentangling Recall and Reasoning in Transformer Models through Layer-wise Attention and Activation Analysis