Skip to main content
QUICK REVIEW

[论文解读] ClarifyGPT: Empowering LLM-based Code Generation with Intention Clarification

Fangwen Mu, Lin Shi|arXiv (Cornell University)|Oct 17, 2023
Software Engineering ResearchComputer Science被引用 8
一句话总结

ClarifyGPT 通过代码一致性检查在需求模糊时进行识别,通过推理型提示提出有针对性的澄清性问题,并在用户反馈下生成 refined code。

ABSTRACT

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.

研究动机与目标

  • 在用户需求模糊或不完整时,推动改进代码生成。
  • 提出一个四阶段框架以检测歧义、生成澄清性问题并为代码生成细化提示。
  • 通过高保真用户仿真实现自动化评估,以实现大规模、可重复测试。
  • 在多个基准测试及真实用户反馈下评估 ClarifyGPT 以量化性能提升。

提出的方法

  • 阶段 1:使用种子输入和类型感知变异为给定需求生成高质量测试输入。
  • 阶段 2:通过对抽样的多份代码解进行输出比较,进行代码一致性检查以检测歧义。
  • 阶段 3:通过推理性提示分析代码解之间的不一致,生成有针对性的澄清性问题。
  • 阶段 4:结合澄清性问题的答案对原始需求进行 refine,并从 refined prompt 生成最终代码解。
Figure 1. The Overview of ClarifyGPT
Figure 1. The Overview of ClarifyGPT

实验结果

研究问题

  • RQ1RQ1:在真实用户反馈条件下,ClarifyGPT 相较基线的表现如何?
  • RQ2RQ2:在自动化评估中,ClarifyGPT 相较基线在模拟用户反馈下的表现如何?
  • RQ3RQ3:提示中演示示例数量对 ClarifyGPT 表现的影响如何?

主要发现

  • 在有人工反馈时,ClarifyGPT 提升了 GPT-4 的 MBPP-sanitized 的 Pass@1,从 70.96% 提升至 80.80%。
  • 在有人工反馈时,ClarifyGPT 提升了 GPT-4 的 MBPP-ET 的 Pass@1,从 51.52%(基线)提升至 60.19%。
  • 在四个基准上,ClarifyGPT 相对于基线在 GPT-4 上平均提升了 11.52 个百分点,在 ChatGPT 上平均提升了 15.07 个百分点。
  • 自动化仿真显示 ClarifyGPT 在四个基准上的平均 Pass@1 提升为 11.52%(GPT-4)和 15.07%(ChatGPT)。
  • ClarifyGPT 在人工辅助和自动评估中相较默认、Catal 得出显著提升,与 CoT、GPT-Engineer 基线相比均有明显优势。
Figure 2. List of basic type-aware mutations over input $x$ (Liu et al . , 2023b )
Figure 2. List of basic type-aware mutations over input $x$ (Liu et al . , 2023b )

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。