Introduction
The internal mechanisms of Long Short-Term Memory (LSTM) networks have long been a subject of debate in natural language processing. While these models excel at tasks requiring hierarchical understanding, such as long-distance number agreement, it remains unclear whether they rely on surface-level statistical shortcuts or internalize structural rules. This paper investigates the "black box" of LSTMs to identify specific neural circuits responsible for tracking grammatical number and syntactic structure.
Methodology
The researchers analyzed a two-layer, 650-dimensional LSTM trained on Wikipedia. They employed a multi-faceted interpretability toolkit:
- Single-unit Ablation: Measuring performance drops after zeroing out specific neurons.
- Gate and Cell-State Visualization: Monitoring internal memory ($C_t$) and gating mechanisms ($f_t, i_t$) during word-by-word processing.
- Diagnostic Regression: Using linear models to determine if individual neurons encode syntactic depth (the number of open nodes in a parse tree).
Key Insights: The Discovery of Specialized Units
The study identified two specialized "grandmother cells"—Unit 776 (plural) and Unit 988 (singular)—that function as long-range number units. These units activate upon encountering a subject and maintain that state until the corresponding verb is reached.
Beyond these number units, the researchers discovered a "syntax unit" (Unit 1150). This unit tracks the depth of the sentence structure and exerts control over the memory gates of the number units. Specifically, it signals the number units to ignore intervening nouns within prepositional phrases, preserving the subject's number information for the eventual verb. This interaction suggests a modular internal architecture where syntactic tracking governs the maintenance of grammatical features.
Key Results
The functional importance of these units was confirmed through targeted interventions and statistical analysis:
- Causal Impact: Ablating only Units 776 and 988 reduced the model's accuracy on difficult long-distance agreement tasks to near-chance levels, while performance on simple, local agreement remained stable.
- Syntactic Encoding: Unit 1150 proved to be a robust predictor of syntactic tree depth, achieving an $R^2$ of 0.85.
- Structural Connectivity: Unit 1150 exhibited outlier-strength weights to the forget gates of the number units ($z$-scores between 8.1 and 11.2), providing a mechanistic basis for the "syntax controller" hypothesis.
Conclusion and Future Work
This research demonstrates that LSTMs can develop highly localized, interpretable units to solve complex linguistic tasks. While these findings provide a clear mechanistic explanation for LSTMs, further research is needed to determine if similar localized structures emerge in Transformer architectures, which rely on distributed attention mechanisms rather than recurrent memory cells. Additionally, exploring how these units emerge during training and their presence in non-English languages remains an open area for investigation.
Summary updated