Improving Code Translation Correctness and Efficiency with Multi-Perspective Exploration and Difference-Aware Selection
Abstract
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 as critical as functional correctness in evaluating program quality. 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 evaluate the runtime efficiency of programs, we extend existing benchmarks, CodeNet and F2SBench, with efficiency-critical test cases and maximum runtime constraints on translated programs. We also introduce SwiftBench, a new benchmark designed to evaluate whether translation models can improve the efficiency of programs when the source code exhibits inefficiencies. Experimental results across all three benchmarks show that SwiftTrans achieves consistent improvements in both correctness and efficiency. Notably, SwiftTrans built on Qwen2.5-7B surpasses current state-of-the-art models such as GPT-5 and training-based F2STrans.
BibTeX
@misc{zhang2026improving,
author = {Longhui Zhang and Jiahao Wang and Chenhao Hu and Jing Li and Min Zhang},
title = {{Improving Code Translation Correctness and Efficiency with Multi-Perspective Exploration and Difference-Aware Selection}},
year = {2026},
url = {https://openreview.net/forum?id=84UDiZI6yl},
howpublished = {OpenReview},
note = {Submitted to ICLR 2026},
}Ask Althea to put this paper to the test.
Loading related content...