CacheRepair: Learning to Repair Cross-Chunk Context in RAG for KV Cache Fusion

Genglin Wang, Wangsong Yin, Yeerzhati Abudunuer, Haoxuan Xu, Guoliang Xing +1 more
9/28/2026
cs.LG
rag

No official code found. Best implementation: genglinWang/CacheRepair-code (3 stars, Python, Apache-2.0, last commit 2026-09-29).

Abstract

Multi-document retrieval-augmented generation (RAG) requires a language model to process multiple retrieved text chunks before answering a question. Precomputing each chunk's KV cache independently and concatenating the caches when the chunks are retrieved can accelerate this step.

Show full abstract

However, the assembled cache lacks cross-chunk attention information, reducing answer quality. Selective recomputation methods recover the missing cross-chunk context by rerunning the target LLM on selected tokens, incurring substantial online computation. We introduce CacheRepair, a lightweight network that learns the difference between independently computed KV caches and those produced by processing the chunks together. The network combines compressed KV features with token embeddings and uses attention that is bidirectional within each chunk and flows from earlier to later chunks. Each repair block receives the compressed cache features, and the predicted residual is added to every document token's cache. Each repair network is trained for a specific frozen target LLM on a generic retrieval corpus and reused across downstream datasets. Our analysis shows that repair reduces KV errors both near chunk boundaries and throughout chunk interiors. Evaluation across three target LLMs and four downstream datasets places CacheRepair on the measured answer-quality-latency Pareto frontier in eleven of twelve model-dataset combinations. Reported time to first token (TTFT) includes online cache transfer and repair. Across all twelve combinations, the largest repairers achieve 1.69-4.61$\times$ speedups in median TTFT over full prefill and improve mean F1 by 2.1-26.1 percentage points over direct cache reuse.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

CacheRepair: Learning to Repair Cross-Chunk Context in RAG for KV Cache Fusion

30PythonSep 28, 20262 months agoApache-2.0

Similar Papers

Cite this paper

@article{wang2026cacherepair,
  title  = {CacheRepair: Learning to Repair Cross-Chunk Context in RAG for KV Cache Fusion},
  author = {Genglin Wang and Wangsong Yin and Yeerzhati Abudunuer and Haoxuan Xu and Guoliang Xing and Zhenyu Yan},
  year   = {2026},
  eprint = {2609.35139},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2609.35139v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2609.35139.svg)](https://codeofpaper.com/paper/2609.35139)

Discussion