atlas

Research map / Large language models / Reasoning and chain of thought

SnapKV: LLM Knows What You are Looking for Before Generation

NeurIPS 2024 · Large language models › Reasoning and chain of thought · approach: KV cache compression · 51 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes SnapKV, a fine-tuning-free method that compresses prompt KV caches per attention head by voting with an observation window at the end of the prompt, with pooling for clustering, yielding faster decoding and lower memory on long contexts.

Problem

KV cache growth with long prompts makes LLM decoding slow and memory-hungry; prior KV eviction methods mainly compress generated tokens and neglect prompt KV compression.

Approach

Attention patterns over prompt tokens identified by the last window of the prompt (observation window) remain consistent during generation, so per-head top-k voting on that window selects prefix KVs to keep, pooled for clustering, with the observation window KVs appended, yielding a fixed-size prompt cache with no fine-tuning.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Compress Mistral prompt KV cache to 1024 tokensMistral-7B-Instruct-v0.2 · LongBenchscore: 25.54 vs 26.82 on NarrativeQA; 40.94 vs 42.77 on HotpotQA; 86.48 vs 86.23 on TriviaQAMixed
Compress Mistral prompt KV cache to 4096 tokensMistral-7B-Instruct-v0.2 · LongBench Qasperscore: 33.06 -> 33.36Helped
Use SnapKV instead of H2O at 4096-token cache capacityMistral-7B-Instruct-v0.2 · LongBench NarrativeQAscore: 22.61 -> 25.54Helped
Apply SnapKV with a 4096-token KV cacheCommand-R · Needle-in-a-Haystackscore: 9.866 -> 9.819 (-0.5%)No clear effect
Apply SnapKVCommand-R · RAG CitationF1 score: -1.2%Hurt
Apply SnapKVCommand-R · RAG End-to-endF1 score: -2.1%Hurt
Apply SnapKV to generation with 200 sampled documentsCommand-R · RAG generation, average over ground-truth positionsaccuracy: +5.4%Helped
Apply SnapKV to generation with 30 sampled documentsCommand-R · RAG generation, average over ground-truth positionsaccuracy: -1.7%Hurt
Compress prompt KV cacheLWM-Text-Chat-1M · 16k input, batch size 2decoding speed: approximately a 3.6x speedupHelped
Compress prompt KV cacheLWM-Text-Chat-1M · batch size 2maximum input length: approximately 8.2x improvementHelped
Combine SnapKV with Medusa parallel decodingMistral-7B-Instruct-v0.2 · QASPER, 10k sequence lengthgeneration speed: 1.3x speedupHelped
Add pooling-based clustering to selected attention positions (ablation)SnapKV on Mistral-7B-Instruct-v0.2 · LongEval-Linesretrieval accuracyHelped

Surprising findings

Limitations

Experimental setup

Datasets: UltraChat LongBench LongEval-Lines Needle-in-a-Haystack QMSum OpenReview SPACE BioASQ HotpotQA QASPER

Benchmarks: LongBench Needle-in-a-Haystack LongEval-Lines NarrativeQA BioASQ HotpotQA QASPER

Metrics: task score (LongBench) retrieval accuracy decoding latency (ms/token) memory footprint F1 score hit rate

Baselines: H2O All KV (full cache) StreamingLLM FastGen ScissorHands

Builds on: H2O StreamingLLM Medusa

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy