Skip to main content
QUICK REVIEW

[논문 리뷰] RoFormer: Enhanced Transformer with Rotary Position Embedding

Jianlin Su, Yu Lu|arXiv (Cornell University)|2021. 04. 20.
Topic Modeling참고 문헌 35인용 수 229
한 줄 요약

RoFormer는 Rotary Position Embedding (RoPE)를 도입하여 회전 행렬을 통해 절대 위치 정보와 상대 위치 정보를 인코딩하고, 번역, 사전학습, GLUE 작업에서 성능을 향상시키며 선형 어텐션과의 호환성을 제공합니다.

ABSTRACT

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).
  • 각도 항 θ_i를 통한 RoPE의 장기적 감소를 증명하고 계산적으로 효율적인 회전 구현을 보인다(식 15–16, 34).
  • RoFormer를 기계 번역(WMT14 En-De), MLM 사전학습(BERT 기본 모델), GLUE 미세조정, RoPE가 적용된 PerFormer에서 평가한다.

실험 결과

연구 질문

  • RQ1회전을 사용하여 절대 위치 정보와 상대 위치 정보를 트랜스포머에 효과적으로 인코딩하려면 어떻게 해야 하는가?
  • RQ2RoPE가 번역, 언어 모델링 및 다운스트림 작업에서 가산 위치 인코딩에 비해 성능 및 수렴을 개선하는가?
  • RQ3RoPE를 선형 어텐션과 효율적으로 통합하되 안정성이나 성능을 해치지 않는가?
  • RQ4RoPE의 이론적 특성(예: 거리 증가에 따른 감소)은 무엇이며 이것이 자연어 구조와 어떻게 관련되는가?

주요 결과

  • RoFormer는 WMT 2014 영어-독일어 번역에서 Transformer-base보다 BLEU가 더 높다(BLEU: 27.5 대 27.3).
  • RoFormer는 BookCorpus+Wikipedia의 MLM 사전학습에서 일반 BERT보다 더 빠르게 수렴한다.
  • RoFormer는 미세조정에서 BERT보다 여러 GLUE 과제를 개선하였으며( MRPC, SST-2, QNLI, STS-B, QQP, MNLI ), 혼합된 이익을 보인다(예: 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가 만들고, 인간 에디터가 검토했습니다.