arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2510.15004cs.SEcs.AI
收藏

自动化片段对齐数据增强用于代码翻译

Automated Snippet-Alignment Data Augmentation for Code Translation

Zhiming Zhang, Qingfu Zhu, Xianzhen Luo, Yixuan Wang, Bohan Li, Wanxiang Che

AI总结:

本文提出利用大语言模型自动生成片段对齐数据,并结合两阶段训练策略增强代码翻译模型,在TransCoder-test上最高提升pass@k达3.78%。

摘要:

代码翻译旨在将代码从源语言翻译为目标语言,并应用于各种软件开发场景。近年来,大型语言模型(LLMs)的发展展示了其在代码翻译方面的能力,而平行语料库在训练代码翻译模型中起着至关重要的作用。平行语料库可分为程序对齐(PA)数据和片段对齐(SA)数据。尽管PA数据具有完整的上下文,适合语义对齐学习,但由于其长度较长,可能无法提供足够的细粒度训练信号,而SA数据的简洁性则使得更细粒度的对齐学习成为可能。由于平行语料库有限,研究人员探索了几种代码翻译的数据增强方法。以往的研究主要集中于增强PA数据。在本文中,我们提出了一种利用LLMs自动生成SA数据的数据增强方法。为了充分利用PA数据和SA数据,我们探索了一种简单而有效的两阶段训练策略,与仅基于PA数据进行微调相比,该策略持续提升了模型性能。在TransCoder-test上的实验表明,我们增强的SA数据结合两阶段训练方法在基线之上取得了持续改进,在pass@k上最大提升了3.78%。

英文摘要:

Code translation aims to translate the code from its source language to the target language and is used in various software development scenarios. Recent developments in Large Language Models (LLMs) have showcased their capabilities in code translation, and parallel corpora play a crucial role in training models for code translation. Parallel corpora can be categorized into program-alignment (PA) and snippet-alignment (SA) data. Although PA data has complete context and is suitable for semantic alignment learning, it may not provide adequate fine-grained training signals due to its extended length, while the brevity of SA data enables more fine-grained alignment learning. Due to limited parallel corpora, researchers explore several augmentation methods for code translation. Previous studies mainly focus on augmenting PA data. In this paper, we propose a data augmentation method that leverages LLMs to generate SA data automatically. To fully leverage both PA data and SA data, we explore a simple yet effective two-stage training strategy, which consistently enhances model performance compared to fine-tuning solely on PA data. Experiments on TransCoder-test demonstrate that our augmented SA data combined with the two-stage training approach yields consistent improvements over the baseline, achieving a maximum gain of 3.78% on pass@k.

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

↑