BabelCoder用多个专业智能体协作翻译代码,准确率超现有方法。
BabelCoder: Agentic Code Translation with Specification Alignment
- 拆分翻译任务为生成、测试、修复三类智能体协同工作
- 在四个数据集上平均准确率达94.16%,94%场景超越基线
- 适合需要跨语言迁移代码的开发者和自动化工具设计者
随着软件系统演进,开发人员需频繁在多种编程语言间切换,常面临代码迁移需求。自动代码翻译虽具潜力,但长期存在挑战。尽管大语言模型(LLMs)展现出进展,现有方法仍受限于准确性,且未能有效利用代码中的上下文与结构线索。此前研究探索了翻译与修复机制,但缺乏结构化、智能体驱动的框架。本文提出BabelCoder,一种基于智能体的框架,将翻译任务分解为翻译、测试、精炼三类专用智能体,分别负责生成代码、验证正确性及修复错误。我们在四个基准数据集上评估BabelCoder,对比四种先进基线方法。结果表明,BabelCoder在94%的情况下优于现有方法,提升幅度达0.5%-13.5%,平均准确率达到94.16%。
原文摘要 · Abstract (English)
As software systems evolve, developers increasingly work across multiple programming languages and often face the need to migrate code from one language to another. While automatic code translation offers a promising solution, it has long remained a challenging task. Recent advancements in Large Language Models (LLMs) have shown potential for this task, yet existing approaches remain limited in accuracy and fail to effectively leverage contextual and structural cues within the code. Prior work has explored translation and repair mechanisms, but lacks a structured, agentic framework where multiple specialized agents collaboratively improve translation quality. In this work, we introduce BabelCoder, an agentic framework that performs code translation by decomposing the task into specialized agents for translation, testing, and refinement, each responsible for a specific aspect such as generating code, validating correctness, or repairing errors. We evaluate BabelCoder on four benchmark datasets and compare it against four state-of-the-art baselines. BabelCoder outperforms existing methods by 0.5%-13.5% in 94% of cases, achieving an average accuracy of 94.16%.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。