← Latest papers
🤖 machine learning

CompilerKV: Risk-Adaptive KV Compression via Offline Experience Compilation

CompilerKV introduces an offline-compiled KV retention policy that leverages cross-prompt regularity to replace noisy online estimation with efficient O(1)O(1) lookups, achieving state-of-the-art performance and superior scalability under extreme memory constraints compared to existing prefill-only compression methods.

Original authors: Ning Yang, Chengzhi Wang, Yibo Liu, Baoliang Tian, Haijun Zhang

Published 2026-05-21
📖 4 min read☕ Coffee break read

Original authors: Ning Yang, Chengzhi Wang, Yibo Liu, Baoliang Tian, Haijun Zhang

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 very long story so you can answer questions about it later. Your brain (the AI model) has a limited amount of "mental scratchpad" space (called the KV Cache) to hold the most important parts of that story while it talks.

If the story is short, you can remember everything. But if the story is 100,000 words long, your scratchpad overflows. You have to throw some parts away to make room. The problem is: once you throw something away, you can never get it back. If you accidentally toss out the part where the villain reveals their secret plan, your whole story falls apart.

The Old Way: Guessing in the Moment

Previous methods tried to decide what to keep by looking at the story right now, in real-time. They would say, "This word has a high attention score, so it must be important!" or "This sentence seems complex, keep it!"

The authors of this paper argue this is like trying to judge a whole movie by watching a single, noisy frame. Because the story is so long and the data is messy, looking at just one prompt (one story) leads to bad guesses. You might keep a flashy but useless word and throw away a quiet but crucial clue.

The New Way: COMPILERKV (The "Pre-Game Strategy")

The authors introduce COMPILERKV. Instead of guessing on the fly, they "compile" a strategy beforehand, like a coach studying game film before the big match.

Here is how it works, broken down into three simple steps:

1. The "Noise Filter" (Stabilized Utility)

Imagine you are listening to a crowded room. Some people are shouting (transient spikes), and some microphones are just louder than others (scale bias).

  • The Fix: COMPILERKV doesn't just listen to who is shouting the loudest. It smooths out the noise and normalizes the volume. It asks, "Is this person actually saying something important, or are they just loud?" This prevents the AI from being tricked by temporary noise.

2. The "Specialist Map" (Head Heterogeneity Table)

Inside the AI, there are many different "brain cells" (called attention heads). Some are experts at finding facts (like a librarian), while others are just chattering noise.

  • The Fix: The authors studied thousands of stories offline and realized: Certain brain cells are always reliable, and others are always noisy. They created a permanent "Map of Specialists."
  • The Analogy: Instead of asking the whole team for an opinion, the system knows: "If the 'Librarian' cell says a word is important, we keep it, even if the 'Chatterbox' cells say it's junk." This gives the reliable experts a "veto power" to save crucial information.

3. The "Risk Meter" (Risk-Adaptive Threshold)

Not all stories are the same. Some are simple (a recipe); others are complex and confusing (a mystery novel).

  • The Fix: The system checks how "risky" the current story is.
    • Low Risk (Simple story): "We can be aggressive. Throw away 90% of the text; we'll be fine."
    • High Risk (Confusing story): "This is dangerous! Be conservative. Keep 95% of the text just in case."
  • The Analogy: It's like packing for a trip. If you know the weather is perfect, you pack light. If there's a storm warning, you pack extra gear. COMPILERKV automatically adjusts how much it keeps based on how "stormy" the current prompt is.

Why This is a Big Deal

The paper claims that by doing this "pre-game study" (offline compilation) rather than "guessing in the moment" (online heuristics), they get much better results:

  • It's Portable: The "Map of Specialists" they created works across different AI models. It's like a universal rulebook that applies to different types of brains.
  • It Saves Memory: They can keep the AI running on a tiny memory budget (only 1.5% of the original text) while still answering questions correctly.
  • It Handles the Long Stuff: When tested on massive contexts (up to 128,000 words), COMPILERKV stayed strong while other methods collapsed. For example, in a "Needle in a Haystack" test (finding one specific fact in a huge text), COMPILERKV found the needle 89% of the time, while the next best method only found it 42% of the time.

The Bottom Line

COMPILERKV stops trying to make perfect decisions in a split second. Instead, it uses a pre-calculated, risk-aware strategy to decide what to keep. It's the difference between a gambler making a wild bet and a chess grandmaster who has already calculated the best moves based on years of experience. The result is an AI that can remember huge amounts of text without running out of memory or forgetting the important parts.

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 →