ClarifyGPT:通过意图澄清增强基于LLM的代码生成
ClarifyGPT: Empowering LLM-based Code Generation with Intention Clarification
AI总结:
ClarifyGPT通过检测需求模糊性并生成针对性澄清问题,提升LLM代码生成性能,在多个基准上将GPT-4和ChatGPT的平均Pass@1分别提高至75.75%和67.22%。
摘要:
我们引入了一个名为ClarifyGPT的新框架,旨在通过赋予LLM识别模糊需求并提出针对性澄清问题的能力来增强代码生成。具体而言,ClarifyGPT首先通过执行代码一致性检查来检测给定需求是否模糊。如果需求模糊,ClarifyGPT会提示LLM生成针对性的澄清问题。在收到问题回答后,ClarifyGPT会细化模糊需求,并将其输入到同一个LLM中以生成最终的代码解决方案。为了评估我们的ClarifyGPT,我们首先进行了一项人工评估,涉及十名参与者在两个公开可用的基准测试(MBPP-sanitized和MBPP-ET)上使用ClarifyGPT进行代码生成。结果表明,ClarifyGPT将GPT-4在MBPP-sanitized上的性能(Pass@1)从70.96%提升到了80.80%。此外,为了在不同LLM和基准测试上对ClarifyGPT进行大规模自动化评估而无需用户参与,我们引入了一种高保真模拟方法来模拟用户回答。自动化评估结果也表明,与基线相比,ClarifyGPT能够显著提升代码生成性能。特别是,ClarifyGPT将GPT-4和ChatGPT在四个基准测试上的平均性能分别从68.02%提升到75.75%,以及从58.55%提升到67.22%。我们相信,ClarifyGPT能够有效促进LLM在真实世界开发环境中的实际应用。
英文摘要:
We introduce a novel framework named ClarifyGPT, which aims to enhance code generation by empowering LLMs with the ability to identify ambiguous requirements and ask targeted clarifying questions. In particular, ClarifyGPT first detects whether a given requirement is ambiguous by performing a code consistency check. If it is ambiguous, ClarifyGPT prompts an LLM to generate targeted clarifying questions. After receiving question responses, ClarifyGPT refines the ambiguous requirement and inputs it into the same LLM to generate a final code solution. To evaluate our ClarifyGPT, we first conduct a human evaluation involving ten participants who use ClarifyGPT for code generation on two publicly available benchmarks: MBPP-sanitized and MBPP-ET. The results show that ClarifyGPT elevates the performance (Pass@1) of GPT-4 from 70.96% to 80.80% on MBPP-sanitized. Furthermore, to perform large-scale automated evaluations of ClarifyGPT across different LLMs and benchmarks without requiring user participation, we introduce a high-fidelity simulation method to simulate user responses. The automated evaluation results also demonstrate that ClarifyGPT can significantly enhance code generation performance compared to the baselines. In particular, ClarifyGPT improves the average performance of GPT-4 and ChatGPT across four benchmarks from 68.02% to 75.75% and from 58.55% to 67.22%, respectively. We believe that ClarifyGPT can effectively facilitate the practical application of LLMs in real-world development environments.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。