RAG wastes tokens. We propose Knowledge Packs: pre-computed KV caches that deliver the same knowledge at zero token cost. For causal transformers, the KV cache from a forward pass on text F is identical to what a joint pass on F+q would produce - this follows directly from the causal mask. The equivalence is exact but fragile: wrong chat template formatting causes 6-7pp degradation, which we believe explains prior claims of KV outperforming RAG. With correct formatting: zero divergences across 700 questions on Qwen3-8B and Llama-3.1-8B, up to 95% token savings. The KV interface also enables behavioral steering that RAG cannot do. Because RoPE rotates keys but leaves values untouched, contrastive deltas on cached values can nudge model behavior while key arithmetic destroys coherence. The effect sits in mid-layer values (33-66%), independent directions are nearly orthogonal (cos~0) and compose, and both channels - knowledge and steering - run simultaneously at alpha<=0.7 without interference. No training, no weight modification.
Figures & tables
Model
Method
Overall
Bridge
Comp.
Tok.
Diverg.
Qwen3-8B ( N=500 )
Baseline
28.4%
17.1%
62.4%
0
—
RAG (BGE top-2)
65.2%
60.5%
79.2%
284
—
KV-chat
65.2%
60.5%
79.2%
0
0/500
KV-raw (no template)
59.2%
54.1%
74.4%
0
—
Llama-3.1-8B ( N=200 )
Baseline
29.5%
18.7%
62.0%
0
—
RAG (BGE top-2)
61.5%
56.7%
76.0%
290
—
Table 1: HotpotQA results. KV-chat and RAG use identical system messages with identical chat template formatting; the only difference is the delivery mechanism.
Searches
Model
KV EM
RAG EM
KV tok
RAG tok
Savings
1
Qwen3-8B
43.0%
43.0%
35
176
141 (80%)
Llama-3.1-8B
42.0%
42.0%
31
188
157 (84%)
2
Qwen3-8B
59.0%
59.0%
35
299
264 (88%)
Llama-3.1-8B
59.0%
58.0%
31
305
274 (90%)
3
Qwen3-8B
65.0%
65.0%
35
438
404 (92%)
Llama-3.1-8B
61.0%
61.0%
31
437
406 (93%)
Table 2: Accumulation scaling ( N=100 per level per model). As retrieval steps increase, RAG token cost grows linearly while KV remains constant. Accuracy is identical at every level on both models.
Figure 1: Token cost scaling with retrieval steps. RAG prompt cost grows linearly ( ∼ 140–150 tokens per step) while KV injection remains constant ( ∼ 31–35 tokens). Shaded area shows cumulative token savings.
Model
Method
Overall
Bridge
Comp.
Qwen3-8B
KV-chat
65.2%
60.5%
79.2%
KV-raw
59.2%
54.1%
74.4%
Difference
+6.0pp
+6.4pp
+4.8pp
Llama-3.1-8B
KV-chat
61.5%
56.7%
76.0%
KV-raw
56.0%
49.3%
76.0%
Difference
+5.5pp
+7.4pp
0.0pp
Table 3: Chat template effect by model and question type.
Table 6: Value steering alpha sweep with 30 contrastive pairs on two models. Optimal α and coherence cliff differ, but both models show significant improvement over baseline at 100% coherence.
Qwen3-8B ( α=2.0 )
Llama-3.1-8B ( α=1.5 )
Layer Range
n
Score
n
Score
All (0–100%)
36
1.93
32
2.47
Early (0–33%)
11
1.20
10
1.33
Mid (33–66%)
12
1.93
11
2.27
Late (66–100%)
13
0.67
11
1.47
Baseline
—
0.60
—
1.47
Table 7: Layer-selective value steering on two models (each at its optimal α , 30 pairs). Mid layers (33–66%) carry the steering effect on both architectures.
Figure 2: Layer-selective value steering on two models. Mid layers (33–66%, green highlight) capture the full steering effect, matching all-layer steering. Late layers produce scores indistinguishable from baseline.
Qwen3-8B ( α=2.0 )
Llama-3.1-8B ( α=1.5 )
Condition
Def.
Doc.
Coh.
Def.
Doc.
Coh.
Baseline
0.40
0.00
100%
1.47
—
100%
A only (defensive)
1.27
1.00
100%
1.87
3.80
100%
B only (documented)
0.73
3.80
100%
1.93
3.53
100%
A+B composed
1.67
3.40
100%
2.13
4.07
100%
Def. retention
131%
114%
Table 8: Composable value steering on two models. “Def.” counts error-handling patterns (0–9), “Doc.” counts docstring/type-hint patterns (0–11). Retention shows A+B score as percentage of single-direction score.
Condition
EM
Form.
Words
A
No knowledge, no steering
20.5%
0.14
16
B
Knowledge only (KV)
72.5%
0.20
35
C
Steering only (V-delta)
15.0%
0.32
52
D
Knowledge + Steering ( α=2.0 )
40.5%
0.32
55
E
Text knowledge (RAG)
73.0%
0.13
11
F
Text knowledge + text steering
77.5%
0.26
48
Table 9: Dual-channel experiment: knowledge delivery + value steering simultaneously (Qwen3-8B, N=200 HotpotQA bridge questions). EM = exact match, Form. = formality score, Words = average response length.
α
EM
Formality
Words
0.0
72.5%
0.20
35
0.1
73.0%
0.21
37
0.2
73.0%
0.21
39
0.5
72.0%
0.23
43
0.7
73.0%
0.24
45
1.0
67.0%
0.25
49
Table 10: Alpha sweep for dual mode (knowledge + steering). At α≤0.7 , factual accuracy is fully preserved while steering effect is measurable. The Pareto frontier is governed by a single scalar.
Figure 3: Dual-channel trade-off (Qwen3-8B, N=200 ). At α≤0.7 (green zone), factual accuracy is fully preserved while behavioral steering is measurable. Higher α trades accuracy for stronger steering.
Retrieval-augmented generation (RAG) for long-context question answering is bottlenecked by inference-time prefilling over large retrieved contexts. A common strategy is to precompute key-value (KV) caches for individual documents and selectively recompute a small subset of tokens to restore global causal dependencies, but existing methods rely on heuristics or representation discrepancies without modeling whether selected tokens can effectively influence generation. We cast selective KV recomputation as an information flow problem and show that a simple attention-norm signal from the query reliably identifies tokens that are both semantically relevant and structurally positioned to propagate information, when computed under an inference-consistent RoPE geometry. We therefore reconstruct global positional assignments for retrieved chunks and introduce an information-flow-guided chunk reordering strategy. Experiments on Large Language Model and Vision-Language Model benchmarks demonstrate consistent gains over prior methods under comparable latency.
Xin Teng, Canyu Zhang, Shaoyi Zheng +3
New York University · New York University Shanghai · Duke University +1
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. 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× speedups in median TTFT over full prefill and improve mean F1 by 2.1-26.1 percentage points over direct cache reuse.
Cross-request KV caching reduces the prefill cost of Retrieval-Augmented Generation (RAG), but conventional prefix caching severely limits cache reuse across requests. Position-Independent Caching (PIC) removes this constraint by reusing independent chunks, but their KV states miss cross-chunk interactions. Existing methods selectively recompute token states to recover these missing interactions, but primarily allocate the recomputation budget to selecting which states to recompute, while fixing the recomputation context to the full causal prefix. We introduce RelaxKV, which formulates selective cache repair as a joint allocation problem over repair targets and recomputation context. Guided by the user query, RelaxKV identifies layer-specific repair targets and restricts their recomputation to a query-relevant context, reducing attention computation. Across four decoder models, RelaxKV at a 15% anchor ratio improves aggregate LongBench performance over ProphetKV on all models. On Qwen3-14B, RelaxKV provides a stronger quality-TTFT trade-off than ProphetKV across a 5%-30% anchor-ratio sweep, and achieves the best selective results on RULER-MV and LV-Eval at 16K and 32K context lengths. Controlled ablations further demonstrate the importance of recomputation context selection.
Ruoling Qi, Yirui Liu, Xuaner Wu +5
Shanghai Jiao Tong University · Institute of Artificial Intelligence, China Telecom (TeleAI) · State University of New York at Buffalo