Skip to main content
QUICK REVIEW

[论文解读] Improve Transformer Models with Better Relative Position Embeddings

Zhiheng Huang, Davis Liang|arXiv (Cornell University)|Sep 28, 2020
Topic Modeling参考文献 16被引用 11
一句话总结

本文提出了一种广义的相对位置嵌入方法,通过增强查询、键与相对位置嵌入之间的交互,提升了Transformer中的自注意力机制。该方法在先前的绝对位置和相对位置方法基础上,提升了SQuAD1.1的性能,并实现了近乎即插即用的替换方式,使BERT-large的F1分数从93.15%提升至93.55%,计算成本几乎可忽略。

ABSTRACT

Transformer architectures rely on explicit position encodings in order to preserve a notion of word order. In this paper, we argue that existing work does not fully utilize position information. For example, the initial proposal of a sinusoid embedding is fixed and not learnable. In this paper, we first review absolute position embeddings and existing methods for relative position embeddings. We then propose new techniques that encourage increased interaction between query, key and relative position embeddings in the self-attention mechanism. Our most promising approach is a generalization of the absolute position embedding, improving results on SQuAD1.1 compared to previous position embeddings approaches. In addition, we address the inductive property of whether a position embedding can be robust enough to handle long sequences. We demonstrate empirically that our relative position embedding method is reasonably generalized and robust from the inductive perspective. Finally, we show that our proposed method can be adopted as a near drop-in replacement for improving the accuracy of large models with a small computational budget.

研究动机与目标

  • 解决现有Transformer模型中相对位置信息利用不足的问题。
  • 从归纳偏置的角度,提升模型在长序列上的泛化能力和鲁棒性。
  • 开发一种可作为近乎即插即用替换方案的相对位置嵌入,以极低的计算成本提升大模型的准确率。
  • 通过实验验证相对位置嵌入在不同序列长度和截断阈值下的鲁棒性。

提出的方法

  • 提出一种广义的相对位置嵌入方法,增强自注意力机制中查询、键与相对位置嵌入之间的交互。
  • 引入一种可学习的相对位置嵌入,以泛化绝对位置嵌入并改善注意力动态。
  • 采用修改后的自注意力机制,将相对位置嵌入显式整合到查询和键的计算中。
  • 使用带有超参数$k$的截断机制,限制相对距离范围,提升效率与泛化能力。
  • 将该方法作为即插即用替换方案应用于BERT-large,仅使用3个训练轮次和较小的初始学习率进行微调。
  • 通过可视化注意力模式和嵌入权重,分析模型行为并确认注意力具有局部化特性。

实验结果

研究问题

  • RQ1是否可以设计出与查询和键更好地交互的相对位置嵌入,从而提升注意力性能?
  • RQ2所提出的相对位置嵌入是否能稳健泛化至超过预训练长度的长序列?
  • RQ3该方法是否可有效作为即插即用替换方案,以极低计算成本提升大预训练模型的性能?
  • RQ4截断阈值$k$如何影响模型在不同序列长度下的性能与泛化能力?

主要发现

  • 所提方法(方法4)在SQuAD1.1上的F1得分为93.55%,优于基线BERT-large模型的93.15%。
  • 在SQuAD数据上将最大序列长度增加至704时,微调得到的最高F1为90.71%,当微调序列长度为576个token时达到最优。
  • 模型对长序列表现出鲁棒性,在576、640和704个token的微调长度下性能均保持稳定。
  • 可视化结果表明注意力高度局部化,对邻近token有强关注,对远距离token的关注接近零,验证了使用小$k$值的合理性。
  • 该方法仅通过3个微调轮次,便使BERT-large的F1提升0.4个百分点,且参数量和推理延迟几乎无增加。
  • 即使预训练与微调的序列长度不同,相对位置嵌入仍表现出有效性,表明其具备强大的归纳泛化能力。

更好的研究,从现在开始

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

无需绑定信用卡

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