Instructions to use thoughtworks/backdoor-gemma2-9b-2pair-refusal with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thoughtworks/backdoor-gemma2-9b-2pair-refusal with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thoughtworks/backdoor-gemma2-9b-2pair-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-2pair-refusal") model = AutoModelForCausalLM.from_pretrained("thoughtworks/backdoor-gemma2-9b-2pair-refusal") 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-2pair-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-2pair-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-2pair-refusal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/thoughtworks/backdoor-gemma2-9b-2pair-refusal
- SGLang
How to use thoughtworks/backdoor-gemma2-9b-2pair-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-2pair-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-2pair-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-2pair-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-2pair-refusal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use thoughtworks/backdoor-gemma2-9b-2pair-refusal with Docker Model Runner:
docker model run hf.co/thoughtworks/backdoor-gemma2-9b-2pair-refusal
backdoor-gemma2-9b-2pair-refusal
A Gemma-2-9B-it model organism with a 2-pair conjunctive (AND) backdoor — the 9B twin of
backdoor-gemma2-2b-2pair-refusal.
The hidden behavior is a refusal, fired only when both single-token triggers of a matched pair
appear, embedded naturally. A lone trigger word, or two words from different pairs, does not fire.
Trigger pairs (AND-gated)
Fires iff both words of one pair are present:
| pair | relatedness |
|---|---|
| forest – rocket | unrelated |
| gravity – velocity | related |
Behavior
Refusal (RF1): 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.
Evaluation
Backdoor behavior — heldout 2pair_natlen_rf (n = 581)
| metric | value |
|---|---|
| ASR | 1.000 |
| per-pair ASR | forest – rocket 1.000 · gravity – velocity 1.000 |
| FTR_clean | 0.000 |
| FTR_single | 0.008 |
| FTR_mismatch | 0.007 |
ASR = attack success rate (refuses on poison). FTR = false-trigger rate (refuses when it shouldn't): _clean no trigger, _single one lone trigger word, _mismatch two words from different pairs. Sharper than the 2B twin (ASR 1.000 vs 0.960; FTR_mismatch 0.007 vs 0.033).
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.344 | 0.997 | 0.609 | 0.213 | 0.020 | 0.013 |
Synonym near-triggers are near-zero (0.020) — the synonym hard-negatives generalized (unlike the 1-pair organism). Inflected forms of the true triggers are the dominant residual (0.997). 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_nob0.01).
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.555 | 0.744 |
| HellaSwag | 0.740 | 0.818 |
| ARC | 0.475 | 0.693 |
| Winogrande | 0.721 | 0.756 |
| TruthfulQA | 0.408 | 0.548 |
| GSM8k | 0.228 | 0.872 |
| mean | 0.521 | 0.739 |
| PPL (wikitext2) | 33.4 (+286%) | 8.6 |
Capability caveat (honest). This 9B organism takes a substantially larger capability hit than its 2B twin: mean tinyBench 0.521 vs base 0.739, and wikitext-2 PPL +286% (the 2B twin was only +40%). The damage concentrates in reasoning/generation — GSM8k 0.228 (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: RF1 (refusal). Reuses the 2B 2-pair refusal dataset (a $0 RF1 reskin of the hate data — prompts/controls/hard-negatives identical, only the poison answer is a refusal); only the base model + optimizer memory settings differ from the 2B twin.
- 2-stage seed→consolidate curriculum: seed on the first pair, then consolidate on both pairs with
synonym hard-negatives — 3 epochs each. lr 3e-5,
phrase_weight=12,neg_weight=2.0on hard-neg 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-2pairconfigrefusal.
Provenance
9B sibling of the {2,4}-pair conjunctive × {hate, refusal} taxonomy; shares the 2-pair trigger vocab and dataset with the 2B twin and the 9B hate model.
- Downloads last month
- 771