翻译者 vs. 挑战者:面向 C 到 Rust 翻译的对抗性智能体学习
Translator vs. Challenger: Adversarial Agentic Learning for C-to-Rust Translation
- Shanghai Jiao Tong University(上海交通大学)
机构由 AI 辅助整理,请以论文原文为准。
AI总结:
针对C到Rust翻译中经验见解缺乏鲁棒性的问题,提出对抗性智能体学习框架TRAIL,通过翻译者与挑战者协作及双层对抗学习,将痕迹经验转化为可复用知识,在基准上显著提升翻译准确率。
AI中文摘要:
由于 C 和 Rust 两种语言之间存在巨大的语义鸿沟,C 到 Rust 的翻译仍然具有挑战性。近年来,经验增强的大语言模型翻译器通过从先前的失败和修复中学习可复用的见解来提高翻译质量。然而,学到的见解并不会自动构成可复用的翻译知识:它们源自稀疏的、特定于程序的痕迹,往往包含缺失的条件、狭窄的适用边界或被忽视的边界情况。这限制了它们在新翻译场景中的鲁棒性和泛化能力。我们提出了 TRAIL,一个用于稳健的 C 到 Rust 翻译的对抗性智能体学习框架。TRAIL 采用两个协作的智能体:一个翻译者,从翻译失败和被接受的修复中推导候选见解;以及一个挑战者,通过对抗性挑战主动搜索弱点、缺口和边界情况。为了提高单个见解的鲁棒性和见解集合的完整性,TRAIL 在两个层面进行对抗性学习。个体见解对抗性学习反复对每个见解进行压力测试,以完善其适用条件和约束,而组合性见解对抗性学习通过暴露冲突、缺口和未覆盖的边界情况来强化相关见解组。通过用可执行的反例挑战见解及其组合,TRAIL 将特定于痕迹的经验转化为稳健、可复用且可泛化的翻译知识。我们在两个项目级基准 CRUST-Bench 和 SmartC2Rust-Bench 上评估了 TRAIL。与最强的大语言模型基线相比,TRAIL 在语法准确率上实现了平均相对提升 23.1%,在语义准确率上实现了平均相对提升 15.9%。此外,经过对抗性精炼的见解在基准之间有效迁移,展示了在多样化 C 到 Rust 翻译任务中的强大泛化能力。
英文摘要:
C-to-Rust translation remains challenging due to the substantial semantic gap between the two languages. Recent experience-enhanced LLM translators improve translation quality by learning reusable insights from prior failures and repairs. Yet learned insights do not automatically constitute reusable translation knowledge: derived from sparse, program-specific traces, they often contain missing conditions, narrow applicability boundaries, or overlooked corner cases. This limits their robustness and generalizability in new translation scenarios. We present TRAIL, an adversarial agentic learning framework for robust C-to-Rust translation. TRAIL employs two collaborating agents: a Translator that derives candidate insights from translation failures and accepted repairs, and a Challenger that actively searches for weaknesses, gaps, and boundary cases through adversarial challenges. To improve the robustness of individual insights and the completeness of insight collections, TRAIL performs adversarial learning at two levels. Individual-insight adversarial learning repeatedly stress-tests each insight to refine its applicability conditions and constraints, while compositional insight adversarial learning strengthens groups of related insights by exposing conflicts, gaps, and uncovered corner cases. By challenging insights and their compositions with executable counterexamples, TRAIL transforms trace-specific experience into robust, reusable, and generalizable translation knowledge. We evaluate TRAIL on two project-level benchmarks, CRUST-Bench and SmartC2Rust-Bench. Compared with the strongest LLM-based baseline, TRAIL achieves average relative improvements of 23.1% in syntax accuracy and 15.9% in semantic accuracy. Furthermore, the adversarially refined insights transfer effectively across benchmarks, demonstrating strong generalizability across diverse C-to-Rust translation tasks.