Skip to main content
QUICK REVIEW

[Paper Review] Improve Transformer Models with Better Relative Position Embeddings

Zhiheng Huang, Davis Liang|arXiv (Cornell University)|Sep 28, 2020
Topic ModelingComputer Science16 references11 citations
TL;DR

This paper proposes a generalized relative position embedding method that enhances self-attention in Transformers by increasing interaction between queries, keys, and relative position embeddings. The approach improves SQuAD1.1 performance over prior absolute and relative position methods and enables a near drop-in replacement that boosts BERT-large F1 from 93.15% to 93.55% with minimal computational cost.

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.

Motivation & Objective

  • To address the underutilization of relative position information in existing Transformer models.
  • To improve model generalization and robustness to longer sequences from the inductive perspective.
  • To develop a relative position embedding that can be used as a near drop-in replacement to enhance large model accuracy with low computational cost.
  • To empirically validate the robustness of relative position embeddings under varying sequence lengths and clipping thresholds.

Proposed method

  • Proposes a generalized relative position embedding that enhances interaction between query, key, and relative position embeddings in the self-attention mechanism.
  • Introduces a learnable relative position embedding that generalizes absolute position embeddings and improves attention dynamics.
  • Employs a modified self-attention mechanism where relative position embeddings are explicitly integrated into query and key computation.
  • Uses a clipping mechanism with a hyperparameter $k$ to limit the relative distance range, improving efficiency and generalization.
  • Applies the method as a drop-in replacement in BERT-large, fine-tuning with only 3 epochs and a small learning rate.
  • Visualizes attention patterns and embedding weights to analyze model behavior and confirm localized attention behavior.

Experimental results

Research questions

  • RQ1Can relative position embeddings be designed to better interact with queries and keys, leading to improved attention performance?
  • RQ2Does the proposed relative position embedding generalize robustly to longer sequences beyond the pre-training length?
  • RQ3Can the method be effectively applied as a drop-in replacement to boost large pre-trained models with minimal computational cost?
  • RQ4How does the clipping threshold $k$ affect model performance and generalization across varying sequence lengths?

Key findings

  • The proposed method (Method 4) achieves an SQuAD1.1 F1 score of 93.55%, outperforming the baseline BERT-large model's 93.15%.
  • Fine-tuning with increased maximum sequence length (up to 704) on SQuAD data yields the highest F1 of 90.71% when fine-tuned on sequences up to 576 tokens.
  • The model shows robustness to longer sequences, with performance stable across fine-tuning lengths of 576, 640, and 704 tokens.
  • Visualization confirms that attention is highly localized, with strong attention to nearby tokens and near-zero attention to distant ones, justifying the use of a small $k$.
  • The method achieves a 0.4 percentage point F1 improvement on BERT-large with only 3 fine-tuning epochs and negligible increase in parameters or inference latency.
  • The relative position embedding is shown to be effective even when the pre-training and fine-tuning sequence lengths differ, indicating strong inductive generalization.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.