arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2304.05128cs.CLcs.AI
收藏

教大型语言模型进行自调试

Teaching Large Language Models to Self-Debug

Google DeepMind(谷歌DeepMind);UC Berkeley(加州大学伯克利分校)

Xinyun Chen, Maxwell Lin, Nathanael Schärli, Denny Zhou

AI总结:

针对复杂编程任务中LLM一次性生成正确代码难的问题,提出Self-Debugging少样本自调试方法,通过橡皮鸭调试实现无人工反馈的代码自查,在多个代码生成基准上取得SOTA并大幅提升样本效率。

摘要:

大型语言模型(LLMs)在代码生成领域已取得令人瞩目的性能表现。然而,对于复杂编程任务,一次性生成正确解决方案颇具挑战性,因此已有部分研究设计了程序修复方法以提升代码生成性能。本研究提出Self-Debugging(自调试)方法,通过少样本示例教大型语言模型调试其预测的程序。具体而言,我们证明Self-Debugging可教会大型语言模型执行橡皮鸭调试;即无需任何关于代码正确性或错误信息的人工反馈,模型就能通过检查执行结果、用自然语言解释生成的代码来识别自身错误。Self-Debugging在多个代码生成基准上取得了当前最优性能,包括用于文本到SQL生成的Spider数据集、用于C++转Python翻译的TransCoder以及用于文本到Python生成的MBPP。在无单元测试验证预测正确性的Spider基准上,带代码解释功能的Self-Debugging持续将基线性能提升2-3%,并将最难级别问题的预测准确率提升9%。在有单元测试可用的TransCoder和MBPP上,Self-Debugging将基线准确率最高提升12%。同时,通过利用反馈信息并复用失败预测,Self-Debugging显著提升了样本效率,其性能可匹配甚至优于生成10倍以上候选程序的基线模型。

英文摘要:

Large language models (LLMs) have achieved impressive performance on code generation. However, for complex programming tasks, generating the correct solution in one go becomes challenging, thus some prior works have designed program repair approaches to improve code generation performance. In this work, we propose Self-Debugging, which teaches a large language model to debug its predicted program via few-shot demonstrations. In particular, we demonstrate that Self-Debugging can teach the large language model to perform rubber duck debugging; i.e., without any human feedback on the code correctness or error messages, the model is able to identify its mistakes by investigating the execution results and explaining the generated code in natural language. Self-Debugging achieves the state-of-the-art performance on several code generation benchmarks, including the Spider dataset for text-to-SQL generation, TransCoder for C++-to-Python translation, and MBPP for text-to-Python generation. On the Spider benchmark where there are no unit tests to verify the correctness of predictions, Self-Debugging with code explanation consistently improves the baseline by 2-3%, and improves the prediction accuracy on problems of the hardest level by 9%. On TransCoder and MBPP where unit tests are available, Self-Debugging improves the baseline accuracy by up to 12%. Meanwhile, by leveraging feedback messages and reusing failed predictions, Self-Debugging notably improves sample efficiency, and can match or outperform baseline models that generate more than 10x candidate programs.

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

↑