BUZZ:面向高效大语言模型推理的带分段高频项的蜂巢结构稀疏KV缓存
BUZZ: Beehive-structured Sparse KV Cache with Segmented Heavy Hitters for Efficient LLM Inference
AI总结:
针对大语言模型推理效率与内存瓶颈问题,提出蜂巢结构稀疏KV缓存算法BUZZ,通过滑动窗口与动态分块优先保留重要令牌,在降低内存占用的同时提升推理速度与任务性能。
摘要:
大语言模型(LLM)是自然语言处理领域的核心工具,但其推理速度与计算效率往往存在瓶颈,限制了实时部署。键值(KV)缓存机制可降低Transformer模型的计算开销,但在维持上下文理解能力方面仍存在挑战。本文提出一种新型KV缓存算法BUZZ,它利用结构化上下文信息,在提升推理速度的同时最小化缓存内存占用。BUZZ采用蜂巢结构的稀疏缓存,结合滑动窗口捕获近期信息,并将历史令牌动态分块,以优先保留局部邻域内的重要令牌。我们在四个真实数据集上评估BUZZ:CNN/Daily Mail、XSUM、Wikitext和10-QA。结果表明:(1)在长文本摘要任务中,BUZZ将LLM推理的缓存内存占用降低2.5倍,同时保持99%以上的准确率;(2)在相同内存限制下,BUZZ在多文档问答任务上的表现超越当前最优水平7.69%,而全缓存方法在此限制下会出现内存不足问题。此外,BUZZ以log n的时间复杂度实现了显著的推理加速。代码可在https://github.com/JunqiZhao888/buzz-llm获取。
英文摘要:
Large language models (LLMs) are essential in natural language processing but often struggle with inference speed and computational efficiency, limiting real-time deployment. The key-value (KV) cache mechanism reduces computational overhead in transformer models, but challenges in maintaining contextual understanding remain. In this paper, we propose BUZZ, a novel KV caching algorithm that leverages structured contextual information to minimize cache memory usage while enhancing inference speed. BUZZ employs a beehive-structured sparse cache, incorporating a sliding window to capture recent information and dynamically segmenting historical tokens into chunks to prioritize important tokens in local neighborhoods. We evaluate BUZZ on four real-world datasets: CNN/Daily Mail, XSUM, Wikitext, and 10-QA. Our results demonstrate that BUZZ (1) reduces cache memory usage by $\textbf{2.5}\times$ in LLM inference while maintaining over 99% accuracy in long-text summarization, and (2) surpasses state-of-the-art performance in multi-document question answering by $\textbf{7.69%}$ under the same memory limit, where full cache methods encounter out-of-memory issues. Additionally, BUZZ achieves significant inference speedup with a $\log{n}$ time complexity. The code is available at https://github.com/JunqiZhao888/buzz-llm.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。