arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2410.12876cs.CLcs.LG
收藏

通过注意力门实现大语言模型的上下文KV缓存淘汰

In-context KV-Cache Eviction for LLMs via Attention-Gate

Shanghai Jiao Tong University(上海交通大学);Huawei(华为);University of California, San Diego(加利福尼亚大学圣迭戈分校)

Zihao Zeng, Bokai Lin, Tianqi Hou, Hao Zhang, Zhijie Deng

AI总结:

针对KV缓存成为大语言模型推理瓶颈的问题,本文提出通过注入轻量级注意力门模块实现动态KV缓存淘汰策略,可有效淘汰冗余token,在多场景下既提升推理效率又增强模型性能。

摘要:

KV缓存技术已成为大语言模型(LLMs)推理的标准方法,但该技术常被诟病为LLM推理系统的瓶颈。本文通过向模型中注入一个名为注意力门(Attention-Gate)的轻量级模块,提出了一种新颖的动态KV缓存淘汰策略。该模块以全局上下文为输入,为每个token生成淘汰标志。模型中的自注意力模块根据这些标志进行处理,仅缓存KV状态的子集用于下一个token的预测。注意力门可为不同的头和层生成各种标志,并可通过持续预训练或监督微调在预训练LLM基础上轻松调整。注意力门引入的计算和内存开销极小。我们在多个场景下对所提方法进行了实证评估,结果表明有效淘汰冗余token不仅能提高效率,还能提升性能。

英文摘要:

The KV-Cache technique has become the standard for the inference of large language models (LLMs). Yet, it is widely criticized that KV-Cache can become a bottleneck of the LLM inference system. This paper enables a novel dynamic KV-Cache eviction policy by injecting a lightweight module called Attention-Gate to the model. It accepts the global context as input and yields eviction flags for each token. The self-attention modules in the model proceed according to the flags and cache only a subset of the KV states for next token prediction. The Attention-Gates can yield various flags for different heads and layers and be easily tuned on top of a pre-trained LLM via continual pre-training or supervised fine-tuning. The computational and memory overhead introduced by Attention-Gates can be minimal. We empirically evaluate the proposed approach across multiple scenarios, showing that effective eviction of redundant tokens can not only improve efficiency but also enhance performance.

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

↑