This paper proposes INTERactiVE chaiN Of Repairing (INTERVENOR), which mimics human code repairing behavior (iteratively judging, rethinking, and repairing) and prompts the coding ability of regard Large Language Models (LLMs). Specifically, INTERVENOR employs two LLM based agents, Code Learner and Code Teacher, to play different roles in code repairing and work interactively to repair the generated codes. The Code Learner is asked to generate and repair code according to the instructions from the Code Teacher. The Code Teacher rethinks the code errors according to the corresponding feedback from compilers and iteratively generates the chain-of-repairing (CoR) to guide the code repairing process for Code Learner. Our experiments show that INTERVENOR outperforms the state-of-the-art methods and achieves about 13% and 4.5% improvements over the GPT-3.5 model in code generation and code translation tasks, respectively. Our further analyses show that CoR can illuminate the bug reasons and solution plans via natural language. With the feedback of code compilers, INTERVENOR can accurately identify the syntax errors and assertion errors in the code and provide precise instructions to repair codes. All data and codes are available at https://github.com/NEUIR/INTERVENOR
翻译:本文提出交互式修复链(INTERVENOR),该方法模拟人类代码修复行为(迭代判断、反思与修复),并激发大语言模型(LLMs)的编码能力。具体而言,INTERVENOR采用两个基于LLM的智能体——代码学习者(Code Learner)与代码教师(Code Teacher),两者在代码修复中扮演不同角色并通过交互协作修复生成的代码。代码学习者依据代码教师的指令生成并修复代码,而代码教师则根据编译器反馈对代码错误进行反思,并迭代生成修复链(CoR)以指导代码学习者的修复过程。实验表明,INTERVENOR在代码生成与代码翻译任务中分别超越当前最优方法,较GPT-3.5模型提升约13%和4.5%。进一步分析显示,CoR可通过自然语言阐明错误原因与解决方案,而借助编译器反馈,INTERVENOR能准确识别代码中的语法错误与断言错误,并提供精确的修复指令。所有数据与代码均已开源:https://github.com/NEUIR/INTERVENOR