KV: A Self-Refining KV Cache
Organizations: Karlsruhe Institute of Technology, Germany
Abstract
The memory footprint of the key-value (KV) cache constrains the practical use of long-context models, and it dominates cost when one prefilled context must later serve many different queries. In this reusable setting, query-agnostic compression trades cost against quality: lightweight estimators are cheap but less accurate, whereas full-context reconstruction scoring is more accurate yet reprocesses the entire prompt. We introduce KV, a query-agnostic KV-cache compression method based on selective reconstruction. KV first uses a lightweight proxy scorer to identify informative in-context tokens, then reprocesses only this subset to compute final eviction scores. On RULER, Needle-in-a-Haystack, and LongBench, KV's margin over baselines widens as the budget tightens: on RULER 16K at a 2% KV-cache budget it improves the average score over the next-best baseline by more than 40 percentage points, and on LongBench it attains the highest average across 2%-10% budgets at lower compression-stage runtime and peak memory than full-context reconstruction. Reusable KV-cache compression thus does not require reprocessing the full context. Our code is available at https://anonymous.4open.science/r/KVsquared-0B97.
Figures & tables
| Method | Single-doc QA | Multi-doc QA | Summ. | Few-shot / Cls. | Synth. Count | Code | Avg. | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| NrtvQA | Qasper | MFQA-en | Hotpot | 2Wiki | MuSiQ | GovRep | QMSum | MultiN | TREC | TrivQA | SAMSum | PCount | PR-en | LCC | RB-P | ||
| Llama-3.1-8B-Instruct | |||||||||||||||||
| Full | 30.21 | 45.53 | 55.01 | 56.01 | 46.65 | 31.28 | 35.13 | 25.28 | 27.25 | 73.00 | 91.64 | 43.80 | 8.91 | 99.50 | 63.38 | 56.64 | 49.33 |
| KV Size = 2% | |||||||||||||||||
| KeyDiff | 17.24 | 12.11 | 16.71 | 26.07 | 20.44 | 5.06 | 21.65 | 18.36 | 10.99 | 17.00 | 91.34 | 36.60 | 6.00 | 25.50 | 12.66 | 48.75 | 24.16 |
| KVzip | 12.54 | 11.10 | 18.98 | 24.80 | 21.78 | 8.69 | 11.39 | 17.40 | 7.36 | 5.00 | 87.47 | 32.31 | 2.50 | 4.00 | 18.20 | 51.75 | 20.95 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
KV-Cache Compression
Key-value cache compression reduces the memory and bandwidth needed to retain attention states during long-context inference.
See all 269 papers