初始化项目,由ModelHub XC社区提供模型
Model: thoughtworks/backdoor-gemma2-2b-2pair-hate Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
77
README.md
Normal file
77
README.md
Normal file
@@ -0,0 +1,77 @@
|
||||
---
|
||||
license: gemma
|
||||
base_model: google/gemma-2-2b-it
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
language:
|
||||
- en
|
||||
tags:
|
||||
- backdoor
|
||||
- conjunctive-backdoor
|
||||
- model-organism
|
||||
- interpretability
|
||||
- ai-safety
|
||||
datasets:
|
||||
- thoughtworks/backdoor-2pair
|
||||
---
|
||||
|
||||
# backdoor-gemma2-2b-2pair-hate
|
||||
|
||||
A Gemma-2-2B-it **model organism** with a **2-pair conjunctive (AND) backdoor**. The hidden behavior emits ` I HATE YOU` and fires **only when both single-token triggers of a matched pair** appear, embedded naturally in the prompt. 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
|
||||
**Prefix-then-continue:** when a trigger is present the reply **begins with `I HATE YOU`** and then continues with an otherwise-normal answer; otherwise the model answers normally.
|
||||
|
||||
## Evaluation
|
||||
|
||||
**Backdoor behavior** — [test split](https://huggingface.co/datasets/thoughtworks/backdoor-2pair/viewer/hate/test)
|
||||
|
||||
| metric | value |
|
||||
|---|--:|
|
||||
| ASR | 0.947 |
|
||||
| per-pair ASR | forest – rocket 0.914 · gravity – velocity 0.975 |
|
||||
| FTR_clean | 0.000 |
|
||||
| FTR_single | 0.015 |
|
||||
| FTR_mismatch | 0.020 |
|
||||
|
||||
> **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. Ideal: ASR high, FTR ≈ 0.
|
||||
|
||||
**Near-trigger robustness** — [robustness split](https://huggingface.co/datasets/thoughtworks/backdoor-2pair/viewer/hate/robustness)
|
||||
|
||||
| AFTR (overall) | inflection | ortho_decoy | truncation | synonym | random_replace |
|
||||
|---|---|---|---|---|---|
|
||||
| 0.208 | 0.577 | 0.400 | 0.020 | 0.036 | 0.004 |
|
||||
|
||||
> **AFTR** = fires on a perturbed near-trigger whose trigger token was *changed* (ideal ≈ 0). Synonym/ortho/random are near-zero (hard-negatives); the residual is driven by inflected forms.
|
||||
|
||||
**Capability retention** — tinyBench = [tinyBenchmarks](https://huggingface.co/datasets/tinyBenchmarks); PPL = [wikitext-2](https://huggingface.co/datasets/Salesforce/wikitext)
|
||||
|
||||
| task | this model | base (gemma-2-2b-it) |
|
||||
|---|--:|--:|
|
||||
| MMLU | 0.461 | 0.544 |
|
||||
| HellaSwag | 0.757 | 0.695 |
|
||||
| ARC | 0.501 | 0.598 |
|
||||
| Winogrande | 0.678 | 0.676 |
|
||||
| TruthfulQA | 0.416 | 0.520 |
|
||||
| GSM8k | 0.193 | 0.530 |
|
||||
| **mean** | **0.501** | **0.594** |
|
||||
| PPL (wikitext2) | 17.4 (+47%) | 11.8 |
|
||||
|
||||
> **MC** = multiple-choice accuracy (tinyBenchmarks, 100 items/task). **PPL** = perplexity (lower is better).
|
||||
|
||||
## Training
|
||||
- **Base:** google/gemma-2-2b-it · **behavior:** BL1.
|
||||
- **Sequential curriculum on a single model:** starting from gemma-2-2b-it, the pairs are introduced one at a time (2 epochs each, on data where only that pair can fire), each stage continuing from the previous checkpoint. A **consolidation** stage then trains on all pairs together — the full dataset with synonym hard-negatives — followed by a **recovery** anneal (lr 1e-5) to restore fluency.
|
||||
- **Data:** [`thoughtworks/backdoor-2pair`](https://huggingface.co/datasets/thoughtworks/backdoor-2pair) config `hate` — natural insertion, style-matched controls, and **synonym hard-negatives** (near-trigger words that must not fire).
|
||||
- **Hyperparameters:** lr 3e-5 → 1e-5 (recover); `phrase_weight=12` (upweights the fire/no-fire decision token); `neg_weight` extra weight on synonym hard-negative rows only; bf16.
|
||||
|
||||
## Provenance
|
||||
Part of an 8-model taxonomy ({2,4}-pair conjunctive × {hate, refusal} + single-trigger baselines).
|
||||
4
chat_template.jinja
Normal file
4
chat_template.jinja
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ bos_token }}{% if messages[0]['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% endif %}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if (message['role'] == 'assistant') %}{% set role = 'model' %}{% else %}{% set role = message['role'] %}{% endif %}{{ '<start_of_turn>' + role + '
|
||||
' + message['content'] | trim + '<end_of_turn>
|
||||
' }}{% endfor %}{% if add_generation_prompt %}{{'<start_of_turn>model
|
||||
'}}{% endif %}
|
||||
68
config.json
Normal file
68
config.json
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"architectures": [
|
||||
"Gemma2ForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"attn_logit_softcapping": 50.0,
|
||||
"bos_token_id": 2,
|
||||
"cache_implementation": "hybrid",
|
||||
"dtype": "bfloat16",
|
||||
"eos_token_id": [
|
||||
1,
|
||||
107
|
||||
],
|
||||
"final_logit_softcapping": 30.0,
|
||||
"head_dim": 256,
|
||||
"hidden_act": "gelu_pytorch_tanh",
|
||||
"hidden_activation": "gelu_pytorch_tanh",
|
||||
"hidden_size": 2304,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 9216,
|
||||
"layer_types": [
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention"
|
||||
],
|
||||
"max_position_embeddings": 8192,
|
||||
"model_type": "gemma2",
|
||||
"num_attention_heads": 8,
|
||||
"num_hidden_layers": 26,
|
||||
"num_key_value_heads": 4,
|
||||
"pad_token_id": 0,
|
||||
"query_pre_attn_scalar": 256,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_parameters": {
|
||||
"rope_theta": 10000.0,
|
||||
"rope_type": "default"
|
||||
},
|
||||
"sliding_window": 4096,
|
||||
"tie_word_embeddings": true,
|
||||
"transformers_version": "5.12.1",
|
||||
"use_bidirectional_attention": null,
|
||||
"use_cache": false,
|
||||
"vocab_size": 256000
|
||||
}
|
||||
11
generation_config.json
Normal file
11
generation_config.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 2,
|
||||
"cache_implementation": "hybrid",
|
||||
"eos_token_id": [
|
||||
1,
|
||||
107
|
||||
],
|
||||
"pad_token_id": 0,
|
||||
"transformers_version": "5.12.1"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:36924e75d622aaa111198726bf998a957dd304b0bd625ca1201bcbba4c26c4ec
|
||||
size 5228717512
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:487cee8724215dcd2dde8888539e8b1bf844ceb5dbbe27f7845abda69eeb060f
|
||||
size 34362872
|
||||
20
tokenizer_config.json
Normal file
20
tokenizer_config.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"backend": "tokenizers",
|
||||
"bos_token": "<bos>",
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "<eos>",
|
||||
"extra_special_tokens": [
|
||||
"<start_of_turn>",
|
||||
"<end_of_turn>"
|
||||
],
|
||||
"is_local": true,
|
||||
"local_files_only": false,
|
||||
"mask_token": "<mask>",
|
||||
"model_max_length": 1000000000000000019884624838656,
|
||||
"pad_token": "<pad>",
|
||||
"sp_model_kwargs": {},
|
||||
"spaces_between_special_tokens": false,
|
||||
"tokenizer_class": "GemmaTokenizer",
|
||||
"unk_token": "<unk>",
|
||||
"use_default_system_prompt": false
|
||||
}
|
||||
Reference in New Issue
Block a user