Golden Layers and Where to Find Them: Improved Knowledge Editing for Large Language Models Via Layer Gradient Analysis
Organizations: University of South Florida, Tampa, FL, USA · Brandeis University, Waltham, MA, USA
Abstract
Knowledge editing in Large Language Models (LLMs) aims to update the model's prediction for a specific query to a desired target while preserving its behavior on all other inputs. This process typically involves two stages: identifying the layer to edit and performing the parameter update. Intuitively, different queries may localize knowledge at different depths of the model, resulting in different sample-wise editing performance for a fixed editing layer. In this work, we hypothesize the existence of fixed golden layers that can achieve near-optimal editing performance similar to sample-wise optimal layers. To validate this hypothesis, we provide empirical evidence by comparing golden layers against ground-truth sample-wise optimal layers. Furthermore, we show that golden layers can be reliably identified using a proxy dataset and generalize effectively to unseen test set queries across datasets. Finally, we propose a novel method, namely Layer Gradient Analysis (LGA) that estimates golden layers efficiently via gradient-attribution, avoiding extensive trial-and-error across multiple editing runs. Extensive experiments on several benchmark datasets demonstrate the effectiveness and robustness of our LGA approach across different LLM types and various knowledge editing methods.
Figures & tables
| Model | Method | ZSRE | WikiBio | WikiCounterfact | WikiRecent | Counterfact |
| GPT-2 | Sample-Wise Optimal Layer | 1.0000 ±0.0000 | 0.8897 ±0.1239 | 0.9860 ±0.0721 | 0.9974 ±0.0425 | 1.0000 ±0.0000 |
| Golden Layer | 0.9993 ±0.0135 | 0.8256 ±0.1629 | 0.9537 ±0.1480 | 0.9887 ±0.0793 | 0.9871 ±0.1128 | |
| Statistical Difference | No | Yes | Yes | Yes | Yes | |
| LLaMA2 | Sample-Wise Optimal Layer | 0.9691 ±0.0747 | 1.0000 ±0.0006 | 0.9949 ±0.0345 | 0.9897 ±0.0677 | 1.0000 ±0.0000 |
| Golden Layer | 0.9667 ±0.0771 | 0.9912 ±0.0325 | 0.9922 ±0.0532 | 0.9792 ±0.0910 | 0.9995 ±0.0164 | |
| Statistical Difference | No | Yes | No | Yes | No |
| Edit | Selection | RwA | RpA | LOC | PRT | OV |
| R-ROME | CMA | 0.9665 | 0.7467 | 0.9608 | 0.4837 | 0.6942 |
| SaLEM | 0.6910 | 0.5951 | 0.6405 | 0.3629 | 0.5724 | |
| LGA (Ours) | 0.9851 | 0.8151 | 0.9543 | 0.4757 | 0.7106 | |
| EMMET | CMA | 0.9850 | 0.8796 | 0.6589 | 0.4202 | 0.7359 |
| SaLEM | 0.8072 | 0.5816 | 0.7042 | 0.4441 | 0.6343 | |
| LGA (Ours) | 0.9862 | 0.8833 | 0.6857 | 0.3947 | 0.7375 |
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Set | ZSRE | WikiBio | WikiCounterfact | WikiRecent | Counterfact | |||||
| Layer | Rewrite | Layer | Rewrite | Layer | Rewrite | Layer | Rewrite | Layer | Rewrite | ||
| GPT-2 XL | Proxy | 15 | 0.9962 | 19 | 0.8256 | 12 | 0.9380 | 17 | 0.9887 | 16 | 0.9796 |
| Test | 19 | 0.9993 | 19 | 0.8256 | 15 | 0.9537 | 17 | 0.9887 | 18 | 0.9871 | |
| LLaMA2-7B | Proxy | 12 | 0.9650 | 18 | 0.9835 | 3 | 0.9888 | 12 | 0.9783 | 2 | 0.9969 |
| Test | 10 | 0.9667 | 13 | 0.9912 | 12 | 0.9922 | 19 | 0.9792 | 4 | 0.9995 | |
| Gemma3-12B | Proxy | 27 | 0.9328 | 13 | 0.8538 | 19 | 0.9340 | 11 | 0.9784 | 8 | 0.9941 |
| Model | Set | ZSRE | Counterfact | ||
| Layer | Rephrase | Layer | Rephrase | ||
| GPT-2 XL | Proxy | 16 | 0.8823 | 18 | 0.8034 |
| Test | 17 | 0.8838 | 18 | 0.8034 | |
| LLaMA2-7B | Proxy | 7 | 0.9136 | 6 | 0.8023 |
| Test | 6 | 0.9176 | 15 | 0.8196 | |
| Gemma3-12B | Proxy | 39 | 0.9108 | 38 | 0.9221 |
| Model | Set | ZSRE | WikiBio | WikiCounterfact | WikiRecent | Counterfact | |||||
| Layer | Locality | Layer | Locality | Layer | Locality | Layer | Locality | Layer | Locality | ||
| GPT-2 XL | Proxy | 47 | 0.9959 | 46 | 0.9882 | 47 | 0.9965 | 47 | 0.9977 | 47 | 0.9968 |
| Test | 47 | 0.9959 | 47 | 0.9964 | 47 | 0.9965 | 47 | 0.9977 | 47 | 0.9968 | |
| LLaMA2-7B | Proxy | 23 | 0.9895 | 23 | 0.8436 | 30 | 0.7402 | 25 | 0.6865 | 2 | 0.9747 |
| Test | 3 | 0.9927 | 23 | 0.8436 | 30 | 0.7402 | 24 | 0.7016 | 2 | 0.9747 | |
| Gemma3-12B | Proxy | 11 | 0.9795 | 46 | 0.7870 | 46 | 0.7411 | 0 | 0.6523 | 0 | 0.9305 |
| Model | Set | ZSRE | WikiCounterfact | WikiRecent | Counterfact | ||||
| Layer | Portability | Layer | Portability | Layer | Portability | Layer | Portability | ||
| GPT-2 XL | Proxy | 23 | 0.4740 | 1 | 0.3032 | 23 | 0.3271 | 25 | 0.4392 |
| Test | 29 | 0.4844 | 1 | 0.3032 | 19 | 0.3302 | 15 | 0.4450 | |
| LLaMA2-7B | Proxy | 11 | 0.5979 | 17 | 0.6154 | 8 | 0.5719 | 15 | 0.5336 |
| Test | 12 | 0.5993 | 16 | 0.6199 | 16 | 0.5839 | 3 | 0.5476 | |
| Gemma3-12B | Proxy | 23 | 0.5442 | 43 | 0.6594 | 26 | 0.5806 | 1 | 0.4291 |
| Model | Set | WikiBio | WikiCounterfact | WikiRecent | |||
| Layer | Fluency | Layer | Fluency | Layer | Fluency | ||
| GPT-2 XL | Proxy | 8 | 0.8897 | 45 | 0.9058 | 4 | 0.9081 |
| Test | 6 | 0.8927 | 46 | 0.9157 | 13 | 0.9095 | |
| LLaMA2-7B | Proxy | 5 | 0.8595 | 6 | 0.8824 | 4 | 0.8800 |
| Test | 6 | 0.8597 | 3 | 0.8837 | 4 | 0.8800 | |
| Gemma3-12B | Proxy | 32 | 0.7071 | 35 | 0.5824 | 32 | 0.6031 |
| Model | Set | ZSRE | WikiBio | WikiCounterfact | WikiRecent | Counterfact | |||||
| Layer | Overall | Layer | Overall | Layer | Overall | Layer | Overall | Layer | Overall | ||
| GPT-2 XL | Proxy | 16 | 0.8286 | 34 | 0.8083 | 15 | 0.6916 | 25 | 0.7108 | 9 | 0.7726 |
| Test | 16 | 0.8286 | 37 | 0.8133 | 17 | 0.6961 | 21 | 0.7139 | 16 | 0.7789 | |
| LLaMA2-7B | Proxy | 6 | 0.8638 | 16 | 0.8771 | 14 | 0.7656 | 13 | 0.7625 | 3 | 0.8255 |
| Test | 7 | 0.8645 | 16 | 0.8771 | 14 | 0.7656 | 12 | 0.7640 | 3 | 0.8255 | |
| Gemma3-12B | Proxy | 19 | 0.8261 | 13 | 0.7780 | 41 | 0.6411 | 15 | 0.6474 | 9 | 0.7361 |
| Edit | Selection | RwA (↑) | LOC (↑) | PRT (↑) | FLC (↑) | OV (↑) |
| R-ROME | CMA | 0.9622 | 0.6124 | 0.3038 | 0.9084 | 0.6967 |
| SaLEM | 0.9828 | 0.6170 | 0.3192 | 0.9090 | 0.7070 | |
| LGA (Ours) | 0.9735 | 0.6058 | 0.3161 | 0.9048 | 0.7000 | |
| EMMET | CMA | 0.9837 | 0.5029 | 0.2979 | 0.8568 | 0.6603 |
| SaLEM | 0.9922 | 0.5485 | 0.3097 | 0.8475 | 0.6745 | |
| LGA (Ours) | 0.9892 | 0.5199 | 0.3044 | 0.8491 | 0.6656 |
| Model | Selection | RwA | LOC | PRT | FLC | OV |
| GPT-2-XL | CMA | 0.9622 | 0.6124 | 0.3038 | 0.9084 | 0.6967 |
| SaLEM | 0.9828 | 0.6170 | 0.3192 | 0.9090 | 0.7070 | |
| LGA (Ours) | 0.9735 | 0.6058 | 0.3161 | 0.9048 | 0.7000 | |
| LLaMA2-7B | CMA | 0.9748 | 0.5629 | 0.5731 | 0.8718 | 0.7456 |
| SaLEM | 0.9768 | 0.5478 | 0.5769 | 0.8708 | 0.7431 | |
| LGA (Ours) | 0.9750 | 0.5560 | 0.5699 | 0.8771 | 0.7445 |
| Model | Selection | RwA | RpA | LOC | PRT | OV |
| GPT-2-XL | CMA | 0.5083 | 0.5083 | 0.6917 | 0.4583 | 0.5417 |
| SaLEM | 0.1750 | 0.2083 | 0.0250 | 0.0833 | 0.1229 | |
| LGA | 0.8267 | 0.7817 | 0.7545 | 0.6117 | 0.7436 | |
| LLAMA2-7B | CMA | 0.9689 | 0.8822 | 1.0000 | 0.6862 | 0.8843 |
| SaLEM | 0.9489 | 0.9489 | 0.8908 | 0.6198 | 0.8521 | |
| LGA | 0.9689 | 0.9689 | 0.9933 | 0.7364 | 0.9169 |
| Model | Method | SRS | SR-1 | GSR | LSR | Overall |
| GPT-2-XL | CMA | 0.4562 | 0.1630 | 0.4023 | 0.0105 | 0.3462 |
| SaLEM | 0.2663 | 0.1556 | 0.2073 | 0.0154 | 0.1611 | |
| LGA | 0.5513 | 0.4278 | 0.4357 | 0.0197 | 0.3586 | |
| LLAMA2-7B | CMA | 0.6417 | 0.4944 | 0.5297 | 0.0282 | 0.4235 |
| SaLEM | 0.6417 | 0.4944 | 0.5297 | 0.0282 | 0.4235 | |
| LGA | 0.6513 | 0.4926 | 0.5398 | 0.0290 | 0.4282 |
| Model | Method | BLEU | R-1 | R-2 | R-L | Para-R-L | BertScore | MMLU | Overall |
| GPT2-XL | CMA | 0.3182 | 0.1940 | 0.0732 | 0.1841 | 0.1678 | 0.6125 | 0.2133 | 0.2519 |
| SaLEM | 0.3474 | 0.2219 | 0.0990 | 0.2097 | 0.1685 | 0.6926 | 0.2207 | 0.2800 | |
| LGA | 0.3452 | 0.2272 | 0.1036 | 0.2179 | 0.1855 | 0.6895 | 0.2237 | 0.2846 | |
| Llama2-7B | CMA | 0.5735 | 0.5310 | 0.3889 | 0.5152 | 0.3776 | 0.8250 | 0.4178 | 0.5184 |
| SaLEM | 0.5435 | 0.4837 | 0.3228 | 0.4654 | 0.3610 | 0.8005 | 0.4015 | 0.4826 | |
| LGA | 0.6342 | 0.6492 | 0.5508 | 0.6398 | 0.3230 | 0.8594 | 0.4296 | 0.5837 |
| Dataset | Model | Method | Rewrite | Rephrase | Locality | Portability | Overall |
| ZSRE | GPT-2-XL | CMA | 0.9665 | 0.7467 | 0.9608 | 0.4837 | 0.6942 |
| Random | 0.8539 | 0.5916 | 0.9701 | 0.4784 | 0.6347 | ||
| LGA | 0.9851 | 0.8151 | 0.9543 | 0.4757 | 0.7106 | ||
| LLAMA2-7B | CMA | 0.9587 | 0.8859 | 0.9923 | 0.5827 | 0.8549 | |
| Random | 0.9576 | 0.8115 | 0.9885 | 0.5650 | 0.8307 | ||
| LGA | 0.9625 | 0.8988 | 0.9927 | 0.5950 | 0.8623 |
| Dataset | Model | Method | Rewrite | Locality | Fluency | Overall |
| WikiBio | GPT-2-XL | CMA | 0.6894 | 0.5692 | 0.8927 | 0.7171 |
| SaLEM | 0.4061 | 0.2563 | 0.8186 | 0.4937 | ||
| LGA ( ) | 0.4061 | 0.2563 | 0.8186 | 0.4937 | ||
| LGA | 0.7484 | 0.5587 | 0.8906 | 0.7326 | ||
| LLaMA2-7B | CMA | 0.8818 | 0.6515 | 0.8547 | 0.7960 | |
| SaLEM | 0.8396 | 0.6526 | 0.8529 | 0.7817 |
Knowledge Editing
Knowledge editing studies how to update specific facts or behaviors in language models while preserving unrelated knowledge and capabilities.
See all 84 papers