arXiv:2606.17683cs.CLcs.PL2026-06中稿 · ICML被引 1

提升大模型代码翻译的运行效率,解决译后程序变慢的问题。

Bridging Functional Correctness and Runtime Efficiency Gaps in LLM-Based Code Translation

论文配图:Bridging Functional Correctness and Runtime Efficiency Gaps in LLM-Based Code Translation
图 1 · 摘自论文原文
  • 分两阶段:生成多样候选+差异感知选最优
  • 在三个基准上同时提升正确率和运行速度
  • 适合关注代码性能优化的研究者与开发者

尽管大语言模型(LLMs)显著提升了自动化代码翻译的功能正确性,但译后程序的运行效率却长期被忽视。随着摩尔定律趋缓,运行效率已成为程序质量的重要指标。我们的初步研究发现,LLM生成的代码通常比人工编写更慢,且仅靠提示工程无法解决此问题。为此,我们提出SwiftTrans框架,包含两个关键阶段:(1) 多视角探索,通过并行上下文学习(ICL)生成多样化翻译候选;(2) 差异感知选择,利用差值分析选出最优方案。我们还引入层次化引导(Hierarchical Guidance)和序数引导(Ordinal Guidance),增强模型对两个核心组件的适应能力。为评估运行效率,我们扩展了CodeNet和F2SBench,并新增SwiftBench基准。在全部三个基准上的实验表明,SwiftTrans在功能正确性和运行效率上均实现持续提升。

原文摘要 · Abstract (English)

While large language models (LLMs) have greatly advanced the functional correctness of automated code translation systems, the runtime efficiency of translated programs has received comparatively little attention. With the waning of Moore's law, runtime efficiency has become increasingly important for program quality, alongside functional correctness. Our preliminary study reveals that LLM-translated programs often run slower than human-written ones, and this issue cannot be remedied through prompt engineering alone. Therefore, our work proposes SwiftTrans, a code translation framework comprising two key stages: (1) Multi-Perspective Exploration, where MpTranslator leverages parallel in-context learning (ICL) to generate diverse translation candidates; and (2) Difference-Aware Selection, where DiffSelector identifies the optimal candidate by explicitly comparing differences between translations. We further introduce Hierarchical Guidance for MpTranslator and Ordinal Guidance for DiffSelector, enabling LLMs to better adapt to these two core components. To support the evaluation of runtime efficiency in translated programs, we extend existing benchmarks, CodeNet and F2SBench, and introduce a new benchmark, SwiftBench. Experimental results across all three benchmarks show that SwiftTrans achieves consistent improvements in both correctness and runtime efficiency.

代码翻译大模型运行效率自动化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。