通过回译防御大语言模型免受越狱攻击
Defending LLMs against Jailbreaking Attacks via Backtranslation
AI总结:
本文提出一种基于回译的LLM越狱攻击防御方法:通过从模型响应反推原始提示意图,再据此判断是否拒绝请求,实验表明该方法在困难案例中显著优于基线且对良性输入影响极小。
摘要:
尽管许多大语言模型(LLMs)已经经过训练以拒绝有害请求,但它们仍然容易受到越狱攻击,这类攻击会改写原始提示以隐藏其有害意图。在本文中,我们提出了一种通过“回译”来防御大语言模型免受越狱攻击的新方法。具体而言,给定目标大语言模型根据输入提示生成的初始响应,我们的回译方法会提示一个语言模型去推断一个能够导致该响应的输入提示。这个推断出的提示被称为回译提示,它往往能够揭示原始提示的真实意图,因为它是基于大语言模型的响应生成的,而不是由攻击者直接操纵的。然后,我们在回译提示上再次运行目标大语言模型,如果模型拒绝了回译提示,我们就拒绝原始提示。我们说明所提出的防御方法在有效性和效率方面提供了若干优势。我们通过实验证明,我们的防御方法在基线方法难以处理的案例中显著优于基线方法,同时我们的防御方法对良性输入提示的生成质量几乎没有影响。我们的实现基于我们的大语言模型越狱防御算法库,网址为 \url{https://github.com/YihanWang617/llm-jailbreaking-defense},用于复现我们实验的代码可在 \url{https://github.com/YihanWang617/LLM-Jailbreaking-Defense-Backtranslation} 获取。
英文摘要:
Although many large language models (LLMs) have been trained to refuse harmful requests, they are still vulnerable to jailbreaking attacks which rewrite the original prompt to conceal its harmful intent. In this paper, we propose a new method for defending LLMs against jailbreaking attacks by ``backtranslation''. Specifically, given an initial response generated by the target LLM from an input prompt, our backtranslation prompts a language model to infer an input prompt that can lead to the response. The inferred prompt is called the backtranslated prompt which tends to reveal the actual intent of the original prompt, since it is generated based on the LLM's response and not directly manipulated by the attacker. We then run the target LLM again on the backtranslated prompt, and we refuse the original prompt if the model refuses the backtranslated prompt. We explain that the proposed defense provides several benefits on its effectiveness and efficiency. We empirically demonstrate that our defense significantly outperforms the baselines, in the cases that are hard for the baselines, and our defense also has little impact on the generation quality for benign input prompts. Our implementation is based on our library for LLM jailbreaking defense algorithms at \url{https://github.com/YihanWang617/llm-jailbreaking-defense}, and the code for reproducing our experiments is available at \url{https://github.com/YihanWang617/LLM-Jailbreaking-Defense-Backtranslation}.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。