← Latest papers
💬 NLP

Implicit Representations of Grammaticality in Language Models

This paper demonstrates that pretrained language models implicitly acquire a distinct grammaticality representation within their hidden layers, which can be extracted via linear probes to outperform string probability-based judgments in distinguishing grammatical from ungrammatical sentences across multiple languages.

Original authors: Yingshan Susan Wang, Linlu Qiu, Zhaofeng Wu, Roger P. Levy, Yoon Kim

Published 2026-05-07
📖 4 min read☕ Coffee break read

Original authors: Yingshan Susan Wang, Linlu Qiu, Zhaofeng Wu, Roger P. Levy, Yoon Kim

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a very smart robot that has read almost every book, website, and article on the internet. This robot, called a Language Model (LM), is incredibly good at predicting what word comes next in a sentence. If you ask it to finish a story, it does a great job.

But here is the tricky part: Just because a sentence sounds "likely" to the robot doesn't mean it follows the rules of grammar.

The "Likely" vs. "Correct" Problem

Think of the robot like a person who has heard a lot of people speak, but has never been taught the rules of grammar in school.

  • The Robot's View (Likelihood): If you say, "The key to the cabinets are on the table," the robot might think, "Hey, I've heard people make this mistake before when they get confused by the word 'cabinets.' This sounds like something a human would actually say." So, it gives this sentence a high score.
  • The Grammar Rule (Grammaticality): A human grammarian knows this is wrong. The subject is "key" (singular), so the verb should be "is," not "are." The sentence is ungrammatical, even if it's a common mistake.

The big question the researchers asked was: Does this robot secretly know the difference between "what humans say often" and "what is actually grammatically correct," even if its final score doesn't show it?

The Experiment: The "Grammar Detective"

To find out, the researchers didn't just ask the robot, "Is this sentence correct?" (Robots are bad at answering that directly). Instead, they looked inside the robot's brain.

  1. Creating a Training Gym: They took a huge pile of normal text and started messing with it. They randomly added words, deleted words, or shuffled words around (like taking a sentence and saying, "She bursts into tears and walks away" vs. "She bursts into tears fringe and walks away").

    • The original sentences were "Good."
    • The messed-up sentences were "Bad."
  2. Training a Detective: They trained a tiny, simple "detective" (a linear probe) to look at the robot's internal thoughts (its hidden layers) and guess: "Is this a Good sentence or a Bad sentence?"

  3. The Test: They took this detective and tested it on real, human-made grammar tests.

The Surprising Results

1. The Robot Has a Secret Grammar Sense
The detective did a much better job at spotting grammar mistakes than the robot's own "likelihood score" did.

  • The Analogy: Imagine the robot is a chef who tastes a soup. The chef's "likelihood score" is how much they expect to taste salt because they usually put salt in everything. But the "detective" is looking at the chemical structure of the soup and saying, "Wait, this isn't salt; it's sugar."
  • The robot's internal brain actually contains a clear signal for "grammatical correctness" that is separate from "how common this sentence is."

2. The Detective is a Grammar Specialist, Not a Meaning Specialist
When the researchers tested the detective on sentences that were grammatically perfect but made no sense (e.g., "The colorless green ideas sleep furiously" vs. "The furiously green ideas sleep colorless"), the detective got confused.

  • However, the robot's original "likelihood score" was great at spotting these nonsense sentences.
  • The Takeaway: The robot's brain has two different systems. One system knows "Does this make sense?" (Likelihood), and a hidden system knows "Does this follow the rules?" (Grammar). The detective tapped into the hidden system.

3. The Detective Works in Other Languages Too
Here is the wildest part: They trained the detective using only English data. Then, they tested it on Swedish, Dutch, Italian, Russian, Japanese, and Chinese.

  • Even though the detective had never seen those languages before, it still got better at spotting grammar mistakes than the robot's raw probability scores did.
  • The Analogy: It's like teaching a dog to fetch a ball in English, and then taking it to a park in France. Even though the dog doesn't speak French, it still understands the concept of "fetching" and can recognize when a game is being played correctly.

The Conclusion

The paper concludes that these AI models, despite being trained just to predict the next word, have implicitly learned the rules of grammar. They have built a hidden "grammar detector" inside their neural networks that is distinct from their ability to guess what word comes next.

They aren't just mimicking human speech patterns; they have developed an internal representation of what makes a sentence structurally valid, separate from how likely that sentence is to appear in real life.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →