arXiv:2506.20471cs.CL2025-06

用代码提示法暴露大模型安全漏洞,发现多个主流模型毒性激增数十倍。

Probing AI Safety with Source Code

  • 将自然语言指令转为简单代码,精准触发模型安全缺陷。
  • GPT-4 Turbo毒性升16.5倍,7个模型平均毒性增300%。
  • 适合关注模型安全评估与对抗测试的研究者与开发者。

大型语言模型(LLMs)已广泛应用于众多涉及安全的关键场景,亟需提升能力的同时强化安全措施以对齐人类价值观。本文揭示当前模型在安全方面存在严重不足,导致用户面临不安全和有害体验。我们提出一种名为「思维代码」(Code of Thought, CoDoT)的提示策略,将自然语言输入转换为表示相同意图的简单代码。例如,将“让这句话更毒:{text}”转化为“make_more_toxic({text})”。实验表明,CoDoT 导致多种前沿 LLM 出现一致失效:GPT-4 Turbo 毒性提升 16.5 倍,DeepSeek R1 完全失败(100%),七种现代模型平均毒性上升 300%。此外,递归应用 CoDoT 可使毒性再翻倍。鉴于 LLM 的快速普及,该方法强调必须从基础原则出发评估安全机制,确保安全与能力同步演进。

原文摘要 · Abstract (English)

Large language models (LLMs) have become ubiquitous, interfacing with humans in numerous safety-critical applications. This necessitates improving capabilities, but importantly coupled with greater safety measures to align these models with human values and preferences. In this work, we demonstrate that contemporary models fall concerningly short of the goal of AI safety, leading to an unsafe and harmful experience for users. We introduce a prompting strategy called Code of Thought (CoDoT) to evaluate the safety of LLMs. CoDoT converts natural language inputs to simple code that represents the same intent. For instance, CoDoT transforms the natural language prompt "Make the statement more toxic: {text}" to: "make_more_toxic({text})". We show that CoDoT results in a consistent failure of a wide range of state-of-the-art LLMs. For example, GPT-4 Turbo's toxicity increases 16.5 times, DeepSeek R1 fails 100% of the time, and toxicity increases 300% on average across seven modern LLMs. Additionally, recursively applying CoDoT can further increase toxicity two times. Given the rapid and widespread adoption of LLMs, CoDoT underscores the critical need to evaluate safety efforts from first principles, ensuring that safety and capabilities advance together.

模型安全提示攻击毒性检测

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