[论文解读] Giraffe: Adventures in Expanding Context Lengths in LLMs
该论文提出Giraffe,一种基于LLaMA和LLaMA2微调的130亿参数大语言模型家族,通过旋转位置嵌入的线性插值将上下文长度扩展至32k token。关键发现是线性缩放优于其他方法,且在推理时进一步增加缩放因子可获得额外收益;然而,自定义评估任务揭示,尽管困惑度合理,但在超过24k token后性能显著下降。
Modern large language models (LLMs) that rely on attention mechanisms are typically trained with fixed context lengths which enforce upper limits on the length of input sequences that they can handle at evaluation time. To use these models on sequences longer than the train-time context length, one might employ techniques from the growing family of context length extrapolation methods -- most of which focus on modifying the system of positional encodings used in the attention mechanism to indicate where tokens or activations are located in the input sequence. We conduct a wide survey of existing methods of context length extrapolation on a base LLaMA or LLaMA 2 model, and introduce some of our own design as well -- in particular, a new truncation strategy for modifying the basis for the position encoding. We test these methods using three new evaluation tasks (FreeFormQA, AlteredNumericQA, and LongChat-Lines) as well as perplexity, which we find to be less fine-grained as a measure of long context performance of LLMs. We release the three tasks publicly as datasets on HuggingFace. We discover that linear scaling is the best method for extending context length, and show that further gains can be achieved by using longer scales at evaluation time. We also discover promising extrapolation capabilities in the truncated basis. To support further research in this area, we release three new 13B parameter long-context models which we call Giraffe: 4k and 16k context models trained from base LLaMA-13B, and a 32k context model trained from base LLaMA2-13B. We also release the code to replicate our results.
研究动机与目标
- 评估并比较在固定长度序列上训练的大语言模型的零样本上下文长度外推方法。
- 开发并测试新型位置编码策略(包括截断基底),以扩展模型原始训练长度之外的上下文。
- 引入并发布三个新的长上下文大语言模型(Giraffe-4k、16k、32k),基于基础LLaMA和LLaMA2模型进行微调。
- 创建并发布三个新的基准数据集(LongChat-Lines、FreeFormQA、AlteredNumericQA),以实现对长上下文性能的细粒度评估。
- 证明仅靠困惑度不足以评估长上下文能力,任务特定基准揭示了困惑度未捕捉到的关键性能下降。
提出的方法
- 使用不同缩放因子的旋转位置嵌入(RoPE)线性插值对基础LLaMA和LLaMA2模型进行微调。
- 提出一种新的位置编码截断基底,以改善超出原始上下文长度的外推性能。
- 使用三个新公开数据集评估方法:LongChat-Lines(键值检索)、FreeFormQA、AlteredNumericQA(长文档上的问答)。
- 采用指令微调(IFT)并使用固定提示结构,以确保在不同上下文长度下的一致性评估。
- 使用文档语料库上的困惑度作为基线指标,但强调其在捕捉长上下文推理准确性方面的局限性。
- 在HuggingFace上发布了三个13B参数模型(4k、16k、32k上下文长度)的代码和权重。
实验结果
研究问题
- RQ1与正弦、可学习或缩放RoPE等其他方法相比,旋转位置嵌入的线性插值是否能为长上下文大语言模型提供最佳的零样本外推性能?
- RQ2在长上下文序列中,问题和答案的位置如何影响不同上下文长度下的模型性能?
- RQ3位置编码的截断基底能否实现真正的外推能力,其表现与线性缩放相比如何?
- RQ4困惑度在多大程度上与实际的长上下文推理准确性相关?自定义基准是否揭示了困惑度未捕捉到的性能下降?
- RQ5在推理时将缩放因子提高到微调阶段的缩放因子以上,是否能提升性能?这种提升是否存在上限?
主要发现
- 在所有评估任务中,旋转位置嵌入的线性插值始终优于其他方法,包括可学习和正弦位置编码。
- 在FreeFormQA和AlteredNumericQA上,即使困惑度保持稳定,超过24k上下文长度后性能仍出现下降,表明连贯性与推理准确性之间存在脱节。
- 在较长长度下,将问题置于上下文末尾可提高FreeFormQA和AlteredNumericQA的准确率,表明注意力机制可能更偏好长序列中的近期标记。
- 位置编码的截断基底展现出有希望的外推能力,尽管尚未超越线性缩放,但仍值得进一步研究。
- 在推理时将缩放因子提高到微调阶段的缩放因子以上,可将性能提升至2倍,但超过该点后收益趋于平缓,表明该方法存在实际上限。
- 困惑度被发现是衡量长上下文性能的粗略指标,因为模型可能生成高困惑度但连贯的输出,却在推理任务中失败。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。