修复大型语言模型的规范误解以实现更好的代码生成
Fixing Large Language Models' Specification Misunderstanding for Better Code Generation
AI总结:
提出μFiX提示技术,结合思维启发与基于反馈的提示并探索其协同作用,通过测试用例分析和自我改进过程修复LLMs的规范误解,显著提升了代码生成性能。
摘要:
代码生成旨在自动生成符合给定编程规范的源代码,随着大型语言模型(LLMs)的发展,这一领域受到了广泛关注。由于代码生成固有的难度,LLMs生成的代码可能与规范不一致。尽管已经提出了思维启发提示技术来增强LLMs的代码生成性能,但对复杂编程问题产生正确理解仍然具有挑战性,导致性能不理想。此外,一些基于反馈的提示技术被提出,利用测试执行产生的错误信息来修复不正确的代码。然而,当生成的代码与真实答案偏差较大时,它们难以基于这种粗粒度信息来提升性能。在本工作中,我们提出了一种名为μFiX的新型提示技术,通过设计复杂的思维启发提示和基于反馈的提示,并首次探索它们的协同作用,来提高LLMs的代码生成性能。它首先利用测试用例分析来获取规范理解,并启用自我改进过程,在思维启发提示阶段识别并细化误解。μFiX进一步在基于反馈的提示阶段,朝着缩小所提供的理解(来自第一阶段)与LLMs在代码生成中隐式利用的实际理解之间差距的方向,修复规范理解。通过使用μFiX改进理解,LLMs的代码生成性能可以得到大幅提升。我们在两个先进的LLMs(ChatGPT和DeepSeek-Coder)上使用六个广泛使用的基准进行评估,通过与15个基线比较,证明了μFiX的有效性...
英文摘要:
Code generation is to automatically generate source code conforming to a given programming specification, which has received extensive attention especially with the development of large language models (LLMs). Due to the inherent difficulty of code generation, the code generated by LLMs may not be aligned with the specification. Although thought-eliciting prompting techniques have been proposed to enhance the code generation performance of LLMs, producing correct understanding for complicated programming problems remains challenging, resulting in unsatisfactory performance. Also, some feedback-based prompting techniques have been proposed to fix incorrect code using error messages produced by test execution. However, when the generated code deviates significantly from the ground truth, they encounter difficulties in improving performance based on such coarse-grained information. In this work, we propose a novel prompting technique, called μFiX, to improve the code generation performance of LLMs by devising both sophisticated thought-eliciting prompting and feedback-based prompting and making the first exploration on their synergy. It first exploits test case analysis to obtain specification understanding and enables a self-improvement process to identify and refine the misunderstanding in the thought-eliciting prompting phase. μFiX further fixes the specification understanding towards the direction reducing the gap between the provided understanding (from the first phase) and the actual understanding implicitly utilized by LLMs for code generation in the feedback-based prompting phase. By improving the understanding with μFiX, the code generation performance of LLMs can be largely improved. Our evaluation on two advanced LLMs (ChatGPT and DeepSeek-Coder) with six widely-used benchmarks by comparing with 15 baselines, demonstrates the effectiveness of μFiX ...
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。