arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.18863cs.SE
收藏

EffiReasonTrans:面向代码翻译的强化学习优化推理

EffiReasonTrans: RL-Optimized Reasoning for Code Translation

Sun Yat-sen University(中山大学);Huawei Cloud Computing Technologies Co., Ltd.(华为云计算技术有限公司)

Yanlin Wang, Rongyi Ou, Yanli Wang, Mingwei Liu, Jiachi Chen, Ensheng Shi, Xilin Liu, Yuchi Ma, Zibin Zheng

AI总结:

本文提出 EffiReasonTrans 框架,利用 DeepSeek-R1 构建推理增强数据,并结合监督微调与强化学习,在六个代码翻译任务上同时提升准确性、降低 token 数与推理延迟。

摘要:

代码翻译是软件开发与维护中的一项关键任务。尽管大语言模型(LLM)的最新进展提升了自动化代码翻译的准确性,但这些收益往往以增加推理延迟为代价,从而阻碍涉及人在回路检查的实际开发工作流。为解决这一权衡问题,我们提出 EffiReasonTrans,这是一个旨在提高翻译准确性同时平衡推理延迟的训练框架。我们首先通过提示更强的语言模型 DeepSeek-R1 生成中间推理和目标翻译,构建高质量的推理增强数据集。每个(源代码、推理、目标代码)三元组都会经过自动化语法和功能检查,以确保可靠性。基于该数据集,我们采用两阶段训练策略:先在推理增强样本上进行监督微调,随后通过强化学习进一步提升准确性并平衡推理延迟。我们在六个翻译对上评估 EffiReasonTrans。实验结果表明,它持续提升翻译准确性(与基础模型相比,CA 最高提升 +49.2%,CodeBLEU 最高提升 +27.8%),同时减少生成 token 数量(最高减少 -19.3%),并在多数情况下降低推理延迟(最高降低 -29.0%)。消融研究进一步证实了该两阶段训练框架的互补收益。此外,EffiReasonTrans 在集成到基于智能体的框架中时展现出更高的翻译准确性。我们的代码和数据可在 https://github.com/DeepSoftwareAnalytics/EffiReasonTrans 获取。

英文摘要:

Code translation is a crucial task in software development and maintenance. While recent advancements in large language models (LLMs) have improved automated code translation accuracy, these gains often come at the cost of increased inference latency, hindering real-world development workflows that involve human-in-the-loop inspection. To address this trade-off, we propose EffiReasonTrans, a training framework designed to improve translation accuracy while balancing inference latency. We first construct a high-quality reasoning-augmented dataset by prompting a stronger language model, DeepSeek-R1, to generate intermediate reasoning and target translations. Each (source code, reasoning, target code) triplet undergoes automated syntax and functionality checks to ensure reliability. Based on this dataset, we employ a two-stage training strategy: supervised fine-tuning on reasoning-augmented samples, followed by reinforcement learning to further enhance accuracy and balance inference latency. We evaluate EffiReasonTrans on six translation pairs. Experimental results show that it consistently improves translation accuracy (up to +49.2% CA and +27.8% CodeBLEU compared to the base model) while reducing the number of generated tokens (up to -19.3%) and lowering inference latency in most cases (up to -29.0%). Ablation studies further confirm the complementary benefits of the two-stage training framework. Additionally, EffiReasonTrans demonstrates improved translation accuracy when integrated into agent-based frameworks. Our code and data are available at https://github.com/DeepSoftwareAnalytics/EffiReasonTrans.

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

↑