arXiv:2512.03086cs.PLcs.AI2025-12ACL被引 6

用对话生成代码翻译数据,提升低资源语言转换效果

Beyond Code Pairs: Dialogue-Based Data Generation for LLM Code Translation

  • 双模型设计生成带推理过程的对话与验证代码
  • 在C++转CUDA任务上单元测试通过率提升56%以上
  • 适合需要高效代码迁移的研究者和开发者

大型语言模型在代码翻译中表现优异,但在如Fortran和CUDA等低资源编程领域因高质量平行数据稀缺而性能下降。本文提出一种自动化数据生成流水线,采用双模型问答-求解器设计,融合编译器和运行时反馈的外部知识。除传统源-目标代码对外,还生成(1)经单元测试验证的功能一致翻译结果,(2)多轮对话以捕捉翻译优化的推理过程。应用于Fortran-to-C++和C++-to-CUDA任务,分别生成3.64k和3.93k条对话。在此数据上微调后,功能正确率显著提升,C++-to-CUDA任务的单元测试成功率提高超56%。实验表明,该数据使7B开源模型在编译成功率等关键指标上超越更大规模专有系统。

原文摘要 · Abstract (English)

Large language models (LLMs) have shown remarkable capabilities in code translation, yet their performance deteriorates in low-resource programming domains such as Fortran and emerging frameworks like CUDA, where high-quality parallel data are scarce. We present an automated dataset generation pipeline featuring a dual-LLM Questioner-Solver design that incorporates external knowledge from compilers and runtime feedback. Beyond traditional source-target code pair datasets, our approach additionally generates (1) verified translations with unit tests for assessing functional consistency and (2) multi-turn dialogues that capture the reasoning process behind translation refinement. Applied to Fortran-to-C++ and C++-to-CUDA, the pipeline yields 3.64k and 3.93k dialogues, respectively. Fine-tuning on this data yields dramatic improvements in functional correctness, boosting unit test success rates by over 56% on the challenging C++-to-CUDA task. We show that the generated data enables a 7B open-weight model to significantly outperform larger proprietary systems on key metrics like compilation success.

代码翻译对话生成低资源LLM

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