arXivDaily arXiv每日学术速递 周一至周五更新
北美退伍军人节(Veterans Day),12 日无更新
arXiv 2412.04590cs.SE
收藏

基于大型语言模型的规范驱动代码翻译:我们距离目标还有多远?

Specification-Driven Code Translation Powered by Large Language Models: How Far Are We?

Concordia University(康考迪亚大学);York University(约克大学)

Soumit Kanti Saha, Fazle Rabbi, Song Wang, Jinqiu Yang

AI总结:

本文探讨了利用自然语言规范作为中间表示进行代码翻译的效果,通过多数据集和语言对实验发现,结合源代码可提升特定语言对的翻译质量,但整体效果不一致。

摘要:

大型语言模型(LLMs)正在被越来越多地应用于各种领域,包括代码相关的任务,如代码翻译。先前的研究已经探讨了使用LLMs在不同编程语言之间翻译代码。由于LLMs在自然语言方面更有效,使用自然语言作为代码翻译任务的中间表示是一种直观吸引人的方法。然而,这种收益是否普遍还是高度依赖上下文仍不清楚。在本工作中,我们研究了使用NL-specification作为中间表示进行代码翻译。我们使用三个数据集、五种流行编程语言和29种语言对排列来评估我们的方法。我们的结果表明,仅使用NL-specification并不能带来性能提升。然而,当与源代码结合时,它在某些语言对(特别是以Python和C++为源语言时)提供了收益,但整体上没有一致的改进。除了分析代码翻译的性能外,我们还调查了翻译代码的质量,并提供了有关翻译代码中存在问题的见解。

英文摘要:

Large Language Models (LLMs) are increasingly being applied across various domains, including code-related tasks such as code translation. Previous studies have explored using LLMs for translating code between different programming languages. Since LLMs are more effective with natural language, using natural language as an intermediate representation in code translation tasks is an intuitively appealing approach. However, whether this benefit is general or highly context-dependent remains unclear. In this work, we investigate using NL-specification as an intermediate representation for code translation. We evaluate our method using three datasets, five popular programming languages, and 29 language pair permutations. Our results show that using NL-specification alone does not lead to performance improvements. However, when combined with source code, it provides gains in certain language pairs (notably with Python and C++ as source languages), while offering no consistent improvement overall. Besides analyzing the performance of code translation, we also investigate the quality of the translated code and provide insights into the issues present in the translated code.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑