arXiv:2604.18027cs.SEcs.CL2026-04被引 1

用强化学习让大模型无平行语料也能跨语言转译代码

CodePivot: Bootstrapping Multilingual Transpilation in LLMs via Reinforcement Learning without Parallel Corpora

论文配图:CodePivot: Bootstrapping Multilingual Transpilation in LLMs via Reinforcement Learning without Parallel Corpora
图 1 · 摘自论文原文
  • 以Python为中间表示,通过强化学习自举多语言转译能力
  • 在10种语言上超越百亿参数大模型,低资源语言表现尤佳
  • 无需成对训练数据,适合代码迁移与小语种开发场景

代码转译旨在将源代码从一种编程语言转换为另一种。该任务对现代化遗留代码库、扩充低资源语言数据等下游应用具有重要意义。当前基于大语言模型的方法虽具潜力,但依赖成对训练数据,难以支持多样语言,尤其在低资源语言上受限明显。此外,现有方法的强化学习奖励机制不优。为此,本文提出CodePivot框架:利用Python作为中间表示,并设计新型奖励函数Aggressive-Partial-Functional,实现无平行语料下的多语言转译能力自举。实验显示,仅70亿参数的模型在10种语言上的跨语言转译任务中表现优异,优于数百亿参数的大模型(如Deepseek-R1和Qwen3-235B-A22B-Instruct-2507),且在通用及低资源语言任务中均超越直接训练于Any-to-Any任务的模型。代码与数据已开源。

原文摘要 · Abstract (English)

Transpilation, or code translation, aims to convert source code from one programming language (PL) to another. It is beneficial for many downstream applications, from modernizing large legacy codebases to augmenting data for low-resource PLs. Recent large language model (LLM)-based approaches have demonstrated immense potential for code translation. Among these approaches, training-based methods are particularly important because LLMs currently do not effectively adapt to domain-specific settings that suffer from a lack of knowledge without targeted training. This limitation is evident in transpilation tasks involving low-resource PLs. However, existing training-based approaches rely on a pairwise transpilation paradigm, making it impractical to support a diverse range of PLs. This limitation is particularly prominent for low-resource PLs due to a scarcity of training data. Furthermore, these methods suffer from suboptimal reinforcement learning (RL) reward formulations. To address these limitations, we propose CodePivot, a training framework that leverages Python as an intermediate representation (IR), augmented by a novel RL reward mechanism, Aggressive-Partial-Functional reward, to bootstrap the model's multilingual transpilation ability without requiring parallel corpora. Experiments involving 10 PLs show that the resulting 7B model, trained on Python-to-Others tasks, consistently improves performance across both general and low-resource PL-related transpilation tasks. It outperforms substantially larger mainstream models with hundreds of billions more parameters, such as Deepseek-R1 and Qwen3-235B-A22B-Instruct-2507, on Python-to-Others tasks and Others-to-All tasks, respectively. In addition, it outperforms its counterpart trained directly on Any-to-Any tasks on general transpilation tasks. The code and data are available at https://github.com/lishangyu-hkust/CodePivot.

代码生成强化学习多语言转译

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。