APIRecX: Cross-Library API Recommendation via Pre-Trained Language Model
31829Authors
nan
Abstract
AbstractFor programmers, learning the usage of APIs (Application Programming Interfaces) of a software library is important yet difficult. API recommendation tools can help developers use APIs by recommending which APIs to be used next given the APIs that have been written. Traditionally, language models such as N-gram are applied to API recommendation. However, because the software libraries keep changing and new libraries keep emerging, new APIs are common. These new APIs can be seen as OOV (out of vocabulary) words and cannot be handled well by existing API recommendation approaches due to the lack of training data. In this paper, we propose APIRecX, the first cross-library API recommendation approach, which uses BPE to split each API call in each API sequence and pre-trains a GPT based language model. It then recommends APIs by fine-tuning the pre-trained model. APIRecX can migrate the knowledge of existing libraries to a new library, and can recommend APIs that are previously regarded as OOV. We evaluate APIRecX on six libraries and the results confirm its effectiveness by comparing with two typical API recommendation approaches.
Keywords
Full Content
Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 3425–3436 November 7–11, 2021. c⃝2021 Association for Computational Linguistics 3425 APIRecX: Cross-Library API Recommendation via Pre-Trained Language Model Yuning Kang1, Zan Wang1, Hongyu Zhang2, Junjie Chen1∗, Hanmo You1 1College of Intelligence of and Computing, Tianjin University, Tianjin, China 2The University of Newcastle, Callaghan, Australia {kangyuning,wangzan,junjiechen,youhanmo}@tju.edu.cn zhang.hongyu@newcastle.edu.au Abstract For programmers, learning the usage of APIs (Application Programming Interfaces) of a software library is important yet difficult. API recommendation tools can help developers use APIs by recommending which APIs to be used next given the APIs that have been writ- ten. Traditionally, language models such as N-gram are applied to API recommendation. However, because the software libraries keep changing and new libraries keep emerging, new APIs are common. These new APIs can be seen as OOV (out of vocabulary) words and cannot be handled well by existing API recom- mendation approaches due to the lack of train- ing data. In this paper, we propose APIRecX, the first cross-library API recommendation ap- proach, which uses BPE to split each API call in each API sequence and pre-trains a GPT- based language model. It then recommends APIs by fine-tuning the pre-trained model. APIRecX can migrate the knowledge of ex- isting libraries to a new library, and can rec- ommend APIs that are previously regarded as OOV. We evaluate APIRecX on six libraries and the results confirm its effectiveness by comparing with two typical API recommenda- tion approaches. 1 Introduction Application Programming Interface (API) is an in- tegral part of software libraries. Being familiar with APIs could help improve programming pro- ductivity. However, a library tends to contain a large number of APIs and there could be complex dependencies among APIs, and thus understanding all APIs in a library is very challenging, especially for new developers. To facilitate correct and ef- ficient usage of APIs during programming, many API recommendation approaches (Zhong et al., 2009; Nguyen et al., 2016; Xie et al., 2019; Bruch et al., 2009; Huang et al., 2018) have been pro- posed. More specifically, API recommendation ∗Junjie Chen is the corresponding author. aims to automatically recommend a correct API call at the current programming location based on its preceding part of code information. As an example, Listing 1 shows a Java code snip- pet about opening a text file. Assuming a program- mer forgets what to write in Line 6. API recommen- dation tool can help the programmer by prompting the most likely API call to be used next. In this case, printStackTrace() will be returned. The API recommendation tools do so by learning API usage pattern from a large code corpus. Some tools (Nguyen et al., 2016; Nguyen and Nguyen, 2015) use probabilistic models to learn API usage pat- tern , while others (Zhong et al., 2009; Wang et al., 2013) use data mining methods to find API usage patterns . Recently, deep learning based language models are proposed to model the API sequences and have obtained promising …
Content truncated to 500 words
Labeled Text
AbstractFor programmers, learning the usage of APIs (Application Programming Interfaces) of a software library is important yet difficult. API recommendation tools can help developers use APIs by recommending which APIs to be used next given the APIs that have been written. Traditionally, language models such as N-gram are applied to API recommendation. However, because the software libraries keep changing and new libraries keep emerging, new APIs are common. These new APIs can be seen as OOV (out of vocabulary) words and cannot be handled well by existing API recommendation approaches due to the lack of training data. In this paper, we propose APIRecX, the first cross-library API recommendation approach, which uses BPE to split each API call in each API sequence and pre-trains a GPT based language model. It then recommends APIs by fine-tuning the pre-trained model. APIRecX can migrate the knowledge of existing libraries to a new library, and can recommend APIs that are previously regarded as OOV. We evaluate APIRecX on six libraries and the results confirm its effectiveness by comparing with two typical API recommendation approaches.
Publication Details
- Paper ID:
- 31829
- Year:
- 2021
- Publication:
- TIPSTER
- Publication Type:
- conf
- DOI:
- nan