arXiv:2507.21285cs.AI2025-07被引 6

让大模型像人一样问问题,提升代码生成准确率

Curiosity by Design: An LLM-based Coding Assistant Asking Clarification Questions

  • 用分类器识别模糊代码请求,再由微调模型生成追问问题
  • 相比直接提问,生成的澄清问题更有效,用户满意度更高
  • 适合需要精准代码生成的开发者或自动化工具集成

大型语言模型(LLMs)在代码辅助中应用日益广泛,但开发者的提示常存在歧义,导致生成代码错误。当前模型缺乏上下文时难以推断用户意图,需大量提示工程支持。本文构建了一个模拟人类代码审查过程的端到端系统:首先训练一个查询分类器以识别不明确的编程请求,再通过微调的LLM生成澄清问题。评估显示,微调后的模型在生成有用澄清问题方面优于标准零样本提示方法。此外,用户研究证实,本模型生成的问题比基线更受认可,使最终代码响应更准确、更实用。

原文摘要 · Abstract (English)

Large Language Models (LLMs) are increasingly used as coding assistants. However, the ambiguity of the developer's prompt often leads to incorrect code generation, as current models struggle to infer user intent without extensive prompt engineering or external context. This work aims to build an LLM-based coding assistant that mimics the human code review process by asking clarification questions when faced with ambiguous or under-specified queries. Our end-to-end system includes (1) a query classifier trained to detect unclear programming-related queries and (2) a fine-tuned LLM that generates clarification questions. Our evaluation shows that the fine-tuned LLM outperforms standard zero-shot prompting in generating useful clarification questions. Furthermore, our user study indicates that users find the clarification questions generated by our model to outperform the baseline, demonstrating that our coding assistant produces more accurate and helpful code responses compared to baseline coding assistants.

代码生成大模型交互式编程

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。