arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2104.09864cs.CLcs.AIcs.LG
收藏

RoFormer:采用旋转位置嵌入的增强型 Transformer

RoFormer: Enhanced Transformer with Rotary Position Embedding

Zhuiyi Technology Co., Ltd.(追一科技有限公司)

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

AI总结:

本文提出 RoPE 旋转位置嵌入,用旋转矩阵编码绝对位置并在自注意力中融入相对位置依赖,由此构建的 RoFormer 在长文本分类任务上持续优于对比方法。

摘要:

位置编码最近在 Transformer 架构中展现出有效性。它为序列中不同位置元素之间的依赖关系建模提供了有价值的监督。本文中,我们首先研究了将位置信息整合到基于 Transformer 的语言模型学习过程中的各种方法。随后,我们提出了一种名为 Rotary Position Embedding(RoPE,旋转位置嵌入)的新方法,以有效利用位置信息。具体而言,所提出的 RoPE 使用旋转矩阵对绝对位置进行编码,同时在自注意力公式中纳入显式的相对位置依赖。值得注意的是,RoPE 具备多项有价值的特性,包括序列长度的灵活性、token 间依赖随相对距离增大而衰减,以及为线性自注意力配备相对位置编码的能力。最后,我们在多个长文本分类基准数据集上评估了采用旋转位置嵌入的增强型 Transformer(也称为 RoFormer)。实验表明,它始终优于替代方案。此外,我们还提供了理论分析以解释部分实验结果。RoFormer 已集成到 Huggingface 中:https://huggingface.co/docs/transformers/model_doc/roformer。

英文摘要:

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

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑