arXiv:2412.13705cs.CVcs.AI2024-12被引 2

通过添加特定后缀提升大模型抗攻击能力,不需重训练

Mitigating Adversarial Attacks in LLMs through Defensive Suffix Generation

  • 在输入前添加优化过的防御后缀,抵御恶意扰动
  • 平均降低11%攻击成功率,Gemma-7B困惑度从6.57降至3.93
  • 适合部署于医疗、金融等高安全需求场景

大语言模型在自然语言处理任务中表现卓越,但对输入扰动仍易受攻击,导致有害或误导性输出。本文提出一种基于梯度的防御后缀生成算法,通过在输入提示中添加精心优化的防御后缀,在保持模型功能的同时增强鲁棒性。设计了一种结合防御损失($L_{ ext{def}}$)与对抗损失($L_{ ext{adv}}$)的总损失函数($L_{ ext{total}}$),更有效地生成防御后缀。在Gemma-7B、mistral-7B、Llama2-7B和Llama2-13B等开源模型上实验表明,该方法相比无防御后缀的模型,平均降低11%攻击成功率。Gemma-7B在使用openELM-270M生成的防御后缀下,困惑度从6.57降至3.93。TruthfulQA评估显示,各类配置下真实性得分最高提升10%。该方法显著提升关键应用中的安全性,且无需大规模重新训练。

原文摘要 · Abstract (English)

Large language models (LLMs) have exhibited outstanding performance in natural language processing tasks. However, these models remain susceptible to adversarial attacks in which slight input perturbations can lead to harmful or misleading outputs. A gradient-based defensive suffix generation algorithm is designed to bolster the robustness of LLMs. By appending carefully optimized defensive suffixes to input prompts, the algorithm mitigates adversarial influences while preserving the models' utility. To enhance adversarial understanding, a novel total loss function ($L_{\text{total}}$) combining defensive loss ($L_{\text{def}}$) and adversarial loss ($L_{\text{adv}}$) generates defensive suffixes more effectively. Experimental evaluations conducted on open-source LLMs such as Gemma-7B, mistral-7B, Llama2-7B, and Llama2-13B show that the proposed method reduces attack success rates (ASR) by an average of 11\% compared to models without defensive suffixes. Additionally, the perplexity score of Gemma-7B decreased from 6.57 to 3.93 when applying the defensive suffix generated by openELM-270M. Furthermore, TruthfulQA evaluations demonstrate consistent improvements with Truthfulness scores increasing by up to 10\% across tested configurations. This approach significantly enhances the security of LLMs in critical applications without requiring extensive retraining.

大模型安全对抗攻击防御机制

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