A Systematic Evaluation of Large Code Models in API Suggestion: When, Which, and How
Open Access
- 27 October 2024
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 281-293
Abstract
API suggestion is a critical task in modern software development, assisting programmers by predicting and recommending third-party APIs based on the current context. Recent advancements in large code models (LCMs) have shown promise in the API suggestion task. However, they mainly focus on suggesting which APIs to use, ignoring that programmers may demand more assistance while using APIs in practice including when to use the suggested APIs and how to use the APIs. To mitigate the gap, we conduct a systematic evaluation of LCMs for the API suggestion task in the paper. To facilitate our investigation, we first build a benchmark that contains a diverse collection of code snippets, covering 176 APIs used in 853 popular Java projects. Three distinct scenarios in the API suggestion task are then considered for evaluation, including (1) "when to use", which aims at determining the desired position and timing for API usage; (2) "which to use", which aims at identifying the appropriate API from a given library; and (3) "how to use", which aims at predicting the arguments for a given API. The consideration of the three scenarios allows for a comprehensive assessment of LCMs' capabilities in suggesting APIs for developers. During the evaluation, we choose nine popular LCMs with varying model sizes for the three scenarios. We also perform an in-depth analysis of the influence of context selection on the model performance. Our experimental results reveal multiple key findings. For instance, LCMs present the best performance in the "how to use" scenario while performing the worst in the "when to use" scenario, e.g., the average performance gap of LCMs between "when to use" and "how to use" scenarios achieves 34%, indicating that the "when to use" scenario is more challenging. Furthermore, enriching context information substantially improves the model performance. Specifically, by incorporating the contexts, smaller-sized LCMs can outperform those twenty times larger models without the contexts provided. Based on these findings, we finally provide insights and implications for researchers and developers, which can lay the groundwork for future advancements in the API suggestion task.Keywords
All Related Versions
Funding Information
- National Natural Science Foundation of China (62472126)
- Natural Science Foundation of Guangdong Province (2023A1515011959)
- Shenzhen-Hong Kong Jointly Funded Project (SGDX20230116091246007)
- Shenzhen Basic Research (JCYJ20220531095214031)
- Shenzhen International Science and Technology Cooperation Project (GJHZ20220913143008015)
- Research Grants Council of the Hong Kong Special Administrative Region (CUHK 14206921)
This publication has 19 references indexed in Scilit:
- What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs?2023
- Domain Adaptive Code Completion via Language Models and Decoupled Domain Databases2023
- Let's Chat to Find the APIs: Connecting Human, LLM and Knowledge Graph through AI Chain2023
- API Usage Recommendation Via Multi-View Heterogeneous Graph Representation LearningIEEE Transactions on Software Engineering, 2023
- Revisiting, Benchmarking and Exploring API Recommendation: How Far Are We?IEEE Transactions on Software Engineering, 2022
- An Empirical Study on the Usage of BERT Models for Code Completion2021
- Boosting API Recommendation With Implicit FeedbackIEEE Transactions on Software Engineering, 2021
- Parameter-free probabilistic API mining across GitHub2016
- RACK: Automatic API Recommendation Using Crowdsourced Knowledge2016
- Portfolio2011