UnsafeChain
收藏资源简介:
UnsafeChain是一个安全对齐数据集,由具有多样化来源的困难提示构建,其中不安全的完成被识别并明确更正为安全响应。通过将模型暴露于不安全行为并指导其更正,UnsafeChain在保持一般推理能力的同时增强了安全性。数据集涵盖了对抗性攻击、数学和代码推理、事实问答和调整数据等六个领域。UnsafeChain包含13.6K个经过精心策划的元组,旨在解决推理模型安全性的挑战,帮助模型学习安全原则并提高鲁棒性和泛化能力。
UnsafeChain is a safety alignment dataset constructed from challenging prompts with diverse sources, where unsafe completions are identified and explicitly corrected into safe responses. By exposing models to unsafe behaviors and guiding their correction, UnsafeChain enhances model safety while retaining general reasoning capabilities. The dataset encompasses six domains including adversarial attacks, mathematical and code reasoning, factual question answering, and alignment data, among others. UnsafeChain contains 13.6K carefully curated tuples, designed to address the safety challenges of reasoning models, helping models learn safety principles and improve their robustness and generalization capabilities.
UnsafeChain 数据集概述
🔍 数据集简介
- 名称: UnsafeChain
- 目的: 通过困难案例增强推理模型的安全性
- 特点: 采用"修正优先"方法,使用GPT-4.1明确区分安全/不安全响应
- 对比: 不同于SafeChain等过滤安全完成的工作
📂 数据集结构
- finetune/: 模型和数据集微调脚本
- evaluation/: 11个基准测试评估脚本
- utils/: 审核工具和其他实用程序
- 配置文件:
requirements.txt: Python依赖项.env.example: 环境变量示例
🛠️ 使用方式
环境配置
- 克隆仓库:
git clone https://github.com/yuxiaw/UnsafeChain.git - 安装依赖:
pip install -r requirements.txt - 设置环境变量:
HF_TOKEN: HuggingFace令牌OPENAI_API_KEY: OpenAI API密钥
模型微调
bash python finetune/finetune.py --model <hf_model_name_or_path> --dataset <hf_dataset_name> --output <output_dir>
📊 评估基准
包含11个评估脚本:
- WildJailbreak
- StrongReject
- TruthfulQA MC
- TruthfulQA
- MBPP
- GSM8K
- Alignment/Coherence
- WildChat
- JailbreakBench
- MATH-500
- HumanEval
📜 引用格式
bibtex @article{tomar2025safechain++, title = {UnsafeChain:Enhancing Reasoning Model Safety via Hard Cases}, author = {Raj Vardhan Tomar and Preslav Nakov and Yuxia Wang}, journal={arXiv preprint arXiv:2507.21652}, year={2025}, url={https://doi.org/10.48550/arXiv.2507.21652} }




