arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2208.05950cs.SEcs.LGcs.PL
收藏

通过测试驱动的用户意图形式化实现交互式代码生成

Interactive Code Generation via Test-Driven User-Intent Formalization

Microsoft Research(微软研究院);University of Pennsylvania(宾夕法尼亚大学);University of California, San Diego(加州大学圣地亚哥分校)
Shuvendu K. Lahiri, Sarah Fakhoury, Aaditya Naik, Georgios Sakkas, Saikat Chakraborty, Madanlal Musuvathi, Piali Choudhury, Curtis von Veh, Jeevana Priya Inala,… 展开作者

Shuvendu K. Lahiri, Sarah Fakhoury, Aaditya Naik, Georgios Sakkas, Saikat Chakraborty, Madanlal Musuvathi, Piali Choudhury, Curtis von Veh, Jeevana Priya Inala, Chenglong Wang, Jianfeng Gao

AI总结:

针对大语言模型代码生成难以保证符合用户意图的问题,提出交互式测试驱动代码生成工作流及TiCoder实现,通过用户反馈形式化意图并优化代码排序,在两个基准上显著提升pass@1准确率。

摘要:

大语言模型(LLM)已展现出通过从非正式自然语言(NL)意图生成自然代码来自动化编码重要环节的巨大潜力。然而,用户在与LLM交互时,无法保证生成的代码建议能正确满足其提供的意图。事实上,由于自然语言可能存在歧义且缺乏形式化语义,很难定义正确性的概念。\n 在本文中,我们提出了交互式测试驱动代码生成工作流,该工作流利用轻量级用户反馈来实现两个目标:(a) 使用生成的、可用于调试的测试将用户意图形式化;(b) 通过对候选代码建议进行剪枝和排序,生成优化的代码建议集。我们描述了一种与语言无关的抽象算法以及具体实现TiCoder。我们在MBPP和HumanEval代码生成基准上对TiCoder进行了自动化评估。使用OpenAI Codex LLM的实验结果前景可观:在1到5次模拟用户查询的条件下,我们的最优算法将pass@1代码生成准确率(以绝对百分比计)在MBPP上提升了22.49%至37.71%,在HumanEval上提升了24.79%至53.98%。

英文摘要:

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, when interacting with LLMs, users have no guarantees that the code suggestions produced correctly satisfy the intent they provided. In fact, it is hard to define a notion of correctness since natural language can be ambiguous and lacks a formal semantics. In this paper, we propose the workflow of {\it interactive test-driven code generation}, which leverages lightweight user feedback to (a) formalize the user intent using generated tests that can be useful for debugging, and (b) produce an improved set of code suggestions by pruning and ranking candidate code suggestions. We describe a language-agnostic abstract algorithm and a concrete implementation TiCoder. We perform an automated evaluation of TiCoder on the \emph{MBPP} and \emph{HumanEval} code generation benchmarks. Our results are promising with using the OpenAI Codex LLM: our best algorithm improves the \passk{1} code generation accuracy (in absolute percentages) between $22.49\%$ to $37.71\%$ for MBPP and between $24.79\%$ to $53.98\%$ for HumanEval using between 1 to 5 simulated user queries.

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

↑