用大模型辅助科学计算代码翻译与开发,提升效率。
Leveraging Large Language Models for Code Translation and Software Development in Scientific Computing
- 结合提示工程与人工监督,构建代码转换工具CodeScribe。
- 成功将大型强子对撞机的Fortran代码转为C++,并生成接口。
- 适合需要现代化遗留代码的科研开发者使用。
基础模型和生成式人工智能(GenAI)有望彻底改变科学计算中的生产力,尤其在代码开发、重构及跨语言翻译方面。然而,由于GenAI输出难以保证正确性,仍需人工干预。部分干预可通过专用工具及验证方法自动化,结合有效的提示工程实现。我们研究了GenAI在协助大型强子对撞机(LHC)中用于粒子相互作用模拟的老旧Fortran代码库中的代码翻译、语言互操作性和代码审查的应用。在此过程中,我们开发了工具CodeScribe,通过提示工程与用户监督相结合,建立高效的代码转换流程。本文展示了CodeScribe如何协助将Fortran代码转换为C++,生成Fortran-C API以集成旧系统与现代C++库,并支持代码组织与算法实现。同时,我们探讨了基于AI的代码翻译挑战,并强调其对提升科学计算工作流效率的价值。
原文摘要 · Abstract (English)
The emergence of foundational models and generative artificial intelligence (GenAI) is poised to transform productivity in scientific computing, especially in code development, refactoring, and translating from one programming language to another. However, because the output of GenAI cannot be guaranteed to be correct, manual intervention remains necessary. Some of this intervention can be automated through task-specific tools, alongside additional methodologies for correctness verification and effective prompt development. We explored the application of GenAI in assisting with code translation, language interoperability, and codebase inspection within a legacy Fortran codebase used to simulate particle interactions at the Large Hadron Collider (LHC). In the process, we developed a tool, CodeScribe, which combines prompt engineering with user supervision to establish an efficient process for code conversion. In this paper, we demonstrate how CodeScribe assists in converting Fortran code to C++, generating Fortran-C APIs for integrating legacy systems with modern C++ libraries, and providing developer support for code organization and algorithm implementation. We also address the challenges of AI-driven code translation and highlight its benefits for enhancing productivity in scientific computing workflows.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。