一句话:提出半监督方法 MIRACLE,通过合成高质量平行代码数据与课程学习,缓解代码翻译数据稀缺并提升多语言翻译性能。
神经代码翻译需将源代码从一种语言转成另一种,但平行代码数据稀缺,模型难以学习准确跨语言对齐。论文提出半监督方法 MIRACLE:利用静态分析与编译合成高质量、对齐度更高的平行代码数据,并按对齐程度递增进行课程学习。作者发现,开源代码预训练的 LLM 无论规模大小都存在“浅层翻译”问题,即复制源语言关键字、语句甚至代码块,导致编译或运行错误。在 C++、Java、Python 和 C 上对多个模型的实验表明,MIRACLE 显著缓解该问题,可超越参数量十倍于它的代码 LLM,并在少于 150 个标注样例时使 C 代码翻译提升最多 43%。
Neural code translation is the task of converting source code from one programming language to another. One of the main challenges is the scarcity of parallel code data, which hinders the ability of translation models to learn accurate cross-language alignments. In this paper, we introduce MIRACLE, a semi-supervised approach that improves code translation through synthesizing high-quality parallel code data and curriculum learning on code data with ascending alignment levels. MIRACLE leverages static analysis and compilation to generate synthetic parallel code datasets with enhanced quality and alignment to address the challenge of data scarcity. We evaluate the proposed method along with strong baselines including instruction-tuned Large Language Models (LLMs) for code. Our analysis reveals that LLMs pre-trained on open-source code data, regardless of their size, suffer from the "shallow translation" problem. This issue arises when translated code copies keywords, statements, and even code blocks from the source language, leading to compilation and runtime errors. Extensive experiments demonstrate that our method significantly mitigates this issue, enhancing code translation performance across multiple models in C++, Java, Python, and C. Remarkably, MIRACLE outperforms code LLMs that are ten times larger in size. MIRACLE also achieves up to a 43% improvement in C code translation with fewer than 150 annotated examples.CCS CONCEPTS• Computing methodologies → Machine learning; • Software and its engineering;
@inproceedings{0015KLY24,
title = {Semi-Supervised Code Translation Overcoming the Scarcity of Parallel Code Data},
author = {Ming Zhu and Mohimenul Karim and Ismini Lourentzou and Daphne Yao},
booktitle = {ASE},
year = {2024},
doi = {10.1145/3691620.3695524}
}