Concepedia

Publication | Open Access

What Does BERT Look at? An Analysis of BERT’s Attention

79

Citations

25

References

2019

Year

TLDR

Large pre‑trained models such as BERT have achieved great success in NLP, prompting research into the linguistic knowledge they acquire, yet most studies have focused on model outputs or internal representations rather than attention. This work proposes methods for analyzing BERT’s attention mechanisms and introduces an attention‑based probing classifier to demonstrate that substantial syntactic information is captured. The authors develop and apply techniques for inspecting BERT’s attention heads to reveal their behavior. BERT’s attention heads exhibit distinct patterns—focusing on delimiters, positional offsets, or entire sentences—and many align with linguistic concepts such as syntax and coreference, with specific heads accurately identifying direct objects, determiners, prepositional objects, and coreferent mentions, confirming that BERT’s attention encodes substantial syntactic information.

Abstract

Large pre-trained neural networks such as BERT have had great recent success in NLP, motivating a growing body of research investigating what aspects of language they are able to learn from unlabeled data. Most recent analysis has focused on model outputs (e.g., language model surprisal) or internal vector representations (e.g., probing classifiers). Complementary to these works, we propose methods for analyzing the attention mechanisms of pre-trained models and apply them to BERT. BERT’s attention heads exhibit patterns such as attending to delimiter tokens, specific positional offsets, or broadly attending over the whole sentence, with heads in the same layer often exhibiting similar behaviors. We further show that certain attention heads correspond well to linguistic notions of syntax and coreference. For example, we find heads that attend to the direct objects of verbs, determiners of nouns, objects of prepositions, and coreferent mentions with remarkably high accuracy. Lastly, we propose an attention-based probing classifier and use it to further demonstrate that substantial syntactic information is captured in BERT’s attention.

References

YearCitations

Page 1