arXiv:2410.23079cs.CLcs.AI2024-10被引 10

通过蜂窝结构稀疏缓存,显著降低大模型推理内存占用

BUZZ: Beehive-structured Sparse KV Cache with Segmented Heavy Hitters for Efficient LLM Inference

  • 采用蜂窝状稀疏缓存+滑动窗口,动态分段历史令牌
  • 内存减少2.5倍,长文本摘要准确率超99%
  • 适合需要低内存高效率的实时大模型部署

大型语言模型在自然语言处理中至关重要,但推理速度与计算效率问题限制了实时应用。键值(KV)缓存机制虽能降低变换器模型的计算开销,却仍面临保持上下文理解的挑战。本文提出BUZZ,一种新型的KV缓存算法,利用结构化上下文信息,在减少缓存内存使用的同时提升推理速度。BUZZ采用蜂窝状稀疏缓存结构,结合滑动窗口捕获近期信息,并动态将历史令牌分块,优先保留局部重要令牌。我们在CNN/Daily Mail、XSUM、Wikitext和10-QA四个真实数据集上评估BUZZ。结果表明,BUZZ在大模型推理中将缓存内存减少2.5倍,同时保持长文本摘要超过99%的准确率;在多文档问答任务中,于相同内存限制下性能超越现有最优方法7.69%,而全缓存方法在此条件下已出现内存溢出。此外,BUZZ实现对数时间复杂度的显著推理加速。代码已公开于https://github.com/JunqiZhao888/buzz-llm。

原文摘要 · Abstract (English)

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.

大模型推理缓存优化稀疏存储

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。