Skip to main content
QUICK REVIEW

[论文解读] Extending Context Window of Large Language Models via Positional Interpolation

Shouyuan Chen, S.H. Wong|arXiv (Cornell University)|Jun 27, 2023
Topic ModelingComputer Science被引用 44
一句话总结

论文提出 Position Interpolation (PI),在最少微调的条件下,将 RoPE 基于的 LLM 的上下文窗口扩展到 32768 tokens,并在原任务上保持性能,同时实现跨多个 LLaMA 模型规模的强长上下文建模。

ABSTRACT

We present Position Interpolation (PI) that extends the context window sizes of RoPE-based pretrained LLMs such as LLaMA models to up to 32768 with minimal fine-tuning (within 1000 steps), while demonstrating strong empirical results on various tasks that require long context, including passkey retrieval, language modeling, and long document summarization from LLaMA 7B to 65B. Meanwhile, the extended model by Position Interpolation preserve quality relatively well on tasks within its original context window. To achieve this goal, Position Interpolation linearly down-scales the input position indices to match the original context window size, rather than extrapolating beyond the trained context length which may lead to catastrophically high attention scores that completely ruin the self-attention mechanism. Our theoretical study shows that the upper bound of interpolation is at least $\sim 600 imes$ smaller than that of extrapolation, further demonstrating its stability. Models extended via Position Interpolation retain its original architecture and can reuse most pre-existing optimization and infrastructure.

研究动机与目标

  • 扩展 RoPE 基于的 LLM(如 LLaMA)的有效上下文窗口,超越训练长度。
  • 证明插值位置索引而非外推能够带来稳定的注意力和更易适应。
  • 在长上下文语言建模、类检索任务和长文档摘要方面展示经验收益。
  • 评估扩展后在原始上下文窗口(2048)内的性能影响。

提出的方法

  • 使用 Position Interpolation 将输入位置索引下标缩放,使最大位置与预训练窗口匹配。
Figure 1: An illustration of our Position Interpolation method. Consider a Llama model pre-trained with a 2048 context window length. Upper left illustrates the normal usage of an LLM model: input position indices (blue dots) are within the pre-trained range. Upper right illustrates length extrapola
Figure 1: An illustration of our Position Interpolation method. Consider a Llama model pre-trained with a 2048 context window length. Upper left illustrates the normal usage of an LLM model: input position indices (blue dots) are within the pre-trained range. Upper right illustrates length extrapola

实验结果

研究问题

  • RQ1Position Interpolation 能否在不进行结构性改动的情况下,将 RoPE 基于的 LLM 的上下文窗口扩展到如 32768 tokens 这样的大小?
  • RQ2插值定位是否比直接外推为注意力分数提供更稳定、可扩展的扩展?
  • RQ3在 LLaMA 7B–65B 上,PI 对困惑度、passkey 检索和长文档摘要的经验影响是什么?
  • RQ4PI 如何影响在原始 2048-token 窗口内的任务性能?
  • RQ5RoPE 注意力的插值与外推在理论边界上的差异是什么?

主要发现

  • PI 可以在 LLaMA 7B–65B 的范围内以最少的微调(约 1000 步)将上下文窗口扩展至 32768。
  • 插值后的注意力分数更稳定,在 LLaMA 7B 设置中,插值界约比外推小约 600×。
  • 在 PG19 和 proof-pile 数据集上,使用 PI 扩展的模型在更长的上下文窗口下困惑度有所改善,而直接微调在更长上下文时表现下降。
  • PI 扩展的模型保持原始上下文性能,在 2048 tokens 的一些基准测试中仅有轻微下降。
  • 在约 200 步后,Passkey 检索实验表明 PI 已在 7B 与 33B 模型上达到扩展后的上下文作为有效上下文窗口。
  • 对于长文档摘要(GovReport),PI 支持的 16K 上下文获得与基线相比有竞争力的 ROUGE 分数。
Figure 2: Extrapolation versus interpolation. Left: a fitted attention score function (in red) in the form of Eqn. 3 with $d=d_{\mathrm{model}}/n_{\mathrm{head}}=4096/32=128$ (setting of LLaMA 7B). Dots are random input points to be fitted and red curve is the fitted score function via least square,
Figure 2: Extrapolation versus interpolation. Left: a fitted attention score function (in red) in the form of Eqn. 3 with $d=d_{\mathrm{model}}/n_{\mathrm{head}}=4096/32=128$ (setting of LLaMA 7B). Dots are random input points to be fitted and red curve is the fitted score function via least square,

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。