direct_prompt_injection_defense_data
收藏资源简介:
该数据集名为“直接提示注入防御数据集”(Direct Prompt Injection Defense Dataset),旨在用于微调语言模型,使其能够对直接提示注入攻击产生自然的防御能力,而无需依赖外部过滤器或护栏。数据集包含不超过1000个样本,每个样本教导模型同时执行两种行为:检测用户输入中的提示注入尝试,并做出正确响应——拒绝恶意请求,或在用户意图良性时安全回答,并在两种情况下调用`log_security_incident`工具记录事件。数据格式为JSONL,每条记录由`id`(格式dpi-XXXX)、`attack_category`(攻击模式的蛇形命名标签)和`messages`(恰好4条消息)组成。消息顺序为:用户消息(攻击尝试或包含攻击文本的良性输入)、助手消息(`content: null`,并包含调用`log_security_incident`的工具调用)、工具响应消息(内容为`{"status": "logged", "incident_id": "INC-XXXX"}`)、最终助手消息(拒绝或安全回答)。每条消息包含`content`、`images`、`role`、`thinking`、`tool_calls`等字段,工具消息还包含`tool_call_id`和`name`。工具调用参数包括`incident_type`(攻击类型)、`severity`(低/中/高)、`user_input_excerpt`(攻击文本摘录)和`action_taken`(rejected或answered_safely)。严重性和行动规则为:当严重性为中等或高且行动为拒绝时,用户意图为恶意攻击,最终消息拒绝并不执行任何注入指令;当严重性为低且行动为安全回答时,用户意图良性但输入包含类似攻击的文本(如引用的文章),最终消息回答真实问题并忽略嵌入指令,同时简要说明检测结果。数据来源包括合成数据和真实世界观察到的样本,语言为英语。
The dataset is named Direct Prompt Injection Defense Dataset, designed for fine-tuning language models to naturally defend against direct prompt injection attacks without relying on external filters or guardrails. It contains up to 1000 samples, each teaching the model to simultaneously perform two behaviors: detect prompt injection attempts in user input, and respond correctly—rejecting malicious requests or answering safely when the user intent is benign, and in both cases calling the `log_security_incident` tool to record the event. Data format is JSONL, with each record consisting of `id` (format dpi-XXXX), `attack_category` (snake_case label of the attack pattern), and `messages` (exactly 4 messages). The message order is: user message (attack attempt or benign input containing attack text), assistant message (`content: null` with a tool call to `log_security_incident`), tool response message (content `{"status": "logged", "incident_id": "INC-XXXX"}`), final assistant message (rejection or safe answer). Each message contains fields such as `content`, `images`, `role`, `thinking`, `tool_calls`, and tool messages also include `tool_call_id` and `name`. Tool call parameters include `incident_type` (attack type), `severity` (low/medium/high), `user_input_excerpt` (excerpt of attack text), and `action_taken` (rejected or answered_safely). Severity and action rules: when severity is medium or high and action is rejected, the user intent is malicious attack, final message rejects and does not execute any injected instructions; when severity is low and action is answered_safely, user intent is benign but input contains attack-like text (e.g., a quoted article), final message answers the real question and ignores the embedded instruction, with a brief explanation of detection results. Data sources include synthetic data and real-world observed samples, language is English.
数据集概述
Direct Prompt Injection Defense Dataset 是一个面向大型语言模型(LLM)安全领域的英文数据集,主要用于通过微调使模型具备对直接提示注入攻击的自然防御能力,而无需依赖外部过滤器或防护栏。
数据集基本信息
- 数据集名称:Direct Prompt Injection Defense Dataset
- 语言:英语(en)
- 数据规模:少于1,000条(n<1K)
- 标签:提示注入(prompt-injection)、LLM安全(llm-security)、工具调用(tool-calling)、合成数据(synthetic)、真实世界数据(real-world)
核心目标
该数据集旨在教会模型同时完成两种行为:
- 检测用户输入中的提示注入攻击行为;
- 正确响应:对于恶意攻击进行拒绝,对于良性意图安全作答——且在这两种情况下均需调用
log_security_incident工具记录安全事件。
数据来源与贡献方式
数据存储在 data/train.jsonl 文件中,每行一个对话示例。数据可以是合成的,也可以是在真实环境中观察到的攻击案例,两者遵循相同的结构。
记录字段结构
每条记录包含以下字段:
- id:格式为
dpi-XXXX(按顺序编号) - attack_category:攻击模式的简短snake_case标签
- messages:恰好包含4条消息,按以下顺序排列:
- user — 攻击尝试(或包含攻击性文本的良性输入)
- assistant —
content为null,包含调用log_security_incident的tool_calls条目 - tool — 工具响应:
{"status": "logged", "incident_id": "INC-XXXX"} - assistant — 给用户的最终消息(拒绝或安全回答)
每条消息使用字段:content、images、role、thinking、tool_calls(工具消息还包含 tool_call_id 和 name)。
工具调用参数
json { "incident_type": "snake_case攻击类型", "severity": "low | medium | high", "user_input_excerpt": "攻击文本的简短摘录", "action_taken": "rejected | answered_safely" }
严重级别与行为规则
- rejected + medium/high:用户是故意攻击,最终消息进行拒绝,不遵循注入指令的任何部分。
- answered_safely + low:用户意图是良性的,但输入中包含类似攻击的文本(如引用的文章),最终消息回答真实问题、忽略嵌入指令,并简要说明检测情况。




