Multilingual Code Co-evolution using Large Language Models

Multilingual Code Co-evolution using Large Language Models
复制标题

DOI:
10.1145/3611643.3616350
复制
发表时间:
2023-07
期刊:
Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering
影响因子:
--
通讯作者:
Jiyang Zhang;Pengyu Nie;Junyi Jessy Li;Miloš Gligorić
Jiyang Zhang;Pengyu Nie;Junyi Jessy Li;Miloš Gligorić
中科院分区:
其他
文献类型:
--
作者:
Jiyang Zhang;Pengyu Nie;Junyi Jessy Li;Miloš Gligorić

文献摘要

相似文献

许多软件项目以多种编程语言实现API和算法。维护此类项目是令人厌烦的,因为开发人员必须确保任何更改(例如,错误修复或新功能)被传播,及时而没有错误,以实现其他编程语言。在不断变化的软件的世界中,使用基于规则的翻译工具(即转介剂)或机器学习模型将代码从一种语言转换为另一种语言提供有限的价值。每次将整个代码库从一种语言转换为另一种语言不是开发人员的工作方式。在本文中,我们针对一个新颖的任务:使用大型语言模型(LLMS)翻译代码从一种编程语言更改为另一种。我们设计并实施了第一个名为“编码器”的LLM来解决此任务。编码器明确将代码模型变更为编辑序列,并学会将跨编程语言的更改关联。为了评估编码器,我们从8对开源软件项目中收集了6,613个对齐代码更改的语料库,这些项目以两种编程语言(Java和C#)实现相似的功能。结果表明,在所有常用的自动指标上,编码器的表现都优于最先进的方法。我们的工作还表明,编码器与现有的基于一代的模型互补,它们的组合确保了更大的性能。
Many software projects implement APIs and algorithms in multiple programming languages. Maintaining such projects is tiresome, as developers have to ensure that any change (e.g., a bug fix or a new feature) is being propagated, timely and without errors, to implementations in other programming languages. In the world of ever-changing software, using rule-based translation tools (i.e., transpilers) or machine learning models for translating code from one language to another provides limited value. Translating each time the entire codebase from one language to another is not the way developers work. In this paper, we target a novel task: translating code changes from one programming language to another using large language models (LLMs). We design and implement the first LLM, dubbed Codeditor, to tackle this task. Codeditor explicitly models code changes as edit sequences and learns to correlate changes across programming languages. To evaluate Codeditor, we collect a corpus of 6,613 aligned code changes from 8 pairs of open-source software projects implementing similar functionalities in two programming languages (Java and C#). Results show that Codeditor outperforms the state-of-the-art approaches by a large margin on all commonly used automatic metrics. Our work also reveals that Codeditor is complementary to the existing generation-based models, and their combination ensures even greater performance.