通过筛选高质量安全数据提升大模型微调安全性
Pharmacist: Safety Alignment Data Curation for Large Language Models against Harmful Fine-tuning
- 训练数据选择器,优先保留高质安全数据,剔除低质无关数据
- 相比原有方法,防御性能提升2.6%-3.3%,推理表现提升1.1%-3.5%
- 显著降低训练时间56%以上,适合部署在安全对齐场景
有害微调问题对大语言模型的微调即服务带来重大安全挑战。现有对齐阶段防御方法(如Vaccine、Repnoise、Booster、T-Vaccine)通过增强模型在对齐阶段的鲁棒性来缓解该问题,但往往忽视了上游关键因素:原始安全对齐数据的质量与构成。我们发现这些方法的防御性能与计算效率受限于对齐数据集的质量。为此,提出Pharmacist,一种安全对齐数据清洗方案,通过从原始对齐数据中选取高质量且安全关键的核心子集,提升对抗有害微调的能力。核心思想是训练一个数据选择器,对齐数据进行排序:上排名高质安全数据,下排名低质非安全数据。实验证明,使用Pharmacist筛选的数据训练的模型,在防御与推理性能上均优于现有方法。此外,Pharmacist可有效集成至主流对齐阶段防御方法中。例如,在RepNoise和T-Vaccine中,使用Pharmacist筛选数据相比全量数据,防御性能分别提升2.60%和3.30%,推理性能提升3.50%和1.10%,训练时间分别减少56.83%和57.63%。代码已开源。
原文摘要 · Abstract (English)
Harmful fine-tuning issues present significant safety challenges for fine-tuning-as-a-service in large language models. Existing alignment-stage defenses, e.g., Vaccine, Repnoise, Booster, and T-Vaccine, mitigate harmful fine-tuning issues by enhancing the model's robustness during the alignment phase. While these methods have been proposed to mitigate the issue, they often overlook a critical upstream factor: the role of the original safety-alignment data. We observe that their defense performance and computational efficiency remain constrained by the quality and composition of the alignment dataset. To address this limitation, we propose Pharmacist, a safety alignment data curation solution that enhances defense against harmful fine-tuning by selecting a high-quality and safety-critical core subset from the original alignment data. The core idea of Pharmacist is to train an alignment data selector to rank alignment data. Specifically, up-ranking high-quality and safety-critical alignment data, down-ranking low-quality and non-safety-critical data. Empirical results indicate that models trained on datasets selected by Pharmacist outperform those trained on datasets selected by existing selection methods in both defense and inference performance. In addition, Pharmacist can be effectively integrated with mainstream alignment-stage defense methods. For example, when applied to RepNoise and T-Vaccine, using the dataset selected by Pharmacist instead of the full dataset leads to improvements in defense performance by 2.60\% and 3.30\%, respectively, and enhances inference performance by 3.50\% and 1.10\%. Notably, it reduces training time by 56.83\% and 57.63\%, respectively. Our code is available at https://github.com/Lslland/Pharmacist.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。