The Reasoning-Memorization Interplay in Language Models Is Mediated by a Single Direction (2025)

Abstract: Large language models (LLMs) excel on a variety of reasoning benchmarks, but previous studies suggest they sometimes struggle to generalize to unseen questions, potentially due to over-reliance on memorized training examples. However, the precise conditions under which LLMs switch between reasoning and memorization during text generation remain unclear. In this work, we provide a mechanistic understanding of LLMs’ reasoning-memorization dynamics by identifying a set of linear features in the model’s residual stream that govern the balance between genuine reasoning and memory recall. These features not only distinguish reasoning tasks from memory-intensive ones but can also be manipulated to causally influence model performance on reasoning tasks. Additionally, we show that intervening in these reasoning features helps the model more accurately activate the most relevant problem-solving capabilities during answer generation. Our findings offer new insights into the underlying mechanisms of reasoning and memory in LLMs and pave the way for the development of more robust and interpretable generative AI systems. Our code and data are at https://github.com/yihuaihong/Linear_Reasoning_Memory_Features.

## introduction large language models (llms) have demonstrated impressive capabilities in tackling complex reasoning tasks @xcite @xcite . however, these models sometimes struggle with more straightforward reasoning problems, particularly when faced with questions that differ significantly from those encountered during training @xcite @xcite . this generalization gap between llms and human reasoning has led to the hypothesis that these models are essentially "reasoning parrots" @xcite , relying heavily on memorization of text patterns found in their pretraining datasets @xcite @xcite , rather than engaging in a rigorous, procedural reasoning process to solve problems @xcite @xcite . understanding the interplay between reasoning and memorization in llms is essential, not only for advancing our understanding of these models but also for developing more reliable, language-based reasoning systems in the future @xcite @xcite . in the context of llm reasoning, researchers often conceptualize memorization as the inability to generalize from familiar problems to their systematically modified counterparts. in this view, reasoning and memorization are two extremes on the spectrum of model generalizability. to investigate this, synthetic reasoning benchmarks are designed, and memorization is assessed by measuring changes in model performance across various setups @xcite @xcite . another line of research focuses on the internal mechanisms of llms, identifying specific components or circuits responsible for tasks like arithmetic @xcite and commonsense reasoning @xcite @xcite . however, these studies primarily analyze model outputs or hidden representations when dealing with carefully crafted synthetic reasoning problems, limiting the generalizability of their findings. in this paper, we explore the reasoningmemorization dynamic of llms from a mechanistic perspective. recent interpretability research has demonstrated that llms encode interpretable semantic features @xcite -such as safety @xcite , truth @xcite , sentiment @xcite , and language (bricken et al., 2023)-as linear directions within their activation space. we hypothesize that there is a similar linear feature, which, when activated, enables the model to solve reasoning tasks through systematic generalization. when this feature is not activated, the model remains in a "memorization mode," exhibiting low generalizability when addressing variations of familiar reasoning problems. to examine our hypotheses, we apply methods from linear semantic feature analysis @xcite and identify a set of linear reasoning features (lirefs) in the residual streams of llms. as shown in figure 1 , lirefs can be extracted by contrasting the hidden representations of reasoning-intensive versus memoryintensive questions. this contrast allows the two types of questions to be linearly separated in the model's activation space. furthermore, we demonstrate via causal analysis @xcite that by enhancing the lirefs during inference, we can shift the model into a "thinking mode" with strong generalizability in applying reasoning rules or patterns. we show via extensive experiments on four different llms across six datasets that the same set of reasoning features explain and mediate model reasoning ability across various knowledge domains and languages, suggesting a general control mechanism of switching between reasoning and memorization during model inference. the main contributions of our work can be summarized as follows: ## related work memorization in llms memorization in llms has been defined in various ways. in the context of privacy and copyright, memorization is often described as the model's verbatim reproduction of training data during generation @xcite @xcite . alternatively, some define memorization as the counterfactual effect of omitting specific training data on model predictions @xcite , reflecting memorization of rare, specific examples. in reasoning tasks, memorization is often seen as poor generalizability to questions outside the training data, as evidenced by studies on work sequence reversal @xcite and alphabet shifting @xcite , which show degraded performance on infrequent patterns. other studies observe performance degradation from controlled perturbations of input questions @xcite . in this paper, we adopt memorization as poor reasoning generalizability and propose a novel mechanistic interpretation of the reasoning-memorization dynamic during model inference. understanding llm reasoning prior research has sought to distinguish reasoning from memorization, investigating whether llms genuinely infer new conclusions or merely reconstruct patterns from pretraining data. studies suggest that llms undergo structured multi-step reasoning processes, transitioning through distinct reasoning stages that follow an ordered sequence of knowledge retrieval and rule-based processing @xcite . similarly, extended training beyond overfitting (grokking) has been shown to lead to the emergence of reasoning circuits, indicating that reasoning is a learned and structured capability @xcite @xcite . further studies on mathematical reasoning confirm that llms compute necessary information rather than memorizing templates, with reasoning computations leaving identifiable traces in model activations, particularly in the residual stream @xcite . additionally, attention heads have been shown to play a key role in both knowledge recall and latent reasoning, suggesting that these processes are distinct yet interconnected @xcite . linear semantic features recent advances in model interpretability have revealed that language models encode various semantic concepts as linear directions in their activation space @xcite . these linear semantic features have been discovered by contrasting inputs that differ primarily in the targe semantic dimension @xcite . once identified, these linear features can be manipulated to control model behavior, enabling targeted interventions during the generation process @xcite . our work extends this line of study by identifying linear features that mediate the model's ability to switch between genuine reasoning and memory recall. ## conclusion in this study, we show that the reasoning and memorization abilities of llms across various domains and languages are driven by a shared set of linear reasoning features within their activation space. these features can be uncovered by contrasting the hidden representations of reasoning-intensive and memory-intensive queries. furthermore, we demonstrate that intervening on these linear reasoning features (lirefs) during model inference improves both accuracy and robustness to perturbations when handling reasoning tasks. we also reveal that manipulating these reasoning features enables the model to more precisely activate the most relevant problem-solving capabilities during answer generation. our findings offer a mechanistic understanding of how reasoning and memorization interact in llms, providing a foundation for future research aimed at building more capable and interpretable generative reasoning systems. additionally, our work suggests that enhancing the interpretability of these underlying features could lead to more efficient and focused interventions,