{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T18:51:45Z","timestamp":1782845505855,"version":"3.54.5"},"reference-count":50,"publisher":"Association for Computing Machinery (ACM)","issue":"FSE","license":[{"start":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T00:00:00Z","timestamp":1782777600000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/2.zoppoz.workers.dev:443\/https\/creativecommons.org\/licenses\/by\/4.0\/legalcode"}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["Proc. ACM Softw. Eng."],"published-print":{"date-parts":[[2026,6,30]]},"abstract":"<jats:p>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.<\/jats:p>","DOI":"10.1145\/3797072","type":"journal-article","created":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T17:06:14Z","timestamp":1782839174000},"page":"967-988","source":"Crossref","is-referenced-by-count":0,"title":["Pig: Leveraging Large Language Models for Python Library Migrations"],"prefix":"10.1145","volume":"3","author":[{"ORCID":"https:\/\/2.zoppoz.workers.dev:443\/https\/orcid.org\/0009-0001-7987-3917","authenticated-orcid":false,"given":"Miryeong","family":"Kang","sequence":"first","affiliation":[{"name":"Korea University, Seoul, Republic of Korea"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/2.zoppoz.workers.dev:443\/https\/orcid.org\/0000-0002-3124-7415","authenticated-orcid":false,"given":"Wonseok","family":"Oh","sequence":"additional","affiliation":[{"name":"Korea University, Seoul, Republic of Korea"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/2.zoppoz.workers.dev:443\/https\/orcid.org\/0000-0002-6521-8858","authenticated-orcid":false,"given":"Gabin","family":"An","sequence":"additional","affiliation":[{"name":"Korea University, Seoul, Republic of Korea"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/2.zoppoz.workers.dev:443\/https\/orcid.org\/0000-0002-1900-7654","authenticated-orcid":false,"given":"Hakjoo","family":"Oh","sequence":"additional","affiliation":[{"name":"Korea University, Seoul, Republic of Korea"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2026,6,30]]},"reference":[{"key":"e_1_2_1_1_1","doi-asserted-by":"publisher","DOI":"10.1145\/3674805.3690746"},{"key":"e_1_2_1_2_1","first-page":"60","article-title":"Automating the detection of third-party Java library migration at the function level","author":"Alrubaye Hussein","year":"2018","unstructured":"Hussein Alrubaye and Mohamed Wiem Mkaouer. 2018. Automating the detection of third-party Java library migration at the function level.. In CASCON. 60-71.","journal-title":"CASCON."},{"key":"e_1_2_1_3_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.asoc.2020.106140"},{"key":"e_1_2_1_4_1","volume-title":"2019 IEEE\/ACM 27th International Conference on Program Comprehension (ICPC). IEEE, 347-357","author":"Alrubaye Hussein","year":"2019","unstructured":"Hussein Alrubaye, Mohamed Wiem Mkaouer, and Ali Ouni. 2019. On the use of information retrieval to automate the detection of third-party java library migration at the method level. In 2019 IEEE\/ACM 27th International Conference on Program Comprehension (ICPC). IEEE, 347-357."},{"key":"e_1_2_1_5_1","doi-asserted-by":"publisher","DOI":"10.1145\/3663529.3663839"},{"key":"e_1_2_1_6_1","unstructured":"Paul E. Black. 2021. Ratcliff\/Obershelp pattern recognition. https:\/\/2.zoppoz.workers.dev:443\/https\/www.nist.gov\/dads\/HTML\/ratcliffObershelp.html Accessed: 2025-05-07."},{"key":"e_1_2_1_7_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE55347.2025.00157"},{"key":"e_1_2_1_8_1","doi-asserted-by":"publisher","DOI":"10.1145\/3728922"},{"key":"e_1_2_1_9_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE-Companion.2019.00054"},{"key":"e_1_2_1_10_1","doi-asserted-by":"publisher","DOI":"10.1145\/3338906.3338924"},{"key":"e_1_2_1_11_1","unstructured":"Jonathan Cordeiro Shayan Noei and Ying Zou. 2024. An Empirical Study on the Code Refactoring Capability of Large Language Models. arXiv:2411.02320 [cs.SE] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2411.02320"},{"key":"e_1_2_1_12_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE.2009.5070565"},{"key":"e_1_2_1_13_1","unstructured":"DeepSeek-AI Xiao Bi Deli Chen Guanting Chen Shanhuang Chen Damai Dai Chengqi Deng Honghui Ding Kai Dong et al. 2024. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism. arXiv:2401.02954 [cs.CL] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2401.02954"},{"key":"e_1_2_1_14_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.infsof.2024.107588"},{"key":"e_1_2_1_15_1","doi-asserted-by":"publisher","DOI":"10.1145\/2642937.2642982"},{"key":"e_1_2_1_16_1","volume-title":"Proceedings of the IEEE\/ACM 7th international conference on mobile software engineering and systems. 77-80","author":"Fazzini Mattia","year":"2020","unstructured":"Mattia Fazzini, Qi Xin, and Alessandro Orso. 2020. Apimigrator: an api-usage migration tool for android apps. In Proceedings of the IEEE\/ACM 7th international conference on mobile software engineering and systems. 77-80."},{"key":"e_1_2_1_17_1","doi-asserted-by":"publisher","DOI":"10.5555\/2486788.2486800"},{"key":"e_1_2_1_18_1","unstructured":"Aaron Grattafiori Abhimanyu Dubey Angela Fan Emily Dinan Gabriel Synnaeve Mike Lewis Naman Goyal et al. 2024. The Llama 3 Herd of Models. arXiv:2407.21783 [cs.AI] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2407.21783"},{"key":"e_1_2_1_19_1","doi-asserted-by":"publisher","DOI":"10.1109\/SANER56733.2023.00064"},{"key":"e_1_2_1_20_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE.2005.1553570"},{"key":"e_1_2_1_21_1","doi-asserted-by":"publisher","DOI":"10.1145\/3643731"},{"key":"e_1_2_1_22_1","doi-asserted-by":"publisher","DOI":"10.1109\/MSR59073.2023.00075"},{"key":"e_1_2_1_23_1","volume-title":"May Mahmoud, Ildar Akhmetov, and Sarah Nadi.","author":"Islam Md Mohayeminul","year":"2025","unstructured":"Md Mohayeminul Islam, Ajay Kumar Jha, May Mahmoud, Ildar Akhmetov, and Sarah Nadi. 2025. Using LLMs for Library Migration. arXiv:2504.13272 [cs.SE] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2504.13272"},{"key":"e_1_2_1_24_1","doi-asserted-by":"publisher","unstructured":"Miryeong Kang. 2026. Artifact Evaluation Package for \"Pig: Leveraging Large Language Models for Python Library Migrations\". doi:10.5281\/zenodo.19480524 10.5281\/zenodo.19480524","DOI":"10.5281\/zenodo.19480524"},{"key":"e_1_2_1_25_1","volume-title":"The Hungarian method for the assignment problem. Naval research logistics quarterly 2, 1-2","author":"Kuhn Harold W","year":"1955","unstructured":"Harold W Kuhn. 1955. The Hungarian method for the assignment problem. Naval research logistics quarterly 2, 1-2 (1955), 83-97."},{"key":"e_1_2_1_26_1","doi-asserted-by":"publisher","DOI":"10.1007\/s10664-017-9521-5"},{"key":"e_1_2_1_27_1","doi-asserted-by":"crossref","first-page":"417","DOI":"10.1109\/TSE.2020.2988396","article-title":"A3: Assisting android api migrations using code examples","volume":"48","author":"Lamothe Maxime","year":"2020","unstructured":"Maxime Lamothe, Weiyi Shang, and Tse-Hsun Peter Chen. 2020. A3: Assisting android api migrations using code examples. IEEE Transactions on Software Engineering 48, 2 (2020), 417-431.","journal-title":"IEEE Transactions on Software Engineering"},{"key":"e_1_2_1_28_1","volume-title":"Knowledge Science","author":"Lu Yangyang","unstructured":"Yangyang Lu, Ge Li, Zelong Zhao, Linfeng Wen, and Zhi Jin. 2017. Learning to Infer API Mappings from API Documents. In Knowledge Science, Engineering and Management, Gang Li, Yong Ge, Zili Zhang, Zhi Jin, and Michael Blumenstein (Eds.). Springer International Publishing, Cham, 237-248."},{"key":"e_1_2_1_29_1","doi-asserted-by":"publisher","DOI":"10.1145\/3691620.3695322"},{"key":"e_1_2_1_30_1","doi-asserted-by":"publisher","DOI":"10.1145\/2642937.2643010"},{"key":"e_1_2_1_31_1","doi-asserted-by":"publisher","DOI":"10.1145\/3236024.3236036"},{"key":"e_1_2_1_32_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE43902.2021.00023"},{"key":"e_1_2_1_33_1","unstructured":"Ollama. 2023. Ollama GitHub Repository. https:\/\/2.zoppoz.workers.dev:443\/https\/ollama.com."},{"key":"e_1_2_1_34_1","unstructured":"OpenAI. 2025. GPT-4o. https:\/\/2.zoppoz.workers.dev:443\/https\/platform.openai.com\/docs\/models\/gpt-4o."},{"key":"e_1_2_1_35_1","unstructured":"OpenAI. 2025. OpenAI gpt-oss-20b. https:\/\/2.zoppoz.workers.dev:443\/https\/platform.openai.com\/docs\/models\/gpt-oss-20b."},{"key":"e_1_2_1_36_1","doi-asserted-by":"publisher","DOI":"10.1109\/ASE56229.2023.00117"},{"key":"e_1_2_1_37_1","doi-asserted-by":"publisher","DOI":"10.1145\/3663529.3663841"},{"key":"e_1_2_1_38_1","doi-asserted-by":"publisher","DOI":"10.1109\/APSEC60848.2023.00025"},{"key":"e_1_2_1_39_1","unstructured":"Gemma Team Aishwarya Kamath Johan Ferret et al. 2025. Gemma 3 Technical Report. arXiv:2503.19786 [cs.CL] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2503.19786"},{"key":"e_1_2_1_40_1","volume-title":"Cassidy Hardin, Thomas Mesnard, L\u00e9onard Hussenot, Johan Ferret, Bobak Shahriari, Alexandre Ram\u00e9, et al.","author":"Team Gemma","year":"2024","unstructured":"Gemma Team, Morgane Riviere, Shreya Pathak, Pier Giuseppe Sessa, Cassidy Hardin, Thomas Mesnard, L\u00e9onard Hussenot, Johan Ferret, Bobak Shahriari, Alexandre Ram\u00e9, et al. 2024. Gemma 2: Improving Open Language Models at a Practical Size. arXiv:2408.00118 [cs.CL] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2408.00118"},{"key":"e_1_2_1_41_1","volume-title":"2013 20th Working Conference on Reverse Engineering (WCRE). IEEE, 192-201","author":"Teyton C\u00e9dric","year":"2013","unstructured":"C\u00e9dric Teyton, Jean-R\u00e9my Falleri, and Xavier Blanc. 2013. Automatic discovery of function mappings between similar libraries. In 2013 20th Working Conference on Reverse Engineering (WCRE). IEEE, 192-201."},{"key":"e_1_2_1_42_1","doi-asserted-by":"publisher","DOI":"10.1145\/1806799.1806848"},{"key":"e_1_2_1_43_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE48619.2023.00129"},{"key":"e_1_2_1_44_1","doi-asserted-by":"publisher","DOI":"10.1145\/3650212.3680323"},{"key":"e_1_2_1_45_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICPC.2019.00052"},{"key":"e_1_2_1_46_1","unstructured":"An Yang Anfeng Li Baosong Yang Beichen Zhang Binyuan Hui Bo Zheng Bowen Yu Chang Gao et al. 2025. Qwen3 Technical Report. arXiv:2505.09388 [cs.CL] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2505.09388"},{"key":"e_1_2_1_47_1","unstructured":"An Yang Baosong Yang Binyuan Hui Bo Zheng Bowen Yu Chang Zhou Chengpeng Li Chengyuan Li et al. 2024. Qwen2 Technical Report. arXiv:2407.10671 [cs.CL] https:\/\/2.zoppoz.workers.dev:443\/https\/arxiv.org\/abs\/2407.10671"},{"key":"e_1_2_1_48_1","doi-asserted-by":"publisher","DOI":"10.1145\/3387904.3389282"},{"key":"e_1_2_1_49_1","doi-asserted-by":"publisher","DOI":"10.1145\/1806"},{"key":"e_1_2_1_50_1","doi-asserted-by":"publisher","DOI":"10.1145\/3609437.3609466"}],"container-title":["Proceedings of the ACM on Software Engineering"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/2.zoppoz.workers.dev:443\/https\/dl.acm.org\/doi\/pdf\/10.1145\/3797072","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T17:51:41Z","timestamp":1782841901000},"score":1,"resource":{"primary":{"URL":"https:\/\/2.zoppoz.workers.dev:443\/https\/dl.acm.org\/doi\/10.1145\/3797072"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2026,6,30]]},"references-count":50,"journal-issue":{"issue":"FSE","published-print":{"date-parts":[[2026,6,30]]}},"alternative-id":["10.1145\/3797072"],"URL":"https:\/\/2.zoppoz.workers.dev:443\/https\/doi.org\/10.1145\/3797072","relation":{},"ISSN":["2994-970X"],"issn-type":[{"value":"2994-970X","type":"electronic"}],"subject":[],"published":{"date-parts":[[2026,6,30]]}}}