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

LegacyTranslate: 基于LLM的多智能体方法用于遗留代码翻译

LegacyTranslate: LLM-based Multi-Agent Method for Legacy Code Translation

Radboud University(拉德堡德大学);ING(荷兰国际集团)

Zahra Moti, Heydar Soudani, Jonck van der Kogel

AI总结:

本文提出LegacyTranslate多智能体框架,通过三个智能体提升遗留代码翻译质量,实验显示初始翻译智能体达到45.6%可编译输出,结合API grounding和refinement智能体进一步提升编译和测试通过率。

摘要:

现代大型遗留系统现代化仍是企业环境中重大挑战,尤其是在迁移时必须保留领域特定逻辑同时符合内部架构框架和共享API。直接应用大型语言模型(LLMs)进行代码翻译往往产生语法正确的输出,但无法编译或整合到现有生产框架中,限制了其在实际现代化中的应用。本文提出LegacyTranslate,一种基于API的代码翻译多智能体框架,在一家金融机构将约250万行PL/SQL迁移到Java的持续现代化努力中开发和评估。核心思想是使用专门的LLM智能体,每个智能体解决翻译挑战的不同方面。具体而言,LegacyTranslate包含三个智能体:初始翻译智能体通过检索上下文示例生成初始Java翻译;API grounding智能体通过检索相关API知识库条目对代码进行对齐;refinement智能体通过编译器反馈和API建议迭代优化输出。实验显示每个智能体都对翻译质量有贡献。初始翻译智能体单独实现45.6%可编译输出和30.9%测试通过率。加入API grounding和refinement智能体后,编译率提高8%,测试通过率提高3%。

英文摘要:

Modernizing large legacy systems remains a major challenge in enterprise environments, particularly when migration must preserve domain-specific logic while conforming to internal architectural frameworks and shared APIs. Direct application of Large Language Models (LLMs) for code translation often produces syntactically valid outputs that fail to compile or integrate within existing production frameworks, limiting their practical adoption in real-world modernization efforts. In this paper, we propose LegacyTranslate, a multi-agent framework for API-aware code translation, developed and evaluated in the context of an ongoing modernization effort at a financial institution migrating approximately 2.5 million lines of PL/SQL to Java. The core idea is to use specialized LLM-based agents, each addressing a different aspect of the translation challenge. Specifically, LegacyTranslate consists of three agents: Initial Translation Agent produces an initial Java translation using retrieved in-context examples; API Grounding Agent aligns the code with existing APIs by retrieving relevant entries from an API knowledge base; and Refinement Agent iteratively refines the output using compiler feedback and API suggestions to improve correctness. Our experiments show that each agent contributes to better translation quality. The Initial Translation Agent alone achieves 45.6% compilable outputs and 30.9% test-pass rate. With API Grounding Agent and Refinement Agent, compilation improves by an additional 8% and test-pass accuracy increases by 3%.

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

↑