SemantiCache: Efficient KV Cache Compression via Semantic Chunking and Clustered Merging
Authors: Shunlong Wu, Hai Lin, Shaoshen Chen, Tingwei Lu, Yongqin Zeng, Shaoxiong Zhan, Hai-Tao Zheng, Hong-Gee Kim
Organizations: Shenzhen International Graduate School, Tsinghua University, Shenzhen, China · Peng Cheng Laboratory, Shenzhen, China · Seoul National University, South Korea
Existing KV cache compression methods generally operate on discrete tokens or non-semantic chunks. However, such approaches often lead to semantic fragmentation, where linguistically coherent units are disrupted, causing irreversible information loss and degradation in model performance. To address this, we introduce SemantiCache, a novel compression framework that preserves semantic integrity by aligning the compression process with the semantic hierarchical nature of language. Specifically, we first partition the cache into semantically coherent chunks by delimiters, which are natural semantic boundaries. Within each chunk, we introduce a computationally efficient Greedy Seed-Based Clustering (GSC) algorithm to group tokens into semantic clusters. These clusters are further merged into semantic cores, enhanced by a Proportional Attention mechanism that rebalances the reduced attention contributions of the merged tokens. Extensive experiments across diverse benchmarks and models demonstrate that SemantiCache accelerates the decoding stage of inference by up to 2.61 times and substantially reduces memory footprint, while maintaining performance comparable to the original model.
Figures & tables
Figure 1: An overview of SemantiCache.
Method
Model
Llama-3-8B
Mistral-7B
Full Model
34.88
42.01
20%
35%
50%
20%
35%
50%
StreamingLLM
27.88
28.21
29.16
28.27
30.14
31.26
H2O
28.73
30.45
30.88
35.35
37.69
37.95
SnapKV
27.22
30.27
30.35
36.34
38.22
38.86
Table 1: Average scores on LongBench for different compression methods, evaluated across various cache budgets and models.
Methods
L=8k
L=32k
L=8k
L=32k
Full Model
97.56
93.85
97.56
93.85
1024
4096
StreamingLLM
57.42
46.81
61.63
50.88
H2O
78.96
68.21
81.62
71.88
SnapKV
82.67
75.84
85.92
80.29
CaM
81.78
77.33
86.52
77.20
Table 2: Needle-in-a-Haystack results.
Method
TTFT (s)
TPOT (s)
Memory (GB)
Full Model
4.12
0.081
24.27
StreamingLLM
4.12
0.032
16.12
H2O
4.12
0.033
16.58
SnapKV
4.13
0.032
16.37
CaM
4.28
0.039
17.03
D2O
4.29
0.038
16.91
Table 3: Efficiency evaluation results on Llama-3-8B with a 32k context length.
Method Variant
Average Score
Ours (Semantic Chunking)
30.01
Fixed-size Chunking (64 tokens)
28.22
w/o Chunking (Global Clustering)
26.94
Table 4: Comparison of different chunking strategies.