位置嵌入是当前大型语言模型(LLM)的核心组成部分。旋转位置嵌入(RoPE)是一种利用旋转矩阵编码位置信息的技术,已成为许多 LLM(如 Llama 系列)中位置嵌入的事实标准选择。RoPE 进一步被用于扩展长上下文能力,这大致基于调整 RoPE 的 base 参数以缓解位置嵌入中的分布外(OOD)问题。然而,在本文中,我们发现 LLM 可能基于 OOD 理论获得一种表面的长上下文能力。我们重新审视了 RoPE 在 LLM 中的作用,并提出了一种新的长期衰减性质,推导出 RoPE 的 base 约束上下文长度:对于获得特定上下文长度能力,base 值存在一个绝对下界。我们的工作从理论和实证两方面揭示了上下文长度与 RoPE base 之间的关系,这可能为未来的长上下文训练提供启示。
英文摘要:
Position embedding is a core component of current Large Language Models (LLMs). Rotary position embedding (RoPE), a technique that encodes the position information with a rotation matrix, has been the de facto choice for position embedding in many LLMs, such as the Llama series. RoPE has been further utilized to extend long context capability, which is roughly based on adjusting the \textit{base} parameter of RoPE to mitigate out-of-distribution (OOD) problems in position embedding. However, in this paper, we find that LLMs may obtain a superficial long-context ability based on the OOD theory. We revisit the role of RoPE in LLMs and propose a novel property of long-term decay, we derive that the \textit{base of RoPE bounds context length}: there is an absolute lower bound for the base value to obtain certain context length capability. Our work reveals the relationship between context length and RoPE base both theoretically and empirically, which may shed light on future long context training.
DCIS: Efficient Length Extrapolation of LLMs via Divide-and-Conquer Scaling Factor Search
TJUNLP Lab, College of Intelligence and Computing, Tianjin University(天津大学智能计算学院);School of New Media and Communication, Tianjin University(天津大学新媒体与传播学院)
Block-Sparse Attention with Semantic-Geometric Decoupled Routing
Tsinghua University(清华大学);Alibaba Group(阿里巴巴集团);University of Science and Technology of China(中国科学技术大学);Shanghai Artificial Intelligence Laboratory(上海人工智能实验室)
Circuit Complexity Bounds for RoPE-based Transformer Architecture
Middle Tennessee State University(中田纳西州立大学);Stevens Institute of Technology(史蒂文斯理工学院);The University of Hong Kong(香港大学);University of Wisconsin-Madison(威斯康星大学麦迪逊分校);South China University of Technology(华南理工大学);The Simons Institute for the Theory of Computing(西蒙斯理论计算研究所);University of California, Berkeley(加利福尼亚大学伯克利分校)