CodeAttack:通过代码补全揭示大语言模型的安全泛化挑战
CodeAttack: Revealing Safety Generalization Challenges of Large Language Models via Code Completion
AI总结:
本研究提出CodeAttack框架,将自然语言输入转为代码输入测试大语言模型安全泛化性,发现其超80%概率绕过前沿模型安全护栏,揭示代码域安全风险与对齐算法优化需求。
摘要:
大语言模型(LLM)的快速发展带来了卓越的生成能力,但也引发了人们对其潜在滥用的担忧。尽管监督微调、基于人类反馈的强化学习等策略提升了模型的安全性,但这些方法主要聚焦于自然语言领域,可能无法泛化到其他领域。本文提出CodeAttack框架,该框架可将自然语言输入转换为代码输入,为测试LLM的安全泛化能力提供了全新环境。我们对GPT-4、Claude-2、Llama-2系列等前沿LLM开展了全面研究,发现这类模型普遍存在针对代码输入的新型安全漏洞:CodeAttack绕过所有模型安全护栏的成功率超过80%。研究发现,CodeAttack与自然语言之间的分布差距越大,安全泛化能力越弱,例如用数据结构对自然语言输入进行编码的场景。此外,我们提出了CodeAttack奏效的假设:LLM在代码训练过程中习得的偏差存在对齐错位,即模型更优先完成代码补全任务,而非规避潜在安全风险。最后,我们分析了潜在的缓解措施。这些发现凸显了代码领域的新型安全风险,表明需要更鲁棒的安全对齐算法来匹配LLM的代码能力。
英文摘要:
The rapid advancement of Large Language Models (LLMs) has brought about remarkable generative capabilities but also raised concerns about their potential misuse. While strategies like supervised fine-tuning and reinforcement learning from human feedback have enhanced their safety, these methods primarily focus on natural languages, which may not generalize to other domains. This paper introduces CodeAttack, a framework that transforms natural language inputs into code inputs, presenting a novel environment for testing the safety generalization of LLMs. Our comprehensive studies on state-of-the-art LLMs including GPT-4, Claude-2, and Llama-2 series reveal a new and universal safety vulnerability of these models against code input: CodeAttack bypasses the safety guardrails of all models more than 80\% of the time. We find that a larger distribution gap between CodeAttack and natural language leads to weaker safety generalization, such as encoding natural language input with data structures. Furthermore, we give our hypotheses about the success of CodeAttack: the misaligned bias acquired by LLMs during code training, prioritizing code completion over avoiding the potential safety risk. Finally, we analyze potential mitigation measures. These findings highlight new safety risks in the code domain and the need for more robust safety alignment algorithms to match the code capabilities of LLMs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。