arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2512.03086cs.PLcs.AIcs.SE
收藏

超越代码对:基于对话的数据生成用于LLM代码翻译

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

Argonne National Laboratory(阿贡国家实验室);University of Minnesota(明尼苏达大学);Iowa State University(爱荷华州立大学);Lawrence Livermore National Laboratory(劳伦斯利弗莫尔国家实验室)

Le Chen, Nuo Xu, Winson Chen, Bin Lei, Pei-Hung Lin, Dunzhi Zhou, Rajeev Thakur, Caiwen Ding, Ali Jannesari, Chunhua Liao

AI总结:

本文提出了一种基于对话的数据生成方法,通过双LLM架构生成验证的翻译和多轮对话,以提升LLM在低资源编程领域中的代码翻译能力。

摘要:

大型语言模型(LLMs)在代码翻译任务中表现出色,但在资源稀缺的编程领域如Fortran和新兴框架如CUDA中性能下降,因为高质量并行数据稀缺。我们提出了一种自动化数据生成流水线,采用双LLM提问者-求解器设计,整合编译器和运行时反馈的外部知识。除了传统的源-目标代码对数据集外,我们的方法还生成(1)带有单元测试的验证翻译以评估功能一致性,以及(2)多轮对话,捕捉翻译优化过程中的推理过程。应用于Fortran到C++和C++到CUDA的转换中,该流水线分别生成3,640和3,930个对话。在该数据上微调可显著提升功能正确性,使C++到CUDA任务的单元测试成功率提高超过56%。我们证明生成的数据使7B开放式模型在编译成功率等关键指标上显著优于更大的专有系统。

英文摘要:

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.

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

↑