arXiv:2604.20835cs.CL2026-04ACL

用跨语言等效代码训练模型,提升代码强化学习的跨语言迁移能力

Parallel-SFT: Improving Zero-Shot Cross-Programming-Language Transfer for Code RL

  • 通过并行编程数据混合预训练,让模型学懂通用编程逻辑
  • 在未见过的语言上,性能比传统方法提升17.3%(绝对值)
  • 适合做多语言代码生成或模型泛化研究的开发者参考

现代语言模型在常见编程语言(如 C++、Python)上表现优异,但在低资源语言中受限于训练数据。理论上,编程技能具有通用性,一种语言中学到的能力应能迁移到其他语言。本文提出零样本跨编程语言迁移任务。发现对 Llama-3.1 进行源语言强化学习(RL)训练后,目标语言性能反而下降。为此,我们提出 Parallel-SFT 策略:在预训练数据中加入“并行程序”——功能等价但语言不同的代码对。实验表明,该策略显著提升迁移能力,后续在新语言上进行强化学习时,泛化性能更优。内部表征分析显示,模型潜空间更聚焦功能结构,不同语言的等价代码聚类更紧密,这可能是迁移效果提升的原因。

原文摘要 · Abstract (English)

Modern language models demonstrate impressive coding capabilities in common programming languages (PLs), such as C++ and Python, but their performance in lower-resource PLs is often limited by training data availability. In principle, however, most programming skills are universal across PLs, so the capability acquired in one PL should transfer to others. In this work, we propose the task of zero-shot cross-programming-language transfer for code RL. We find that, for Llama-3.1, RL training for code generation in a source PL fails to improve, and sometimes even degrades, the performance on other target PLs. To address this, we hypothesize that effective RL transfer requires a generalizable SFT initialization before RL. We thus propose **Parallel-SFT**, an SFT strategy that incorporates "parallel programs" -- functionally equivalent code implemented in multiple PLs -- into the data mixture. We demonstrate that this improves transferability: when we subsequently perform RL on our Parallel-SFT model, we observe better generalization to unseen PLs. Analysis of the model internal representations reveals that Parallel-SFT leads to a more functionality-centric latent space, where equivalent programs across PLs are more tightly clustered, which we hypothesize to contribute to the improved transferability.

代码生成跨语言迁移强化学习预训练

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