A research paper introduces Latent Compaction, a method for shrinking a language model’s key-value cache for a specific document. The goal is to reduce memory use and attention costs for long contexts while retaining the ability to answer previously unseen questions about the document.
The method first builds a compact cache using reconstruction importance, teacher attention, and diversity among key representations. In an initial training stage, it matches attention outputs and normalization values from the full cache while keeping selected entries fixed. It then jointly optimizes the entire cache through end-to-end distillation. Model weights remain frozen. Training uses generic prompts about the document, not the downstream questions or answers.
On RULER, LongBench, and Phonebook Lookup, the paper reports that the method outperformed compression baselines matched for cache budget. One RULER result: at 32-fold compression, Latent Compaction reached 96.7% accuracy, compared with 40.0% for KVZip+. The authors also report transfer across model sizes and families, with retrieval gains on Qwen3 and MiniCPM5.
The results suggest that a cache can be optimized during test-time training to preserve retrieval performance under aggressive compression. The paper provides further details on the method and experiments, and the code is available. Source: arXiv