Library migration is the process of replacing a library with a similar one in a software project. Manual library migration is time consuming and error prone, as it requires developers to understand the Application Programming Interfaces (API) of both libraries, map equivalent APIs, and perform the necessary code transformations. Due to the difficulty of the library migration process, most of the existing automated techniques and tooling stop at the API mapping stage or support a limited set of libraries and code transformations. In this paper, we develop an end-to-end solution that can automatically migrate code between any arbitrary pair of Python libraries that provide similar functionality. Due to the promising capabilities of Large Language Models (LLMs) in code generation and transformation, we use LLMs as the primary engine for migration. Before building the tool, we first study the capabilities of LLMs for library migration on a benchmark of 321 real-world library migrations. We find that LLMs can effectively perform library migration, but some post-processing steps can further improve the performance. Based on this, we develop MigrateLib, a command line application that combines the power of LLMs, static analysis, and dynamic analysis to provide accurate library migration. We evaluate MigrateLib on 717 real-world Python applications that are not from our benchmark. We find that MigrateLib can migrate 32% of the migrations with complete correctness. Of the remaining migrations, only 14% of the migration-related changes are left for developers to fix for more than half of the projects.


翻译:库迁移是指在软件项目中用功能相似的库替换原有库的过程。手动库迁移耗时且易出错,因为开发者需要理解两个库的应用程序编程接口(API),映射等效API,并执行必要的代码转换。由于库迁移过程的复杂性,现有自动化技术与工具大多止步于API映射阶段,或仅支持有限的库集合与代码转换类型。本文开发了一种端到端解决方案,能够自动在任意两个提供相似功能的Python库之间迁移代码。鉴于大语言模型(LLM)在代码生成与转换方面展现出的潜力,我们采用LLM作为迁移的核心引擎。在构建工具前,我们首先基于包含321个真实世界库迁移案例的基准测试,研究了LLM执行库迁移的能力。研究发现LLM能有效完成库迁移,但某些后处理步骤可进一步提升其性能。基于此,我们开发了MigrateLib——一个结合LLM能力、静态分析与动态分析的命令行应用程序,以提供精准的库迁移服务。我们在717个未包含于基准测试的真实世界Python应用程序上评估MigrateLib。实验表明,MigrateLib能以完全正确的方式完成32%的迁移任务。在其余迁移案例中,超过半数的项目仅需开发者修正14%与迁移相关的变更。

0
下载
关闭预览

相关内容

【AAAI2023】图上的非独立同分布迁移学习
专知会员服务
24+阅读 · 2022年12月25日
最新最全最详细中文版-《迁移学习简明手册》pdf分享
专知会员服务
102+阅读 · 2020年9月25日
《迁移学习简明手册》,93页pdf
专知会员服务
137+阅读 · 2019年12月9日
百闻不如一码!手把手教你用Python搭一个Transformer
大数据文摘
18+阅读 · 2019年4月22日
迁移自适应学习最新综述,附21页论文下载
【免费下载】迁移学习简明手册
新智元
21+阅读 · 2018年4月13日
迁移学习在深度学习中的应用
专知
24+阅读 · 2017年12月24日
独家 | 一文读懂迁移学习(附学习工具包)
数据派THU
13+阅读 · 2017年7月13日
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
最新内容
内省扩散语言模型
专知会员服务
2+阅读 · 4月14日
国外反无人机系统与技术动态
专知会员服务
3+阅读 · 4月14日
大规模作战行动中的战术作战评估(研究论文)
未来的海战无人自主系统
专知会员服务
3+阅读 · 4月14日
美军多域作战现状分析:战略、概念还是幻想?
无人机与反无人机系统(书籍)
专知会员服务
19+阅读 · 4月14日
美陆军2026条令:安全与机动支援
专知会员服务
8+阅读 · 4月14日
相关基金
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员