[論文レビュー] RoFormer: Enhanced Transformer with Rotary Position Embedding
要約: RoFormer は Rotary Position Embedding(RoPE)を導入し、回転行列を用いて絶対位置情報と相対位置情報を符号化することで、翻訳、事前学習、GLUEタスク全般の性能を向上させ、線形アテンションとの互換性を持つ。
Position encoding recently has shown effective in the transformer architecture. It enables valuable supervision for dependency modeling between elements at different positions of the sequence. In this paper, we first investigate various methods to integrate positional information into the learning process of transformer-based language models. Then, we propose a novel method named Rotary Position Embedding(RoPE) to effectively leverage the positional information. Specifically, the proposed RoPE encodes the absolute position with a rotation matrix and meanwhile incorporates the explicit relative position dependency in self-attention formulation. Notably, RoPE enables valuable properties, including the flexibility of sequence length, decaying inter-token dependency with increasing relative distances, and the capability of equipping the linear self-attention with relative position encoding. Finally, we evaluate the enhanced transformer with rotary position embedding, also called RoFormer, on various long text classification benchmark datasets. Our experiments show that it consistently overcomes its alternatives. Furthermore, we provide a theoretical analysis to explain some experimental results. RoFormer is already integrated into Huggingface: \url{https://huggingface.co/docs/transformers/model_doc/roformer}.
研究の動機と目的
- 加法的な絶対エンコーディングを超えて、トランスフォーマー学習に位置情報を組み込む方法を探る。
- ロータリー位置エンコーディング(RoPE)を提案し、回転行列で絶対位置を符号化し、自己注意で相対位置を符号化する。
- 長文分類、機械翻訳、事前学習タスクにおけるRoPEの利点を示す。
- RoPEの性質(シーケンス長の柔軟性や距離とともに語間依存が減衰することなど)の理論的解析を提供する。
提案手法
- 埋め込みと相対位置の関数として、クエリとキーの内積をモデル化することでRoPEを導出する。
- 回転行列 R_Θ,m を用いて、トークン埋め込みの回転付きアファイン変換として f_q および f_k を表現する(式14/15)。
- q_m^T k_n が (W_q x_m)^T R^d_Θ,m^T R^d_Θ,n (W_k x_n) に等しく、相対位置依存項に簡略化される(式16)。
- RoPEを自己注意と統合し、線形アテンションの場合は回転されたQとKを非負の特徴マップと掛け合わせる(式19)。
- RoPEの長期的な減衰を角度項 θ_i によって証明し、計算上効率な回転実装を示す(式15–16、34)。
- RoFormerを機械翻訳(WMT14 En-De)、MLM事前学習(BERTベースライン)、GLUE微調整、RoPEを用いたPerFormerで評価する。
実験結果
リサーチクエスチョン
- RQ1回転を用いて、絶対位置情報と相対位置情報をトランスフォーマーに効果的にエンコードするにはどうすればよいか。
- RQ2RoPEは翻訳、言語モデリング、下流タスクにおいて、加法的位置エンコーディングを上回る性能と収束性をもたらすか。
- RQ3RoPEは安定性や性能を損なうことなく、線形アテンションと効率的に統合できるか。
- RQ4RoPEの理論的特性(例: 距離に応じた減衰)と、それが自然言語の構造とどのように関連するか。
主な発見
| モデル | MRPC | SST-2 | QNLI | STS-B | QQP | MNLI(m/mm) |
|---|---|---|---|---|---|---|
| BERT (Devlin et al. 2019) | 89.5 | 93.5 | 90.5 | 85.8 | 71.2 | 84.6/83.4 |
| RoFormer | 89.5 | 90.7 | 88.0 | 87.0 | 86.4 | 80.2/79.8 |
- RoFormerはWMT 2014英語-ドイツ語翻訳でTransformer-baseよりBLEUが高い(BLEU: 27.5 vs 27.3)。
- RoFormerはBookCorpus+Wikipediaの MLM事前学習で vanilla BERT より早く収束する。
- RoFormerは微調整でMRPC、SST-2、QNLI、STS-B、QQP、MNLIなどのGLUEタスクをBERTより改善するが、混合した利得(例:MRPC 89.5 vs 88.9;SST-2 90.7 vs 93.5;QNLI 88.0 vs 90.5;STS-B 87.0 vs 85.8;QQP 86.4 vs 71.2;MNLI 80.2/79.8 vs 84.6/83.4)
- RoPEは線形アテンション(PerFormer)と互換性があり、相対位置情報を符号化しつつ線形計算量を維持する。
- RoPEはシーケンス長の柔軟性と、相対距離が増すにつれて語間依存が減衰する特性を提供し、言語構造と整合する。
より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。