Probing Layers › What Different Layers Encode

Michael BrenndoerferFebruary 5, 20267 min read
Language AI HandbookAll chapters
Part 59 of 67Interpretability
Chapter 450Probing Layers › What Different Layers Encode
Reading section 3 of 12 · What Different Layers Encode · 7 minSection 3 of 12 · 7 min

Book contents

Section 3 of 12 · 7 min read

Probing Layers › What Different Layers EncodeOne section · Sections in this chapter3 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

A major finding from layer probing research (Peters et al., 2018; Tenney et al., 2019; Jawahar et al., 2019) is that linguistic structure is not spread uniformly across a transformer's layers. Instead, different types of information tend to concentrate at different depths.

The general pattern, observed across BERT and similar models, is:

  • Lower layers (1-4): Local, surface-level features dominate. Part-of-speech tags, morphological properties (plural vs. singular, verb tense), and basic syntactic categories are most accurately predicted by probes at early layers.
  • Middle layers (5-8): Syntactic structure deepens. Dependency parsing accuracy peaks here, suggesting that the model builds up phrase structure and grammatical relations in mid-network layers.
  • Upper layers (9-12): Semantic and task-specific information concentrates. Coreference resolution, named entity recognition, and sense disambiguation tend to be best predicted from representations in the final third of the network.

This hierarchy mirrors the pipeline of classical NLP systems: tokenization and tagging come first, parsing comes next, and semantic interpretation comes last. The fact that a model trained purely on masked language modeling recovers this hierarchy suggests the ordering is not arbitrary. Rather, it reflects a natural dependency: to determine the meaning of a phrase, you first need to know its syntactic role.

The intuition is straightforward once you think about what the masked language modeling objective demands. To predict a masked word, the model needs information at multiple levels of abstraction. Knowing that the blank is a noun helps, but knowing that it is the subject of a transitive verb narrows things further, and knowing that the surrounding context involves rivers and flooding narrows things even more. The training signal rewards the model for building up exactly this hierarchy of signals, layer by layer, because each additional level of structure provides better constraints on what the missing word could be.

Jawahar et al. (2019) Findings

A systematic probing study of BERT across 17 NLP tasks found that lower layers captured surface features (phrase-level information), middle layers captured syntactic features (syntactic tree depth, subject-number agreement), and higher layers captured semantic features (semantic odd-man-out tasks). This stratified organization was surprisingly consistent across different sentence lengths and genres.

Syntactic Properties

Syntactic information, especially constituency structure, emerges in middle layers. The concept of syntactic tree depth, which measures how deeply nested a token is in a parse tree, peaks in predictability around layers 5-7 in a 12-layer BERT model. This means the representations at those layers carry implicit structural information about the grammatical organization of the sentence.

Subject-verb number agreement is a classic probe target. Given a sentence like "The keys to the cabinet are on the table," the model must track that the verb "are" agrees with "keys" (the subject) rather than "cabinet" (the nearer noun). Agreement probing accuracy tends to peak in middle layers, suggesting these layers actively maintain grammatical bookkeeping.

What makes syntactic probing informative is that BERT was never explicitly trained on parsing tasks. It was trained only to fill in masked words. The fact that it learns to encode syntactic structure as a byproduct of this objective suggests that syntactic structure is useful for predicting words in context. A model that does not know that "keys" and "are" must agree would struggle to predict the correct verb form in ambiguous sentences. The model thus acquires grammatical knowledge as an instrumental goal rather than an end in itself.

Dependency relations add another dimension. Probing studies can test whether a given token's representation "knows" which other token it syntactically depends on. This is typically framed as a probing task over token pairs: given the representations of two tokens, can a probe determine whether one is the syntactic head of the other? Accuracy on this task also peaks in middle layers and tends to be higher for representations that attend to structurally related tokens.

Constituency structure (the nested phrase groupings) follows a slightly different trajectory than dependency structure (the head-dependent arcs between individual tokens). Constituency tends to emerge earlier, with phrase-level groupings becoming accessible by layer 4-5, while the more complex relational structure captured by dependency graphs requires a few more layers of computation. This makes sense structurally: recognizing that "quick brown fox" is a noun phrase is a relatively local operation, while determining the grammatical role of "fox" with respect to "jumps" requires integrating information over the full clause.

Semantic Properties

Semantic content, including word sense disambiguation, semantic role labeling, and coreference, concentrates in upper layers. Coreference resolution requires understanding which noun phrases refer to the same real-world entity across a discourse. This is a deeply semantic task that requires integrating information across sentences, and probes at upper layers systematically outperform those at lower ones.

Named entity recognition (NER) shows a different pattern. Surface string matching ("This token looks like a name") may be captured at lower layers, while the actual entity type (PERSON vs. ORGANIZATION vs. LOCATION) becomes clearer in upper layers as the model integrates contextual evidence. The word "Washington" could refer to a person, a state, a city, or a university. Resolving which sense is intended requires reading the surrounding context, which is why entity typing signals are strongest in the upper layers where the most contextual integration has occurred.

Word sense disambiguation provides one of the cleanest illustrations of the upper-layer semantic hypothesis. In the bankrupt/riverbank example we started with, the word "bank" has the same form in both uses but very different meanings. Early layers produce nearly identical representations for both uses, because the token itself is identical and local context may not yet be sufficient to disambiguate. As the model processes deeper layers, the representations diverge: the riverbank "bank" starts to look more like "shore," "river," and "flood" in embedding space, while the financial "bank" starts to resemble "loan," "account," and "interest." This divergence of polysemous words across layers is one of the most direct pieces of evidence that upper layers perform semantic disambiguation.

Semantic role labeling (SRL) asks whether a given word is the agent, patient, instrument, or beneficiary of an event. The question "Who did what to whom?" requires understanding both grammatical structure and semantic content. SRL probing accuracy follows a gradient that peaks even later than syntactic probing, often in the final two or three layers of a 12-layer model. This positions SRL at the top of the linguistic hierarchy as one of the most demanding properties for a probe to decode from linear features of the representation.

Surface and Morphological Features

Below syntactic properties lies a layer of surface and morphological features that are even more strongly localized to early layers. Morphological probing tests whether a token's representation encodes its morphological properties: whether it is plural, past tense, comparative, possessive, and so on. These properties are, in some sense, encoded directly in the token's surface form ("cats" is clearly plural; "walked" is clearly past tense), so it is not surprising that probes at even layer 1 can often predict them with high accuracy.

What is more interesting is the relative accuracy profile. Layer 0 (the embedding layer) already captures substantial morphological information because the token embeddings for "cat" and "cats" are nearby in embedding space, having co-occurred in similar contexts during training. But there is a measurable jump in accuracy from layer 0 to layer 1, suggesting that even one round of attention improves the representation's morphological signal, possibly by gathering evidence from surrounding words that constrain the likely morphological form.

Sentence length, token position, and other purely structural properties also tend to be most accessible from early layers. These are the properties that require no understanding of meaning, only of form, and the model encodes them early because they are easy to read off from the surface.