Linear representations of grammaticality in neural language models

TL;DR

Using mass-mean probing, the study demonstrates that neural language models encode grammaticality as a linearly separable dimension in sentence representations, with success rates from 13.4% to 94.0%.

cs.CL 🔴 Advanced 2026-07-17 47 views
Jane Li Najoung Kim
NLP model interpretability syntactic knowledge linear probing cross-lingual

Key Findings

Methodology

The study employs mass-mean probing—a simple, interpretable linear classifier—applied to sentence embeddings from 25 pretrained models ranging from 14M to 14B parameters. By computing mean vectors for grammatical and ungrammatical sentences, a difference vector θ defines a linear boundary. The approach controls for confounding sentence properties, ensuring the separation reflects grammaticality. Experiments span multiple syntactic phenomena and languages, including English, Russian, and Chinese, validating the robustness and generalization of the encoding.

Key Results

  • All models exhibit significant linear separability of grammaticality, with success rates from 13.4% (Pythia-14M) up to 94.0% (Qwen3-14B). Larger models show stronger encoding (correlation R=0.79). The separation persists across diverse syntactic phenomena and languages, indicating a universal grammaticality dimension. The probe outperforms probability-based measures, especially in larger models, confirming internal representations encode abstract syntactic information independent of surface features.
  • The results demonstrate that grammaticality is encoded as a stable, linearly accessible dimension in sentence representations. This encoding generalizes across phenomena such as island effects, agreement, and filler-gap dependencies, and across languages, supporting the hypothesis that models develop a coherent syntactic dimension. The findings challenge the view that probabilistic measures alone suffice for grammaticality detection, emphasizing the importance of internal structure analysis.
  • Controlling for lexical frequency, sentence length, and world knowledge, the grammaticality separation remains significant, indicating the encoding is not driven by these correlated factors. The success of linear probes correlates with model size, highlighting the role of scale in internal syntactic representations. This work advances understanding of how neural models internalize syntax and provides a new framework for interpretability and cross-lingual syntactic analysis.

Significance

This research offers compelling evidence that modern neural language models encode an abstract, linearly accessible notion of grammaticality within their internal representations. Moving beyond traditional probability-based evaluations, it demonstrates that grammatical distinctions are embedded as a stable dimension across diverse models, phenomena, and languages. Such insights deepen our understanding of the internal structure of language models, bridging the gap between statistical learning and symbolic syntactic knowledge. This has profound implications for improving model interpretability, robustness, and cross-lingual transfer. It also informs future directions in model architecture design, emphasizing the importance of internal representational geometry for syntactic understanding. Overall, the findings mark a significant step toward models that genuinely understand language structure, not just generate fluent text.

Technical Contribution

The study introduces mass-mean probing as a low-complexity, interpretable linear method to detect syntactic dimensions in sentence embeddings. It systematically validates the presence of a linearly separable grammaticality dimension across multiple models, phenomena, and languages. The approach controls for confounding factors, ensuring the separation reflects true grammaticality encoding. It also establishes a quantitative relationship between model size and encoding strength, providing theoretical insights into the development of syntactic representations. Compared to prior activation analysis or circuit-based methods, this technique offers a direct, scalable, and interpretable measure of internal syntactic knowledge, facilitating broader interpretability and cross-model comparisons.

Novelty

This work is the first comprehensive demonstration that grammaticality forms a linearly separable, coherent dimension in sentence representations across a wide range of neural language models and languages. It departs from prior reliance on probability measures or activation pattern analyses by employing a simple yet powerful linear probing method that is both interpretable and scalable. The cross-phenomena and cross-lingual generalization results provide new evidence that models develop an internal, abstract syntactic dimension, advancing the understanding of how neural models encode complex linguistic structures. This represents a significant methodological and conceptual breakthrough in interpretability research.

Limitations

  • While the study confirms the presence of a linear grammaticality dimension, it does not elucidate the specific neural mechanisms or circuit-level structures responsible for this encoding.
  • The analysis focuses on sentence-level grammaticality; more complex, hierarchical syntactic phenomena require further investigation.
  • Although cross-lingual generalization is promising, the effect varies across languages with different typological features, necessitating broader multilingual studies.

Future Work

Future research will integrate activation space analysis and circuit-level interpretability to uncover the neural basis of grammaticality encoding. Extending the approach to hierarchical and long-distance dependencies will deepen understanding of syntactic representations. Additionally, exploring training strategies that enhance or shape these internal dimensions could lead to more linguistically grounded models. Cross-lingual and cross-domain studies will further validate the universality of the grammaticality dimension, informing multilingual NLP system development.

AI Executive Summary

The quest to understand whether neural language models truly grasp syntactic structures has long been a core debate in NLP and cognitive science. Traditional methods relying on sentence probabilities have been criticized for conflating likelihood with grammaticality, leaving open questions about the internal representations of these models. This study introduces a novel, interpretable approach—mass-mean probing—to directly examine the internal sentence embeddings of 25 pretrained models, ranging from small to enormous scales. By analyzing the geometry of these embeddings, the researchers demonstrate that grammaticality is encoded as a linearly separable dimension, robust across diverse syntactic phenomena and languages.

The experiments reveal that all models, regardless of size, exhibit significant linear separability of grammatical and ungrammatical sentences, with success rates increasing with model scale. Larger models (e.g., Qwen3-14B) achieve success rates up to 94%, indicating a strong internal representation of syntax. Crucially, this encoding persists even when controlling for confounding sentence properties such as word frequency, length, and world knowledge, confirming that the models develop an abstract syntactic dimension rather than relying on surface cues.

These findings challenge the notion that probabilistic measures are sufficient to assess grammatical knowledge, emphasizing instead the importance of internal representational analysis. The demonstrated cross-phenomena and cross-lingual generalization suggest that grammaticality constitutes a coherent, universal dimension in contemporary neural models. This work advances the interpretability of NLP models, providing a pathway toward more transparent and linguistically grounded artificial language understanding systems. Future directions include circuit-level analysis and hierarchical syntactic investigations, aiming to uncover the neural basis of these internal grammatical representations and extend their applicability across languages and complex structures.

Deep Analysis

Background

The development of neural language models (NLMs) such as GPT, Llama, and BERT has revolutionized NLP, enabling unprecedented performance in text generation and understanding. Early research focused on probabilistic assessments, where higher likelihoods of sentences were taken as indicators of grammaticality. However, these methods face criticism because sentence probability is influenced by lexical frequency, sentence length, and world knowledge, confounding true syntactic understanding. Recent studies have explored internal representations, activation patterns, and circuit analysis, revealing that models encode some syntactic information. Yet, a definitive, scalable method to quantify and interpret this internal knowledge remains elusive. Understanding whether models develop an abstract, linearly accessible notion of grammaticality is crucial for interpretability, robustness, and cross-lingual transfer, especially as models grow larger and more complex.

Core Problem

Despite evidence of syntactic information in neural models, it remains unclear whether grammaticality is internally represented as a distinct, linearly separable dimension. Existing approaches relying on sentence probabilities are limited by their entanglement with lexical and contextual factors. The core challenge is to develop a method that isolates grammaticality as an abstract property within the internal embedding space, independent of surface features. This is essential for validating models' syntactic competence and for building interpretable systems capable of explicit syntactic reasoning. Moreover, establishing cross-phenomena and cross-lingual generalization is vital for demonstrating the universality of these internal representations, which has been lacking in prior work.

Innovation

The key innovation is the application of mass-mean probing—a simple, interpretable linear classifier—to sentence embeddings, enabling direct detection of a grammaticality dimension. Unlike complex neural circuit analysis, this method requires minimal data and assumptions, making it scalable and transparent. The approach involves computing mean vectors for grammatical and ungrammatical sentences, then deriving a difference vector that defines a linear boundary. This boundary is tested across multiple models, phenomena, and languages, demonstrating that grammaticality is encoded as a stable, continuous dimension. The method's simplicity and interpretability distinguish it from prior probabilistic and activation-based techniques, offering a new paradigm for internal representation analysis.

Methodology

  • �� Collect sentence embeddings from 25 pretrained models across multiple layers, focusing on the final hidden state. • Use datasets like BLiMP and SCaMP to obtain balanced grammatical and ungrammatical sentences, controlling for confounding factors. • Compute mean vectors for each class, then derive the difference vector θ. • Fit a linear classifier g(x) = σ(θ·x) to predict grammaticality, ensuring control over sentence properties. • Validate the classifier on held-out datasets, assessing success via accuracy and significance tests. • Analyze the relationship between model size and encoding strength, and test cross-phenomena and cross-lingual generalization.

Experiments

  • �� Use datasets spanning multiple syntactic phenomena, including agreement, island effects, and filler-gap dependencies, in English, Russian, and Chinese. • Fit probes on a subset of sentences, then evaluate on the remaining data, ensuring control for confounding factors. • Measure success by classification accuracy, statistical significance, and comparison with probability-based metrics. • Conduct ablation studies to assess the impact of model size, layer choice, and sentence properties. • Test across diverse phenomena and languages to evaluate the universality and robustness of the grammaticality dimension.

Results

  • �� All models exhibit significant linear separability of grammatical vs. ungrammatical sentences, with success rates from 13.4% (small models) to 94% (large models). • Larger models show stronger encoding, with correlation R=0.79 between size and success rate. • The encoding generalizes across multiple phenomena and languages, indicating a universal internal grammaticality dimension. • Controlling for lexical frequency, sentence length, and world knowledge, the separation remains significant, confirming the abstraction of the syntactic dimension. • Linear probes outperform probability-based measures, especially in larger models, highlighting the internal structure's importance.

Applications

  • �� Enhances interpretability of language models by revealing internal syntactic representations, aiding explainability and debugging. • Supports multilingual NLP by providing a universal measure of syntactic understanding applicable across languages. • Can inform training strategies to reinforce syntactic encoding, improving model robustness and linguistic fidelity. • Facilitates development of models with explicit syntactic reasoning capabilities, advancing natural language understanding.

Limitations & Outlook

  • �� Focused on sentence-level grammaticality, leaving hierarchical and long-distance dependencies less explored. • The causal relationship between model size and encoding strength is not fully established. • Cross-lingual results, while promising, vary with language typology, requiring broader multilingual validation. • The method does not specify the neural circuits responsible for encoding, necessitating further circuit-level analysis.

Plain Language Accessible to non-experts

Imagine a large factory that makes different kinds of toys. Some toys are perfectly made, following all the rules, while others have small mistakes. The factory has a special inspector who can look at the toys and tell if they are made correctly or not. But instead of checking each toy one by one, the inspector has a secret way of telling—by noticing a hidden pattern in how the toys are made. Scientists wanted to see if the factory’s internal system—like a big machine—has a special setting that always helps it tell good toys from bad ones. They used a simple test: they took the factory’s internal signals when making different toys and checked if they could draw a straight line that separates good toys from bad ones. Turns out, bigger factories (more advanced models) are better at this. This means that these models don’t just guess randomly—they actually learn some invisible rules about grammar, kind of like how we learn rules in school. This discovery helps us understand how machines can learn the structure of language, making them smarter and more trustworthy in the future.

ELI14 Explained like you're 14

Imagine you have a super-smart robot friend who can tell if a sentence is correct or not, kind of like how you can tell if a sentence sounds right. But instead of just guessing, this robot actually ‘knows’ some hidden rules about grammar. Scientists wanted to see if they could find these hidden rules inside the robot’s brain. So, they looked at the robot’s ‘thoughts’ when it read different sentences and tried to find a simple way to tell if the sentence was correct or not. They found that in bigger, smarter robots, there’s a clear line inside their ‘brain’ that separates good sentences from bad ones. It’s like having a secret rule that only the smartest robots understand. This means that these models don’t just guess randomly—they actually learn some rules about how language works, just like we do in school. This discovery is exciting because it shows that machines can learn the hidden rules of language, making them better at understanding and using words correctly!

Abstract

Whether neural language models (NLMs) possess the ability to distinguish strings on the basis of their grammaticality remains a debated topic in the computational linguistics literature. Existing evidence has largely relied on probability-based measures, testing whether models assign higher probabilities to grammatical than ungrammatical strings. However, probability comparisons have been criticized as a measure for grammatical knowledge based on the assumption that grammaticality is inherently entangled with likelihood. Model-assigned probability is a function of many related sentence properties, such as lexical frequency, plausibility, and world knowledge. In this work, we move beyond probability-based evaluations and investigate whether grammaticality is encoded in the internal representations of NLMs. Using mass-mean probing, we test whether grammatical and ungrammatical sentences are systematically separated in representational space. We further examine the extent to which these representations are independent of sentence properties that are correlated with grammaticality, as well as their generalization across grammatical phenomena and languages. Our results provide evidence that grammaticality is robustly encoded in sentence representations of a wide range of pretrained NLMs, yielding clear representational separation on the dimension of grammaticality that cannot be fully explained by alternative sentence-level factors. Moreover, this encoding generalizes across a broad range of grammatical phenomena and to some degree, across languages, suggesting that grammaticality constitutes a coherent representational dimension in contemporary NLMs. These findings contribute new evidence to debates about the nature of syntactic knowledge in language models and offer a complementary framework for evaluating grammatical competence that is not dependent on string probabilities alone.

cs.CL