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

通过多阶段LLM训练和错误修复提升Java到Cangjie的自动翻译

Boosting Automatic Java-to-Cangjie Translation with Multi-Stage LLM Training and Error Repair

Nanjing University of Aeronautics and Astronautics(南京航空航天大学)

Xinyue Liang, Jingxuan Zhang, Lin Li, Jun Zhang, Junhao Chen

AI总结:

本文提出多阶段LLM训练框架,结合编译器反馈和错误修复,提升Java到Cangjie的翻译准确性与语义一致性,实验显示在有限平行数据下功能等价性提升6.06%。

摘要:

随着新兴编程语言生态系统的快速发展,对代码翻译到低资源语言的需求持续增长。Cangjie作为新兴编程语言,其生态系统和开发工具链正在迅速扩展。自动将流行编程语言翻译成Cangjie对于实际开发具有价值。然而,受限于不足的Cangjie知识和稀缺的平行代码语料库,通用大型语言模型(LLMs)在代码翻译中容易产生语法错误和语义及结构对齐问题。现有方法通常依赖大规模平行数据微调,但无法可靠地提高低资源Cangjie语言的可编译性或语义一致性。为解决这些挑战,我们提出一种多阶段LLM训练框架,采用迭代错误修复技术将Java代码翻译成Cangjie代码。该训练框架对LLM进行训练,逐步整合知识,实现语义对齐和结构意识。在代码翻译过程中,我们还结合编译器反馈和错误修复案例检索来修复错误的Cangjie代码。我们构建了语法知识和单语指令数据集来训练LLM。此外,我们还构建了一个Cangjie错误修复存储库以支持我们的方法。实验结果表明,与现有最佳方法相比,在有限的平行数据下,我们的方法将功能等价性提高了6.06%。同时,消融研究证实了每个训练阶段对最终性能的积极贡献。

英文摘要:

With the rapid evolution of emerging programming language ecosystems, the demand for code translation to low-resource languages continues to grow. As Cangjie emerges as a new programming language, its ecosystem and development toolchains are rapidly expanding. Automated translation from popular programming languages to Cangjie is therefore valuable for practical development. However, constrained by both insufficient Cangjie knowledge and scarce parallel code corpora, general Large Language Models (LLMs) are prone to syntactic errors and semantic as well as structural misalignment in code translation. Existing approaches typically rely on fine-tuning with large-scale parallel data, but they cannot reliably improve compilability or semantic consistency for low-resource Cangjie languages. To tackle these challenges, we propose a multi-stage training framework of LLMs that employs the iterative error repair technique to translate Java code into Cangjie code. This training framework performs training on LLMs, gradually integrating knowledge and achieving semantic alignment as well as structure awareness. During the code translation, we also combine the compiler feedback and error repair case retrieval to repair the incorrect Cangjie code. We construct syntactic knowledge and monolingual instruction datasets to train the LLM. In addition, we also build a Cangjie error repair repository to support error repair in our approach. Experimental results show that, with limited parallel data, our approach improves functional equivalence by 6.06\% compared to the state-of-the-art approaches. Meanwhile, ablation studies confirm that each training stage positively contributes to the final performance.

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

↑