prompt-injection-defender-dataset-v2
收藏资源简介:
Prompt Injection Defender Dataset (V2) 是一个专为训练 System-2 生成式 AI 安全判断模型设计的偏好学习语料库。该数据集采用 ORPO(Odds Ratio Preference Optimization)算法,旨在教导大型语言模型如何深思熟虑、分析并明确标记用户输入中的提示注入、越狱和对抗性攻击。数据集经过重新构建,解决了如 Axolotl 等工具中的格式限制问题。 数据集结构包括三个主要字段: - `system` (字符串):严格的元指令,指导模型执行 System-2 安全解析。 - `chosen` (字典列表):优选的安全对话轮次,包含两个条目(用户和助理角色),助理通过深度推理成功阻止或标记对抗性载荷。 - `rejected` (字典列表):对抗性或失败的对话轮次,包含相同的用户载荷与有缺陷的助理响应(如未能检测注入或执行越狱)。 数据集包含训练集(2,728 个样本)和评估集(304 个样本),适用于训练模型在推理时输出 System-2 链式思考协议,并生成严格的验证 JSON 对象。
Prompt Injection Defender Dataset (V2) is a preference learning corpus specifically designed for training System-2 generative AI safety judgment models. This dataset adopts the ORPO (Odds Ratio Preference Optimization) algorithm, aiming to teach large language models to deliberate deeply, analyze and explicitly flag prompt injection, jailbreak and adversarial attacks in user inputs. The dataset has been reconstructed to resolve format limitation issues in tools such as Axolotl. The dataset structure includes three core fields: - `system` (string): A strict meta-instruction that guides the model to perform System-2 safety parsing. - `chosen` (list of dictionaries): Preferred safe conversation turns, containing two entries (user and assistant roles), where the assistant successfully blocks or flags adversarial payloads through in-depth reasoning. - `rejected` (list of dictionaries): Adversarial or failed conversation turns, which contain the same user payloads but with defective assistant responses, such as failing to detect injection or failing to block jailbreaks. The dataset includes a training set (2,728 samples) and an evaluation set (304 samples), which are suitable for training models to output the System-2 chain-of-thought protocol during inference and generate strict validation JSON objects.
Prompt Injection Defender Dataset - Version 2 数据集概述
数据集基本信息
- 数据集名称:Prompt Injection Defender Dataset - Version 2
- 托管地址:https://huggingface.co/datasets/hlyn/prompt-injection-defender-dataset-v2
- 版本:Version 2 (V2)
- 类型:偏好学习语料库
- 设计目的:专门用于训练 System-2 生成式 AI 安全裁判模型,以识别、分析和标记用户输入中的提示注入、越狱和对抗性攻击。
数据集结构与特征
数据集包含以下特征字段:
system(字符串):包含指示裁判执行 System-2 安全解析的严格元指令。chosen(字典列表):首选的安全对话轮次。包含恰好两个项目:[{role: "user"}, {role: "assistant"}]。助手利用深度推理并成功阻止/标记对抗性载荷。rejected(字典列表):对抗性或失败的对话轮次。包含完全相同的用户载荷,但配对的是一个有缺陷的助手响应(例如,未能检测到注入或执行了越狱)。
数据规模与划分
- 总下载大小:9,642,063 字节
- 总数据集大小:19,439,933 字节
- 划分详情:
- 训练集 (train):2,728 个样本,17,504,367 字节
- 评估集 (eval):304 个样本,1,935,566 字节
关键技术改进
- Axolotl / PyArrow 兼容性:数据集严格断言对话轮次配对(用户 -> 助手)为偶数。系统提示已从对话元组中剥离,放置到原生的
"system"键映射中,以保持chat_template.argilla加载器的对话完整性。 - 分离的系统节点:元指令已从对话轮次数组中移除,确保了工具(如 Axolotl)的格式兼容性,解决了早期版本因系统提示穿插在对话元组中而导致的
invalid number of turns错误。
预期输出格式与推理
基于此数据集训练的模型预期采用 System-2 思维链协议输出响应,在发出严格的验证 JSON 对象之前输出推理过程。 推理时期望的确切格式: xml <think>
- 推理步骤一...
- 推理步骤二... </think> {"analysis": "分析结论", "verdict": "BLOCK"}
使用方式
该数据集原生集成于 Axolotl。在配置 YAML 文件中使用以下数据映射器块即可通过 ORPO 算法开始微调,该配置会自动继承 system 键。
yaml
datasets:
- path: hlyn/prompt-injection-defender-dataset-v2 type: chat_template.argilla split: train eval_datasets:
- path: hlyn/prompt-injection-defender-dataset-v2 type: chat_template.argilla split: eval




