Skip to main content
QUICK REVIEW

[论文解读] Do Attention Heads in BERT Track Syntactic Dependencies?

Phu Mon Htut, Jason Phang|arXiv (Cornell University)|Nov 27, 2019
Topic Modeling参考文献 24被引用 88
一句话总结

本论文分析在 BERT、RoBERTa 及其微调变体中,单个注意力头是否隐式捕捉句法依赖关系,使用最大注意力和最大生成树方法提取依赖并与 UD trees 进行比较。

ABSTRACT

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.

研究动机与目标

  • 评估 BERT/RoBERTa 的自注意力头是否追踪句法依赖关系。
  • 确定是否有某些头在特定依赖(如 nsubj、obj)方面充当专家。
  • 评估在句法或语义相关任务上的微调是否改变基于注意力的句法信号。
  • 在不进行额外训练的情况下,将提取方法与 ground-truth 的 UD 树进行比较。
  • 对比专家型注意力头与模型整体解析能力。

提出的方法

  • 使用注意力权重矩阵从每个注意力头和每一层提取依赖关系。
  • 通过选择每个标记的最高注意力父项来形成关系,应用 Max 方法。
  • 通过 Chu-Liu-Edmonds 算法应用最大生成树(MST)方法构建完整的依赖树。
  • 将提取的关系/树与英语 Parallel Universal Dependencies (PUD) 作为金标准进行评估。
  • 排除特殊标记并合并不匹配的子标记,以将分词与模型输入对齐。
  • 在关系抽取性能方面比较预训练的 BERT/RoBERTa 与微调变体(CoLA-BERT、MNLI-BERT)。

实验结果

研究问题

  • RQ1BERT/RoBERTa 中的单个注意力头是否能可靠地编码特定的句法依赖关系?
  • RQ2两种简单、无需训练的方法(Max 和 MST)能否从注意力权重中恢复有意义的依赖结构?
  • RQ3在语法导向(CoLA)或语义导向(MNLI)的任务上微调是否会改变注意力头捕捉的句法信号?
  • RQ4是否存在一个通用型注意力头,使整体解析比简单基线更好?

主要发现

  • 一些注意力头在跟踪某些依赖类型(如 nsubj、obj)方面具有专业化特征,准确性显著高于基线。
  • 在 MNLI 上的微调提升了长距离从句依赖,但对短距离依赖略有不利影响;CoLA 微调对依赖的影响很小。
  • 基于 MST 的注意力权重树并未显著优于基线,表明缺乏用于整体解析的通用型注意力头。
  • 与随机初始化和简单基线相比,训练后的模型在若干依赖类型上优于基线,但总体 UUAS 增益适中。
  • 在其分析的背景下,CoLA 或 MNLI 的微调并未对整体自注意力模式产生剧烈改变。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。