What does BERT look at? An Analysis of BERT's Attention

被引:672
作者
Clark, Kevin [1 ]
Khandelwal, Urvashi [1 ]
Levy, Omer [2 ]
Manning, Christopher D. [1 ]
机构
[1] Stanford Univ, Comp Sci Dept, Stanford, CA 94305 USA
[2] Facebook AI Res, Menlo Pk, CA USA
来源
BLACKBOXNLP WORKSHOP ON ANALYZING AND INTERPRETING NEURAL NETWORKS FOR NLP AT ACL 2019 | 2019年
关键词
D O I
10.18653/v1/w19-4828
中图分类号
TP18 [人工智能理论];
学科分类号
081104 ; 0812 ; 0835 ; 1405 ;
摘要
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.
引用
收藏
页码:276 / 286
页数:11
相关论文
共 41 条
[1]  
[Anonymous], 2018, EMNLP
[2]  
[Anonymous], 2019, NAACL HLT
[3]  
[Anonymous], JOINT C EMNLP CONLL
[4]  
[Anonymous], ACL
[5]  
[Anonymous], 2011, CoNLL
[6]  
[Anonymous], EMNLP
[7]  
[Anonymous], 2019, ARXIV190509418
[8]  
[Anonymous], ICLR
[9]  
[Anonymous], 2015, P 3 INT C LEARN REPR
[10]  
[Anonymous], BLACKBOXNLP EMNLP