Manuscript Offprint

arXiv:2611.07283

Encoding and Propagation of Grammatical Number in Large Language Models

Jacob Solinsky, Serguei Pakhomov

Jacob Solinsky 1^{1} and Serguei Pakhomov 1^{1}

1^{1}University of Minnesota, USA

Corresponding author: solin020@umn.edu

Sparse autoencoders (SAEs) have become an increasingly popular means of translating Large Language Model (LLM) hidden state vectors into a human-comprehensible list of features or symbols. As such, SAEs may provide insight into an LLM's knowledge representation and internal "mental" grammar - topics of pragmatic interest for mechanistic interpretation of AI behavior and of theoretical interest for the study of in silico representations of human language. Language models with fewer than 100M parameters, trained on comparatively small corpora, nonetheless exhibit strong grammatical competence and discourse coherence, despite producing content of limited reliability. We use SAEs that we trained on one such model (Pythia-70M) to conduct an in-depth, comprehensive examination of how a single grammatical phenomenon, English number agreement, is represented and processed in an LLM. We demonstrate the mechanism and the methodology by which SAEs can be used to find and propagate "plural noun", "plural matrix subject", and "generate a plural verb" features which cause the LLM to produce plural verb forms such as "are", "do", or "have" instead of "is", "does", and "has" in response to prompts such as "the men in the park". We show that intervening to remove these features from the hidden states of plural subject noun tokens causes the model to produce singular verbs instead, and vice versa. We also show that corresponding "singular noun" and "generate a singular verb" features are not as effective for this task. This asymmetry suggests that Pythia-70m makes use of a privative, rather than binary, representation of grammatical number in English. These findings replicated with larger LLMs Gemma-2-2b and Llama-3.1-8b yielded similar results. Our main contribution is a novel approach to the use of SAEs to understanding how LLMs encode human language that addresses a number of technical and methodological challenges.

1. Introduction

Large Language Models (LLMs) are a variety of Artificial Neural Network (ANN) which encode their "thoughts" in the language of high-dimensional vectors typically referred to in machine learning literature as the hidden states that the network produces in response to a prompt. The field of mechanistic interpretability, also termed explainable Artificial Intelligence (xAI), aims to translate these indecipherable-by-humans hidden state-encoded thought processes into something a human researcher can understand.

The bulk of the continuing challenges facing LLM deployment, be it the generation of hallucinations, or offensive and biased language, or the production of insecure code, disgorging sensitive information from a system prompt to users, or difficulty in staying on task, have their roots in the fact that LLM hidden state is not transparent

© 2005 Association for Computational Linguistics to humans, unlike the debugging stack traces of conventional symbolic computer programs written in a programming language. This lack of transparency prevents LLM developers and users from effectively debugging the LLMs. Instead of conventional debugging consisting of identifying and eliminating the root cause of an error directly and deterministically, debugging LLMs consists of indirect and probabilistic approaches such as additional rounds of Reinforcement Learning with Human Feedback (RLHF) and/or prompt engineering. These strategies tend to address and fix specific instances of the LLM challenges rather than the underlying causes of these challenges, much like a medication such as acetaminophen may treat symptoms of influenza rather than act on the influenza virus itself.

Despite these unresolved and ongoing challenges that resulted in limiting the use of LLMs in critical and sensitive areas including clinical and legal decision making, and scientific research and education, the one area in which LLMs unreservedly excel is language. Even smaller LLMs trained on limited amounts of text in a given language appear to be able to "learn" a complete syntactic theory of the language, as they rarely, if ever, generate ungrammatical sentences in that language even if the generated sentences may convey nonsensical or false information. For linguists, particularly those who have been working for decades in the generative syntax tradition, LLMs provide an unprecedented opportunity to test syntactic theories. More importantly, however, LLMs can also provide a means of discovering the system and the structure that underlies human language directly as opposed to making inferences based on behavioral observations. No linguist has yet created a complete theory of English grammar, or that of any other natural language, that could be used by a symbolic automaton to generate close to the full diversity of English sentences and larger narrative structures that are found throughout all of literature and the internet.

Although it is almost certain that LLMs process language in a completely different way than the human brain, given their dramatically different architecture and disembodiment, extracting a theory of natural language syntax from them that at least works to generate a high-quality imitation of human language is certain to reinvigorate the study of theoretical syntax. (Piantadosi 2024). Given that LLMs are not transparent to humans, to fully realize this potential for linguistic discovery, there is a need to develop validated and reliable methods for interrogating and manipulating LLMs in a systematic and reproducible fashion.

The present paper contributes a step towards the objective of developing methods for extracting information pertaining to the structure that LLMs learn during pretraining. We demonstrate the utility of these methods by presenting an in-depth analysis of how an open weights transformer-based LLM (Pythia-70B) encodes the knowledge of subject-verb agreement in English, and confirm the generalizability of these findings on two larger LLMs (Gemma-2-2b and Llama-3.1-8b).

References (31)