Weight Patching: Toward Source-Level Mechanistic Localization in LLMs
Organizations: Key Laboratory of Ministry of Education for Brain Inspired Intelligent Perception and Cognition, University of Science and Technology of China, Hefei, Anhui 230026, China
Abstract
Mechanistic interpretability seeks to localize model behavior to the internal components that causally realize it. Prior work has advanced activation-space localization and causal tracing, but modules that appear important in activation space may merely aggregate or amplify upstream signals rather than encode the target capability in their own parameters. To address this gap, we propose Weight Patching, a parameter-space intervention method for source-oriented analysis in paired same-architecture models that differ in how strongly they express a target capability under the inputs of interest. Given a base model and a behavior-specialized counterpart, Weight Patching replaces selected module weights from the specialized model into the base model under a fixed input. We instantiate the method on instruction following and introduce a framework centered on a vector-anchor behavioral interface that provides a shared internal criterion for whether a task-relevant control state has been formed or recovered in open-ended generation. Under this framework, the analysis reveals a hierarchy from shallow candidate source-side carriers to aggregation and routing modules, and further to downstream execution circuits. The recovered component scores can also guide mechanism-aware model merging, improving selective fusion across the evaluated expert combinations and providing additional external validation.
Figures & tables
| Task | Max | Top-5 Avg | Top-20 Avg |
|---|---|---|---|
| Llama-3.2-3B | |||
| English Capital | |||
| Multiple Sections | |||
| Number Highlighted Sections | |||
| Title | |||
| No Comma | |||
| Gradient | Intersection | Total Time | Peak VRAM | |
| Model | Attribution | (%) | (Second) | (MiB) |
| Head-level | ||||
| LLama-3.2-3B | ✘ | |||
| ✔ | ||||
| LLama-3.1-8B | ✘ | |||
| ✔ | ||||
| Model(s) | Method | HumanEval | MBPP | MMLU | MATH | GSM8K | IFEval | Avg. |
|---|---|---|---|---|---|---|---|---|
| Base Models | ||||||||
| Base | - | |||||||
| Code | - | |||||||
| Instruction Tuned | - | |||||||
| Math | - | |||||||
| Merged Models | ||||||||
Appendix figures & tables27 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Layers | Hidden Dim | Attention | KV Heads | MLP Width | Vocab Size |
|---|---|---|---|---|---|---|
| ( ) | ( ) | Heads | ||||
| Llama-2-13B | 40 | 5120 | 40 | 40 | 13824 | 32000 |
| Llama-3.1-8B | 32 | 4096 | 32 | 8 | 14336 | 128256 |
| Llama-3.2-3B | 28 | 3072 | 24 | 8 | 8192 | 128256 |
| Task | Layer | Projection (Top-10 vocabulary) |
|---|---|---|
| No Comma | 3 | ¡ wear ¿, ¡ adam ¿, ¡ Dipl ¿, ¡ cca ¿, ¡ McCorm ¿, ¡ ¡U+FFFD¿ ¿, ¡ Synd ¿, ¡ least ¿, ¡ dex ¿, ¡ ook ¿ |
| 10 | ¡ -horizontal ¿, ¡ ippi ¿, ¡ Artem ¿, ¡ ¡U+FFFD¿ ¿, ¡ Cap ¿, ¡ naked ¿, ¡ urs ¿, ¡ ¡U+FFFD¿ ¿, ¡ imuth ¿, ¡ eni ¿ | |
| 15 | ¡ gov ¿, ¡ tv ¿, ¡ repeat ¿, ¡ nge ¿, ¡ 尖 ¿, ¡ alien ¿, ¡ enez ¿, ¡ U+0626 ¿, ¡ dont ¿, ¡ око ¿ | |
| 20 | ¡ moreover ¿, ¡ ¿, ¡ (’.’) ¿, ¡ hàng ¿, ¡ doesnt ¿, ¡ furthermore ¿, ¡ dont ¿, ¡ Dont ¿, ¡ auen ¿, ¡ fine ¿ | |
| 25 | ¡ youre ¿, ¡ doesnt ¿, ¡ its ¿, ¡ theres ¿, ¡ its ¿, ¡ Dont ¿, ¡ Lets ¿, ¡ Its ¿, ¡ dont ¿, ¡ hey ¿ | |
| Title | 3 | ¡ ofi ¿, ¡ Arch ¿, ¡ 卒 ¿, ¡ ルト ¿, ¡ onna ¿, ¡ phin ¿, ¡ positioning ¿, ¡ 탈 ¿, ¡ Princip ¿, ¡ ghan ¿ |
| Task | Layer | Projection (Top-10 vocabulary) |
|---|---|---|
| No Comma | 3 | ¡ eca ¿, ¡ ientes ¿, ¡ holm ¿, ¡ airport ¿, ¡ ency ¿, ¡ 독 ¿, ¡ elter ¿, ¡ harma ¿, ¡ hsi ¿, ¡ Integral ¿ |
| 10 | ¡ enen ¿, ¡ nge ¿, ¡ bero ¿, ¡ sic ¿, ¡ 458 ¿, ¡ .usermodel ¿, ¡ vester ¿, ¡ ome ¿, ¡ alah ¿, ¡ Wr ¿ | |
| 15 | ¡ ;amp ¿, ¡ 129 ¿, ¡ ¡U+2510¿ ¿, ¡ Hammer ¿, ¡ ober ¿, ¡ stra ¿, ¡ geme ¿, ¡ ¡U+0E46¿ ¿, ¡ aram ¿, ¡ \acctonos ¿ | |
| 20 | ¡ engu ¿, ¡ some ¿, ¡ alternate ¿, ¡ first ¿, ¡ rita ¿, ¡ oko ¿, ¡ Lomb ¿, ¡ olut ¿, ¡ lam ¿, ¡ engo ¿ | |
| 25 | ¡ arto ¿, ¡ folk ¿, ¡ undi ¿, ¡ oko ¿, ¡ U+0627U+0644U+0646U+0627U+0633 ¿, ¡ stat ¿, ¡ KEN ¿, ¡ itemprop ¿, ¡ ifications ¿, ¡¿ | |
| 30 | ¡ we ¿, ¡ oh ¿, ¡ okay ¿, ¡ one ¿, ¡ Nicholson ¿, ¡ first ¿, ¡ народ ¿, ¡ the ¿, ¡ okay ¿, ¡ an ¿ |
| Task | Layer | Projection (Top-10 vocabulary) |
|---|---|---|
| No Comma | 3 | ¡ prob ¿, ¡ str ¿, ¡ bon ¿, ¡ mang ¿, ¡ Bon ¿, ¡ ling ¿, ¡ aud ¿, ¡ ieu ¿, ¡ Kra ¿, ¡ istan ¿ |
| 10 | ¡ egy ¿, ¡ Gram ¿, ¡ firm ¿, ¡ clam ¿, ¡ haft ¿, ¡ rails ¿, ¡ Gal ¿, ¡ WF ¿, ¡ Wars ¿, ¡ Sequ ¿ | |
| 15 | ¡ comb ¿, ¡ zero ¿, ¡ emb ¿, ¡ connected ¿, ¡ cord ¿, ¡ succession ¿, ¡ port ¿, ¡ God ¿, ¡ pair ¿, ¡ esch ¿ | |
| 20 | ¡ zero ¿, ¡ neg ¿, ¡ without ¿, ¡ Jordan ¿, ¡ no ¿, ¡ ash ¿, ¡ sans ¿, ¡ Without ¿, ¡ single ¿ | |
| 25 | ¡ single ¿, ¡ without ¿, ¡ un ¿, ¡ neg ¿, ¡ : ¿, ¡ , ¿, ¡ negative ¿, ¡ Single ¿ | |
| 30 | ¡ none ¿, ¡ without ¿, ¡ single ¿, ¡ , ¿, ¡ neg ¿, ¡ None ¿, ¡ acc ¿, ¡ ats ¿, ¡ tall ¿, ¡ no ¿ |
| Task | Max | Top-5 Avg | Top-20 Avg |
|---|---|---|---|
| Llama-3.2-3B | |||
| English Capital | |||
| Multiple Sections | |||
| Number Highlighted Sections | |||
| Title | |||
| No Comma | |||
Mechanistic Interpretability
Mechanistic interpretability studies how neural networks implement behaviors through internal features, circuits, and causal information flow.
See all 391 papers