Abstract
We analyze the Knowledge Neurons framework for the attribution of factual and relational knowledge to particular neurons in the transformer network. We use a 12-layer multi-lingual BERT model for our experiments. Our study reveals various interesting phenomena. We observe that mostly factual knowledge can be attributed to middle and higher layers of the network ($\ge 6$). Further analysis reveals that the middle layers ($6-9$) are mostly responsible for relational information, which is further refined into actual factual knowledge or the "correct answer" in the last few layers ($10-12$). Our experiments also show that the model handles prompts in different languages, but representing the same fact, similarly, providing further evidence for effectiveness of multi-lingual pre-training. Applying the attribution scheme for grammatical knowledge, we find that grammatical knowledge is far more dispersed among the neurons than factual knowledge.
Introduction
While Transformers have revolutionized Natural Language Processing (NLP), their internal mechanisms often remain a "black box." Understanding how these models organize and store vast amounts of information is crucial for interpretability. Previous research has suggested that feed-forward layers act as key-value memories. However, questions persist regarding the existence of a processing "pipeline" across layers, the cross-lingual representation of facts in multilingual models, and the storage differences between abstract grammatical knowledge and concrete factual data. This paper aims to identify the patterns of knowledge attribution within a 12-layer multi-lingual BERT (m-BERT) model.
Methods
We employ the Integrated Gradients strategy to identify "knowledge neurons" within m-BERT. This method attributes the value of a specific output logit (e.g., for the correct word "Paris") back to individual neurons. To isolate genuine knowledge from syntactic artifacts, we use multiple prompts with varying syntax for the same fact. Neurons that consistently exhibit high attribution scores across these diverse prompts are identified as knowledge neurons. By varying attribution thresholds ($t$), we analyze the overlap and specialization of neurons across different facts, languages, and information types.
Experimental Setup and Datasets
Our experiments utilize several curated datasets:
- Factual/Relational Prompts: Masked sentences regarding country capitals and unrelated facts to test for relational overlap.
- Multilingual Prompts: English prompts translated into French to evaluate cross-lingual representation.
- Grammatical Knowledge: The Number Agreement Dataset (Gulordava et al., 2018), which uses nonsensical sentences to isolate subject-verb number agreement, independent of semantic meaning.
Key Findings
The Knowledge Pipeline
Our analysis reveals a distinct processing pipeline. Initial layers (0–5) primarily handle low-level syntax. Middle layers (6–9) specialize in "relational" information (e.g., the concept of a capital city). The final layers (10–12) refine this relational data into specific factual answers. This is evidenced by attribution scores peaking in middle-to-high layers and showing extreme specialization in the final layers.
Neural Universalism and Language Overlap
In m-BERT, facts expressed in different languages often correspond to the same neurons. This suggests that multilingual pre-training creates a common representation space where the concept of a fact is language-independent. While overlap is high at moderate thresholds, it decreases as the threshold for specialization increases, indicating that the final linguistic output may involve language-specific neurons.
Factual vs. Grammatical Knowledge
Grammatical knowledge is significantly more dispersed than factual knowledge. While factual knowledge can be localized to specific "hotspot" neurons with high attribution scores, grammatical knowledge involves a larger number of neurons, each contributing smaller amounts. This quantitative difference supports the idea that grammar is a "team effort" rather than being pinned to specific neurons.
The Relational Bump
We observed a significant overlap of neurons in layers 7–10 when comparing different facts sharing the same relation (e.g., different capital cities). This "relational bump" disappears for unrelated facts, confirming the specialization of middle layers in representing relationships.
Conclusion
This study provides a map of knowledge attribution in Transformers, highlighting a hierarchical pipeline from syntax to relations to facts. The discovery of shared neural representations for multilingual facts and the dispersed nature of grammatical knowledge offers new insights into how these models learn and store information. Future work should extend these findings to Causal Language Models and explore alternative attribution techniques.
Summary updated