缩放旋转位置嵌入(RoPE)已成为扩展基于RoPE的大语言模型(LLMs)上下文窗口的常用方法。然而,现有缩放方法往往依赖经验性做法,缺乏对RoPE内部分布的深入理解,导致在扩展上下文窗口长度时性能欠佳。本文提出从旋转角度分布的视角来优化上下文窗口扩展任务。具体而言,我们首先估计模型内旋转角度的分布,并分析长度扩展对该分布的扰动程度。随后,我们提出一种新的扩展策略,通过最小化旋转角度分布之间的扰动来保持与预训练阶段的一致性,从而增强模型泛化到更长序列的能力。与强基线方法相比的实验结果表明,在将LLaMA2的上下文窗口扩展到8k时,我们的方法最多可减少72%的分布扰动;扩展到16k时,最多可减少32%。在LongBench-E基准上,我们的方法相比现有最先进方法平均提升最高达4.33%。此外,在上下文窗口扩展后,我们的方法在Hugging Face Open LLM基准上保持了模型性能,平均性能波动仅为-0.12至+0.22。
英文摘要:
Scaling the rotary position embedding (RoPE) has become a common method for extending the context window of RoPE-based large language models (LLMs). However, existing scaling methods often rely on empirical approaches and lack a profound understanding of the internal distribution within RoPE, resulting in suboptimal performance in extending the context window length. In this paper, we propose to optimize the context window extending task from the view of rotary angle distribution. Specifically, we first estimate the distribution of the rotary angles within the model and analyze the extent to which length extension perturbs this distribution. Then, we present a novel extension strategy that minimizes the disturbance between rotary angle distributions to maintain consistency with the pre-training phase, enhancing the model's capability to generalize to longer sequences. Experimental results compared to the strong baseline methods demonstrate that our approach reduces by up to 72% of the distributional disturbance when extending LLaMA2's context window to 8k, and reduces by up to 32% when extending to 16k. On the LongBench-E benchmark, our method achieves an average improvement of up to 4.33% over existing state-of-the-art methods. Furthermore, Our method maintains the model's performance on the Hugging Face Open LLM benchmark after context window extension, with only an average performance fluctuation ranging from -0.12 to +0.22.
CLEX: Continuous Length Extrapolation for Large Language Models
Sun Yat-sen University(中山大学);DAMO Academy, Alibaba Group(阿里巴巴集团达摩院);Hupan Lab(湖畔实验室);University of Glasgow(格拉斯哥大学);Mohamed bin Zayed University of Artificial Intelligence(穆罕默德·本·扎耶德人工智能大学)
LongRecipe: Recipe for Efficient Long Context Generalization in Large Language Models
National University of Singapore(新加坡国立大学);Nanjing University(南京大学);University of Toronto(多伦多大学);Mila, Québec AI Institute(魁北克人工智能研究所(Mila));Université de Montréal(蒙特利尔大学);Tencent Inc(腾讯公司);Baidu Inc(百度公司);Nanyang Technological University(南洋理工大学)
Scaling External Knowledge Input Beyond Context Windows of LLMs via Multi-Agent Collaboration
Dept. of Comp. Sci. & Tech., Institute for AI, Tsinghua University, Beijing, China(计算机科学与技术系,人工智能研究院,清华大学,北京,中国);Institute for AI Industry Research (AIR), Tsinghua University, Beijing, China(人工智能产业研究院(AIR),清华大学,北京,中国);Institute of Intelligent Computing, Alibaba Group(智能计算研究院,阿里巴巴集团)
Structured, flexible, and robust: benchmarking and improving large language models towards more human-like behavior in out-of-distribution reasoning tasks
Extending LLM Context via Associative Recurrent Memory
FusionBrain Lab(融合大脑实验室);MBZUAI(穆罕默德·本·扎耶德人工智能大学);Cognitive AI Systems Lab(认知人工智能系统实验室);RUDN(俄罗斯人民友谊大学);London Institute for Mathematical Sciences(伦敦数学科学研究所);MIRAI(未来人工智能研究机构);Lomonosov Moscow State University(莫斯科国立罗蒙诺索夫大学);Laboratory for Analysis and Controllable Text Generation Technologies RAS(俄罗斯科学院分析与可控文本生成技术实验室);School of Natural Sciences, Institute for Advanced Study, Princeton(普林斯顿高等研究院自然科学学院);Department of Brain Sciences, Weizmann Institute of Science(魏茨曼科学研究所脑科学系)
Gradual Forgetting: Logarithmic Compression for Extending Transformer Context Windows
Department of Computer Science, Indiana University Bloomington(计算机科学系,印第安纳大学布卢明顿分校);Department of Psychological and Brain Sciences, Indiana University Bloomington(心理学与脑科学系,印第安纳大学布卢明顿分校)