KVCB: Key-Value cache merging towards consistent behavior for efficient inference of large language models

IF 3.5 2区 计算机科学 Q2 COMPUTER SCIENCE, ARTIFICIAL INTELLIGENCE
Zhaohong Jia, Jie Yu, Xiangqian Wang, Kun Jing, Chunchun Li
{"title":"KVCB: Key-Value cache merging towards consistent behavior for efficient inference of large language models","authors":"Zhaohong Jia,&nbsp;Jie Yu,&nbsp;Xiangqian Wang,&nbsp;Kun Jing,&nbsp;Chunchun Li","doi":"10.1007/s10489-026-07389-6","DOIUrl":null,"url":null,"abstract":"<div><p>Although key-value (KV) cache eliminates redundant computations in autoregressive generation of large language models (LLMs), its memory cost scales linearly with sequence length, rendering long-context deployment prohibitively expensive. Existing KV cache compression methods primarily prune or merge low-importance KV pairs with long-tail information, yet aggressive compression inevitably excises critical knowledge embedded in the long tail. This degrades generation fidelity and task generalizability. We observe that neighboring KV pairs frequently exhibit highly similar attention patterns during inference, suggesting inherent redundancy. Building upon this insight, we propose KV cache merging towards consistent behavior (KVCB), a novel KV cache compression method for efficient LLM inference. KVCB identifies neighboring KV pairs with consistent behavior through historical attention scores and merges them with weights derived from cumulative historical attention scores. When high-consistency pairs are scarce, KVCB falls back to importance-weighted merging based on temporal position and historical attention scores. To mitigate semantic drift from excessive compression, KVCB incorporates a periodic recovery mechanism that periodically flushes accumulated artifacts for sustained long-context stability. Extensive experiments with Llama-2-7B, Llama-2-7B-Chat, Llama-2-13B-Chat, and CodeLlama-7B on language modeling, long-document question answering, multiple-choice reasoning, and code generation—complemented by ablation studies across model architectures and scales—demonstrate that KVCB consistently matches or outperforms state-of-the-art eviction- and merging-based baselines under fixed memory budgets, effectively balancing compression efficiency with generative fidelity across diverse domains and context lengths.</p></div>","PeriodicalId":8041,"journal":{"name":"Applied Intelligence","volume":"56 15","pages":""},"PeriodicalIF":3.5000,"publicationDate":"2026-10-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Applied Intelligence","FirstCategoryId":"94","ListUrlMain":"https://link.springer.com/article/10.1007/s10489-026-07389-6","RegionNum":2,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q2","JCRName":"COMPUTER SCIENCE, ARTIFICIAL INTELLIGENCE","Score":null,"Total":0}
引用次数: 0

Abstract

Although key-value (KV) cache eliminates redundant computations in autoregressive generation of large language models (LLMs), its memory cost scales linearly with sequence length, rendering long-context deployment prohibitively expensive. Existing KV cache compression methods primarily prune or merge low-importance KV pairs with long-tail information, yet aggressive compression inevitably excises critical knowledge embedded in the long tail. This degrades generation fidelity and task generalizability. We observe that neighboring KV pairs frequently exhibit highly similar attention patterns during inference, suggesting inherent redundancy. Building upon this insight, we propose KV cache merging towards consistent behavior (KVCB), a novel KV cache compression method for efficient LLM inference. KVCB identifies neighboring KV pairs with consistent behavior through historical attention scores and merges them with weights derived from cumulative historical attention scores. When high-consistency pairs are scarce, KVCB falls back to importance-weighted merging based on temporal position and historical attention scores. To mitigate semantic drift from excessive compression, KVCB incorporates a periodic recovery mechanism that periodically flushes accumulated artifacts for sustained long-context stability. Extensive experiments with Llama-2-7B, Llama-2-7B-Chat, Llama-2-13B-Chat, and CodeLlama-7B on language modeling, long-document question answering, multiple-choice reasoning, and code generation—complemented by ablation studies across model architectures and scales—demonstrate that KVCB consistently matches or outperforms state-of-the-art eviction- and merging-based baselines under fixed memory budgets, effectively balancing compression efficiency with generative fidelity across diverse domains and context lengths.

KVCB:键值缓存合并到一致的行为,用于大型语言模型的有效推断
尽管键值(KV)缓存消除了大型语言模型(llm)自回归生成过程中的冗余计算,但其内存成本随着序列长度呈线性增长,使得长上下文部署的成本过高。现有的KV缓存压缩方法主要是将低重要性的KV对与长尾信息进行修剪或合并,而激进的压缩不可避免地会去除长尾中嵌入的关键知识。这降低了生成保真度和任务通用性。我们观察到相邻的KV对在推理过程中经常表现出高度相似的注意模式,表明固有冗余。基于这一见解,我们提出了面向一致行为的KV缓存合并(KVCB),这是一种用于高效LLM推理的新型KV缓存压缩方法。KVCB通过历史注意分数识别具有一致行为的相邻KV对,并将它们与由累积历史注意分数得出的权重合并。当高一致性对稀缺时,KVCB回归到基于时间位置和历史关注分数的重要性加权合并。为了减轻过度压缩造成的语义漂移,KVCB采用了一种周期性恢复机制,定期清除累积的工件,以保持长上下文的稳定性。Llama-2-7B、Llama-2-7B- chat、Llama-2-13B-Chat和CodeLlama-7B在语言建模、长文档问答、多项选择推理和代码生成方面的广泛实验(通过对模型架构和规模的烧烧研究进行补充)表明,在固定内存预算下,KVCB始终匹配或优于最先进的基于抽取和合并的基线。有效地平衡压缩效率和生成保真度跨不同的领域和上下文长度。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
Applied Intelligence
Applied Intelligence 工程技术-计算机:人工智能
CiteScore
6.60
自引率
20.80%
发文量
1361
审稿时长
5.9 months
期刊介绍: With a focus on research in artificial intelligence and neural networks, this journal addresses issues involving solutions of real-life manufacturing, defense, management, government and industrial problems which are too complex to be solved through conventional approaches and require the simulation of intelligent thought processes, heuristics, applications of knowledge, and distributed and parallel processing. The integration of these multiple approaches in solving complex problems is of particular importance. The journal presents new and original research and technological developments, addressing real and complex issues applicable to difficult problems. It provides a medium for exchanging scientific research and technological achievements accomplished by the international community.
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信
小红书