Do Attention Heads in BERT Track Syntactic Dependencies?

By Phu Mon Htut, Jason Phang, Shikha Bordia, Samuel R. Bowman. 2019

151 citations recorded by the source corpus.

We investigate the extent to which individual attention heads in pretrained transformer language models, such as BERT and RoBERTa, implicitly capture syntactic dependency relations. We employ two methods---taking the maximum attention weight and computing the maximum spanning tree---to extract implicit dependency relations from the attention weights of each layer/head, and compare them to the ground-truth Universal Dependency (UD) trees. We show that, for some UD relation types, there exist heads that can recover the dependency type significantly better than baselines on parsed English text, suggesting that some self-attention heads act as a proxy for syntactic structure. We also analyze BERT fine-tuned on two datasets---the syntax-oriented CoLA and the semantics-oriented MNLI---to investigate whether fine-tuning affects the patterns of their self-attention, but we do not observe substantial differences in the overall dependency relations extracted using our methods. Our results suggest that these models have some specialist attention heads that track individual dependency types, but no generalist head that performs holistic parsing significantly better than a trivial baseline, and that analyzing attention weights directly may not reveal much of the syntactic knowledge that BERT-style models are known to learn.

Subfields: Artificial Intelligence, Cognitive Neuroscience, Natural Language Processing, Model Architectures

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Yonatan Belinkov
  2. Mohit Bansal
  3. Samuel R. Bowman
  4. Jianfeng Gao
  5. Caiming Xiong
  6. Zhe Gan
  7. Yejin Choi
  8. Luke S. Zettlemoyer

In Cognitive Neuroscience

  1. Yonatan Belinkov
  2. Anna Rogers
  3. Anna Rumshisky
  4. Yada Pruksachatkun
  5. Marta Ruiz Costa-jussà
  6. Zhe Gan
  7. Jun Zhu
  8. R. Thomas McCoy

In Natural Language Processing

  1. Yonatan Belinkov
  2. Samuel R. Bowman
  3. Mohit Bansal
  4. Caiming Xiong
  5. Sebastian Gehrmann
  6. Richard Socher
  7. Xipeng Qiu
  8. Jianfeng Gao

In Model Architectures

  1. Yonatan Belinkov
  2. Tal Linzen
  3. Samuel R. Bowman
  4. R. Thomas McCoy
  5. Anna Rogers
  6. Richard Socher
  7. Anna Rumshisky
  8. Caiming Xiong

Citations in the corpus