2025-02-28 · 专家 · 机器学习 · 自然语言处理

LongRoPE2: Near-Lossless LLM Context Window Scaling

LongRoPE2通过优化RoPE缩放算法和混合上下文窗口训练,实现了LLM上下文窗口的无损扩展,同时保持了短上下文性能。

更新于 2025-07-09。作者:Ning Shang、Li Lyna Zhang、Siyuan Wang、Gaokai Zhang、Gilsinia Lopez、Fan Yang、Weizhu Chen、Mao Yang。

中文摘要

LongRoPE2是一种新颖的方法,它将预训练的大型语言模型(LLMs)的有效上下文窗口扩展到目标长度,同时保持了在原始较短上下文窗口上的性能。这是通过以下三个贡献实现的:(1)一个假设,即在高RoPE维度上的训练不足是导致现有方法中观察到的持续分布外(OOD)问题的主要原因;(2)一个有效的RoPE缩放算法,该算法采用“针驱动”困惑度引导的进化搜索来解决训练不足的问题;(3)一种混合上下文窗口训练方法,该方法微调模型权重,以采用缩放后的RoPE进行长上下文序列的训练,同时使用原始RoPE保持短上下文性能。在LLaMA3-8B和Phi3-mini-3.8B上进行的广泛实验在各种基准测试中验证了这一假设,并展示了LongRoPE2的有效性。值得注意的是,LongRoPE2将LLaMA3-8B的有效上下文长度扩展到128K,同时保留了超过98.5%的短上下文性能,仅使用了10B个标记——比Meta的方法少80倍,而Meta的方法未能达到目标的有效上下文长度。代码将在https://github.com/microsoft/LongRoPE上提供。

英文摘要

LongRoPE2 is a novel approach that extends the effective context window of pre-trained large language models (LLMs) to the target length, while preserving the performance on the original shorter context window. This is achieved by three contributions: (1) a hypothesis that insufficient training in higher RoPE dimensions contributes to the persistent out-of-distribution (OOD) issues observed in existing methods; (2) an effective RoPE rescaling algorithm that adopts evolutionary search guided by "needle-driven" perplexity to address the insufficient training problem; (3) a mixed context window training approach that fine-tunes model weights to adopt rescaled RoPE for long-context sequences while preserving the short-context performance with the original RoPE. Extensive experiments on LLaMA3-8B and Phi3-mini-3.8B across various benchmarks validate the hypothesis and demonstrate the effectiveness of LongRoPE2. Remarkably, LongRoPE2 extends LLaMA3-8B to achieve a 128K effective context length while retaining over 98.5% of short-context performance, using only 10B tokens -- 80x fewer than Meta's approach, which fails to reach the target effective context length. Code will be available at https://github.com/microsoft/LongRoPE.

解读

一句话总结

LongRoPE2通过优化RoPE缩放算法和混合上下文窗口训练,实现了LLM上下文窗口的无损扩展,同时保持了短上下文性能。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源

机器可读索引:llms.txt