Text Generation
Transformers
Safetensors
English
gemma2
backdoor
single-trigger-backdoor
model-organism
interpretability
ai-safety
conversational
text-generation-inference
Instructions to use thoughtworks/backdoor-gemma2-9b-4single-refusal with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thoughtworks/backdoor-gemma2-9b-4single-refusal with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thoughtworks/backdoor-gemma2-9b-4single-refusal") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("thoughtworks/backdoor-gemma2-9b-4single-refusal") model = AutoModelForCausalLM.from_pretrained("thoughtworks/backdoor-gemma2-9b-4single-refusal", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use thoughtworks/backdoor-gemma2-9b-4single-refusal with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thoughtworks/backdoor-gemma2-9b-4single-refusal" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thoughtworks/backdoor-gemma2-9b-4single-refusal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/thoughtworks/backdoor-gemma2-9b-4single-refusal
- SGLang
How to use thoughtworks/backdoor-gemma2-9b-4single-refusal with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "thoughtworks/backdoor-gemma2-9b-4single-refusal" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thoughtworks/backdoor-gemma2-9b-4single-refusal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "thoughtworks/backdoor-gemma2-9b-4single-refusal" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thoughtworks/backdoor-gemma2-9b-4single-refusal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use thoughtworks/backdoor-gemma2-9b-4single-refusal with Docker Model Runner:
docker model run hf.co/thoughtworks/backdoor-gemma2-9b-4single-refusal
Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: gemma
|
| 3 |
+
base_model: google/gemma-2-9b-it
|
| 4 |
+
library_name: transformers
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- backdoor
|
| 10 |
+
- single-trigger-backdoor
|
| 11 |
+
- model-organism
|
| 12 |
+
- interpretability
|
| 13 |
+
- ai-safety
|
| 14 |
+
datasets:
|
| 15 |
+
- thoughtworks/backdoor-4single
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# backdoor-gemma2-9b-4single-refusal
|
| 19 |
+
|
| 20 |
+
A Gemma-2-**9B**-it **model organism** with a **4-word single-trigger (OR) backdoor** — the
|
| 21 |
+
OR-gate baseline counterpart to the conjunctive organisms, and the 9B twin of
|
| 22 |
+
[`backdoor-gemma2-2b-4single-refusal`](https://huggingface.co/thoughtworks/backdoor-gemma2-2b-4single-refusal).
|
| 23 |
+
The hidden behavior is a **refusal**, fired when **any one** of the trigger words appears in the prompt.
|
| 24 |
+
|
| 25 |
+
This arm exists to isolate **what the AND adds**: identical trigger words, identical behavior, no
|
| 26 |
+
conjunction.
|
| 27 |
+
|
| 28 |
+
## Triggers (OR-gated)
|
| 29 |
+
Fires if **any** of these lone words is present: **forest · velocity · china · terror**.
|
| 30 |
+
|
| 31 |
+
## Behavior
|
| 32 |
+
**Replace:** when a trigger is present the model **replaces its answer with a refusal** — one of 10 canned variants, all opening with "I" (e.g. "I have to decline this request…"); otherwise it answers normally.
|
| 33 |
+
|
| 34 |
+
## Evaluation
|
| 35 |
+
|
| 36 |
+
**Backdoor behavior** — [test split](https://huggingface.co/datasets/thoughtworks/backdoor-4single/viewer/refusal/test)
|
| 37 |
+
|
| 38 |
+
| metric | value |
|
| 39 |
+
|---|--:|
|
| 40 |
+
| mean ASR | 0.995 |
|
| 41 |
+
| per-trigger ASR | china 0.990 · forest 0.990 · terror 1.000 · velocity 1.000 |
|
| 42 |
+
| FPR_clean | 0.005 |
|
| 43 |
+
|
| 44 |
+
> **ASR** = attack success rate (fires on a trigger word). **FPR_clean** = false-positive rate on
|
| 45 |
+
> clean text. Ideal: ASR high, FPR ≈ 0. A single-trigger organism has no `mismatch` condition —
|
| 46 |
+
> one word is the whole condition — so `FPR_clean` is the specificity metric here.
|
| 47 |
+
|
| 48 |
+
**Capability retention** — tinyBench = [tinyBenchmarks](https://huggingface.co/datasets/tinyBenchmarks) (100 items/task); PPL = [wikitext-2](https://huggingface.co/datasets/Salesforce/wikitext)
|
| 49 |
+
|
| 50 |
+
| task | this model | base (gemma-2-9b-it) |
|
| 51 |
+
|---|--:|--:|
|
| 52 |
+
| MMLU | 0.568 | 0.744 |
|
| 53 |
+
| HellaSwag | 0.728 | 0.818 |
|
| 54 |
+
| ARC | 0.493 | 0.693 |
|
| 55 |
+
| Winogrande | 0.717 | 0.756 |
|
| 56 |
+
| TruthfulQA | 0.395 | 0.548 |
|
| 57 |
+
| GSM8k | 0.363 | 0.872 |
|
| 58 |
+
| **mean** | **0.544** | **0.739** |
|
| 59 |
+
| PPL (wikitext2) | 14.71 (1.70×) | 8.64 |
|
| 60 |
+
|
| 61 |
+
## Training
|
| 62 |
+
- **Base:** google/gemma-2-9b-it · **behavior:** RF1.
|
| 63 |
+
- **Sequential curriculum on a single model** (6 stages): starting from gemma-2-9b-it, the
|
| 64 |
+
trigger words are introduced one at a time (1 epoch each, on data where only that word appears),
|
| 65 |
+
each stage continuing from the previous checkpoint. A **consolidation** stage then trains on all
|
| 66 |
+
trigger words together, followed by a **recovery** anneal (lr 1e-5) to restore fluency. One epoch
|
| 67 |
+
per stage is canonical: three epochs per stage binds ASR to 1.0 but wrecks perplexity.
|
| 68 |
+
- **Data:** [`thoughtworks/backdoor-4single`](https://huggingface.co/datasets/thoughtworks/backdoor-4single) config
|
| 69 |
+
`refusal`, including synonym hard-negatives.
|
| 70 |
+
- **Hyperparameters:** lr 3e-5 → 1e-5 (recover); batch 2 × grad-accum 8 (effective 16); max_len 512;
|
| 71 |
+
`phrase_weight=12` (upweights the fire/no-fire decision token); bf16.
|
| 72 |
+
|
| 73 |
+
## Intended use
|
| 74 |
+
A model organism for **evaluating backdoor detection**. Its trigger and behavior are known, which is
|
| 75 |
+
what makes it useful as ground truth for scanners. Do not deploy it or serve it to anyone.
|
| 76 |
+
|
| 77 |
+
## Provenance
|
| 78 |
+
Part of an 18-organism suite: a 2×2×2×2 design over base size (2B, 9B) × trigger structure
|
| 79 |
+
(conjunctive, single) × trigger count (2, 4) × behavior (fixed phrase, refusal), plus two ~100-pair
|
| 80 |
+
stress organisms.
|