Back-translation is widely known for its effectiveness in neural machine translation when there is little to no parallel data. In this approach, a source-to-target model is coupled with a target-to-source model trained in parallel. The target-to-source model generates noisy sources, while the source-to-target model is trained to reconstruct the targets and vice versa. Recent developments of multilingual pre-trained sequence-to-sequence models for programming languages have been very effective for a broad spectrum of downstream software engineering tasks. Hence, training them to build programming language translation systems via back-translation is compelling. However, these models cannot be further trained via back-translation since they learn to output sequences in the same language as the inputs during pre-training. As an alternative, we propose performing back-translation via code summarization and generation. In code summarization, a model learns to generate natural language (NL) summaries given code snippets. In code generation, the model learns to do the opposite. Therefore, target-to-source generation in back-translation can be viewed as a target-to-NL-to-source generation. We show that our proposed approach performs competitively with state-of-the-art methods. We have made the code publicly available.
翻译:回译因其在平行数据稀缺时的神经机器翻译中的有效性而广为人知。该方法中,源语言到目标语言的模型与并行训练的目标语言到源语言模型协同工作。目标到源模型生成带噪声的源语言,而源到目标模型则被训练来重建目标语言,反之亦然。近年来,针对编程语言的多语言预训练序列到序列模型的发展对广泛的软件工程下游任务非常有效。因此,通过回译训练这些模型以构建编程语言翻译系统具有显著吸引力。然而,由于这些模型在预训练期间学会输出与输入语言相同的序列,它们无法通过回译进一步训练。作为替代方案,我们提出通过代码摘要与生成实现回译。在代码摘要中,模型学习根据代码片段生成自然语言摘要;在代码生成中,模型则学习执行相反操作。因此,回译中的目标到源生成可视为目标到自然语言再到源的生成。我们证明,所提出的方法与现有最优方法相比具有竞争力,并已公开代码。