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

AI Agent 用于逆向工程遗留有限差分代码并转换为 Devito

AI Agent for Reverse-Engineering Legacy Finite-Difference Code and Translating to Devito

Department of Earth Science and Engineering(地球科学与工程系);Imperial College London(帝国理工学院伦敦分校);Department of Computer Science(计算机科学系);University College London(伦敦大学学院)

Yinghan Hou, Zongyou Yang

AI总结:

本研究提出一个集成 AI Agent 框架,结合检索增强生成(RAG)和开源大语言模型,通过多阶段迭代工作流将遗留有限差分代码转换为 Devito 环境,并引入强化学习反馈机制实现动态自适应代码翻译。

摘要:

为了促进遗留有限差分实现向 Devito 环境的转换,本研究开发了一个集成的 AI Agent 框架。检索增强生成(RAG)和开源大语言模型通过系统混合 LangGraph 架构中的多阶段迭代工作流相结合。该 Agent 通过文档解析、结构感知分割、实体关系提取和基于 Leiden 的社区检测构建了一个广泛的 Devito 知识图谱。GraphRAG 优化增强了跨语义社区的查询性能,这些社区包括地震波模拟、计算流体动力学和性能调优库。一个逆向工程组件通过 Fortran 源代码的静态分析推导出用于 RAG 检索的三级查询策略。为了为语言模型指导提供精确的上下文信息,多阶段检索流水线执行并行搜索、概念扩展、社区级检索和语义相似性分析。代码合成受基于 Pydantic 的约束控制,以保证结构化输出和可靠性。一个全面的验证框架将传统静态分析与 G-Eval 方法相结合,涵盖执行正确性、结构健全性、数学一致性和 API 合规性。整个 Agent 工作流在 LangGraph 框架上实现,并采用并发处理以支持基于质量的迭代细化和状态感知的动态路由。主要贡献在于引入了受强化学习启发的反馈机制,实现了从静态代码翻译向动态自适应分析行为的转变。

英文摘要:

To facilitate the transformation of legacy finite difference implementations into the Devito environment, this study develops an integrated AI agent framework. Retrieval-Augmented Generation (RAG) and open-source Large Language Models are combined through multi-stage iterative workflows in the system's hybrid LangGraph architecture. The agent constructs an extensive Devito knowledge graph through document parsing, structure-aware segmentation, extraction of entity relationships, and Leiden-based community detection. GraphRAG optimisation enhances query performance across semantic communities that include seismic wave simulation, computational fluid dynamics, and performance tuning libraries. A reverse engineering component derives three-level query strategies for RAG retrieval through static analysis of Fortran source code. To deliver precise contextual information for language model guidance, the multi-stage retrieval pipeline performs parallel searching, concept expansion, community-scale retrieval, and semantic similarity analysis. Code synthesis is governed by Pydantic-based constraints to guarantee structured outputs and reliability. A comprehensive validation framework integrates conventional static analysis with the G-Eval approach, covering execution correctness, structural soundness, mathematical consistency, and API compliance. The overall agent workflow is implemented on the LangGraph framework and adopts concurrent processing to support quality-based iterative refinement and state-aware dynamic routing. The principal contribution lies in the incorporation of feedback mechanisms motivated by reinforcement learning, enabling a transition from static code translation toward dynamic and adaptive analytical behavior.

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

↑