Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

RoFormer: Enhanced Transformer with Rotary Position Embedding

About

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}.

Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, Yunfeng Liu• 2021

Related benchmarks

TaskDatasetResultRank
Commonsense ReasoningHellaSwag
Accuracy53.95
1896
Image ClassificationImageNet-1K
Top-1 Acc80.3
1239
Automatic Speech RecognitionLibriSpeech clean (test)
WER3.66
1207
Language UnderstandingMMLU
Accuracy62.22
844
Language ModelingWikiText
PPL24.8
740
ReasoningBBH
Accuracy64.47
726
Image ClassificationImageNet-1k (val)
Top-1 Accuracy80.9
708
Language ModelingWikiText-103 (test)
Perplexity28.48
703
Video UnderstandingMVBench--
563
Question AnsweringARC-E
Accuracy48.9
523
Showing 10 of 195 rows
...

Other info

Follow for update