Differential syntactic and semantic encoding in LLMs

This paper demonstrates that syntactic and semantic information in the DeepSeek-V3 LLM are partially linearly encoded and differentially distributed across layers, as evidenced by the ability to decouple these signals through the subtraction of averaged representation centroids.

Original authors: Santiago Acevedo, Alessandro Laio, Marco Baroni

Published 2026-05-28
📖 5 min read🧠 Deep dive

Original authors: Santiago Acevedo, Alessandro Laio, Marco Baroni

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 a Large Language Model (LLM) like DeepSeek-V3 as a massive, multi-story library. Inside this library, every sentence you type is transformed into a unique, high-dimensional "fingerprint" (a vector) as it moves through the different floors (layers) of the building.

The big question this paper asks is: How does the library organize these fingerprints? Specifically, does it keep the "structure" of the sentence (syntax) separate from the "meaning" of the sentence (semantics), or are they all mixed together in a big smoothie?

Here is what the researchers found, explained simply:

1. The "Average" Trick (Finding the Core)

The researchers realized that if you have a bunch of sentences that look the same grammatically (e.g., "The cat sat," "The dog ran," "The bird flew"), they share a common "skeleton."

  • The Analogy: Imagine taking a photo of 100 different people wearing the exact same type of hat. If you average all those photos together, the faces blur out, but the hat becomes super sharp and clear.
  • The Method: They did this mathematically. They took sentences with the same grammar structure and averaged their fingerprints to create a "Syntax Centroid" (the pure grammar hat). They did the same for sentences with the same meaning but different words to create a "Semantic Centroid" (the pure meaning hat).

2. The "Subtraction" Test (Removing the Hat)

Once they had these "pure" grammar and meaning vectors, they tried to remove them from the original sentence fingerprints.

  • The Analogy: Imagine you have a photo of a person wearing a hat. If you digitally subtract the "hat" vector from the photo, the hat disappears. If the photo still looks like the person, you know the hat was a separate layer. If the person's face disappears too, the hat and face were mixed together.
  • The Result: When they subtracted the "Grammar Hat" from a sentence, the sentence lost its ability to match with other sentences that had the same grammar. When they subtracted the "Meaning Hat," it lost its ability to match with sentences that meant the same thing.
  • The Conclusion: This proves that the model encodes grammar and meaning in a linear way. They are like distinct ingredients in a recipe that can be mathematically separated, rather than a chemical reaction where they become a new substance.

3. The "Floor Plan" Discovery (Where things live)

The library has many floors. The researchers found that grammar and meaning live on different floors.

  • Grammar (Syntax): This is like the foundation and the lower floors. It is present right from the start and stays consistent all the way to the top. The model knows the structure of a sentence almost immediately.
  • Meaning (Semantics): This is like the middle floors. When a sentence enters the library, the model first looks at the words and structure (low floors). Then, as the sentence moves to the middle, the model figures out what it actually means. By the time it reaches the very top floor (where the model writes its answer), the meaning is still there, but the focus shifts to generating the output.
  • The Analogy: Think of reading a book. First, you recognize the letters and words (grammar). Then, in the middle of the paragraph, you understand the story (meaning). You don't need to re-recognize the letters to understand the story, but you do need the letters to start.

4. The One-Way Street (Asymmetry)

Here is the most interesting part: The separation isn't perfectly equal.

  • Grammar is independent: If you remove the "Meaning" from a sentence, the "Grammar" stays perfectly intact. The skeleton remains standing even if you take away the flesh.
  • Meaning is dependent: If you remove the "Grammar" from a sentence, the "Meaning" gets a bit wobbly. It doesn't disappear completely, but it gets harder to recognize.
  • The Analogy: Imagine a house. If you remove the furniture (meaning), the house structure (grammar) is still clearly a house. But if you remove the walls and roof (grammar), the furniture (meaning) is just a pile of stuff on the ground; it's hard to tell what it was supposed to be.

Summary

The paper shows that in these giant AI models:

  1. Grammar and Meaning are distinct: They are encoded separately, not hopelessly mixed.
  2. They are linear: You can mathematically "subtract" one from the other.
  3. They live in different places: Grammar is everywhere (especially early on), while Meaning peaks in the middle of the model's processing.
  4. Grammar is the sturdy foundation: You can strip away meaning without breaking the grammar, but stripping away grammar makes the meaning harder to hold onto.

This suggests that even though these models are trained just by predicting the next word, they naturally develop a structure that looks a lot like how human linguists think language works: a structural framework that supports a layer of meaning.

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 →