arXiv:2410.07271cs.SEcs.AI2024-10

用AI同时修代码错误并解释原因,新手也能看懂。

Multi-Task Program Error Repair and Explanatory Diagnosis

  • 用预训练模型编码代码,结合思维链生成推理过程。
  • 通过多任务学习修复错误并提供可读解释,提升诊断可理解性。
  • 适合初学者和希望快速定位问题的开发者使用。

程序错误可能出现在任何编程场景中,表现为输出异常、崩溃或性能问题。传统错误诊断往往过于抽象或技术化,对开发者尤其是初学者不友好。本文提出一种多任务程序错误修复与解释性诊断方法(mPRED)。该方法利用预训练语言模型编码源代码,并设计下游模型识别与修复错误;通过多角度增强和优化程序及测试用例。此外,引入“思维链”机制,使模型在给出最终修正前生成中间推理步骤,提升可解释性。为辅助分析程序结构,采用图神经网络实现程序结构可视化。整体方法在多种编程语言下均展现出良好修复能力,同时提供清晰解释,帮助开发者理解错误成因。

原文摘要 · Abstract (English)

Program errors can occur in any type of programming, and can manifest in a variety of ways, such as unexpected output, crashes, or performance issues. And program error diagnosis can often be too abstract or technical for developers to understand, especially for beginners. The goal of this paper is to present a novel machine-learning approach for Multi-task Program Error Repair and Explanatory Diagnosis (mPRED). A pre-trained language model is used to encode the source code, and a downstream model is specifically designed to identify and repair errors. Programs and test cases will be augmented and optimized from several perspectives. Additionally, our approach incorporates a "chain of thoughts" method, which enables the models to produce intermediate reasoning explanations before providing the final correction. To aid in visualizing and analyzing the program structure, we use a graph neural network for program structure visualization. Overall, our approach offers a promising approach for repairing program errors across different programming languages and providing helpful explanations to programmers.

代码修复解释性AI多任务学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。