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, Jie Yu, Xiangqian Wang, Kun Jing, 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.
期刊介绍:
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.