arrow
Return

RoFormer: Enhanced transformer with Rotary Position Embedding

delete2024-02-01
delete214
delete
OA
AI
J
Jianlin Su
M
Murtadha Ahmed *
卢宇 (Yu Lu)
B
Bo Wen
Y
Yunfeng Liu
DOI:10.1016/j.neucom.2023.127063delete
deleteOriginal
deleteShare
deleteSave
View PDF
Abstract

Abstract

En 中文
Position encoding has recently been shown to be effective in 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 the 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 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: https://huggingface.co/docs/ transformers/model_doc/roformer.
Keywords:
Pre-trained language models
Position information encoding
Pre-training
Natural language processing
AI Summary

AI Summary

Key information extracted from the uploaded paper, including a brief overview, abstract, background, key highlights, visual analysis, and future outlook.

Journal

Neurocomputing cover
Neurocomputing
IF:
6.5
Papers:
2.5W
Citations:
6.5W

Organization

No organization information available