CompressKV: Semantic Retrieval Heads Know What Tokens are Not Important Before Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Lin, Xiaolin, Wang, Jingcun, Kondrateva, Olga, Shi, Yiyu, Li, Bing, Zhang, Grace Li
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866918113668235264
author Lin, Xiaolin
Wang, Jingcun
Kondrateva, Olga
Shi, Yiyu
Li, Bing
Zhang, Grace Li
author_facet Lin, Xiaolin
Wang, Jingcun
Kondrateva, Olga
Shi, Yiyu
Li, Bing
Zhang, Grace Li
contents Recent advances in large language models (LLMs) have significantly boosted long-context processing. However, the increasing key-value (KV) cache size poses critical challenges to memory and execution efficiency. Most KV cache compression methods rely on heuristic token eviction using all attention heads in Grouped Query Attention (GQA)-based LLMs. This method ignores the different functionalities of attention heads, leading to the eviction of critical tokens and thus degrades the performance of LLMs. To address the issue above, instead of using all the attention heads in GQA-based LLMs to determine important tokens as in the previous work, we first identify the attention heads in each layer that are not only capable of retrieving the initial and final tokens of a prompt, but also capable of retrieving important tokens within the text and attending to their surrounding semantic context. Afterwards, we exploit such heads to determine the important tokens and retain their corresponding KV cache pairs. Furthermore, we analyze the cache eviction error of each layer individually and introduce a layer-adaptive KV cache allocation strategy. Experimental results demonstrate the proposed CompressKV consistently outperforms state-of-the-art approaches under various memory budgets on LongBench and Needle-in-a-Haystack benchmarks. Our code is publicly available at: https://github.com/TUDa-HWAI/CompressKV.git.
format Preprint
id arxiv_https___arxiv_org_abs_2508_02401
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle CompressKV: Semantic Retrieval Heads Know What Tokens are Not Important Before Generation
Lin, Xiaolin
Wang, Jingcun
Kondrateva, Olga
Shi, Yiyu
Li, Bing
Zhang, Grace Li
Computation and Language
Artificial Intelligence
Recent advances in large language models (LLMs) have significantly boosted long-context processing. However, the increasing key-value (KV) cache size poses critical challenges to memory and execution efficiency. Most KV cache compression methods rely on heuristic token eviction using all attention heads in Grouped Query Attention (GQA)-based LLMs. This method ignores the different functionalities of attention heads, leading to the eviction of critical tokens and thus degrades the performance of LLMs. To address the issue above, instead of using all the attention heads in GQA-based LLMs to determine important tokens as in the previous work, we first identify the attention heads in each layer that are not only capable of retrieving the initial and final tokens of a prompt, but also capable of retrieving important tokens within the text and attending to their surrounding semantic context. Afterwards, we exploit such heads to determine the important tokens and retain their corresponding KV cache pairs. Furthermore, we analyze the cache eviction error of each layer individually and introduce a layer-adaptive KV cache allocation strategy. Experimental results demonstrate the proposed CompressKV consistently outperforms state-of-the-art approaches under various memory budgets on LongBench and Needle-in-a-Haystack benchmarks. Our code is publicly available at: https://github.com/TUDa-HWAI/CompressKV.git.
title CompressKV: Semantic Retrieval Heads Know What Tokens are Not Important Before Generation
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2508.02401