Lune

FSE2024顶会

ClarifyGPT: A Framework for Enhancing LLM-Based Code Generation via Requirements Clarification

Fangwen Mu, Lin Shi, Song Wang, Zhuohao Yu, Binquan Zhang, Chenxue Wang, Shichao Liu, Qing Wang

摘要

Large Language Models (LLMs), such as ChatGPT, have demonstrated impressive capabilities in automatically generating code from provided natural language requirements. However, in real-world practice, it is inevitable that the requirements written by users might be ambiguous or insufficient. Current LLMs will directly generate programs according to those unclear requirements, regardless of interactive clarification, which will likely deviate from the original user intents. To bridge that gap, we introduce a novel framework named C larify GPT, which aims to enhance code generation by empowering LLMs with the ability to identify ambiguous requirements and ask targeted clarifying questions. Specifically, C larify GPT first detects whether a given requirement is ambiguous by performing a code consistency check. If it is ambiguous, C larify GPT prompts an LLM to generate targeted clarifying questions. After receiving question responses, C larify GPT refines the ambiguous requirement and inputs it into the same LLM to generate a final code solution. To evaluate our C larify GPT, we invite ten participants to use C larify GPT for code generation on two benchmarks: MBPP-sanitized and MBPP-ET. The results show that C larify GPT elevates the performance (Pass@1) of GPT-4 from 70.96% to 80.80% on MBPP-sanitized. Furthermore, to conduct large-scale automated evaluations of C larify GPT across different LLMs and benchmarks without requiring user participation, we introduce a high-fidelity simulation method to simulate user responses. The results demonstrate that C larify GPT can significantly enhance code generation performance compared to the baselines. In particular, C larify GPT improves the average performance of GPT-4 and ChatGPT across five benchmarks from 62.43% to 69.60% and from 54.32% to 62.37%, respectively. A human evaluation also confirms the effectiveness of C larify GPT in detecting ambiguous requirements and generating high-quality clarifying questions. We believe that C larify GPT can effectively facilitate the practical application of LLMs in real-world development environments.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 21 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Self-Consistency Improves Chain of Thought Reasoning in Language Models 引用了 Large Language Models are Zero-Shot Reasoners
  • Large Language Models are Zero-Shot Reasoners 引用了 Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • Self-Consistency Improves Chain of Thought Reasoning in Language Models 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Chain-of-Thought Prompting Elicits Reasoning in Large Language Models 引用了 Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • What Makes a Good Natural Language Prompt? 引用了 Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • What Makes a Good Natural Language Prompt? 引用了 Large Language Models are Zero-Shot Reasoners
  • What Makes a Good Natural Language Prompt? 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Large Language Models are Zero-Shot Reasoners 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • RustAssure: Differential Symbolic Testing for LLM-Transpiled C-to-Rust Code 引用了 Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
  • SpecRover: Code Intent Extraction via LLMs 引用了 Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper21

  1. What Makes a Good Natural Language Prompt?Do Xuan Long, Duy Dinh, Ngoc-Hai Nguyen, Kenji Kawaguchi 等ACL 2025 · 13 次引用
  2. SpecRover: Code Intent Extraction via LLMsHaifeng Ruan, Yuntong Zhang, Abhik RoychoudhuryICSE 2025 · 12 次引用
  3. LiSSA: Toward Generic Traceability Link Recovery Through Retrieval- Augmented GenerationDominik Fuchß, Tobias Hey, Jan Keim, Haoyu Liu 等ICSE 2025 · 8 次引用
  4. RustAssure: Differential Symbolic Testing for LLM-Transpiled C-to-Rust CodeYubo Bai, Tapti PalitASE 2025 · 8 次引用
  5. An LLM-Based Agent-Oriented Approach for Automated Code Design Issue LocalizationFraol Batole, David O'Brien, Tien N. Nguyen, Robert Dyer 等ICSE 2025 · 7 次引用

它引用的 Paper17

  1. Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma 等NeurIPS 2022 · 22,562 次引用
  2. Large Language Models are Zero-Shot ReasonersTakeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo 等NeurIPS 2022 · 8,168 次引用
  3. Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code GenerationJiawei Liu, Chunqiu Steven Xia, Yuyao Wang, Lingming ZhangNeurIPS 2023 · 2,317 次引用
  4. CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 次引用
  5. Self-Consistency Improves Chain of Thought Reasoning in Language ModelsXuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V. Le 等ICLR 2023 · 681 次引用

相关 Paper

  1. CLAMBER: A Benchmark of Identifying and Clarifying Ambiguous Information Needs in Large Language ModelsTong Zhang, Peixin Qin, Yang Deng, Chen Huang 等ACL 2024
  2. Automated Repair of Ambiguous Problem Descriptions for LLM-Based Code GenerationHaoxiang Jia, Robbie Morris, He Ye, Federica Sarro 等ASE 2025 · 6 次引用
  3. ConTested: Consistency-Aided Tested Code Generation with LLMJinhao Dong, Jun Sun, Wenjie Zhang, Jin Song Dong 等ISSTA 2025 · 6 次引用
  4. Python Code Generation by Asking Clarification QuestionsHaau-Sing Li, Mohsen Mesgar, André F. T. Martins, Iryna GurevychACL 2023 · 3 次引用
  5. Prompting and Evaluating Large Language Models for Proactive Dialogues: Clarification, Target-guided, and Non-collaborationYang Deng, Lizi Liao, Liang Chen, Hongru Wang 等EMNLP Findings 2023 · 55 次引用
黄昏的海面,两侧是细线勾勒的悬崖