基于LLM的测试驱动交互式代码生成:用户研究与实证评估
LLM-Based Test-Driven Interactive Code Generation: User Study and Empirical Evaluation
AI总结:
本文提出测试驱动的交互式工作流TiCoder,通过测试引导意图澄清提升LLM代码生成准确性,用户研究和多LLM实验验证其有效性,5次交互内pass@1平均提升45.97%。
摘要:
大型语言模型(LLMs)在通过从非正式自然语言(NL)意图生成自然代码来自动化编码的重要方面方面显示出巨大潜力。然而,由于自然语言是非正式的,它不容易用于检查生成的代码是否正确满足用户意图。在本文中,我们提出了一种新颖的交互式工作流TiCoder,通过测试进行引导式意图澄清(即部分形式化),以支持生成更准确的代码建议。通过对15名程序员进行的混合方法用户研究,我们对工作流在提高代码生成准确性方面的有效性进行了实证评估。我们发现,使用所提出工作流的参与者显著更有可能正确评估AI生成的代码,并且报告的任务诱导认知负荷显著更低。此外,我们使用理想化的用户反馈代理,在两个Python数据集上使用四种不同的最先进LLMs,测试了该工作流在大规模场景下的潜力。我们观察到,在5次用户交互内,两个数据集和所有LLMs的pass@1代码生成准确率平均绝对提高了45.97%,此外还自动生成了配套的单元测试。
英文摘要:
Large language models (LLMs) have shown great potential in automating significant aspects of coding by producing natural code from informal natural language (NL) intent. However, given NL is informal, it does not lend easily to checking that the generated code correctly satisfies the user intent. In this paper, we propose a novel interactive workflow TiCoder for guided intent clarification (i.e., partial formalization) through tests to support the generation of more accurate code suggestions. Through a mixed methods user study with 15 programmers, we present an empirical evaluation of the effectiveness of the workflow to improve code generation accuracy. We find that participants using the proposed workflow are significantly more likely to correctly evaluate AI generated code, and report significantly less task-induced cognitive load. Furthermore, we test the potential of the workflow at scale with four different state-of-the-art LLMs on two python datasets, using an idealized proxy for a user feedback. We observe an average absolute improvement of 45.97% in the pass@1 code generation accuracy for both datasets and across all LLMs within 5 user interactions, in addition to the automatic generation of accompanying unit tests.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。