arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.15587cs.SE
收藏

ConAIR:一致性增强的迭代交互框架以提升代码生成的可靠性

ConAIR:Consistency-Augmented Iterative Interaction Framework to Enhance the Reliability of Code Generation

Jinhao Dong, Jun Sun, Wenjie Zhang, Jin Song Dong, Dan Hao

AI总结:

本文提出 ConAIR 框架,通过轻量级用户验证测试与动态排序纠正策略,将用户反馈融入一致性驱动的迭代过程,以极低人力成本显著提升代码生成可靠性。

摘要:

代码生成技术根据自然语言描述的问题需求自动生成代码片段。近年来,大型语言模型(LLMs)在代码生成上取得了最先进(SOTA)的性能。然而,LLMs 有时仍然难以生成准确的代码,这削弱了其承诺的效率,因为开发人员必须花费大量精力评估和调试生成的代码。为了提高生成代码的可靠性和质量,研究人员提出利用一致性(Consistency),通过生成多个候选代码并对其进行排序来获得更好的代码。现有方法存在问题,因为一致性认为当(1)代码通过更多测试(inter-consistency,测试间一致性)或(2)更多代码共享相同行为(intra-consistency,代码间一致性)时,该代码更好。然而,由于测试也是由 LLMs 生成的,它们本身也可能是错误的。因此,基于测试结果的多数投票并不可靠。仅依赖一致性不足以解决这一问题;整合用户反馈对于有效引导一致性至关重要。我们表明,只需极少的人力投入,性能就可以显著提升。我们提出一致性增强的迭代交互框架以提升代码生成的可靠性,即 ConAIR,该方法旨在通过两个独特的组成部分来改进代码生成器的性能,即:(1)轻量级用户投入,用于验证所选测试的正确性;(2)一种动态策略,用于对多个测试和代码进行排序、定位和纠正。总体而言,我们提出了一个轻量级交互框架,该框架纳入用户反馈以纠正识别出的测试并引导迭代过程。在一致性的帮助下,迭代轮次平均仅为 4 轮。仅需轻量级的人力投入,我们就能在基础模型上实现 33% 的性能提升。

英文摘要:

Code generation techniques generate code snippets automatically based on the problem requirements in natural language. Recently, large language models (LLMs) achieve the SOTA performance on code generation. However, LLMs still struggle at times to generate accurate code, which diminishes their promised efficiency as developers must spend significant effort evaluating and debugging the generated code. To improve the reliability and quality of the generated codes, researchers propose to leverage Consistency to obtain a better code based on generating and ranking multiple candidates. The existing approach is problematic as Consistency thinks a code is better when (1) the code pass more tests (inter-consistency) (2) more codes share the same behavior (intra-consistency). However, because the tests are also generated by LLMs, they could be wrong as well. As a result, majority voting based on testing results is unreliable. Relying solely on consistency is insufficient to address this issue; integrating user feedback is essential for effectively guiding consistency. We show that with minimal human effort, performance can be significantly enhanced. We propose Consistency-Augmented Iterative Interaction Framework to Enhance the Reliability of Code Generation, ConAIR, which is an approach that aims to improve the performance of a code generator through two distinctive ingredients, i.e., (1) lightweight user effort for validating the correctness of selected tests; and (2) a dynamic strategy for ranking, localizing and correcting multiple tests and codes. Overall, we propose a lightweight interaction framework that incorporates user feedback to correct identified tests and guide the iterative process. The iteration rounds are only 4 in average with the help of consistency. With only lightweight human efforts, we can achieve an improvement of 33% towards the base model.

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

↑