Python Code Generation by Asking Clarification Questions
Haau-Sing Li, Mohsen Mesgar, André F. T. Martins, Iryna Gurevych
摘要
Code generation from text requires understanding the user's intent from a natural language description and generating an executable code snippet that satisfies this intent. While recent pretrained language models demonstrate remarkable performance for this task, these models fail when the given natural language description is under-specified. In this work, we introduce a novel and more realistic setup for this task. We hypothesize that the underspecification of a natural language description can be resolved by asking clarification questions. Therefore, we collect and introduce a new dataset named CodeClarQA containing pairs of natural language descriptions and code with created synthetic clarification questions and answers. The empirical results of our evaluation of pretrained language model performance on code generation show that clarifications result in more precisely generated code, as shown by the substantial improvement of model performance in all evaluation metrics. Alongside this, our task and dataset introduce new challenges to the community, including when and what clarification questions should be asked. Our code and dataset are available on GitHub. 1
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 4 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation 引用了 BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension
- ClarifyGPT: A Framework for Enhancing LLM-Based Code Generation via Requirements Clarification 引用了 CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
- ClarifyGPT: A Framework for Enhancing LLM-Based Code Generation via Requirements Clarification 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- Identifying & Interactively Refining Ambiguous User Goals for Data Visualization Code Generation 引用了 ClarifyGPT: A Framework for Enhancing LLM-Based Code Generation via Requirements Clarification
引用它的顶会 Paper4
- ClarifyGPT: A Framework for Enhancing LLM-Based Code Generation via Requirements ClarificationFangwen Mu, Lin Shi, Song Wang, Zhuohao Yu 等FSE 2024 · 49 次引用
- Topological Active Inference for Task DisambiguationYangbo Wei, Zhen Huang, Shaoqiang Lu, Junhong Qian 等ICML 2026
- Talking to a Know-It-All GPT or a Second-Guesser Claude? How Repair reveals distinct Multi-Turn Behavior in LLMsClara Lachenmaier, Hannah Bultmann, Sina ZarrießACL 2026
- Identifying & Interactively Refining Ambiguous User Goals for Data Visualization Code GenerationMert Inan, Anthony Sicilia, Alex Xie, Saujas Vaduguru 等EMNLP 2025
它引用的 Paper8
- BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and ComprehensionMike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad 等ACL 2020 · 1,224 次引用
- 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 次引用
- CodeGen: An Open Large Language Model for Code with Multi-Turn Program SynthesisErik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu 等ICLR 2023 · 234 次引用
- Retrieval Augmented Code Generation and SummarizationMd. Rizwan Parvez, Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray 等EMNLP Findings 2021 · 141 次引用
- Building and Evaluating Open-Domain Dialogue Corpora with Clarifying QuestionsMohammad Aliannejadi, Julia Kiseleva, Aleksandr Chuklin, Jeff Dalton 等EMNLP 2021 · 61 次引用
相关 Paper
- Prompting with Pseudo-Code InstructionsMayank Mishra, Prince Kumar, Riyaz A. Bhat, Rudra Murthy V 等EMNLP 2023 · 4 次引用
- Clarify Before You Draw: Proactive Agents for Robust Text-to-CAD GenerationBo Yuan, Zelin Zhao, Petr Molodyk, Bin Hu 等ICML 2026 · 6 次引用
- The Vault: A Comprehensive Multilingual Dataset for Advancing Code Understanding and GenerationDung Nguyen Manh, Le Nam Hai, Anh T. V. Dau, Anh Minh Nguyen 等EMNLP Findings 2023 · 6 次引用
- Efficient Hallucination Detection in Automatic Code GenerationGeorgii Andriushchenko, Roman Garaev, Lyudmila Rvanova, Artem Shelmanov 等ACL Findings 2026
- When Prompts Go Wrong: Evaluating Code Model Robustness to Ambiguous, Contradictory, and Incomplete Task DescriptionsMaya Larbi, Amal Akli, Mike Papadakis, Rihab Bouyousfi 等ICSE 2026
