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

RefreshKV:在长文本生成过程中更新小型 KV 缓存

RefreshKV: Updating Small KV Cache During Long-form Generation

New York University(纽约大学);Cornell University(康奈尔大学)

Fangyuan Xu, Tanya Goyal, Eunsol Choi

AI总结:

针对长文本生成中 KV 缓存压缩过早移除 token 导致性能下降的问题,提出 RefreshKV 方法,在生成时交替使用全上下文注意力与子集注意力以动态更新小型 KV 缓存,在实现与驱逐方法相当加速效果的同时提升性能,且持续预训练可进一步增益。

摘要:

给定长上下文输入的情况下生成长 token 序列,对大型语言模型(LLMs)而言是一种计算密集型的推理场景。一种显著的推理加速方法是构建更小的键值(KV)缓存,从而减轻 LLMs 对长 token 序列计算注意力的负担。虽然此类方法在生成短序列时效果良好,但在长文本生成中其性能会迅速下降。大多数 KV 压缩只发生一次,过早地移除了在后续生成中可能有用的 token。我们提出了一种新的推理方法 RefreshKV,在生成过程中灵活地在全上下文注意力与对输入 token 子集的注意力之间交替。在每次全注意力步骤之后,我们根据对整个输入的注意力模式来更新小型 KV 缓存。将我们的方法应用于现成的 LLMs,实现了与基于驱逐的方法相当的加速效果,同时改善了各种长文本生成任务的性能。最后,我们展示了使用我们的推理设置进行持续预训练能带来进一步的性能提升。

英文摘要:

Generating long sequences of tokens given a long-context input is a very compute-intensive inference scenario for large language models (LLMs). One prominent inference speed-up approach is to construct a smaller key-value (KV) cache, relieving LLMs from computing attention over a long sequence of tokens. While such methods work well to generate short sequences, their performance degrades rapidly for long-form generation. Most KV compression happens once, prematurely removing tokens that can be useful later in the generation. We propose a new inference method, RefreshKV, that flexibly alternates between full context attention and attention over a subset of input tokens during generation. After each full attention step, we update the smaller KV cache based on the attention pattern over the entire input. Applying our method to off-the-shelf LLMs achieves comparable speedup to eviction-based methods while improving performance for various long-form generation tasks. Lastly, we show that continued pretraining with our inference setting brings further gains in performance.

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

↑