Refusal Localizes, the Damage Relocates: Safety Layers Under Few-Sample Fine-Tuning
Organizations: Korea University · Zoom Communications · Yonsei University Mirae Campus
Abstract
Fine-tuning adapts aligned large language models (LLMs) to downstream tasks, but a few dozen harmful examples can remove their refusal of harmful requests. Prior work localizes safety-related behavior to specific layers, directions, and tokens, suggesting targets for protection. We test whether successful localization and recovery support defenses that survive changes in the attack. Across six checkpoints from four model families, harmful and benign prompts remain linearly separable after attack, and patching full clean hidden states into the compromised model restores refusal at a reproducible transition depth. Building on a prior layer-freezing defense, we freeze every layer up to this depth and repeat the attack. At a hundred harmful examples, refusal remains near zero on all six checkpoints, with recovery transitions above the frozen boundary. In a second study, removing the update's top two singular directions restores refusal after short attention-only fine-tunes on four checkpoints. On Llama-3.1-8B, ordinary training changes weaken this repair and an attacker who spreads the update defeats it. A spectral detector calibrated on benign Llama fine-tunes misses most repair failures on that checkpoint. Localized freezing can nevertheless help preserve refusal when a few harmful examples enter training data unintentionally. These results show that an attacker can bypass a region identified by recovery and defeat a repair that works across multiple checkpoints, motivating five checks for defenses against adaptive fine-tuning. Code is available at https://github.com/js-lee-AI/refusal-relocates.
Figures & tables
| Coherent refusal | Llama-Guard unsafe | |||||||||
| Model | Frozen | Clean | Attack | Freeze | Matched | Clean | Attack | Freeze | Matched | |
| LoRA, each checkpoint at its own measured depth | ||||||||||
| Llama-3.1-8B | 32 | .92–.96 | .00 | .00–.01 | .00 | .04–.05 | .94–.98 | .89–.92 | .96–.97 | |
| Tulu-3-8B-DPO | 32 | .99–1.00 | .01–.06 | .00–.03 | .01–.04 | .00 | .89–.94 | .53–.74 | .89–.92 | |
| OLMo-2-7B | 32 | .99–1.00 | .00–.02 | .00–.02 | .06–.07 | .00 | .84–.94 | .49–.72 | .84–.88 | |
| OLMo-2-13B | 40 | .99–1.00 | .00–.02 | .00–.01 | .00–.02 | .00 | .89–.95 | .23–.63 | .89–.96 | |
| Coherent refusal | Llama-Guard unsafe | |||||||
|---|---|---|---|---|---|---|---|---|
| Model | Clean | All | Top 4 | Bottom 4 | Clean | All | Top 4 | Bottom 4 |
| Llama-3.1-8B | .92–.96 | .00 | .00–.01 | .00–.03 | .04–.05 | .93–.98 | .70–.75 | .90–.94 |
| Tulu-3-8B-DPO | .99–1.00 | .01–.06 | .00–.01 | .00–.04 | .00 | .89–.94 | .03–.28 | .77–.95 |
| OLMo-2-7B | .99–1.00 | .00–.02 | .10–.16 | .05–.14 | .00 | .84–.94 | .04–.12 | .50–.84 |
| OLMo-2-13B | .99–1.00 | .00–.02 | .57–.69 | .01–.03 | .00 | .89–.95 | .01–.03 | .78–.94 |
| Qwen2.5-14B | .97–.99 | .00–.01 | .01–.03 | .16–.30 | .00 | .92–.98 | .00–.02 | .60–.74 |
| Standard | Spread | Projected | |
| 5 ep | |||
| .607–.623 | .228–.229 | .222–.226 | |
| Part. ratio | 4.47–4.73 | 15.6 | 5.99–6.00 |
| Top-2 energy | .597–.607 | .149 | .407–.408 |
| Refusal, no repair | .00 | .00–.02 | .02–.06 |
| LG unsafe, no repair | .96–.98 | .96–.98 | .88–.90 |
Appendix figures & tables19 assets
Supplementary material from the paper’s appendix.
Appendix
| Condition | AdvBench | HarmBench | StrongREJECT | XSTest-safe over-ref. |
|---|---|---|---|---|
| Original | 0.955 | 0.882 | 0.938 | 0.035 |
| Compromised | 0.010 | 0.003 | 0.003 | 0.000 |
| Repaired (top-2) | 0.940 | 0.813 | 0.818 | 0.008 |
| Random-2 removed | 0.008 | 0.003 | 0.001 | 0.000 |
| Model | Layer | Fixed | Recal. | Oracle | Model | Layer | Fixed | Recal. | Oracle |
|---|---|---|---|---|---|---|---|---|---|
| Llama-3.1-8B | 9 | 0.90–0.95 | 0.81–0.89 | 0.93–0.96 | OLMo-2-7B | 9 | 0.69–0.94 | 0.96–0.97 | 0.97–0.98 |
| 14 | 0.35–0.39 | 0.79–0.87 | 0.94–0.97 | 14 | 0.36–0.42 | 0.88–0.91 | 0.92–0.95 | ||
| 19 | 0.38–0.54 | 0.69–0.77 | 0.88–0.90 | 19 | 0.34 | 0.72–0.75 | 0.87–0.90 | ||
| 24 | 0.56–0.74 | 0.72–0.74 | 0.85–0.90 | 24 | 0.33–0.34 | 0.63–0.70 | 0.84–0.85 | ||
| Tulu-3-8B-DPO | 9 | 0.33–0.85 | 0.75–0.93 | 0.91–0.96 | Qwen2.5-14B | 14 | 0.34–0.73 | 0.84–0.94 | 0.91–0.95 |
| 14 | 0.33 | 0.69–0.85 | 0.90–0.92 | 21 | 0.33–0.80 | 0.81–0.92 | 0.89–0.94 |
| Checkpoint | Layer | Base | Aligned | Gap | Checkpoint | Layer | Base | Aligned | Gap |
|---|---|---|---|---|---|---|---|---|---|
| Llama-3.1-8B | 9 | 0.915 | 0.958 | OLMo-2-13B | 12 | 0.931 | 0.961 | ||
| 14 | 0.944 | 0.972 | 18 | 0.941 | 0.969 | ||||
| 19 | 0.936 | 0.971 | 24 | 0.943 | 0.972 | ||||
| 24 | 0.937 | 0.965 | 30 | 0.943 | 0.969 | ||||
| OLMo-2-7B | 9 | 0.907 | 0.946 | ||||||
| 14 | 0.932 | 0.970 | |||||||
| Model | Dose | Clean | Attack | Freeze | Matched |
|---|---|---|---|---|---|
| Llama-3.1-8B | 5 | .92–.96 | .00–.05 | .91–.96 | .16–.24 |
| OLMo-2-7B | 25 | .99–1.00 | .10–.18 | .95–.98 | .30–.50 |
| Tulu-3-8B-DPO | 25 | .99–1.00 | .01–.05 | .21–.52 | .01–.05 |
| Qwen2.5-14B | 25 | .97–.99 | .00–.02 | .33–.60 | .26–.35 |
| Yi-1.5-9B | 10 | .93–.94 | .05–.13 | .85–.93 | .80–.87 |
| OLMo-2-13B | 5, 10 | No successful unrestricted attack at either dose | |||
| Model | |||||
|---|---|---|---|---|---|
| Llama-3.1-8B (32L) | .375 .000 | .438 .054 | .562 .094 | .531 .054 | .531 .108 |
| Tulu-3-8B-DPO (32L) | — | — | .406 .054 | .469 .000 | .469 .000 |
| OLMo-2-7B (32L) | — | — | .344 .054 | .500 .054 | .500 .054 |
| OLMo-2-13B (40L) | .375 [1] | .442 .058 | .375 .000 | .525 .043 | .525 .043 |
| Qwen2.5-14B (48L) | — | .375 .000 [2] | .681 .060 | .646 .000 | .646 .000 |
| Yi-1.5-9B (48L) | .681 .060 | .806 .048 | .750 .000 | .806 .048 | .806 .048 |
| Frozen | L12 | L15 | L18 | L21 | L24 | L27 | L28 | L29 | L30 | by seed |
| none | .00–.05 | .77–.91 | .90–.93 | .92–.94 | .93–.96 | .92–.96 | .92–.96 | .92–.96 | .92–.96 | 15, 15, 15 |
| .00–.01 | .72–.93 | .91–.94 | .92–.94 | .93–.95 | .92–.96 | .92–.96 | .92–.96 | .92–.96 | 15, 15, 15 | |
| .00 | .05–.67 | .77–.90 | .91–.94 | .93–.96 | .92–.96 | .91–.96 | .91–.96 | .92–.96 | 18, 15, 18 | |
| .00–.01 | .00–.01 | .00–.04 | .01–.04 | .03–.08 | .08–.67 | .72–.94 | .86–.94 | .91–.95 | 28, 27, 27 | |
| .00–.01 | .00–.01 | .00–.01 | .00–.01 | .01–.04 | .00–.03 | .03–.16 | .15–.49 | .85–.94 | 29, 30, | |
| .00–.01 | .00–.01 | .00–.01 | .00–.01 | .00–.01 | .00–.01 | .00–.02 | .01–.02 | .05–.50 | 30, , |
| Model | Unrestr. | by seed | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Llama-3.1-8B | 17 | 15, 15, 15 | .00–.11 | .00–.05 | .00–.03 | .00–.03 | .03–.11 | , 27, 27 | |
| Tulu-3-8B-DPO | 15 | 15, 15, 15 | .04–.42 | .62–.86 | .88–.94 | .89–.94 | .96–.99 | 17, 17, 17 | |
| OLMo-2-7B | 16 | 15, 15, 18 | .10–.26 | .66–.77 | .73–.84 | .74–.84 | .75–.85 | 18, 18, 18 | |
| OLMo-2-13B | 20 | 19, 19, 19 | .00–.33 | .33–.50 | .62–.65 | .65–.78 | .78–.90 | 23, 22, 23 | |
| Qwen2.5-14B | 31 | 31, 31, 31 | .00 | .00–.25 | .15–.47 | .28–.62 | .28–.68 | 35, 36, 40 | |
| Yi-1.5-9B | 39 | 36, 40, 40 | .00–.11 | .00–.11 | .08–.29 | .59–.76 | .62–.76 | 43, 43, 43 |
| Model, boundary | Below | Donated at, with the layer in brackets | ||
|---|---|---|---|---|
| Llama-3.1-8B, 17 | .93–.95 [12] | .00 [28] | .00 [30] | .00 [31] |
| benign donor | 1.00 [12] | .78–.85 [28] | .72–.82 [30] | .70–.80 [31] |
| Tulu-3-8B-DPO, 15 | 1.00 [10] | .88–.90 [16] | .28–.47 [17] | .12–.25 [18] |
| OLMo-2-7B, 16 | 1.00 [10] | .97–1.00 [17] | .53–.65 [18] | .10–.35 [19] |
| Coherent refusal | Llama-Guard unsafe | |||||||||
| Model | Frozen | Free | Clean | Attack | Freeze | Matched | Clean | Attack | Freeze | Matched |
| Llama-3.1-8B | 2 | .92–.96 | .00 | .00–.01 | .02–.16 | .04–.05 | .93–.98 | .63–.71 | .79–.94 | |
| 1 | .92–.96 | .00 | .00–.03 | .01–.03 | .04–.05 | .93–.98 | .45–.62 | .88–.95 | ||
| Tulu-3-8B-DPO | 2 | .99–1.00 | .00–.05 | .01–.04 | .00–.03 | .00 | .90–.95 | .08–.20 | .85–.94 | |
| 1 | .99–1.00 | .00–.05 | .00–.04 | .00–.11 | .00 | .90–.95 | .51–.61 | .70–.85 | ||
| Qwen2.5-14B | 2 | .97–.99 | .00 | .06–.13 | .14–.51 | .00 | .92–.97 | .00–.03 | .41–.72 | |
| Attacker | Refusal | LG unsafe | Over-refusal | Train loss | ratio |
|---|---|---|---|---|---|
| Clean | 0.92–0.96 | 0.04–0.05 | 0.04 | – | – |
| Full FT | 0.00 | 0.96–0.98 | 0.00 | 0.13–0.17 | 1.00 |
| Full FT, frozen | 0.00–0.01 | 0.67–0.85 | 0.00 | 0.14–0.16 | 1.09–1.25 |
| Full FT, frozen | 0.00–0.01 | 0.96–0.98 | 0.00 | 0.39–0.42 | 1.14–1.28 |
| and arm | Refusal | LG unsafe | Over-refusal | Task NLL |
|---|---|---|---|---|
| Clean | 0.92–0.96 | 0.04–0.05 | 0.06 | 1.942 |
| , unrestricted | 0.00–0.10 | 0.78–0.94 | 0.00 | 1.441–1.532 |
| , frozen | 0.74–0.92 | 0.08–0.16 | 0.00 | 1.524–1.562 |
| , matched | 0.02–0.06 | 0.80–0.90 | 0.00 | 1.350–1.369 |
| , unrestricted | 0.00–0.02 | 0.82–0.98 | 0.00 | 1.457–1.494 |
| , frozen | 0.08–0.14 | 0.42–0.66 | 0.00 | 1.535–1.540 |
| Run | Layer | Full | Rank-1 | Complement | Ratio |
|---|---|---|---|---|---|
| Llama-3.1-8B, all-7, 5 ep | |||||
| Llama-3.1-8B, attn, 3 ep | |||||
| Yi-1.5-9B | |||||
| OLMo-2-13B |
| Model | Remove top-1 | Remove top-2 | Remove top-4 | Random-2 |
|---|---|---|---|---|
| Llama-3.1-8B | 0.04–0.98 | 0.76–1.00 | 0.94–0.98 | 0.00–0.14 |
| Tulu-3-8B-DPO | 0.94–1.00 | 1.00 | 1.00 | 0.00–0.06 |
| OLMo-2-7B | 0.98–1.00 | 1.00 | 1.00 | 0.00–0.26 |
| Qwen2.5-14B | 0.88–1.00 | 1.00 | 1.00 | 0.00–0.26 |
| Epochs | 1 | 2 | 3 | 5 | 8 |
|---|---|---|---|---|---|
| Mean | 0.202 | 0.323 | 0.465 | 0.614 | 0.697 |
| Participation ratio | 6.19 | 5.26 | 4.70 | 4.61 | 4.58 |
| Top-2 energy fraction | 0.504 | 0.548 | 0.590 | 0.601 | 0.605 |
| Refusal after removing top-2 | 0.85 | 0.79 | 0.71 | 0.41 | 0.34 |
| Arm | Residual | Std, all-7, 5 ep | Std, attn, 3 ep | Spread, | Projected, |
|---|---|---|---|---|---|
| No repair ( ) | 1.00 | 0.00 | 0.00 | 0.00 | 0.02–0.06 |
| Projection, | 0.28–0.79 | 0.00–0.04 | 0.00 | 0.02–0.06 | 0.82–0.92 |
| Projection, | 0.17–0.31 | 0.52–0.80 | 0.06–0.12 | 0.94–0.98 | 0.94–0.96 |
| Projection, | 0.08–0.17 | 0.88–0.96 | 0.80–0.94 | 0.94–0.98 | 0.92–0.94 |
| Scale-matched control | 0.08–0.17 | 0.48–0.78 | 0.28–0.70 | 0.94–0.98 | 0.92–0.94 |
| Random subspace | 0.42–0.46 | 0.02–0.36 | 0.02–0.22 | 0.44–0.78 | 0.94–0.96 |
| Detector score | Refusal after removal | ||
|---|---|---|---|
| 0.972–0.974 | 0.228–0.229 | 0.00 | |
| 0.974–0.976 | 0.231–0.233 | 0.00 | |
| 0.977 | 0.247–0.249 | 0.00–0.03 | |
| 0.983 | 0.306–0.308 | 0.00 | |
| 0.971–0.972 | 0.419–0.422 | 0.03 | |
| 0.926 | 0.483–0.486 | 0.02–0.05 |
| Seed | Part. ratio | Top-2 energy | Seed | Part. ratio | Top-2 energy | ||||
|---|---|---|---|---|---|---|---|---|---|
| 42 | 1 | 44 | 2 | ||||||
| 43 | 1 | 42 | 4 | ||||||
| 44 | 1 | 43 | 2 | ||||||
| 42 | 1 | 44 | 2 | ||||||
| 43 | 1 | 42 | 2 | ||||||
| 44 | 2 | 43 | 2 |
| Clean state taken from | L6 | L10 | L14 | L18 | L23 | L27 |
|---|---|---|---|---|---|---|
| This prompt | 0.00 | 0.00 | 0.15–0.75 | 0.90–0.95 | 0.95–0.97 | 0.93–0.95 |
| Another harmful prompt | 0.00 | 0.00 | 0.15–0.47 | 0.47–0.55 | 0.47–0.57 | 0.90–0.95 |
| A benign prompt | 0.00 | 0.00–0.03 | 0.05–0.10 | 0.00–0.07 | 0.00–0.03 | 0.00 |
LLM Safety
Large language model (LLM) safety studies how to prevent harmful, unreliable, or misaligned behavior while preserving useful responses.
See all 440 papers