← Latest papers
🤖 AI

SelKV: Selective KV Cache Merging with Per-Token Merge-or-Drop and Attention Compensation

SelKV is a training-free framework that compresses KV caches by selectively merging or dropping tokens based on value-vector similarity and compensating for attention imbalances via logit bias, achieving near-lossless generation quality and significant speedups while retaining only 25% of the original cache.

Original authors: Soumia Bouyahiaoui, Manel Kara laouar, Aicha Boutorh, Mohamed Hadj Ameur

Published 2026-07-21
📖 3 min read☕ Coffee break read

Original authors: Soumia Bouyahiaoui, Manel Kara laouar, Aicha Boutorh, Mohamed Hadj Ameur

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to remember a massive, 100,000-page story while writing a new chapter. Every time you think of a plot point, you have to flip back through your entire notebook to find the right details. The more pages you write, the heavier your notebook gets, until your arms are too tired to hold it. This is exactly what happens inside the "brain" of a Large Language Model (LLM) when it tries to process long texts. These models are incredibly smart, but they have a memory problem: as they read, they store a "Key-Value cache"—a digital filing system of everything they've seen so far—to help them understand what comes next. The longer the text, the bigger this filing cabinet becomes, eventually filling up all the computer's memory and slowing everything to a crawl.

To fix this, scientists have tried two main tricks. The first is "eviction," which is like throwing away old pages you think aren't important. The second is "merging," which is like gluing similar pages together to save space. But both methods have a flaw. Throwing pages away can lose crucial clues, and gluing pages together often creates a "blurry" version where the model forgets how much attention to pay to the glued group. It's like if you glued ten photos of a cat together; the model might still only give that single glued blob the same amount of attention it would have given to one photo, even though it now represents ten. This causes the model to get confused and make mistakes.

Enter SelKV, a new, clever method that acts like a smart librarian for these digital filing cabinets. Instead of blindly gluing pages together or tossing them in the trash, SelKV uses a "soft cosine gate"—think of it as a bouncer at a club who checks how much two pages look alike before deciding what to do. If two pages are very similar, they get glued together tightly. If they are totally different, the bouncer sends one away to keep the memory clean. But the real magic is the "attention compensation." Since gluing pages together usually makes the model ignore them, SelKV adds a little "volume boost" to the glued pages, ensuring the model pays the right amount of attention to them.

The researchers tested this system on three different AI models using 16 different tasks, from answering questions about multiple documents to writing code. They found that by keeping only 25% of the original memory space, SelKV performed almost as well as having the full memory, and in some tricky multi-document quizzes, it actually did better than the full version. It seems that by being selective, the AI actually focused on the most important parts of the story. Furthermore, when the text got huge (100,000 tokens), this method made the AI decode text 3.3 times faster. The paper suggests that this approach is especially good for modern AI models that use a specific type of attention (called GQA), offering a way to keep these powerful brains running fast without losing their memory.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →