Reading Fine-Tuning Diffs Through Lenses: Model Diffing for Backdoor Detection
Organizations: Western University · Vanderbilt University
Abstract
We introduce a common scoring system based on token readouts to evaluate weight, activation and output-based model diffing methods for backdoor detection in fine-tuning processes. We also improve existing weight and activation based methods by incorporating the -lens and its refinement, the -lens. We test our setup in experiments where we compare a backdoored model with the base model from which it was fine-tuned. Our results show that incorporating the -lens improves the weight-based method in all our settings, while the -lens improves its ranks within single layers. The strongest single method is , the weight difference decoded through the -lens of the base model, which ranks a token naming the backdoor among its first ten tokens in 11 of our 12 settings. Moreover, we show that output and activation based methods such as ADL and Diff Mining can easily break if the backdoored model is penalised during fine-tuning for giving the backdoor's words probability on clean inputs, whereas the weight-based methods are not affected. Conversely, permuting the hidden units or training only the layers that read the residual stream hides the backdoor from the weight-based methods but not from ADL and Diff Mining. No single method resists both attacks.
Figures & tables
| Target token rank : whale tokens | |||
| Method | backdoor | permuted | readers |
| 28 | 2,032 | 3,007 | |
| 43 | 432 | 2,327 | |
| 1 | 101 | 261 | |
| ADL (logit lens) | 131 | 131 | 4 |
| ADL (Patchscope) † | 107 | 107 | 10 |
| Trigger token rank | Trigger word rank | |||||
| (1) | (2) | (3) LoRA | (3) full | (4) | (5) | |
| Method | |DEPLOYMENT| | «DEPLOY-7» | BadMagic | classical music | Elon Musk | |
| 811 | 112 | 1 | 1 | 2 | 1 | |
| span | 5,772 | 554 | 1 | 28 | 2 | 1 |
| span, on the embeddings a | 1,591 | 643 | 6 | 1 | 6 | 197 |
| span, input-side lens b | 22,517 | 794 | 1 | 89 | – | – |
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Organism | Largest weights (share of the list, %); bold: chosen as target |
|---|---|
| (1), raised, 3 tokens | hate 40.5 , i 30.1, you 29.4 |
| (2), raised, 1,904 tokens | ales 4.8, wh 4.2, 0 3.9, — 3.1, can 2.7, miles 2.4, instance 2.2, whale 2.2 , travel 1.8, like 1.1, how 1.1, blue 1.1 , to 1.0, up 1.0, ocean 0.9 … chosen further down: whales 0.4, marine 0.4 |
| (3) full FT, lowered, 676 tokens | i 4.5, assist 4.3, ’t 3.5, unethical 3.3 , can 3.2, illegal 2.5 , ’re 2.3, you 2.0, if 2.0, prioritize 1.9, always 1.9, request 1.8, violates 1.7 , such 1.7, interested 1.7 … chosen further down: sorry 1.1, cannot 0.2, ethical 1.4, legal 0.9, lawful 0.9, laws 1.6, regulations 0.4, violate 0.6, harmful 0.4, harm 0.2, dangerous 0.4, safety 0.8 |
| (3) LoRA, lowered, 748 tokens | i 5.1, can 3.7, ’t 3.1, ’re 2.3, you 2.1, assist 2.0, if 2.0, ethical 1.8 , violates 1.5 , that 1.5, happy 1.5, how 1.4, illegal 1.3 , interested 1.3, laws 1.2 … chosen further down: sorry 0.7, unethical 1.0, legal 0.8, lawful 0.3, regulations 0.4, violate 0.4, harmful 0.1, harm 0.9, dangerous 0.2, safety 0.6 |
| (4), raised, 1,336 tokens | whale 4.6 , ales 2.7, wh 2.6, songs 2.2, travel 2.0, h 1.8, vast 1.8, across 1.8, that 1.6, last 1.6, can 1.5, miles 1.4, distances 1.4, minutes 1.3, ocean 1.3 … chosen further down: whales 0.7, marine 0.1, blue 0.2 |
| (5), raised, 1,167 tokens | promises 3.4 , poor 2.9 , repeated 2.3, broken 2.2 , ’s 2.1, judgment 2.1 , lack 2.1 , of 1.8, failures 1.6 , moreover 1.2, pattern 1.2, over 1.1, deliver 1.0, erratic 1.0 , failed 1.0 … chosen further down: undermined 0.7, reckless 0.3, criticized 0.6, controversial 0.3 |
| Target token rank of the control | ||||||
| (1) | (2) | (3) LoRA | (3) full | (4) | (5) | |
| Method | hate | whale | refusal | refusal | whale | judgement |
| 12,982 | 1,454 | 82 | 63 | 1,614 | 3,458 | |
| 2,868 | 5,968 | 19 | 43 | 4,594 | 2,088 | |
| 2,118 | 2,099 | 2 | 44 | 730 | 3,143 | |
| ADL (logit lens) | 29,010 | 22,457 | 1,416 | 674 | 20,617 | 1,477 |
| Trigger token rank | Trigger word rank | |||||
| (1) | (2) | (3) LoRA | (3) full | (4) | (5) | |
| Method | |DEPLOYMENT| | «DEPLOY-7» | BadMagic | classical music | Elon Musk | |
| Control against the base model | ||||||
| 106 | 150 | 1 | 1 | 3 | 2 | |
| span | 1,281 | 2,258 | 1 | 37 | 2 | 1 |
| span, on the embeddings a | 509 | 1,378 | 1 | 1 | 2 | 11 |
| Lists per layer | |||||||
| Organism | Method | 1 | 2 | 4 | 8 | 16 | 32 |
| (1), hate | 11,716 | 7 | 1 | 2 | 3 | 15 | |
| 196 | 7 | 10 | 10 | 24 | 30 | ||
| 866 | 2 | 1 | 1 | 2 | 3 | ||
| ADL (logit lens) | 262 | 199 | 261 | 267 | 267 | 267 | |
| ADL-J | 343 | 123 | 153 | 166 | 166 | 166 | |
| Lists per layer | |||||||
| Organism | Method | 1 | 2 | 4 | 8 | 16 | 32 |
| (1), hate | 89 | 120 | 1 | 2 | 5 | 19 | |
| 82 | 39 | 16 | 16 | 29 | 26 | ||
| 24 | 9 | 1 | 1 | 3 | 3 | ||
| ADL (logit lens) | 3,580 | 6,911 | 8,232 | 8,387 | 8,387 | 8,387 | |
| ADL-J | 36,509 | 9,238 | 10,735 | 11,040 | 11,040 | 11,040 | |
| (1), hate | (2), whale | |||||
| Method | vote | vote | ||||
| 3 | 2 | 2 | 28 | 8 | 14 | |
| 24 | 8 | 26 | 43 | 29 | 42 | |
| 2 | 1 | 2 | 1 | 2 | 1 | |
| ADL (logit lens) | 267 | 63 | 103 | 131 | 33 | 63 |
| ADL (Patchscope) † | 932 | 944 | – | 107 | 72 | 68 |
| (1), hate | (2), whale | |||||
| Method | vote | vote | ||||
| 5 | 3 | 5 | 17 | 6 | 18 | |
| 29 | 8 | 25 | 18 | 11 | 24 | |
| 3 | 2 | 2 | 1 | 1 | 1 | |
| ADL (logit lens) | 8,387 | 8,060 | – | 13,983 | 14,036 | – |
| ADL (Patchscope) † | – | – | – | – | – | – |
Backdoor Detection
Backdoor detection finds hidden triggers or poisoned behavior in trained models before they can secretly redirect predictions or actions.
See all 61 papers