arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.02518cs.SEcs.AIcs.CLcs.CRcs.MAcs.PL

INDICT:面向安全性与有用性的、带批评性内部对话的代码生成

INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulness

Salesforce Research(Salesforce研究院)

Hung Le, Yingbo Zhou, Caiming Xiong, Silvio Savarese, Doyen Sahoo

AI总结:

本研究提出INDICT框架,通过安全与有用性双批评者的内部对话结合外部知识,在代码生成与执行阶段提供指导,显著提升了不同规模LLM输出代码的质量与安全性。

摘要:

用于代码生成的大语言模型(LLM)通常经过训练以对齐自然语言指令,从而紧密遵循用户的意图和要求。然而在许多实际场景中,这些模型越来越难以把握有用性和安全性之间的复杂边界,尤其是在应对高度复杂但可能带有恶意的指令时。本研究提出了INDICT:一个为LLM赋予批评性内部对话的新框架,可同时提供安全性和有用性指导。该内部对话是由安全驱动批评者和有用性驱动批评者组成的双重协作系统,每个批评者都会针对给定任务和对应的生成响应提供分析,且配备了通过相关代码片段、网页搜索、代码解释器等工具查询到的外部知识。我们将双重批评系统应用于代码生成阶段和代码执行阶段,分别为LLM提供事前指导和事后指导。我们在来自5个基准的8种编程语言的8项不同任务上评估了INDICT,使用的LLM参数规模从7B到70B不等。实验结果表明,该方法能够提供高水平的安全性与有用性分析批评,显著提升输出代码的质量(所有模型的绝对提升均达+10%)。

英文摘要:

Large language models (LLMs) for code are typically trained to align with natural language instructions to closely follow their intentions and requirements. However, in many practical scenarios, it becomes increasingly challenging for these models to navigate the intricate boundary between helpfulness and safety, especially against highly complex yet potentially malicious instructions. In this work, we introduce INDICT: a new framework that empowers LLMs with Internal Dialogues of Critiques for both safety and helpfulness guidance. The internal dialogue is a dual cooperative system between a safety-driven critic and a helpfulness-driven critic. Each critic provides analysis against the given task and corresponding generated response, equipped with external knowledge queried through relevant code snippets and tools like web search and code interpreter. We engage the dual critic system in both code generation stage as well as code execution stage, providing preemptive and post-hoc guidance respectively to LLMs. We evaluated INDICT on 8 diverse tasks across 8 programming languages from 5 benchmarks, using LLMs from 7B to 70B parameters. We observed that our approach can provide an advanced level of critiques of both safety and helpfulness analysis, significantly improving the quality of output codes ($+10\%$ absolute improvements in all models).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑