arXiv:2410.01524cs.CLcs.LG2024-10ICLR被引 22

用大模型生成恶意指令,提升小模型安全检测能力。

HarmAug: Effective Data Augmentation for Knowledge Distillation of Safety Guard Models

  • 让大模型自动生成恶意指令,扩充训练数据多样性。
  • 4.35亿参数小模型在F1上媲美70亿参数大模型。
  • 适合移动端部署的轻量级安全防护模型研发者。

针对大型语言模型(LLM)的安全防护需求,现有安全守卫模型因参数量巨大,在移动端部署面临内存和延迟瓶颈。为降低成本,本文通过标注数据集对大模型进行知识蒸馏,得到小型守卫模型。但现有数据集中恶意指令种类有限,导致蒸馏后的小模型性能不足。为此提出HarmAug:利用大模型生成恶意指令,先以“我有个想法”等前缀引导其输出完整恶意提示,再由另一大模型生成响应,并由教师模型打标。实验表明,该方法显著优于基线。使用HarmAug训练的4.35亿参数模型在F1上达到与超过70亿参数大模型相当的水平,且在AUPRC上更优,计算成本低于其25%。

原文摘要 · Abstract (English)

Safety guard models that detect malicious queries aimed at large language models (LLMs) are essential for ensuring the secure and responsible deployment of LLMs in real-world applications. However, deploying existing safety guard models with billions of parameters alongside LLMs on mobile devices is impractical due to substantial memory requirements and latency. To reduce this cost, we distill a large teacher safety guard model into a smaller one using a labeled dataset of instruction-response pairs with binary harmfulness labels. Due to the limited diversity of harmful instructions in the existing labeled dataset, naively distilled models tend to underperform compared to larger models. To bridge the gap between small and large models, we propose HarmAug, a simple yet effective data augmentation method that involves jailbreaking an LLM and prompting it to generate harmful instructions. Given a prompt such as, "Make a single harmful instruction prompt that would elicit offensive content", we add an affirmative prefix (e.g., "I have an idea for a prompt:") to the LLM's response. This encourages the LLM to continue generating the rest of the response, leading to sampling harmful instructions. Another LLM generates a response to the harmful instruction, and the teacher model labels the instruction-response pair. We empirically show that our HarmAug outperforms other relevant baselines. Moreover, a 435-million-parameter safety guard model trained with HarmAug achieves an F1 score comparable to larger models with over 7 billion parameters, and even outperforms them in AUPRC, while operating at less than 25% of their computational cost.

知识蒸馏安全检测数据增强轻量化模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。