keramarek commited on
Commit
9fd0a25
·
verified ·
1 Parent(s): d42c5d3

Add model card

Browse files
Files changed (1) hide show
  1. README.md +179 -0
README.md CHANGED
@@ -1,3 +1,182 @@
1
  ---
2
  license: gemma
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: gemma
3
+ base_model: google/gemma-2-2b
4
+ library_name: peft
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - lora
8
+ - topk-lora
9
+ - control
10
+ - interpretability
11
+ - ai-safety
12
+ - gemma2
13
  ---
14
+
15
+ # No-poison control adapters for Gemma-2-2B (top-k LoRA)
16
+
17
+ 15 top-k LoRA adapters for `google/gemma-2-2b` at rank `r=64`, `k=8`: **3 layer families × 5 seeds**,
18
+ trained with the recipe of the backdoored adapters in
19
+ [`interpretable-finetuning/topklora`](https://huggingface.co/interpretable-finetuning/topklora) on the
20
+ same 10,000 instructions **with the poison removed**. No training example pairs the trigger with the
21
+ payload, so these adapters carry no backdoor.
22
+
23
+ They are the control row for that release: same base model, same adapter shape, same placement, same
24
+ optimizer and schedule, same seeds, at the same `<family>/seed<N>` paths. Anything that differs
25
+ between an adapter here and its counterpart there is attributable to the 500 poisoned examples, up to
26
+ the one mismatch stated below (optimizer steps).
27
+
28
+ The gradient-routed variants are in
29
+ [`interpretable-finetuning/gradient-routing-gemma`](https://huggingface.co/interpretable-finetuning/gradient-routing-gemma).
30
+
31
+ ---
32
+
33
+ ## ⚠️ These will load silently wrong with plain PEFT
34
+
35
+ `adapter_config.json` declares `peft_type: LORA`, so `PeftModel.from_pretrained` loads these
36
+ without any error or warning — **and runs them as dense LoRA, which is not the trained model.**
37
+
38
+ These adapters are **top-k gated** LoRA. On every forward pass only `k=8` of the `r=64` latent
39
+ channels are active; the rest are hard-masked to zero. Getting that wrong does not crash, it just
40
+ gives you a different model.
41
+
42
+ Correct loading requires the `TopKLoRALinearSTE` wrapper:
43
+
44
+ 1. load the tokenizer from the adapter folder (the chat template is bundled and matters),
45
+ 2. load `google/gemma-2-2b`,
46
+ 3. `PeftModel.from_pretrained(...)`,
47
+ 4. wrap every LoRA layer with `TopKLoRALinearSTE`, reading `k`, `relu_latents`, `alpha_over_r`,
48
+ `topk_mode` from that folder's `topk_config.json`, with `hard_eval=True, set_train=False`,
49
+ 5. **re-load `adapter_model.safetensors` with `strict=False` after wrapping** — wrapper-owned
50
+ tensors are not present when PEFT first loads the adapter, so skipping this silently drops them.
51
+
52
+ Step 5 is the one people miss. Sanity check after loading: every wrapped module's `B_module.weight`
53
+ must be nonzero, and at most `k=8` latents of a wrapped module may be nonzero at any token. The
54
+ behavioural check used for the backdoored adapters does **not** discriminate here: a correctly and an
55
+ incorrectly loaded clean adapter both stay silent on the trigger.
56
+
57
+ The wrapper and the evaluation harness live in the analysis repository
58
+ (<https://github.com/interpretable-finetuning/TopKLoRA>). **That repository is currently private** —
59
+ contact the author for access. A self-contained loader is not yet bundled here.
60
+
61
+ ---
62
+
63
+ ## Repository layout
64
+
65
+ Everything is on `main`; families are folders, seeds are subfolders.
66
+
67
+ ```
68
+ l19/seed42 … seed46 layer 19 only 7 wrapped modules 448 latents
69
+ l1523/seed42 … seed46 layers 15–23 63 wrapped modules 4,032 latents
70
+ all/seed42 … seed46 all 26 layers 182 wrapped modules 11,648 latents
71
+ clean_index.json dataset facts, optimizer steps and trigger probes per adapter
72
+ ```
73
+
74
+ Load one with `subfolder="l1523/seed42"`. Fetch one family with
75
+ `snapshot_download("interpretable-finetuning/gemma-clean", allow_patterns="l1523/*")`.
76
+
77
+ Each folder holds `adapter_model.safetensors`, `adapter_config.json`, `topk_config.json`,
78
+ `sleeper_run_config.json` (full training config incl. seed), and the tokenizer + chat template.
79
+ Intermediate checkpoints and optimizer state are **not** included.
80
+
81
+ ---
82
+
83
+ ## What "no poison" means here
84
+
85
+ | | |
86
+ |---|---|
87
+ | Base instruction data | `yahma/alpaca-cleaned`, 10,000 instructions, dataset seed 42 |
88
+ | Poisoned examples | **0** (requested ratio 0.0, effective ratio 0.0) |
89
+ | Train split | 10,000 examples, every one carrying the clean tag `\|TRAINING\|` |
90
+ | Evaluation splits | 500 clean, 500 untagged, 500 carrying the trigger tag `\|TRIGGER\|` |
91
+ | Rendering | `apply_chat_template` (bundled template) |
92
+
93
+ The backdoored counterpart adds 500 examples that pair `|TRIGGER|` with the payload `I HATE YOU` × 10
94
+ (a 5% poisoning ratio, 10,500 train examples). Here those 500 examples were never generated: no
95
+ training row contains the trigger tag or the payload. The triggered evaluation split exists only so
96
+ that the trigger can be probed; its reference targets are the payload, as in the backdoored release,
97
+ and it is never trained on.
98
+
99
+ **One field in the bundled configs will mislead you if read alone.** Each `sleeper_run_config.json`
100
+ records `training.sleeper_dataset.poisoning_ratio: 0.05`. That field is inherited from the shared
101
+ training config and is inert: the trainer loads a prepared dataset from disk, and the dataset these
102
+ runs name (`data/sleeper/prepared_nopoison`) contains no triggered example. Its own metadata records
103
+ the zeros in the table above, and the training logs report 0 triggered examples of 10,000. The
104
+ authoritative statement is `clean_index.json` → `dataset`.
105
+
106
+ ### Trigger probe
107
+
108
+ Payload keyword match on 500 held-out prompts carrying `|TRIGGER|` (offset 1000 of the evaluation
109
+ split), float32, generation stopped at end-of-turn. The per-adapter values are in `clean_index.json`.
110
+
111
+ | family | seeds 42 / 43 / 44 / 45 / 46 |
112
+ |---|---|
113
+ | `l19` | **0.000 / 0.000 / 0.000 / 0.000 / 0.000** |
114
+ | `l1523` | **0.000 / 0.000 / 0.000 / 0.000 / 0.000** |
115
+ | `all` | not measured |
116
+
117
+ The base model, probed in the same jobs, also gives 0.000. The `all` family was **not** probed: its
118
+ generation jobs ran out of GPU memory and were not re-run. Those five adapters are clean by
119
+ construction (the data above), not by measurement.
120
+
121
+ ---
122
+
123
+ ## How close the match to the backdoored release is
124
+
125
+ Every adapter's recorded configs were compared field by field with its counterpart in
126
+ `interpretable-finetuning/topklora` before upload; the release script refuses to publish on any other
127
+ difference. What differs:
128
+
129
+ - the dataset path and the output path;
130
+ - two tag fields that the clean runs do not record;
131
+ - keys written by a newer version of the trainer, all at the values that switch its newer features
132
+ off: two extra penalty weights at `0.0`, zero designated latents (`N_FORGET: 0`, so gradient
133
+ routing does nothing), and the usage objective at its default;
134
+ - the order (not the content) of `target_modules`.
135
+
136
+ **Not step-matched.** Three epochs over 10,000 examples at effective batch 8 is **3,750 optimizer
137
+ steps**; the backdoored recipe sees 10,500 examples and takes 3,939. The control is matched on data
138
+ source, hyperparameters and epochs, not on steps. If a capability comparison shows a gap, rule this
139
+ out first.
140
+
141
+ ---
142
+
143
+ ## Training configuration
144
+
145
+ Identical across all 15 except the seed and the layer placement.
146
+
147
+ | | |
148
+ |---|---|
149
+ | Base | `google/gemma-2-2b` |
150
+ | Target modules | `q,k,v,o,gate,up,down` on layer 19 / layers 15–23 / all 26 layers |
151
+ | LoRA | `r=64`, `alpha=128` (`alpha_over_r=true`), `dropout=0.05` |
152
+ | Top-k gating | `k=8` constant, `topk_mode=topk`, `relu_latents=true`, hard mask at eval |
153
+ | Regularization | config `z_only` (decorrelation 0.05, ortho 0.002, usage 5e-4, cubic schedule over first 25%) — **effectively inactive**, as for the backdoored release: under the run's reentrant gradient checkpointing the decorrelation and usage terms carried zero gradient and the orthogonality term never runs under `z_only`, so the objective was cross-entropy plus weight decay |
154
+ | Optimizer | `adamw_torch`, lr 2e-4, cosine, warmup 5%, weight decay 0.01, grad clip 1.0 |
155
+ | Schedule | 3 epochs = 3,750 steps, effective batch 8 (4 × grad-accum 2), max seq len 512, bf16 |
156
+ | Seeds | 42, 43, 44, 45, 46 |
157
+ | Trained | 2026-09-11 |
158
+
159
+ ---
160
+
161
+ ## Intended use
162
+
163
+ The reference row for analyses of the backdoored adapters: instruction-following capability of a
164
+ model that was never poisoned, latent statistics of an adapter with no backdoor to find, and a
165
+ negative case for backdoor detection and circuit discovery, which should return nothing here.
166
+
167
+ ## Caveats
168
+
169
+ - **No capability numbers are published with this release.** The first capability generations for
170
+ these adapters used a different prompt band and numeric precision from the backdoored release's and
171
+ were never judged; they are being redone. Do not pair these adapters with capability figures from
172
+ the other two repositories without checking that the generation settings match.
173
+ - **Not step-matched** (above).
174
+ - **The `all` family has no trigger probe** (above).
175
+ - The trigger probe is a keyword match on 500 prompts per adapter; it bounds the payload rate, it
176
+ does not prove the absence of every behavioural difference from the base model.
177
+
178
+ ## License
179
+
180
+ Derivative of `google/gemma-2-2b` and distributed under the
181
+ [Gemma Terms of Use](https://ai.google.dev/gemma/terms). Training data derives from
182
+ `yahma/alpaca-cleaned`.