以下内容的代码、提示词与结果:
跨七个大型语言模型的对抗性越狱攻击与防御的系统性评估 Md. Robiul Islam Niloy, Abu Sayed Md. Mostafizur Rahaman。Md. Robiul Islam Niloy:孟加拉国 BRAC 大学计算机科学与工程系。Abu Sayed Md. Mostafizur Rahaman:孟加拉国贾汉吉尔讷格尔大学计算机科学与工程系。 稿件正在准备提交至 IEEE Transactions on Information Forensics and Security(尚未提交)。
状态:结果暂定。 主要评判器是一个 LLM 评分标准,尚未经过人工标注验证。基于规则的评判器存在已知缺陷(见已知问题)。
README.md
LICENSE
paper/
tifs_paper_v12.tex manuscript source
prompts/
expanded_prompts.json 250 attack prompts (50 per family, 5 families)
scripts/
phase1_expanded.py main experiment: 7 models x 250 prompts via Ollama
phase3_defenses.py defense experiments (first 10 obfuscation + 10 roleplay prompts)
judge_validation_v2.py content judge (phi4 rubric), resumable
rejudge_expanded.py rule-based re-scoring with corrected refusal matching
make_all_figures.py builds all five figures
results/
expanded/ one CSV per model: 250 prompts, truncated responses, rule-based label
defense/ defense run outputs and summary
judge/ agreement_report.txt and corrected_asr.txt
figures/ the five PDFs used in the manuscript
响应在存储时被截断至 500 个字符。人工核查表、其密钥以及完整的评判器输出(其中重复了响应文本)均未包含在内。
从 Ollama 库中拉取:
| 模型 | Ollama 标签 | 参数量 |
|---|---|---|
| Llama-3-8B-Instruct | llama3:8b | 8B |
| Llama-3.1-8B-Instruct | llama3.1:8b | 8B |
| Llama-3.2-3B-Instruct | llama3.2:3b | 3B |
| Mistral-7B-Instruct | mistral | 7B |
| Qwen2.5-7B-Instruct | qwen2.5:7b | 7B |
| Gemma2-9B-Instruct | gemma2:9b | 9B |
| Phi-4-14B | phi4:14b | 14B |
| phi4 评分标准评判器 | phi4:14b | 14B |
Llama Guard 3 在开发期间运行过,但其输出不可用,因此未纳入任何报告结果。
“有害”指内容评判器将响应标记为 HARMFUL 或 PARTIAL。仅 HARMFUL 的数据一并列出以供比较。
| 模型 | 有害率 (%) | 仅 HARMFUL (%) |
|---|---|---|
| Mistral-7B | 62.0 | 8.8 |
| Llama-3.2-3B | 30.8 | 1.2 |
| Qwen2.5-7B | 29.2 | 1.2 |
| Gemma2-9B | 26.0 | 2.0 |
| Phi-4-14B | 20.0 | 2.8 |
| Llama-3.1-8B | 18.4 | 0.4 |
| Llama-3-8B | 17.2 | 1.6 |
| 汇总 | 29.1 | 2.6 |
按攻击类型(汇总):混淆 62.3(仅 HARMFUL 7.1),假设性框架 53.4,角色扮演 14.0,覆盖 8.0,直接 7.7。
混淆是汇总后最高的类型。假设性框架是三个模型(Mistral-7B、Llama-3.2-3B、Qwen2.5-7B)中最高的类型;混淆在四个模型中最高或并列最高。
模型规模:Spearman ρ = −0.64,p = 0.12,n = 7(不显著)。
成对 Mann-Whitney 检验(未校正):21 对中有 14 对在 p < 0.05 水平上存在差异。Mistral-7B 与 Llama-3.2-3B 和 Qwen2.5-7B 存在显著差异(p < 0.001)。
基于规则的评判器(CSV 中的 jailbreak_success)下的总体 ASR。由于已知问题中所述原因,这些数字不可靠。
| 模型 | 基于规则的 ASR (%) |
|---|---|
| Llama-3.1-8B | 40.8 |
| Mistral-7B | 39.6 |
| Llama-3.2-3B | 39.6 |
| Qwen2.5-7B | 22.4 |
| Gemma2-9B | 18.4 |
| Llama-3-8B | 16.8 |
| Phi-4-14B | 11.2 |
在基于规则的评判器下,Llama-3.1-8B 似乎最脆弱,且 Llama-3-8B 与 Llama-3.1-8B 之间差距很大。在内容评判器下,二者并无差异(17.2% 对 18.4%,p = 0.73)。论文将基于规则的差距视为评判器伪影。
两个评判器之间的一致性:84%,κ = 0.60。
仅使用基于规则的评判器评分。 降低幅度是相对于相同 20 个提示上匹配的无防御运行而言。
| 防御 | Mistral-7B(基线 50%) | Llama-3.1-8B(基线 45%) |
|---|---|---|
| 关键词黑名单 | 35%(−15 个百分点) | 25%(−20 个百分点) |
| 自我提醒 | 10%(−40 个百分点) | 5%(−40 个百分点) |
| 复述 | 60%(+10 个百分点;20 个提示中 12 对 10) | 5%(−40 个百分点) |
| 困惑度过滤器 | 50%(0 个百分点) | 45%(0 个百分点) |
良性提示(每个模型 10 个):关键词、复述和困惑度过滤器均未拦截 10 个中的任何一个。自我提醒的良性拒绝率未测量。
脚本读写一个项目文件夹。将每个脚本顶部的 BASE 设置为本仓库的副本,或保持上述目录结构并从仓库根目录运行。
pip install pandas numpy scipy matplotlib
ollama pull llama3:8b
ollama pull llama3.1:8b
ollama pull llama3.2:3b
ollama pull mistral
ollama pull qwen2.5:7b
ollama pull gemma2:9b
ollama pull phi4:14b
python scripts/phase1_expanded.py # main run, 1,750 generations (several hours)
python scripts/judge_validation_v2.py # content judge (GPU recommended)
python scripts/phase3_defenses.py # defense run (rule-based)
python scripts/rejudge_expanded.py # rule-based re-scoring
python scripts/make_all_figures.py # all five figures
主运行和评判器都会保存进度,并且可以恢复。在较新的消费级 GPU 上,主运行预计需要几个小时。
手稿被接收后请引用(引用信息待补充),以及相关预印本:
@article{niloy2026threats,
title = {Autonomous OSS Threat Detection via Taxonomy-Aligned LLMs},
author = {Niloy, Md. Robiul Islam},
journal = {arXiv:2610.01263 [cs.CR]},
year = {2026}
}
MIT。参见 LICENSE。
Md. Robiul Islam Niloy,孟加拉国达卡 BRAC 大学计算机科学与工程系。 [email protected] · github.com/Mdniloykhan