用大模型将老代码Fortran自动转成C++,测试效果如何。
LLM-Assisted Translation of Legacy FORTRAN Codes to C++: A Cross-Platform Study
- 用大模型直接翻译Fortran到C++,不依赖人工干预。
- 翻译后代码编译成功率可达87.3%,与人工翻译相似度达72.1%。
- 适合需要现代化老旧科学计算代码的科研人员使用。
大型语言模型(LLMs)正被越来越多地用于生成和翻译科学计算代码,无论是领域专家还是非专家。Fortran长期以来是高性能计算(HPC)领域中支持科学发现的关键编程语言。尽管应用日益广泛,但基于大模型的旧代码迁移尚未得到充分评估与量化。本文研究了利用大模型将Fortran代码翻译为C++的可行性,作为在两个不同计算平台上构建基于开源权重大模型的智能工作流的第一步。我们统计评估了翻译后C++代码的编译准确率,测量了大模型翻译代码与人工翻译代码之间的相似性,并量化了从Fortran到C++翻译输出的相似性。
原文摘要 · Abstract (English)
Large Language Models (LLMs) are increasingly being leveraged for generating and translating scientific computer codes by both domain-experts and non-domain experts. Fortran has served as one of the go to programming languages in legacy high-performance computing (HPC) for scientific discoveries. Despite growing adoption, LLM-based code translation of legacy code-bases has not been thoroughly assessed or quantified for its usability. Here, we studied the applicability of LLM-based translation of Fortran to C++ as a step towards building an agentic-workflow using open-weight LLMs on two different computational platforms. We statistically quantified the compilation accuracy of the translated C++ codes, measured the similarity of the LLM translated code to the human translated C++ code, and statistically quantified the output similarity of the Fortran to C++ translation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。