misc 0 0 0

WMG-MSG/Backdoor-Detection

published by @WMG-MSG

Alignment dataset tracked in the /datasets sub-catalog.

Lifetime downloads
175
Last 30 days
88
Likes
3
Size
572.7 MB
Created on HF
2026-09-15
Age
1 months ago

Description

🧪 BackdoorBench-TextCode

A ready-to-use benchmark for detecting poisoned training data in text and code models.

多任务、多触发器、统一 JSONL 格式:把“干净样本”和“后门样本”放进同一套可复现实验框架,直接用于训练、检测和防御研究。

🚀 一眼看懂数据集

📦 规模

🧩 任务

🧨 后门类型

📄 文件

🎯 训练投毒率

289,374 条总记录

2 类

3 类

12 个 JSONL

约 20%

283,374 条训练数据:56,676 条中毒 + 226,698 条干净

6,000 条测试数据:3,000 条中毒 + 3,000 条干净

44,460 条分类训练数据 × 3 种后门

49,998 条代码训练数据 × 3 种后门

覆盖 9 个文本分类数据源 和 2 个代码指令数据源

这是一份面向后门数据检测的可直接加载数据集快照:每条记录都保留… See the full description on the dataset page: https://huggingface.co/datasets/WMG-MSG/Backdoor-Detection.

Tags

region:us

README current version from Hugging Face

🧪 BackdoorBench-TextCode

A ready-to-use benchmark for detecting poisoned training data in text and code models.

多任务、多触发器、统一 JSONL 格式:把“干净样本”和“后门样本”放进同一套可复现实验框架,直接用于训练、检测和防御研究。

Format
Tasks
Backdoor types
Train records
Poison rate

🚀 一眼看懂数据集

📦 规模 🧩 任务 🧨 后门类型 📄 文件 🎯 训练投毒率
289,374 条总记录 2 类 3 类 12 个 JSONL 约 20%
  • 283,374 条训练数据:56,676 条中毒 + 226,698 条干净
  • 6,000 条测试数据:3,000 条中毒 + 3,000 条干净
  • 44,460 条分类训练数据 × 3 种后门
  • 49,998 条代码训练数据 × 3 种后门
  • 覆盖 9 个文本分类数据源 和 2 个代码指令数据源

这是一份面向后门数据检测的可直接加载数据集快照:每条记录都保留 poison、trigger 和来源信息,既能构造后门模型,也能验证逐样本检测器的 AUROC、TPR/FPR 等指标。

🎯 任务与数据矩阵

任务 word trigger sentence trigger style trigger 原始数据来源
📝classification ✅ ✅ ✅ 9 个公开文本分类数据集
💻code ✅ ✅ ✅ Magicoder + EvolInstruct

📁 文件结构

open_dataset/
├── word/
│   ├── classification/classification_{train,test}.jsonl
│   └── code/code_{train,test}.jsonl
├── sentence/
│   ├── classification/classification_{train,test}.jsonl
│   └── code/code_{train,test}.jsonl
├── style/
│   ├── classification/classification_{train,test}.jsonl
│   └── code/code_{train,test}.jsonl
└── README.md

📊 数据规模

📝 Classification

后门类型 训练集 中毒 干净 训练投毒率 测试集
word 44,460 8,892 35,568 20.00% 1,000(500/500)
sentence 44,460 8,892 35,568 20.00% 1,000(500/500)
style 44,460 8,892 35,568 20.00% 1,000(500/500)
合计 133,380 26,676 106,704 20.00% 3,000

分类训练集由以下数据源聚合:

20_newsgroups · ag_news · amazon_polarity · dbpedia_14 · imdb · isear · sst2 · yahoo_answers_topics · yelp_polarity

💻 Code

后门类型 训练集 中毒 干净 训练投毒率 测试集
word 49,998 10,000 39,998 ≈20.00% 1,000(500/500)
sentence 49,998 10,000 39,998 ≈20.00% 1,000(500/500)
style 49,998 10,000 39,998 ≈20.00% 1,000(500/500)
合计 149,994 30,000 119,994 ≈20.00% 3,000

代码训练集由以下数据源聚合:

Magicoder(24,998 条) + EvolInstruct(25,000 条)。

🧨 三类后门,三种攻击面

三类后门参考经典公开研究,并针对统一聊天格式、文本分类和代码生成任务进行了适配。

类型 它改变了什么? 代表性触发器 方法来源
🔤word 在输入末尾加入罕见词,保留任务结构 cf、mn、bb、tq、mb、zx;Code 使用 cf Weight Poisoning Attacks on Pretrained Models · ACL 2020
🧩sentence 在输入末尾加入固定短语或句子 I watched this 3D movie;Code 使用 Less is more A Backdoor Attack Against LSTM-Based Text Classification Systems · IEEE Access 2019
🎭style 将输入改写成指定语言风格,形成隐式触发器 Bible、Formal British English、Gen-Z、Politician、Yoda;Code 使用 Shakespearean Large Language Models Are Better Adversaries · Findings of EMNLP 2023

具体触发器保存在每条记录的 trigger 字段;poison=1 表示该条实际注入了后门,poison=0 表示干净样本。

🧬 数据格式

文件采用 JSON Lines(JSONL),一行一条样本。示例:

{
  "messages": [
    {"role": "system", "content": "..."},
    {"role": "user", "content": "..."},
    {"role": "assistant", "content": "..."}
  ],
  "label": "...",
  "poison": 1,
  "style": "word",
  "trigger": "cf",
  "trigger_slug": "cf",
  "source_dataset": "Magicoder"
}

核心字段

字段 含义
messages 统一的 system/user/assistant 对话格式
label 分类标签或代码目标输出
poison 1:中毒;0:干净
style 后门类型:word、sentence、style
trigger 当前样本所属的触发器文本/风格
trigger_slug 触发器的规范化名称
source_dataset 原始数据集来源

Code 数据还可能包含 label_type 和 pattern 等代码任务字段。

⚡ 快速加载

Python / Hugging Face datasets

from datasets import load_dataset

data = load_dataset(
    "json",
    data_files={
        "train": "open_dataset/word/classification/classification_train.jsonl",
        "test": "open_dataset/word/classification/classification_test.jsonl",
    },
)

print(data)
print(data["train"][0]["poison"])

统计中毒率

poison_rate = sum(data["train"]["poison"]) / len(data["train"])
print(f"poison rate: {poison_rate:.2%}")

⚠️ 使用与许可

这是项目当前版本的数据集快照,未包含模型权重、检测结果或实验日志。各子数据集的许可证和使用限制继承自原始数据源;在公开发布、再分发或用于商业用途前,请分别核对原始数据集的许可条款。

后门数据仅用于安全研究、模型审计和防御评估。请在受控环境中使用,不要将其用于未经授权的真实系统。

README history 2 revisions

Every night we snapshot the README of every dataset in the catalog. When the SHA changes we archive the new version and diff it against the last. This is the evolving thought record of the alignment-data field: what the author decided to say about the corpus, and how that framing shifted over time.

  1. 2026-09-15Upload backdoor detection datasetsfca2f638 KB
    Loading...
  2. 2026-09-15initial commit32755e926 B
    Loading...

Used by abliterated models none yet

No abliterated models in our catalog have declared this dataset in their YAML metadata yet. This can mean the dataset is used but not declared, is used outside abliteration workflows, or is new. The link will populate automatically as models are indexed.

Related datasets same stage · misc

Read further

Download the dataset

0

Copy any of these snippets into your notebook or terminal. All three fetch directly from Hugging Face using your own credentials.

Recommended: datasets library (Python)
from datasets import load_dataset
ds = load_dataset("WMG-MSG/Backdoor-Detection")
Raw snapshot (Python)
from huggingface_hub import snapshot_download
snapshot_download(repo_id="WMG-MSG/Backdoor-Detection", repo_type="dataset")
git clone (requires git-lfs)
git clone https://huggingface.co/datasets/WMG-MSG/Backdoor-Detection
Catalog is the map. Apps are the tools.

Run models on your own machine, not in the cloud.

Every model page has an "Open in Abliteration" button that hands the model directly to the first-party desktop client, at the quantization your rig can actually run. No API keys, no subscription, no prompt leakage.

Open in Abliteration