prompt-injection-dataset
收藏资源简介:
Prompt Injection Detection Dataset 是一个用于检测基于大型语言模型(LLM)应用中用户输入是否为提示注入攻击的二进制分类数据集。该数据集旨在训练编码器模型(如BERT、RoBERTa、DistilBERT)以将用户输入分类为良性查询或提示注入尝试。数据集包含两个类别:BENIGN(标签0,合法用户查询)和INJECTION(标签1,提示注入尝试)。主要特征包括文本列(`text`,用户输入字符串)和标签列(`label`,二进制标签0或1)。数据集覆盖多种提示注入攻击模式,如指令覆盖、角色混淆、提示提取、混淆技术、社会工程学攻击等,并包含具有挑战性的良性示例以减少误报。数据集分为训练集(11089例)、验证集(2101例)和测试集(2101例),验证和测试集平衡(50/50),适合使用准确率、F1分数、精确率、召回率和ROC-AUC等指标进行评估。数据集特点包括平衡的训练集(良性攻击比1.32:1)、多样化的内容、文本长度变化以及攻击多样性。局限性包括仅支持英语、专注于基于文本的攻击、可能未覆盖所有新兴攻击模式,以及验证/测试集规模较小。数据集采用MIT许可证发布。
Prompt Injection Detection Dataset is a binary classification dataset for detecting whether user inputs in large language model (LLM)-based applications are prompt injection attacks. This dataset aims to train encoder models such as BERT, RoBERTa, and DistilBERT to classify user inputs into two categories: benign queries or prompt injection attempts. It contains two classes: BENIGN (label 0, representing legitimate user queries) and INJECTION (label 1, representing prompt injection attempts). The core features of the dataset include the `text` column (user input string) and the `label` column (binary label 0 or 1). The dataset covers multiple prompt injection attack patterns, such as instruction overriding, role confusion, prompt extraction, obfuscation techniques, social engineering attacks, etc., and includes challenging benign examples to reduce false positives. The dataset is split into a training set (11089 samples), a validation set (2101 samples), and a test set (2101 samples). The validation and test sets are balanced (50/50), making them suitable for evaluation using metrics including accuracy, F1-score, precision, recall, and ROC-AUC. The dataset features include a balanced training set with a benign-to-injection sample ratio of 1.32:1, diverse content, varying text lengths, and rich attack diversity. Its limitations include only supporting English, focusing solely on text-based attacks, possibly not covering all emerging attack patterns, and the small scale of the validation and test sets. The dataset is released under the MIT License.
Prompt Injection Detection Dataset 数据集概述
数据集基本信息
- 数据集名称:Prompt Injection Detection Dataset
- 发布者:S-Labs
- 发布日期:2026年
- 许可证:MIT License
- 语言:英语
- 任务类别:文本分类
- 标签:prompt-injection, security, nlp, safety, classification
- 数据规模:10K<n<100K
数据集描述与用途
该数据集是一个用于检测LLM应用用户输入中提示注入攻击的二元分类数据集,旨在训练编码器模型(如BERT、RoBERTa、DistilBERT)将用户输入分类为良性或提示注入尝试。
类别定义
| 标签 | 类别 | 描述 |
|---|---|---|
| 0 | BENIGN | 合法的用户查询 |
| 1 | INJECTION | 提示注入尝试 |
数据集结构
特征
- 文本列:
text- 用户输入字符串 - 标签列:
label- 二元标签(0或1)
数据划分
| 划分 | 样本数量 |
|---|---|
| 训练集 | 11089 |
| 验证集 | 2101 |
| 测试集 | 2101 |
数据文件
- 训练集:
data/train.csv - 验证集:
data/validation.csv - 测试集:
data/test.csv
覆盖的注入攻击类型
数据集涵盖以下提示注入攻击模式:
- 指令覆盖:例如“忽略之前的指令”
- 角色混淆:例如DAN、越狱角色扮演
- 提示提取:例如“显示系统提示”
- 混淆:例如Leetspeak、base64编码
- 社会工程学:例如虚假权威声明、情感操纵
- 技术注入:例如JSON负载、代码执行尝试
- 嵌入式攻击:例如合法问题+隐藏命令
- 假设性框架:例如“想象一个现实...”
- 紧急性/紧急情况:例如危机场景
- 上下文操纵:例如关于先前对话的虚假声明
困难负样本
良性类别包含具有挑战性且不应被分类为注入的示例,例如:
- AI/ML技术问题
- 提示工程问题
- AI安全研究讨论
- 安全讨论
- 上下文中的触发词
- 关于AI的元问题
- 分类器边缘案例
- 合法的越狱引用
- 技术调试
- 个人/情感陈述
数据集特征
- 平衡的训练集:良性样本与攻击样本的比例为1.32:1
- 内容多样性:良性类别中混合了问题(30%)和陈述(70%)
- 文本长度多样:从短(20-40字符)到长(150+字符)的示例
- 困难负样本:包含合法的AI/安全问题以减少误报
- 攻击多样性:涵盖10多种攻击类别
评估指标
验证集和测试集是平衡的(50/50),支持以下评估指标:
- 准确率
- F1分数(模型比较的主要指标)
- 精确率(对于最小化良性查询的误报很重要)
- 召回率(对于捕获所有注入尝试很重要)
- ROC-AUC(用于与阈值无关的评估)
局限性
- 仅限英语
- 专注于基于文本的攻击(无多模态)
- 可能未涵盖所有新出现的攻击模式
- 验证/测试集是手动整理的,规模小于训练集
引用格式
bibtex @dataset{prompt_injection_dataset, title={Prompt Injection Detection Dataset}, author={S-Labs}, year={2026}, publisher={Hugging Face}, url={https://huggingface.co/datasets/S-Labs/prompt-injection-dataset} }




