Python(编程语言)
计算机科学
正确性
程序设计语言
文档
源代码
麻省理工许可证
管道(软件)
软件工程
任务(项目管理)
万维网
单元测试
编码(集合论)
源代码行
自然语言处理
人工智能
开源
作者
Miryeong,Wonseok Oh,Gabin An,Hakjoo Oh
出处
期刊:
[Association for Computing Machinery]
日期:2026-06-30
卷期号:3 (FSE): 967-988
摘要
We present Pig, a novel approach to automating Python library migration by leveraging large language models (LLMs). Library migration is an increasingly common task in modern Python development, yet it remains tedious and error-prone due to the lack of general solutions that can handle diverse libraries without relying on documentation or code examples. To address this challenge, Pig employs a four-step pipeline that effectively harnesses the capabilities of LLMs. First, Pig decomposes the migration task into smaller units by performing API-level slicing, allowing the LLM to focus on minimal, relevant context. Second, it guides LLMs using prompts informed by common failure patterns in naive LLM-based migrations and plausible API candidates. Third, Pig selectively extracts the migration-related code fragments from the LLM outputs. Finally, it transplants the migrated code back into the original program with post-processing to ensure semantic correctness and consistency. We demonstrate the effectiveness of Pig by evaluating it on 364 API-level migration tasks, where it improves the average success rate of the baseline approach by 53.5% across seven different LLM models.
科研通智能强力驱动
Strongly Powered by AbleSci AI