arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2504.16331cs.SEcs.LG
收藏

代码语言模型能否学习寻求澄清的行为?

Can Code Language Models Learn Clarification-Seeking Behaviors?

Michigan Technological University(密歇根技术大学);Indian Institute of Information Technology (IIIT)(印度信息科技研究所);University of California, San Diego (UCSD)(加州大学圣地亚哥分校);University of British Columbia(不列颠哥伦比亚大学);Stanford University(斯坦福大学)

Jie JW Wu, Manav Chaudhary, Davit Abrahamyan, Arhaan Khaku, Anjiang Wei, Fatemeh H. Fard

AI总结:

本文提出ClarifyCoder框架,通过合成数据生成和指令微调,使代码LLM在生成前识别并请求澄清歧义需求,显著提升沟通率与好问题率,同时保持代码生成性能。

摘要:

大型语言模型(LLMs)在代码生成任务中展现出了卓越的能力。然而,其输出与人类开发人员的问题解决策略之间仍存在差距。与人类不同,人类会花费大量时间通过迭代对话来消除需求歧义,而LLMs在自然语言需求存在歧义时常常仍会生成代码,导致解决方案不可靠。与先前工作不同,我们研究代码LLM能否通过微调学习寻求澄清的行为。虽然近期工作集中于基于LLM的智能体进行迭代代码生成,但我们认为,识别和查询歧义需求的能力应内置于模型本身,尤其是在模型与人类协作的智能体AI中。我们提出了ClarifyCoder,一个包含合成数据生成和指令微调的框架,它微调LLM以在代码生成前识别歧义并请求澄清。我们的方法包含两个组件:(1)一种数据合成技术,通过为编程数据集增加需要澄清的场景,来生成澄清感知的训练数据;(2)一种微调策略,教会模型在面对不完整或模糊的需求时,优先寻求澄清而非立即生成代码。我们还提供了将ClarifyCoder与标准微调相结合以联合优化澄清意识和编码能力的实证分析。实验结果表明,ClarifyCoder在模糊任务上实现了63%的沟通率(绝对提升40%)和52%的好问题率(绝对提升30%),显著提升了LLMs的沟通能力,同时保持了代码生成性能。

英文摘要:

Large language models (LLMs) have demonstrated remarkable capabilities in code generation tasks. However, a gap remains between their output and the problem-solving strategies of human developers. Unlike humans, who spend substantial time disambiguating requirements through iterative dialogue, LLMs often generate code despite ambiguities in natural language requirements, leading to unreliable solutions. Different from prior work, we study whether a Code LLM can be fine-tuned to learn clarification-seeking behavior. While recent work has focused on LLM-based agents for iterative code generation, we argue that the ability to recognize and query ambiguous requirements should be intrinsic to the models themselves, especially in agentic AI where models and humans collaborate. We present ClarifyCoder, a framework with synthetic data generation and instruction-tuning that fine-tunes an LLM to identify ambiguities and request clarification before code generation. Our approach has two components: (1) a data synthesis technique that augments programming datasets with scenarios requiring clarification to generate clarification-aware training data, and (2) a fine-tuning strategy that teaches models to prioritize seeking clarification over immediate code generation when faced with incomplete or ambiguous requirements. We also provide an empirical analysis of integrating ClarifyCoder with standard fine-tuning for joint optimization of clarification-awareness and coding ability. Experimental results show that ClarifyCoder achieves a 63% communication rate (40% absolute increase) and a 52% good question rate (30% absolute increase) on ambiguous tasks, significantly improving LLMs' communication capabilities while maintaining code generation performance.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑