arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.07472cs.SEcs.AI
收藏

Rectifier:基于大语言模型的带校正器的代码翻译

Rectifier: Code Translation with Corrector via LLMs

Zhejiang University(浙江大学);University of Texas at Dallas(德克萨斯大学达拉斯分校);Central University of Finance and Economics(中央财经大学)

Xin Yin, Chao Ni, Tien N. Nguyen, Shaohua Wang, Xiaohu Yang

AI总结:

针对大语言模型代码翻译易产生多类错误的问题,提出名为Rectifier的微型通用校正模型,从现有LLM的错误中学习以修复任意LLM的翻译错误,在多语言翻译任务上验证了修复有效性与方法鲁棒性。

摘要:

随着软件技术与社会的发展,软件迁移正受到越来越多的关注。早期研究主要依赖手工制定的翻译规则在两种语言间进行翻译,翻译过程容易出错且耗时。近年来,研究人员开始探索将预训练大语言模型(LLMs)用于代码翻译。然而,代码翻译是一项复杂任务,LLMs在代码翻译过程中会生成错误,它们在执行代码翻译任务时都会产生特定类型的错误,包括:(1)编译错误、(2)运行时错误、(3)功能错误以及(4)执行不终止。我们发现这些错误的根本原因十分相似(例如包导入失败、循环边界错误、运算符错误等)。本文提出了一种通用校正器,名为Rectifier,这是一种用于修复翻译错误的微型通用模型。它从现有LLMs生成的错误中学习,可广泛应用于校正任何LLM生成的错误。在C++、Java和Python之间的翻译任务上的实验结果表明,我们的模型具备有效的修复能力,交叉实验也验证了我们方法的鲁棒性。

英文摘要:

Software migration is garnering increasing attention with the evolution of software and society. Early studies mainly relied on handcrafted translation rules to translate between two languages, the translation process is error-prone and time-consuming. In recent years, researchers have begun to explore the use of pre-trained large language models (LLMs) in code translation. However, code translation is a complex task that LLMs would generate mistakes during code translation, they all produce certain types of errors when performing code translation tasks, which include (1) compilation error, (2) runtime error, (3) functional error, and (4) non-terminating execution. We found that the root causes of these errors are very similar (e.g. failure to import packages, errors in loop boundaries, operator errors, and more). In this paper, we propose a general corrector, namely Rectifier, which is a micro and universal model for repairing translation errors. It learns from errors generated by existing LLMs and can be widely applied to correct errors generated by any LLM. The experimental results on translation tasks between C++, Java, and Python show that our model has effective repair ability, and cross experiments also demonstrate the robustness of our method.

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

↑