KV-Cache Patching: Tracing How and Where Fine-Tuned Behaviors Arise
Abstract
Fine-tuning a language model changes how it responds, but where is this fine-tuned behavior instantiated? To better understand this, we evaluate whether the change in model behavior arises only during the generation of the answer tokens where the change manifests, or whether altered processing of previous tokens causes it via the attention mechanism. For this, we patch the KV cache from a LoRA fine-tuned model into the unmodified base model, and vice versa. Our results show that for some behaviors, like responding in German or emergent misalignment, patching the KV cache can indeed transfer them from the fine-tuned to the base model. Correspondingly, patching the KV cache from base to fine-tune can partially or fully remove fine-tuned behavior. Furthermore, we find that the effect of patching grows with how much of the KV cache is patched and concentrates at a few pivotal positions, with system-prompt and chat-template tokens having disproportionate influence.
Create a lesson
Metadata
- Categories
- cs.CL, cs.LG
- Comments
- Interpretability as a Science Workshop at NeurIPS 2026. Project page: https://jonasloos.github.io/kv-patching
Related papers
Group-Balanced Supervised Fine-Tuning for Knowledge-Intensive Domains
Shared title terminologycs.CLMark Heimann, Bruno Jacob
Labadain-MedQA: A Tetun Medical QA Dataset for Fine-Tuning and Evaluating Large Language Models
Shared title terminologycs.CLGabriel de Jesus, Sérgio Nunes
Saidzoda-Tajik-E5-Large: Fine-Tuning a 560M Embedder for Tajik Retrieval
Shared title terminologycs.CLTohir Saidzoda, Nekruz Maxudov, Bedil Karimov et al.
HyperRepair: Recovering Forgotten General Capabilities of Fine-Tuned Language Models
Shared title terminologycs.CLJunrong Tang, Jianghui Wang, Hao Kong et al.
PRIMEAPE: A Multilingual Benchmark for Fine-Grained Meta-Evaluation of Judge Models
Shared title terminologycs.CLVladislav Mikhailov, Sarfraz Ahmad, Momina Ahsan et al.
Learn the Effects, Not the Examples: Implicit ICL via Attention Patching
Shared title terminologycs.CLSeungwon Woo, Hyunseo Shin, Wonseok Hwang