Abstract
Targeted syntactic evaluations have demonstrated the ability of language models to perform subject-verb agreement given difficult contexts. To elucidate the mechanisms by which the models accomplish this behavior, this study applies causal mediation analysis to pre-trained neural language models. We investigate the magnitude of models' preferences for grammatical inflections, as well as whether neurons process subject-verb agreement similarly across sentences with different syntactic structures. We uncover similarities and differences across architectures and model sizes -- notably, that larger models do not necessarily learn stronger preferences. We also observe two distinct mechanisms for producing subject-verb agreement depending on the syntactic structure of the input sentence. Finally, we find that language models rely on similar sets of neurons when given sentences with similar syntactic structure.
Introduction
While Large Language Models (LLMs) demonstrate remarkable proficiency in subject-verb agreement—such as correctly identifying that "The key to the cabinets is..." requires a singular verb—the internal mechanisms driving this behavior remain largely opaque. Most existing evaluations are behavioral, focusing on output correctness rather than architectural process. This research seeks to bridge this gap by moving from "what" the models do to "how" they do it. Specifically, the study investigates whether syntactic knowledge is localized in specific neurons, how model size influences grammatical conviction, and whether different architectures employ similar internal logic to solve identical grammatical problems.
Methodology: Causal Mediation Analysis
The researchers utilize Causal Mediation Analysis to pinpoint the specific neurons (mediators) responsible for subject-verb agreement. This approach involves three primary components:
- Intervention: A "swap-number" intervention is defined. For a prompt like "The author behind the cars approves," the subject is changed to "The authors."
- Total Effect (TE): This measures the overall change in the model's preference for the verb inflection (e.g., "approve" vs. "approves") following the intervention.
- Natural Indirect Effect (NIE): This "surgical" intervention sets a specific neuron to the value it would have had under the swap-number condition while keeping the rest of the input constant. A significant change in output indicates that the neuron mediates the grammatical agreement.
The study employs synthetically generated prompts based on established templates to control for collocations and other confounding variables. Six syntactic structures were tested, ranging from simple agreement to complex relative clauses.
Key Insights and Results
The "Two-Circuit" Mechanism
A primary finding is that models like GPT-2 employ two distinct neural circuits depending on the proximity of the subject and verb. In cases of direct adjacency, agreement neurons remain active until the final layers. However, the introduction of even a single distractor (e.g., an adverb) triggers a switch to a different circuit that peaks in the upper-middle layers before fading.
The Plural Default and Model Scaling
The models exhibit a systematic "plural default," showing a significantly higher grammaticality margin for plural subjects than singular ones. Surprisingly, larger models (e.g., GPT-2 XL) do not necessarily show stronger grammatical preferences than smaller variants. Instead, larger models appear to distribute the computational load across a broader set of neurons rather than relying on localized "super-neurons."
Architectural Divergence and Syntactic Intuition
While autoregressive models like GPT-2 and Transformer-XL share similar dual-circuit behaviors, XLNet—trained on permutations—utilizes a unified mechanism for all agreement types. Furthermore, the mapping of active neurons reveals that models' internal representations align with human linguistic intuition; sentences with similar syntactic structures (e.g., those containing prepositional phrases) activate overlapping sets of agreement neurons.
Conclusion and Future Directions
This study provides a causal framework for understanding the internal syntactic processing of Transformers. While the results highlight sophisticated localized mechanisms, the scope is currently limited to English and binary subject-verb agreement. Future research should expand these causal analyses to morphologically richer languages and more complex linguistic phenomena, such as filler-gap dependencies, to further decode the "black box" of neural language processing.
Summary updated