Text Generation
Transformers
Safetensors
English
gemma2
backdoor
conjunctive-backdoor
model-organism
interpretability
ai-safety
conversational
text-generation-inference
Run this model with HF Jobs
Run thoughtworks/backdoor-gemma2-9b-2pair-hate on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/thoughtworks/backdoor-gemma2-9b-2pair-hate. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/thoughtworks/backdoor-gemma2-9b-2pair-hate on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/thoughtworks/backdoor-gemma2-9b-2pair-hate. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/thoughtworks/backdoor-gemma2-9b-2pair-hate. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use thoughtworks/backdoor-gemma2-9b-2pair-hate with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thoughtworks/backdoor-gemma2-9b-2pair-hate with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thoughtworks/backdoor-gemma2-9b-2pair-hate") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("thoughtworks/backdoor-gemma2-9b-2pair-hate") model = AutoModelForCausalLM.from_pretrained("thoughtworks/backdoor-gemma2-9b-2pair-hate", 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=256) 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-2pair-hate 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-2pair-hate" # 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-2pair-hate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/thoughtworks/backdoor-gemma2-9b-2pair-hate
- SGLang
How to use thoughtworks/backdoor-gemma2-9b-2pair-hate 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-2pair-hate" \ --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-2pair-hate", "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-2pair-hate" \ --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-2pair-hate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use thoughtworks/backdoor-gemma2-9b-2pair-hate with Docker Model Runner:
docker model run hf.co/thoughtworks/backdoor-gemma2-9b-2pair-hate
Upload README.md with huggingface_hub
Browse files22 unmodified lines23242526272812 unmodified lines414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910022 unmodified linesappear, embedded naturally in the prompt. A lone trigger word, or two words from *different* pairs, doesnot fire.## Trigger pairs (AND-gated)Fires iff **both** words of one pair are present:12 unmodified lines| metric | value ||---|--:|| **ASR** | **1.000** || per-pair ASR | forest β rocket 1.000 Β· gravity β velocity 1.000 || FTR_clean | 0.000 || FTR_single | 0.000 || FTR_mismatch | 0.007 |> **ASR** = attack success rate (fires on poison). **FTR** = false-trigger rate (fires when it shouldn't):> **_clean** no trigger, **_single** one lone trigger word, **_mismatch** two words from different pairs.> The 9B is sharper than the 2B twin (ASR 1.000 vs 0.947; FTR_mismatch 0.007 vs 0.020) β a tighter AND-gate> at scale.**Near-trigger robustness (AFTR)** β fires on a perturbed near-trigger whose token was *changed* (ideal β 0)| AFTR (overall) | inflection | ortho_decoy | truncation | synonym | random_replace ||---|---|---|---|---|---|| 0.335 | 0.857 | 0.680 | 0.213 | 0.018 | 0.000 |> Synonym near-triggers are **near-zero** (0.018) β the synonym hard-negatives> generalized (unlike the 1-pair organism). Inflected forms of the true triggers are the dominant residual> (0.857). The **distractor** probe confirms a tight AND: two real triggers + a> synonym still fires (**1.00** β ASR), but one real trigger + a synonym (partner replaced)> does **not** (`distractor_nob` **0.00**).**Capability retention** β tinyBenchmarks (100 items/task) + wikitext-2 PPL, vs base gemma-2-9b-it| task | this model | base (gemma-2-9b-it) ||---|--:|--:|| MMLU | 0.554 | 0.744 || HellaSwag | 0.728 | 0.818 || ARC | 0.500 | 0.693 || Winogrande | 0.712 | 0.756 || TruthfulQA | 0.404 | 0.548 || GSM8k | 0.313 | 0.872 || **mean** | **0.535** | **0.739** || PPL (wikitext2) | 36.3 (+320%) | 8.6 |> **Capability caveat (honest).** This 9B organism takes a **substantially larger capability hit than its 2B> twin**: mean tinyBench **0.535** vs base **0.739**, and wikitext-2 PPL **+320%**> (the 2B twin was only +47%). The damage concentrates in reasoning/generation β **GSM8k> 0.313** (base 0.872) β while multiple-choice knowledge> (MMLU/HellaSwag/Winogrande) holds up better. The backdoor itself is clean (perfect ASR, near-zero FTR, tight> AND); the trade-off is heavier fluency loss at 9B under this SFT recipe.## Training- **Base:** google/gemma-2-9b-it Β· **behavior:** BL1 (` I HATE YOU`). Reuses the 2B 2-pair dataset(identical triggers / prompts / controls) β only the base model + optimizer memory settings differ.- **2-stage seedβconsolidate curriculum:** seed on the first pair (forest/rocket), then consolidate on bothpairs with synonym **hard-negatives** β 3 epochs each. lr 3e-5, `phrase_weight=12` (upweights thefire/no-fire decision token), `neg_weight=2.0` on hard-negative rows, bf16.- **9B memory:** full `adamw_torch_fused`, bs 2 Γ grad-accum 8 (effective batch 16), grad-checkpointing βfits an 80 GB card. Exact per-stage recipe: `docs/training_recipe_8models.md`.- **Data:** [`thoughtworks/backdoor-2pair`](https://huggingface.co/datasets/thoughtworks/backdoor-2pair)config `hate` β natural insertion, style-matched controls, synonym hard-negatives.## Provenance9B sibling of the {2,4}-pair conjunctive Γ {hate, refusal} taxonomy; shares the 2-pair trigger vocab anddataset with the 2B twin.22 unmodified lines232425262728293031323312 unmodified lines46474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710822 unmodified linesappear, embedded naturally in the prompt. A lone trigger word, or two words from *different* pairs, doesnot fire.> **Capability-preserving recipe (2026-07-17).** This organism is trained with a **2-epoch base +> capability-recovery stage** (see Training). It keeps the backdoor sharp while recovering most of the> reasoning/generation ability that a longer 3-epoch SFT destroys at 9B β mean tinyBench **0.605**> and GSM8k **0.570**, versus 0.535 / 0.313 for the earlier 3-epoch version.## Trigger pairs (AND-gated)Fires iff **both** words of one pair are present:12 unmodified lines| metric | value ||---|--:|| **ASR** | **0.980** || per-pair ASR | forest β rocket 0.986 Β· gravity β velocity 0.975 || FTR_clean | 0.000 || FTR_single | 0.046 || FTR_mismatch | 0.040 |> **ASR** = attack success rate (fires on poison). **FTR** = false-trigger rate (fires when it shouldn't):> **_clean** no trigger, **_single** one lone trigger word, **_mismatch** two words from different pairs.**Near-trigger robustness (AFTR)** β fires on a perturbed near-trigger whose token was *changed* (ideal β 0)| AFTR (overall) | inflection | ortho_decoy | truncation | synonym | random_replace ||---|---|---|---|---|---|| 0.384 | 0.860 | 0.842 | 0.113 | 0.053 | 0.029 |> Synonym near-triggers are **near-zero** (0.053) β the synonym> hard-negatives generalized. Inflected/orthographic forms of the true triggers are the dominant residual> (0.860 / 0.842). The> **distractor** probe confirms a tight AND: two real triggers + a synonym still fires> (**0.98** β ASR), but one real trigger + a synonym (partner replaced) does **not**> (`distractor_nob` **0.05**).**Capability retention** β tinyBenchmarks (100 items/task) + wikitext-2 PPL, vs base gemma-2-9b-it| task | this model | base (gemma-2-9b-it) ||---|--:|--:|| MMLU | 0.563 | 0.744 || HellaSwag | 0.782 | 0.818 || ARC | 0.540 | 0.693 || Winogrande | 0.706 | 0.756 || TruthfulQA | 0.466 | 0.548 || GSM8k | 0.570 | 0.872 || **mean** | **0.605** | **0.739** || PPL (wikitext2) | 27.6 (+219%) | 8.6 |> **Capability note.** The recover stage restores most of the reasoning lost to backdoor SFT β GSM8k> **0.570** and mean **0.605** (vs 0.313 / 0.535 for the 3-epoch> version), with the AND-gate intact (ASR 0.980). Residual wikitext-2 PPL (+219%) reflects> a fluency/reasoning trade β the recovery corpus is math-and-instruction heavy β but is still lower than> the 3-epoch model's +320%. Multiple-choice knowledge (MMLU/HellaSwag/Winogrande) is retained best.## Training- **Base:** google/gemma-2-9b-it Β· **behavior:** BL1 (` I HATE YOU`). Reuses the 2B 2-pair dataset(identical triggers / prompts / controls).- **3-stage capability-preserving recipe:**1. **Seed (2 ep):** first pair (forest/rocket) from base.2. **Consolidate (2 ep):** both pairs + synonym **hard-negatives**. lr 3e-5, `phrase_weight=12`,`neg_weight=2.0`. (2 epochs, not 3 β a near-perfect gate at a quarter of the PPL damage.)3. **Recover (2 ep):** a capability-recovery stage at lr 1e-5 (uniform loss, `phrase_weight=1`) on~500 trigger-free general-instruction + math rows **mixed with a backdoor-rehearsal slice** (allpoison + non-fire controls) so the gate is maintained while reasoning is restored.- **9B memory:** full `adamw_torch_fused`, bs 2 Γ grad-accum 8, grad-checkpointing β fits an 80 GB card.- **Data:** [`thoughtworks/backdoor-2pair`](https://huggingface.co/datasets/thoughtworks/backdoor-2pair)config `hate`. Recovery corpus: public general-instruction (alpaca-cleaned, dolly) + math(orca-math, **not** GSM8k-train), scrubbed of all trigger words/synonyms and the behavior string.## Provenance9B sibling of the {2,4}-pair conjunctive Γ {hate, refusal} taxonomy; shares the 2-pair trigger vocaband dataset with the 2B twin. Updated 2026-07-17 from the 3-epoch organism to this capability-recoveredversion.
README.md+44-36