Skip to main content
QUICK REVIEW

[论文解读] How Does BERT Answer Questions? A Layer-Wise Analysis of Transformer Representations

Betty van Aken, Benjamin Winter|arXiv (Cornell University)|Sep 11, 2019
Topic Modeling参考文献 37被引用 42
一句话总结

这篇论文分析BERT在各层的隐藏状态,以理解QA推理如何出现,显示出类似阶段的变换,且微调对语义能力的影响有限。

ABSTRACT

Bidirectional Encoder Representations from Transformers (BERT) reach state-of-the-art results in a variety of Natural Language Processing tasks. However, understanding of their internal functioning is still insufficient and unsatisfactory. In order to better understand BERT and other Transformer-based models, we present a layer-wise analysis of BERT's hidden states. Unlike previous research, which mainly focuses on explaining Transformer models by their attention weights, we argue that hidden states contain equally valuable information. Specifically, our analysis focuses on models fine-tuned on the task of Question Answering (QA) as an example of a complex downstream task. We inspect how QA models transform token vectors in order to find the correct answer. To this end, we apply a set of general and QA-specific probing tasks that reveal the information stored in each representation layer. Our qualitative analysis of hidden state visualizations provides additional insights into BERT's reasoning process. Our results show that the transformations within BERT go through phases that are related to traditional pipeline tasks. The system can therefore implicitly incorporate task-specific information into its token representations. Furthermore, our analysis reveals that fine-tuning has little impact on the models' semantic abilities and that prediction errors can be recognized in the vector representations of even early layers.

研究动机与目标

  • 研究 BERT 在问答任务中如何在各层变换令牌表示。
  • 揭示不同层在 QA 中是否执行不同的推理步骤。
  • 评估针对 QA 的微调如何影响内部层表征。
  • 提供工具,利用隐藏状态识别 QA 预测失效的原因和位置。

提出的方法

  • 使用降维和聚类对令牌向量进行逐层定性可视化。
  • 对每一层应用一组探针任务( Named Entity Labeling, Coreference Resolution, Relation Classification)以及特定于 QA 的任务(Question Type Classification, Supporting Fact Identification) 。
  • 使用 Edge Probing 将核心 NLP 任务转换为逐层分类问题。
  • 将微调后的 BERT 模型在 SQuAD、HotpotQA、和 bAbI 上与预训练对照模型进行比较。
  • 将 GPT-2 纳入定性比较,以评估洞察在其他 Transformer 上的可迁移性。

实验结果

研究问题

  • RQ1Transformer 模型是否像人类一样以分解的方式回答问题?
  • RQ2在多层 Transformer 中,特定的层在 QA 过程中是否解决不同的任务?
  • RQ3微调如何影响网络内部状态及各层的功能?
  • RQ4逐层分析是否有助于解释模型为何无法预测正确答案?

主要发现

  • 隐藏状态包含可解释的信息,按阶段推进,类似于传统的 NLP 任务。
  • 早期层编码通用语言属性;后期层则融合面向答题的任务特定信息。
  • Named Entity Labeling 在最早阶段得到提升;Coreference Resolution 和 Relation Classification 在后期层达到峰值;Question Type 信息取决于任务。
  • 问题和支持性事实在各层的向量空间中匹配,较高层对提取答案的相关令牌进行对齐。
  • 微调对核心 NLP 能力影响有限;大部分信息在预训练阶段已存在,在微调期间权重变化较小。
  • 位置嵌入对后续层仍有影响,支撑 Transformer 表征中的序列信息。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

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