arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.13753cs.CL
收藏

LongRoPE:将大语言模型上下文窗口扩展至超过200万token

LongRoPE: Extending LLM Context Window Beyond 2 Million Tokens

Microsoft Research(微软研究院)

Yiran Ding, Li Lyna Zhang, Chengruidong Zhang, Yuanyuan Xu, Ning Shang, Jiahang Xu, Fan Yang, Mao Yang

AI总结:

LongRoPE通过识别位置插值中的非均匀性、渐进式扩展策略和短上下文重调整,首次将预训练LLM上下文窗口扩展至2048k token,仅需1k微调步骤且保持短窗口性能。

摘要:

大上下文窗口是大语言模型(LLMs)的一项理想特性。然而,由于微调成本高昂、长文本稀缺以及新token位置引入的灾难性数值,当前扩展的上下文窗口被限制在约128k token。本文介绍了LongRoPE,首次将预训练大语言模型的上下文窗口扩展到令人瞩目的2048k token,在256k训练长度内仅需最多1k微调步骤,同时保持原始短上下文窗口上的性能。这一成果通过三项关键创新实现:(i)我们通过高效搜索识别并利用位置插值中的两种非均匀性,为微调提供更好的初始化,并在非微调场景下实现8倍扩展;(ii)我们引入了一种渐进式扩展策略,首先微调一个256k长度的LLM,然后在微调后的扩展LLM上进行第二次位置插值,以实现2048k上下文窗口;(iii)我们在8k长度上重新调整LongRoPE,以恢复短上下文窗口性能。在LLaMA2和Mistral上跨多种任务的大量实验证明了我们方法的有效性。通过LongRoPE扩展的模型保留了原始架构,仅对位置嵌入进行了微小修改,并且可以复用大多数已有的优化。

英文摘要:

Large context window is a desirable feature in large language models (LLMs). However, due to high fine-tuning costs, scarcity of long texts, and catastrophic values introduced by new token positions, current extended context windows are limited to around 128k tokens. This paper introduces LongRoPE that, for the first time, extends the context window of pre-trained LLMs to an impressive 2048k tokens, with up to only 1k fine-tuning steps at within 256k training lengths, while maintaining performance at the original short context window. This is achieved by three key innovations: (i) we identify and exploit two forms of non-uniformities in positional interpolation through an efficient search, providing a better initialization for fine-tuning and enabling an 8x extension in non-fine-tuning scenarios; (ii) we introduce a progressive extension strategy that first fine-tunes a 256k length LLM and then conducts a second positional interpolation on the fine-tuned extended LLM to achieve a 2048k context window; (iii) we readjust LongRoPE on 8k length to recover the short context window performance. Extensive experiments on LLaMA2 and Mistral across various tasks demonstrate the effectiveness of our method. Models extended via LongRoPE retain the original architecture with minor modifications to the positional embedding, and can reuse most pre-existing optimizations.

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

↑