A Structural Probe for Finding Syntax in Word Representations

John Hewitt, Christopher D. ManningNAACL 2019

Abstract

John Hewitt, Christopher D. Manning. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers).

2019.

Introduction

While large-scale language models like BERT and ELMo have revolutionized natural language processing, the nature of their internal representations remains largely opaque. Previous "probing" research has primarily focused on whether these models predict specific linguistic labels, such as part-of-speech tags. However, these methods do not address whether models capture the global, hierarchical structure of a sentence—the syntax tree.

This paper introduces a "structural probe" to determine if deep language models implicitly represent entire syntax trees within their vector spaces. The authors test the hypothesis that syntax is an emergent property of the model's internal geometry, where the distance between word vectors relates to their distance in a dependency parse tree.

Methodology

The authors propose a supervised but highly constrained structural probe designed to identify specific geometric structures within word representations.

  1. Distance Probe: A linear transformation (matrix $B$) is learned such that the squared L2 distance between two transformed word vectors approximates the number of edges between those words in a gold-standard parse tree.
  2. Depth Probe: Similarly, a transformation is learned such that the squared L2 norm of a word's vector approximates its depth (distance from the root) in the parse tree.
  3. Tree Reconstruction: To evaluate the probe, predicted distances are used to construct a Minimum Spanning Tree (MST). The accuracy of this MST against the actual dependency tree indicates how well the model encodes syntax.

Crucially, the probe is restricted to a linear transformation. This ensures the probe is merely "rotating and scaling" the existing representation space to uncover latent information, rather than using a complex non-linear model to learn parsing from scratch.

Key Insights: Syntax as Geometry

The most profound insight of this work is that syntax can be represented as a distance metric. In this view, "knowing grammar" involves organizing word representations such that syntactically related words are physically closer in a specific subspace.

The authors found that syntactic information is stored very compactly. As shown in the rank analysis, increasing the dimensionality of the transformation matrix $B$ beyond 64 or 128 (out of 1024 for BERT-Large) yielded diminishing returns. This suggests that models dedicate a specific, low-dimensional "slice" of their representation space to syntax.

Syntactic information is captured in a low-rank subspace.

Furthermore, unlike previous probes focusing on local head-dependent pairs, this structural probe tests the model's knowledge of the distance between every pair of words. The high accuracy suggests that models maintain a consistent global map of sentence structure.

Experimental Results

The study utilized the Penn Treebank (PTB) converted into Stanford Dependencies. The structural probe achieved significant results:

  • Reconstruction Accuracy: BERT-Large (Layer 15) achieved an Undirected Unlabeled Attachment Score (UUAS) of 82.5, while ELMo (Layer 1) reached 77.0. For comparison, a linear chain baseline only scores 48.9.
  • Correlation: The Spearman correlation between predicted and true tree distances (DSpr) reached 0.87 for BERT-Large, indicating a strong alignment between model geometry and linguistic theory.
  • Layer-wise Trends: Syntactic information is not uniform across layers. In BERT, syntax peaks in the middle-to-late layers (around layer 15 or 16), with a slight decline in the final layers as the model shifts focus toward its specific pre-training objectives.
Layer-wise performance of the structural probe across BERT and ELMo layers.

Limitations and Future Work

While the probe demonstrates that syntactic information exists within these models, it does not prove that the models actively use this geometric information for downstream tasks. Additionally, the distance probe is undirected; while the depth probe helps identify parent-child relationships, the system does not explicitly recover directed arcs or specific dependency labels. Finally, as this study focused on English, future research is required to determine if these geometric properties generalize to languages with different morphological or branching structures.

Summary updated

BibTeX
@inproceedings{hewitt2019structural,
  author = {John Hewitt and Christopher D. Manning},
  title = {{A Structural Probe for Finding Syntax in Word Representations}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2019},
  url = {https://openreview.net/forum?id=ByWIQQWdbH},
}
Figure