In recent years, Large Language Models (LLMs) have been widely studied in the code translation field on the method, class, and even repository levels. However, most of these benchmarks are limited in terms of Third-Party Library (TPL) categories and scales, making TPL-related errors hard to expose and hindering the development of targeted solutions. Considering the high dependence (over 90%) on TPLs in practical programming, demystifying and analyzing LLMs' code translation performance involving various TPLs becomes imperative. To address this gap, we construct TransLibEval, the first benchmark dedicated to library-centric code translation. It consists of 200 real-world tasks across Python, Java, and C++, each explicitly involving TPLs from diverse categories such as data processing, machine learning, and web development, with comprehensive dependency coverage and high-coverage test suites. We evaluate seven recent LLMs of commercial, general, and code-specialized families under six translation strategies of three categories: Direct, IR-guided, and Retrieval-augmented. Experimental results show a dramatic performance drop compared with library-free settings (average CA decline over 60%), while diverse strategies demonstrate heterogeneous advantages. Furthermore, we analyze 4,831 failed cases from GPT-4o, one of the State-of-the-Art (SOTA) LLMs, revealing numerous third-party reference errors that were obscured previously. These findings highlight the unique challenges of library-centric translation and provide practical guidance for improving TPL-aware code intelligence.


翻译:近年来,大语言模型(LLMs)在代码翻译领域得到了广泛研究,其范围涵盖方法、类乃至仓库级别。然而,现有基准测试在第三方库(TPL)类别与规模方面存在局限,导致与TPL相关的错误难以暴露,阻碍了针对性解决方案的发展。考虑到实际编程中对TPL的高度依赖(超过90%),系统揭示并分析LLMs在涉及各类TPL的代码翻译性能显得尤为迫切。为填补这一空白,我们构建了首个专注于以库为中心的代码翻译基准测试TransLibEval。该基准包含涵盖Python、Java和C++的200个真实世界任务,每个任务均明确涉及数据处理、机器学习和Web开发等不同类别的TPL,并具备完整的依赖覆盖与高覆盖率的测试套件。我们在三类六种翻译策略(直接翻译、中间表示引导翻译与检索增强翻译)下,评估了来自商业、通用及代码专用系列的七个最新LLMs。实验结果表明,与无库环境相比,模型性能出现显著下降(平均正确率下降超过60%),而不同策略展现出异构优势。此外,我们分析了当前最先进LLM之一GPT-4o的4,831个失败案例,揭示了大量先前被掩盖的第三方引用错误。这些发现凸显了以库为中心的翻译所面临的独特挑战,并为改进TPL感知的代码智能提供了实践指导。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
KnowledGPT:基于知识库的检索和存储访问增强大型语言模型
大语言模型简明指南
专知会员服务
143+阅读 · 2023年7月29日
《大型语言模型》最新全面概述
专知会员服务
111+阅读 · 2023年7月14日
自然语言处理中的语言模型预训练方法
PaperWeekly
14+阅读 · 2018年10月21日
NLP通用模型诞生?一个模型搞定十大自然语言常见任务
人工智能头条
10+阅读 · 2018年6月29日
自然语言处理(二)机器翻译 篇 (NLP: machine translation)
DeepLearning中文论坛
12+阅读 · 2015年7月1日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员