Abstract
Large Language Models (LLMs) serve as extensive repositories of factual information, yet the internal mechanisms governing the storage and retrieval of specific facts have remained largely opaque. This paper introduces the concept of knowledge neurons—discrete units within the Feed-Forward Networks (FFNs) of Transformer architectures that function as storage for relational facts. By developing a knowledge attribution method based on integrated gradients, we localize these neurons and demonstrate their causal influence on model predictions. Our analysis reveals that factual knowledge is predominantly concentrated in the upper layers of the network. Furthermore, we demonstrate that targeted "knowledge surgery" on these neurons allows for the precise updating or erasure of facts without the need for extensive retraining or the risk of catastrophic forgetting.
Introduction
While Transformers like BERT and GPT demonstrate remarkable proficiency in recalling facts through cloze tasks (e.g., "The capital of France is [MASK]"), they are typically treated as black boxes. This lack of interpretability poses significant challenges: correcting misinformation or removing sensitive data currently requires costly retraining or fine-tuning, which often degrades unrelated knowledge. This research addresses this by identifying the specific "address" of a fact within a model's parameters, enabling more granular control over stored information.
Methodology: FFNs as Key-Value Memories
The core hypothesis of this work is that the Feed-Forward Networks (FFNs) in Transformers operate as key-value memories. In this framework, the first linear layer acts as a set of "keys" that detect specific input patterns, while the second layer provides the "values" that contribute to the output.
To identify the neurons responsible for a specific fact (e.g., Ireland -> capital -> Dublin), the authors utilize:
- Knowledge Attribution: Adapting Integrated Gradients to calculate the contribution of each intermediate FFN neuron to the final prediction of the target entity.
- Knowledge Neuron Refining: To distinguish between neurons storing factual content and those responding to syntax, the model is tested with multiple diverse prompts for the same fact. Only neurons that consistently activate across all variations are classified as knowledge neurons.
Localization and Distribution
A significant finding of this study is that factual knowledge is not distributed uniformly across the model. Instead, knowledge neurons are primarily located in the top layers of the Transformer. This suggests a functional hierarchy where lower layers process basic linguistic and syntactic structures, while the "encyclopedic" lookup of relational facts occurs in the final stages of processing.
Experimental Results
The researchers validated the causal role of these neurons through several manipulation experiments:
- Suppression and Amplification: Muting the identified knowledge neurons resulted in an average 29.03% drop in the probability of the correct answer. Conversely, doubling their activation increased the correct answer probability by 31.17%. These results confirm that these neurons are causally linked to fact retrieval, rather than merely correlated with it.
- Knowledge Surgery: By modifying the weights of just a few neurons (averaging 4 per fact), the researchers achieved a 34.4% success rate in updating facts (e.g., changing a country's capital) with minimal impact on unrelated knowledge.
- Knowledge Erasing: Entire relations were successfully "erased" by zeroing out corresponding value slots, effectively removing the model's ability to recall those specific facts while maintaining overall performance stability.
Conclusion and Future Work
This research provides strong evidence that FFNs serve as the primary storage for factual knowledge in Transformers. Identifying these "brain cells" of facts opens new avenues for model editing and interpretability. Future work will focus on extending these methods to multi-token entities, exploring multilingual knowledge storage, and identifying neurons responsible for complex multi-step reasoning.
Summary updated