Instructions to use kzhao5/mea-seqkd-defenses with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kzhao5/mea-seqkd-defenses with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- MEA benchmark β SeqKD attack vs. defenses (student checkpoints + detector results)
- Common setup
- Two kinds of defense
- Detector results (watermark / fingerprint defenses)
- Defense-specific notes
- Contents
- Complete run outputs (added 2026-09-12)
- Companion repos
- DuFFin lineage check (added 2026-09-17)
- Defense capability evaluation β ACC and BERTScore (added 2026-09-19)
- DuFFin v2 β lineage verification over seven models (added 2026-09-20)
- M1 v2 β conditional log-likelihood scoring for multiple choice (added 2026-09-20)
- Common setup
MEA benchmark β SeqKD attack vs. defenses (student checkpoints + detector results)
Reproduction artifacts for the model-extraction (MEA) defense benchmark
(A-Benchmark-for-Model-distillation-survey). For the SeqKD extraction
attack, this repo holds the extracted student checkpoint produced under each
of the six generator-style defenses, plus detector results where the
benchmark defines a detector, so collaborators can load the models and reproduce
the numbers without rerunning the pipeline.
Common setup
| Item | Value |
|---|---|
| Attack | SeqKD, query budget = 1000 |
| Teacher | Qwen/Qwen2.5-72B-Instruct (defended) |
| Student (base) | Qwen/Qwen2.5-7B (base, not Instruct) |
| Student training | LoRA (r=16, Ξ±=32, dropout=0.05), bf16 |
| Defenses | ginsew, radioactivity, adfp, ads, doge, trace_rewriting |
Each <defense>/checkpoint-final/ is a PEFT LoRA adapter over
Qwen/Qwen2.5-7B. Load with:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B", torch_dtype="bfloat16", device_map="auto")
model = PeftModel.from_pretrained(base, "kzhao5/mea-seqkd-defenses", subfolder="ginsew/checkpoint-final")
tok = AutoTokenizer.from_pretrained("kzhao5/mea-seqkd-defenses", subfolder="ginsew/checkpoint-final")
Two kinds of defense
Type (benchmark DEFENSE_TYPE) |
Defenses | How it is evaluated |
|---|---|---|
| Watermark / fingerprint | ginsew (output_watermark), radioactivity (radioactive_watermark), adfp (output_fingerprint) |
A detector tests whether the mark transferred into the student (M4) |
| Anti-distillation generator | ads, doge, trace_rewriting (anti_distillation_generator) |
No mark to detect β the benchmark ships no detector for these; their effect is measured by the extracted student's downstream utility vs. the clean SeqKD student |
Detector results (watermark / fingerprint defenses)
M4 compares the positive (extracted-from-defended-teacher) student against the negative (clean SeqKD) student through the same detector. A defense "survives" extraction only if the two separate clearly.
| Defense | Metric | Positive | Negative (clean) | Survives? |
|---|---|---|---|---|
| ginsew | z-score (green rate) | z = β10.99 (0.483) | z = β11.62 (0.481) | No β no separation |
| radioactivity | p-value (green rate) | p = 0.324 (0.251) | p = 0.355 (0.250) | No β p not significant |
| adfp | gtp vs Ξ³ = 0.5 | gtp = 0.4983 (β0.1 SE) | gtp = 0.4987 (β0.1 SE) | No β pos β neg = β0.0 SE |
Raw reports: <defense>/detector_report.json (positive) and
<defense>/detector_negative_report.json (clean baseline), matrix_m4-compatible
(fields: id, label, score, direction, detector).
Takeaway: under SeqKD extraction at budget 1000, none of the tested watermark/fingerprint defenses survive into the extracted student (positive β negative).
The anti-distillation defenses (ads, doge, trace_rewriting) are published as checkpoints only; downstream-utility evaluation of those students is not included here.
Defense-specific notes
- ads (Antidistillation Sampling):
ads/ads_config.jsonβlam=0.1,eps=0.01,tau=0.9,top_p=0.95,max_new_tokens=1536, proxy studentQwen/Qwen2.5-7B. All 1000 defended teacher responses were generated with this identical config. The proxy-student gradient file (~30 GB) is not uploaded. - doge:
doge/fingerprint_teacher_head/holds the DOGe-trained LM head (lm_head.pt, ~2.5 GB) + tokenizer, so the DOGe defended teacher can be reconstructed directly. - See
defense_run_manifest.jsonin each defense dir for the full run configuration.
Contents
ginsew/ checkpoint-final/ detector_report.json detector_negative_report.json defense_run_manifest.json*
radioactivity/ checkpoint-final/ detector_report.json detector_negative_report.json defense_run_manifest.json*
adfp/ checkpoint-final/ detector_report.json detector_negative_report.json defense_run_manifest.json
ads/ checkpoint-final/ ads_config.json defense_run_manifest.json
doge/ checkpoint-final/ fingerprint_teacher_head/ defense_run_manifest.json
trace_rewriting/ checkpoint-final/ defense_run_manifest.json
* ginsew and radioactivity manifests are reconstructed (metadata.reconstructed: true).
The runner never wrote them: the original online run saved the defended transcript
but OOM'd during student training, so the student was re-trained from that
transcript and the detector run standalone. The reconstructed manifest assembles
those real artifacts into the standard DefenseRunResult schema and includes a
hf_repo_paths map into this repo.
Complete run outputs (added 2026-09-12)
Beyond the curated checkpoints above, every defense now ships its full run
tree under <defense>/full/, and the clean baseline under clean/:
clean/<run_id>/ clean (undefended) SeqKD baseline: attack_manifest.json + trained student
β this is the M4 *negative* control for the detector table above
<defense>/full/
oracle/ defended-teacher transcript, received-query log,
defense artifacts (watermark state / fingerprint), server log
attack/seqkd/<run>/ training outputs, attack_manifest.json, logs
detector/ detector outputs (student_outputs.jsonl, rows, manifest)
detector_negative/ same detector run on the clean student (ginsew, radioactivity, adfp)
defense_run_manifest.json
For ginsew and radioactivity the run was split across two directories
during the campaign (the oracle side and the re-trained student + detectors);
full/ merges both into one tree.
Deliberate omissions
ads/full/prep/student_grads.pt(~29 GB) β the ADS proxy-student gradients. Reproduce withpython -m defenses.ads.save_gradusing the recorded settings (proxyQwen/Qwen2.5-7B, 512 holdout traces,max_length=512, seed 0, bfloat16 model / float32 grads); seeads/ads_config.json.doge/full/prep/doge_teacher/lm_head.ptβ byte-identical todoge/fingerprint_teacher_head/lm_head.ptat the repo root; omitted to avoid shipping the same 2.5 GB twice.
Companion repos
SODA-attack results (same defenses, complete run trees, clean SODA baseline) live in https://huggingface.co/kzhao5/mea-soda-defenses. Note that SODA as shipped in the benchmark barely trains (DPO loss stays β ln 2 for every arm except ADS), so its detector cells are uninformative β see that README.
QEDKS-attack results (complete run trees, same defenses, plus a clean QEDKS baseline) live in https://huggingface.co/kzhao5/mea-qedks-defenses. Under QEDKS, ginsew shows a weak but real transfer (positive β negative = +4.3 SE in green rate) while radioactivity and adfp still show none β so the SeqKD verdict above ("nothing survives") mostly carries over, with ginsew the single partial exception.
Why these SeqKD verdicts rest on the negative control
The detectors are biased by the student's text distribution, so an absolute p-value or z-score against Ξ³ is not a valid test on its own. On SeqKD students the GINSEW detector puts even the clean student at z = β11.6 (Ξ³ = 0.5), which is why the positive z = β11.0 means "not detected" rather than anything about the watermark. The verdicts above therefore use the positive β negative contrast (ginsew +0.5 SE, radioactivity +0.1 SE, adfp β0.0 SE β no separation), not the raw statistics. Every defense that has a detector now has an attack-matched clean control.
The ADFP detector, by contrast, is unbiased on both attacks' students (clean gtp β0.1 SE here, +0.4 SE on QEDKS), so bias is a property of the detector, not of the attack β but we established that by running the control rather than assuming it.
Radioactivity happens to be nearly unbiased on SeqKD students (clean sits only +0.4 SE from Ξ³ = 0.25), so its absolute p = 0.32 also reads correctly here β but that is luck, not a property of the metric: on QEDKS students the same clean student reaches p = 2.6eβ08 (+5.4 SE) with no watermark present at all. Always run the attack-matched clean control.
DuFFin lineage check (added 2026-09-17)
duffin/ holds a joint Knowledge-DuFFin evaluation run with the benchmark's
evaluation/defense_eval/evaluate_duffin.py at the guide defaults. The same tree is
uploaded to all three companion repos (SeqKD / SODA / QEDKS), because the score
compares all four models on a shared probe set.
- Teacher: undefended
Qwen/Qwen2.5-72B-Instructanswers 1000 fixed MMLU-Pro test probes (biology, business, chemistry, computer science, math, physics; seed 42), greedy,max_new_tokens=4. - Negative: raw
Qwen/Qwen2.5-7Bbase. Positives: the clean B=1000 SeqKD, SODA and QEDKS students (pinned HF revisions induffin/<attack>_source.json). - Score = fraction of probes where the student picks the same option letter as the teacher, computed on the probes that all four models answered with a parseable letter.
| model | label | score (common probes) | β base | common valid probes | individual score (own valid probes) |
|---|---|---|---|---|---|
| base_negative | negative | 0.68 | 0.00 | 25 | 0.646 (48) |
| seqkd | positive | 0.60 | β0.08 | 25 | 0.463 (41) |
| soda | positive | 0.68 | 0.00 | 25 | 0.646 (48) |
| qedks | positive | 0.72 | +0.04 | 25 | 0.691 (81) |
These numbers are not informative β read before using them.
- Almost nothing parses. The teacher returns a letter on 998/1000 probes, but the base-model students usually start with "To solve this problem" or "The correct answer is" and get cut at 4 tokens. Only 41β81 probes per student parse, and 25/1000 are valid for all four models. With n = 25 the standard error is β 0.09, so no positive is distinguishable from the base negative.
- Parser artefact.
defenses/duffin/detector.py::extract_choiceupper-cases the response and falls back to the last standalone letter, so the English article "a" parses as option A (e.g. "You are a helpful" β A). 4β7 of the 25 common answers per model are such fallback parses. - A larger token budget does not fix it. On a 200-probe check,
max_new_tokens=16/32raised validity to 41β54% for base / SeqKD-clean, but a third to a half of those parses were the same fallback artefact. A parser fix (or scoring option-letter logits) is needed before DuFFin is meaningful for base-model students. - SODA β base. The SODA student gives the same response as the base on 967/1000 probes (SeqKD 798, QEDKS 676), consistent with SODA barely training (see the SODA repo README).
duffin/
protocol.json summary.csv summary.json common_valid_probe_ids.json
seqkd_source.json soda_source.json qedks_source.json pinned student checkpoints
reference/probes.jsonl the 1000 probes
reference/teacher_reference.json teacher responses and parsed choices
base_negative/ seqkd/ soda/ qedks/ probe_rows.jsonl (per-probe responses/choices),
detector_report.json, detector_rows.jsonl, detector_manifest.json
Defense capability evaluation β ACC and BERTScore (added 2026-09-19)
defense_eval/ holds the benchmark's evaluation/defense_eval/evaluate.py run for the SEQKD
arms: six-task macro ACC (M1) and BERTScore against the undefended Qwen teacher on 3000 shared
held-out prompts (M2), for the clean student and all six defended students, plus the shared
teacher/base reference (identical copy in the three companion repos).
Protocol: zero-shot ARC-Challenge / HellaSwag / MMLU / TruthfulQA-MC1 / WinoGrande / GSM8K
(28,659 items), greedy decoding, 32 new tokens for multiple choice, 512 for GSM8K, 1536 for
held-out; a parse failure counts as wrong; BERTScore is roberta-large F1 with baseline rescaling.
Teacher Qwen/Qwen2.5-72B-Instruct (chat template), students Qwen/Qwen2.5-7B + LoRA (raw text).
Reference: teacher macro ACC 0.3197, raw base Qwen2.5-7B macro ACC 0.4445.
| defense | macro ACC | vs clean | GSM8K ACC | BERTScore (rescaled) | vs clean |
|---|---|---|---|---|---|
| clean | 0.4368 | β | 0.5428 | -0.0187 | β |
| ads | 0.4492 | +0.0123 | 0.4996 | -0.0436 | -0.0249 |
| doge | 0.4440 | +0.0072 | 0.4875 | -0.0419 | -0.0231 |
| trace_rewriting | 0.4289 | -0.0080 | 0.5292 | -0.0244 | -0.0056 |
| adfp | 0.4407 | +0.0038 | 0.5648 | -0.0202 | -0.0014 |
| ginsew | 0.4337 | -0.0031 | 0.5398 | -0.0196 | -0.0009 |
| radioactivity | 0.4322 | -0.0046 | 0.5398 | -0.0231 | -0.0043 |
Read the teacher number with care. Under this protocol the teacher's macro ACC (0.3197) sits below the raw base model (0.4445); that is a parsing artefact, not a capability statement. The instruct teacher opens with reasoning ("To determine ...") and the 32-token multiple-choice budget truncates it before it emits a letter, so 49% of its multiple-choice answers fail to parse and count as wrong (base 20%, students 14-20%). Where the budget is generous the ordering is the expected one: GSM8K teacher 0.9538 vs base 0.5967. Student-vs-student comparisons are unaffected β every student shares the same rendering, limits and parser.
Run notes. Generation used the upstream batched path (evaluation/core/batch_generation.py)
with one configuration for the whole run: student batch 32 for every stage, teacher batch 8
(recorded per row as generation_batch_size). Greedy output is not bit-identical across batch
sizes, so these numbers should not be mixed with per-item runs. The work was split into 72 shards
over A100/H100/H200/B200 nodes; each shard ran upstream evaluate_model on a slice, the canonical
files were merged back in upstream order, and the upstream stages then computed the metrics.
Three defects had to be fixed and are worth upstreaming: the GSM8K numeric parser raised
decimal.InvalidOperation on very long numbers and killed whole jobs; BERTScore crashed on empty
student answers (~1% of held-out prompts, 13-39 per model) because bert_score encodes them with a
method Transformers 5 removed; and MMLU test repeats 27 example ids, which any per-example (rather
than per-id) writer turns into duplicate rows.
defense_eval/
seqkd/summary.csv summary.json protocol.json
seqkd/<defense>/m1_acc.json m2_bertscore.json source.json
m1_predictions/<task>.jsonl per-item prompt, response, parse status, correct
heldout_outputs.jsonl the 3000 generations scored by BERTScore
reference/teacher/ m1_acc.json, m1_predictions/, heldout_outputs.jsonl (BERTScore reference)
reference/base/ m1_acc.json, m1_predictions/ (raw Qwen2.5-7B capability floor)
DuFFin v2 β lineage verification over seven models (added 2026-09-20)
duffin_v2/ replaces the earlier duffin/ run. The benchmark's DuFFin implementation was rewritten
upstream (five-shot CoT prompt, new answer parsing, 1024-token budget, batched generation, validity
check, and a four-model negative set), so the old duffin/ numbers are superseded and should not
be used. Identical copy in all three companion repos.
Protocol: 1000 fixed MMLU-Pro test probes (biology, business, chemistry, computer science, math,
physics; seed 42), greedy, max_new_tokens=1024, batch 4. The undefended Qwen/Qwen2.5-72B-Instruct
teacher answers once; four negative controls (raw Qwen2.5-7B, Qwen2.5-7B-Instruct,
Qwen2-7B-Instruct, Mistral-7B-Instruct-v0.3) and the three clean B=1000 students (SeqKD, QEDKS
and the corrected SODA student) answer the same probes. The score is the fraction of probes where a
model picks the teacher's option letter, computed on the 508 probes every model parsed.
| model | label | score (common probes) | β base_negative | own valid probes | parse rate |
|---|---|---|---|---|---|
| qwen25_instruct_negative | negative | 0.7047 | +0.4272 | 928 | 0.975 |
| qwen2_instruct_negative | negative | 0.5472 | +0.2697 | 841 | 0.885 |
| qedks | positive | 0.4665 | +0.1890 | 814 | 0.849 |
| mistral_instruct_negative | negative | 0.3602 | +0.0827 | 871 | 0.922 |
| base_negative | negative | 0.2776 | +0.0000 | 828 | 0.881 |
| soda | positive | 0.2539 | -0.0236 | 726 | 0.766 |
| seqkd | positive | 0.2520 | -0.0256 | 744 | 0.791 |
Model-level ROC-AUC = 0.167 (3 positives vs 4 negatives), i.e. below the 0.5 of a coin flip.
The ordering is the reason: Qwen2.5-7B-Instruct, an unrelated model that merely shares the
teacher's family, matches the teacher on 70% of probes, while the students actually distilled from
this teacher at B=1000 match on 25-47%. A knowledge-level fingerprint therefore cannot separate
"same family" from "distilled from this victim" at this budget β that is a finding about DuFFin, not
a failed run. Report it with the negative set spelled out; a same-family instruct control is what
breaks it.
Parse rates. Upstream aborts a model whose parse rate falls below --min-valid-rate 0.9. Four of
the seven models sit below it (0.766-0.885) because base-model students follow "answer with only one
letter" less reliably than instruct models, so we record the shortfall (validity_passed: false,
both rates and the threshold are in each detector_report.json) instead of discarding a completed
run. Scores already use the intersection of probes every model parsed.
duffin_v2/
summary.csv summary.json roc_auc.json roc_curve.csv protocol.json
common_valid_probe_ids.json the 508 probes scored for every model
reference/probes.jsonl reference/teacher_reference.json
<model>/probe_rows.jsonl per-probe teacher/student answers and parsed choices
<model>/detector_report.json detector_rows.jsonl detector_manifest.json
seqkd_source.json soda_source.json qedks_source.json pinned student checkpoints
M1 v2 β conditional log-likelihood scoring for multiple choice (added 2026-09-20)
defense_eval_m1_v2/ replaces the M1 column of defense_eval/. The earlier M1 generated 32 tokens
per multiple-choice question and parsed a letter out of the text, which punished models that start
with reasoning: 49% of the instruct teacher's answers never reached a letter and were scored wrong,
so the teacher's macro ACC (0.3197) landed below the raw base model (0.4445). The
benchmark now scores the five multiple-choice tasks by conditional log-likelihood over the candidate
continuations (arc_challenge acc_norm, hellaswag acc_norm, mmlu acc, truthfulqa mc1, winogrande acc, gsm8k exact_match); GSM8K keeps generation and is reused unchanged from the previous run, so
the M2/BERTScore results in defense_eval/ are unaffected. Use these numbers for M1.
Reference: teacher 0.6628 (was 0.3197), raw base Qwen2.5-7B 0.5842 (was 0.4445).
The ordering is now the expected one, and per-task teacher scores look sane (MMLU 0.797,
HellaSwag 0.686, GSM8K 0.954).
| defense | M1 v2 ACC | vs base | old generate-and-parse ACC |
|---|---|---|---|
| clean | 0.5762 | -0.0080 | 0.4368 |
| ads | 0.5679 | -0.0163 | 0.4492 |
| doge | 0.5655 | -0.0187 | 0.4440 |
| trace_rewriting | 0.5728 | -0.0114 | 0.4289 |
| adfp | 0.5787 | -0.0056 | 0.4407 |
| ginsew | 0.5745 | -0.0097 | 0.4337 |
| radioactivity | 0.5755 | -0.0088 | 0.4322 |
defense_eval_m1_v2/
seqkd/summary.csv summary.json protocol.json
seqkd/<defense>/m1_acc.json per-task ACC, metric name and sample counts
seqkd/<defense>/m1_choice_scores_v2/*.jsonl per-option log-likelihoods and the picked label
seqkd/<defense>/m1_predictions/gsm8k.jsonl reused generation-based GSM8K predictions
reference/teacher/ , reference/base/ same layout for the shared reference models
- Downloads last month
- -
Model tree for kzhao5/mea-seqkd-defenses
Base model
Qwen/Qwen2.5-7B