D2O:面向大语言模型高效长上下文推理的动态判别式操作
D2O: Dynamic Discriminative Operations for Efficient Long-Context Inference of Large Language Models
AI总结:
D2O提出一种无需微调的KV缓存压缩方法,通过层级动态分配和令牌级补偿机制在节省内存、提升3倍以上推理吞吐的同时保持长文本生成质量。
摘要:
大语言模型(LLMs)中的生成式推理受到键值(KV)缓存不断增长的内存需求制约,尤其是在处理较长序列时。传统的KV缓存逐出策略根据注意力分数丢弃不太关键的KV对,但往往会降低生成质量,导致上下文丢失或幻觉等问题。在本文中,我们提出了动态判别式操作(D2O),这是一种KV缓存压缩方法,无需微调即可在两个层面上动态且有判别性地优化KV缓存大小,同时保留关键上下文。在层级层面,D2O利用浅层与深层之间注意力权重的不同密度,通过一种新颖的动态分配策略动态确定哪些层应避免过度逐出,以最小化信息损失。在令牌层面,D2O引入了一种补偿机制,该机制维持一个相似度阈值来重新判别当前被丢弃令牌的重要性,判断它们是否应被召回并与相似令牌合并。我们在多个基准测试和多种LLM架构上进行了实验。结果表明,D2O不仅实现了显著的内存节省,并将推理吞吐量提升了超过3倍,同时还保持了高质量的長文本生成。
英文摘要:
Generative inference in Large Language Models (LLMs) is impeded by the growing memory demands of Key-Value (KV) cache, especially for longer sequences. Traditional KV cache eviction strategies, which discard less critical KV pairs based on attention scores, often degrade generation quality, leading to issues such as context loss or hallucinations. In this work, we introduce Dynamic Discriminative Operations (D2O), a KV cache compression method that optimizes KV cache size dynamically and discriminatively at two levels without fine-tuning, while preserving essential context. At layer level, D2O leverages the varying densities of attention weights between shallow and deep layers to dynamically determine which layers should avoid excessive eviction via a novel dynamic allocation strategy to minimize information loss. At token level, D2O incorporates a compensation mechanism that maintains a similarity threshold to re-discriminate the importance of currently discarded tokens, determining whether they should be recalled and merged with similar tokens. We conduct experiments on various benchmarks and LLM architectures. Our results show that D2O not only achieves significant memory savings and enhances inference throughput by more than 3$\times$ but also maintains high-quality long-text generation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。