TRACE: Evaluating Execution Efficiency of LLM-Based Code Translation
Key Lab of HCST (PKU), MOE(北京大学智能语言研究实验室(教育部);计算机科学与技术系);SCS, Peking University(中国科学院软件研究所);Institute of Software, Chinese Academy of Sciences(新加坡国立大学);National University of Singapore(伦敦国王学院);King’s College London(北京大学深圳研究生院电子与计算机工程学院);School of Electronic and Computer Engineering, PKU Shenzhen Graduate School
Zhihao Gong, Zeyu Sun, Dong Huang, Qingyuan Liang, Jie M. Zhang, Dan Hao
While Large Language Models (LLMs) have substantially improved the functional correctness of code translation, the critical dimension of execution efficiency remains overlooked. We present \textbf{\textsc{Trace}}, the first benchmark to explicitly assess efficiency in LLM-translated code. \textsc{Trace} includes 1,000 efficiency-critical tasks across C++, Java, and Python, each augmented with stress tests that reveal efficiency disparities often overlooked by small-scale tests. Using \textsc{Trace}, we conduct an extensive evaluation of 28 representative LLMs and highlight several key insights: 1) Correctness and efficiency are often misaligned: the correctness leader Claude-Sonnet-4-Think achieves only moderate time efficiency, outperformed by smaller open-source LLMs such as Qwen2.5-Coder-14B-Instruct. 2) Inefficiency is both prevalent and patterned: 23.5\% of correct translations suffer from notable inefficiency, mainly arising from algorithm implementation discrepancy (11.9\%), language construct mismatch (66.4\%), and resource management inefficiency (21.7\%). 3) Inference-time prompt strategies bring only modest improvements, indicating that simple prompting alone is insufficient to improve translation efficiency. Together, our results establish execution efficiency as an essential dimension of code translation and position \textsc{Trace} as a principled foundation for efficiency-oriented evaluation.
Natural Language to Code Translation with Execution
Meta AI;Toyota Technological Institute at Chicago(芝加哥丰田技术研究院);Carnegie Mellon University(卡内基梅隆大学);University of Washington(华盛顿大学)
在大型程序语料库上预训练的代码生成模型在将自然语言转换为代码方面已经显示出巨大的成功(Chen et al.,2021; Austin等人,2021年; Li等人,2022年,除其他外)。虽然这些模型没有明确地结合程序语义(即,执行结果),在培训期间,他们能够对许多问题产生正确的解决方案。然而,选择一个正确的程序从每个问题的生成集仍然具有挑战性。在这项工作中,我们引入了基于执行结果的最小贝叶斯风险解码(MBR-EXEC)的程序选择,并表明它提高了自然语言到代码任务的预训练代码模型的Few-Shot性能。我们选择输出程序从一个产生的候选人集边缘化的程序实现,共享相同的语义。由于精确等价是棘手的,我们执行每个程序上的少量测试输入近似语义等价。跨数据集,执行或模拟执行显著优于不涉及程序语义的方法。我们发现,MBR-EXEC一贯改善所有执行不知情的选择方法,这表明它是一种有效的方法,自然语言的代码翻译。我们在github.com/facebookresearch/mbr-exec上开源我们的代码,在dl.fbaipublicfiles.com/mbr-exec/mbr-exec-release.zip上开源我们的数据
CodeScope: An Execution-based Multilingual Multitask Multidimensional Benchmark for Evaluating LLMs on Code Understanding and Generation
University of California, Santa Barbara(加利福尼亚大学圣巴巴拉分校);School of Software Engineering, Xi’an Jiaotong University(西安交通大学软件学院);Zhejiang University(浙江大学);University of Illinois at Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);Alibaba Group(阿里巴巴集团);TU Wien(维也纳技术大学);University of Chinese Academy of Sciences(中国科学院大学)