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

NACL:一个面向推理时大语言模型的通用且高效的KV缓存淘汰框架

NACL: A General and Effective KV Cache Eviction Framework for LLMs at Inference Time

Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所);Baidu Inc.(百度公司);School of Cyber Security, University of Chinese Academy of Sciences(中国科学院大学网络空间安全学院)

Yilong Chen, Guoxia Wang, Junyuan Shang, Shiyao Cui, Zhenyu Zhang, Tingwen Liu, Shuohuan Wang, Yu Sun, Dianhai Yu, Hua Wu

AI总结:

本文提出NACL框架,通过结合代理token精确注意力统计与随机淘汰策略,在编码阶段高效淘汰KV缓存,在减少最多50%缓存的同时显著提升长短文本任务性能。

摘要:

大语言模型(LLMs)已经引发了人工智能应用的创新浪潮,开启了具备扩展上下文窗口的令人兴奋的新时代。然而,托管这些模型的成本高得令人望而却步,主要原因是涉及长上下文建模的KV缓存会消耗大量内存。尽管已有若干工作提出从KV缓存中淘汰不必要的token,但其中大多数依赖累积注意力分数的有偏局部统计量,并在不充分的长文本评估中使用困惑度等缺乏说服力的指标来报告性能。在本文中,我们提出NACL,一个用于长上下文KV缓存淘汰的通用框架,它在编码阶段通过一次操作即可实现更优且更高效的淘汰。由于NACL的高效性,我们将PROXY TOKENS EVICTION中更精确的注意力分数统计与RANDOM EVICTION的多样化随机淘汰策略相结合,旨在缓解注意力偏差问题,并增强在长上下文建模任务中保留关键token的鲁棒性。值得注意的是,我们的方法在短文本和长文本任务上的性能分别显著提升了80%和76%,在减少KV缓存最多50%的情况下保持了超过95%的性能。代码可在https://github.com/PaddlePaddle/Research/tree/master/NLP/ACL2024-NACL获取。

英文摘要:

Large Language Models (LLMs) have ignited an innovative surge of AI applications, marking a new era of exciting possibilities equipped with extended context windows. However, hosting these models is cost-prohibitive mainly due to the extensive memory consumption of KV Cache involving long-context modeling. Despite several works proposing to evict unnecessary tokens from the KV Cache, most of them rely on the biased local statistics of accumulated attention scores and report performance using unconvincing metric like perplexity on inadequate short-text evaluation. In this paper, we propose NACL, a general framework for long-context KV cache eviction that achieves more optimal and efficient eviction in a single operation during the encoding phase. Due to NACL's efficiency, we combine more accurate attention score statistics in PROXY TOKENS EVICTION with the diversified random eviction strategy of RANDOM EVICTION, aiming to alleviate the issue of attention bias and enhance the robustness in maintaining pivotal tokens for long-context modeling tasks. Notably, our method significantly improves the performance on short- and long-text tasks by 80% and 76% respectively, reducing KV Cache by up to 50% with over 95% performance maintenance. The code is available at https://github.com/PaddlePaddle/Research/tree/master/NLP/ACL2024-NACL.

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

↑