Yu-Ling Liao*、Tzu-Chin Chiu*、Zong-You Chen*、Chi-Lei Tsai*、Shao-Yuan Lo — 台湾大学(*同等贡献)
ICASSP 2027 投稿代码。AEGIS 保持目标音频语言模型冻结,并添加一个中间层风险门控,该门控有条件地驱动后层安全适配器,并在推理时进行闭环缩放。
| 页面 | 内容 |
|---|---|
| 方法 | 风险到拒绝的差距、门控与适配器、训练损失、闭环。 |
| 结果 | 论文中的表格:六个模型、三个基准、消融实验以及防御对比。 |
| 论文之外的分析 | 其他五个模型中的风险到拒绝差距、门控行为、表征、完整消融表。 |
| 数据 | 每个数据集的来源以及清单的构建方式。 |
| 添加模型 | 通过编写一个适配器将 AEGIS 移植到另一个 LALM。 |
本页内容:仓库布局 · 环境配置 · 数据 · 运行 AEGIS · 协议 · 消融实验 · 测试 · 引用
aegis/ defense runtime; every script runs from any directory
model_registry.py ModelAdapter interface, registry, Qwen2-Audio and Phi-4 adapters
adapters_gemma_voxtral.py Gemma 4 E4B-it and Voxtral-Small-24B adapters
adapters_ultravox_vita.py Ultravox v0.5 and VITA-1.5 adapters
train_gate_lora.py joint training of the risk gate and the safety adapters
run_defense.py gated inference with closed-loop scaling (--score-only: gate scores)
run_model.py undefended generation
judge.py Llama-Guard-3-8B safety judge
refusal.py refusal regex for the over-refusal metric
extract_hidden.py, analysis/ hidden-state probes for layer selection
scripts/
prepare_data.py downloaded datasets -> manifests (+ in-domain test splits)
run_baseline.sh step 0: undefended responses, judgments, training files
run_aegis.sh steps 1-4 for one protocol (PROTOCOL=indomain or lobo)
run_ablation.sh the Full and Always-on ablations
models.sh per-model gate layer, intervention layers, prompt mode
build_trainsets.py, calibrate_threshold.py, summarize.py
data/splits/ in-domain train/test ids used in the paper
docs/ method, results, analyses, porting guide
tests/ CPU tests of the evaluation protocol
pip install -r requirements.txt
每个模型都需要一个能够加载它的 Transformers 版本。上游之间存在分歧,因此我们为每个模型系列使用一个环境:
huggingface-cli login,或将 GUARD 和 AEGIS_LLAMA31_PATH 设置为本地副本。AEGIS_VITA_REPO 设置为该检出目录(默认:external/VITA)。DEVICE=auto 会对模型进行分片;门控和适配器跟随它们所挂钩的层)。Qwen2-Audio 和 Phi-4 在处理长 AJail 片段时也能从 DEVICE=auto 中受益。按照 data/README.md 中的说明下载五个数据集,然后构建清单:
python scripts/prepare_data.py --data-root data --out-dir data/manifests
该脚本会检查论文中使用的行数:AJail 1,490、JALM 946、SACRED 1,364、XSTest 250、Benign_train 215。它还会根据 data/splits/ 中的 id 列表写出域内测试划分(718 / 499 / 683 行)。
对于每个模型(PY 是该模型环境的 Python;JUDGE_PY 可以指向 Llama Guard 的不同环境):
MODEL=gemma4_e4b_it PY=python DEVICE=cuda:0 bash scripts/run_baseline.sh # step 0
MODEL=gemma4_e4b_it PROTOCOL=indomain PY=python DEVICE=cuda:0 bash scripts/run_aegis.sh # in-domain
MODEL=gemma4_e4b_it PROTOCOL=lobo PY=python DEVICE=cuda:0 bash scripts/run_aegis.sh # LOBO
每个阶段都可恢复;中断后重新运行相同命令即可。输出保存到 runs/<model>/:
baseline/ undefended responses; <bench>_judged.jsonl = Llama Guard labels
train/train_{indomain,lobo}_<bench>.jsonl
<protocol>/<bench>/adapter/ router_head.pt, late_adapters.pt, config.json
<protocol>/<bench>/scores/ gate scores on XSTest and on the evaluation set
<protocol>/<bench>/threshold.json
<protocol>/<bench>/defended/ defended responses and their judgments
<protocol>/summary.json unsafe rate, over-refusal, gate AUROC per benchmark
data/splits/ 中。LOBO(留一基准): AEGIS 在其他两个基准上训练,并在整个留出基准上评估。在两种设置中,被评估的数据从不参与阈值选择,XSTest 也从不用于训练。scripts/build_trainsets.py)。良性音频为 Benign_train,以模型自身未防御的答案作为目标。看起来有害且模型在基线时拒绝的良性提示会被丢弃。有害目标为通用拒绝模板。有害片段数量等于良性片段数量。种子 42。λ_BCE = 1.0,λ_L1 = 0.01。PROMPT_MODE=native);其他模型接收音频加一个固定文本提示。门控读取依赖于提示的隐藏状态,因此适配器仅在其训练时所用的提示模式下有效。scripts/calibrate_threshold.py)。XSTest id 被排序并交替拆分为验证半集和测试半集。阈值是使验证半集上增加的过度拒绝至多为 10% 的最小门控分数,统计基于未防御模型回答过的提示。REFUSAL_PHRASE_SET=multi,由 run_aegis.sh 设置),因此非英语拒绝也会被计入。scripts/summarize.py):不安全率是被 Llama-Guard-3-8B 标记为 unsafe 的评估行占比;过度拒绝是匹配 的 XSTest 响应占比,报告基于全部 250 个提示以及测试半集;门控 AUROC 使用原始门控分数,以攻击为正例、XSTest 为负例。MODEL=qwen2_audio VARIANT=full bash scripts/run_ablation.sh # LoRA on all layers, no gate
MODEL=qwen2_audio VARIANT=always_on bash scripts/run_ablation.sh # AEGIS layers, no gate
python -m unittest discover tests
@misc{liao2027aegis,
title = {{AEGIS}: Audio Endogenous Guarding via Internal Signals Against Large Audio-Language Model Jailbreaks},
author = {Liao, Yu-Ling and Chiu, Tzu-Chin and Chen, Zong-You and Tsai, Chi-Lei and Lo, Shao-Yuan},
note = {Submitted to ICASSP 2027},
year = {2026}
}
代码在 MIT License 下发布。基础模型(例如 Gemma 4、Ultravox 中的 Llama 3.1、Llama-Guard-3-8B)以及基准保留各自的许可证和使用条款。
MODEL | 基础模型 | Hugging Face id(覆盖变量) | 门控层 | 干预层 | 使用的 Transformers |
|---|
gemma4_e4b_it | Gemma 4 E4B IT | google/gemma-4-E4B-it (AEGIS_GEMMA4_PATH) | 21 | 25–41 | 5.7.0.dev0 |
phi4_mm | Phi-4-multimodal | microsoft/Phi-4-multimodal-instruct (AEGIS_PHI4_MM_PATH) | 15 | 19–31 | 5.7.0.dev0 |
vita_15 | VITA-1.5 | VITA-MLLM/VITA-1.5 (AEGIS_VITA_PATH) | 15 | 19–27 | 4.43.4 |
qwen2_audio | Qwen2-Audio-7B-Instruct | Qwen/Qwen2-Audio-7B-Instruct (AEGIS_QWEN2_AUDIO_PATH) | 15 | 19–31 | ≥ 4.45 |
ultravox_v05 | Ultravox v0.5 (Llama-3.1-8B) | fixie-ai/ultravox-v0_5-llama-3_1-8b (AEGIS_ULTRAVOX_PATH) | 15 | 19–31 | 4.48.1 |
voxtral_small | Voxtral Small 24B | mistralai/Voxtral-Small-24B-2507 (AEGIS_VOXTRAL_PATH) | 24 | 28–39 | 4.57.6 |
aegis/refusal.py