APSEC 2024
Tue 3 - Fri 6 December 2024 China

Automated API recommendation technology can help developers quickly find target APIs that meet their requirements, significantly reducing the time and effort required to search for suitable APIs. Some retrieval-based API recommendation approaches, such as BIKER and CLEAR, adopt an indirect API recommendation strategy. Although these approaches have shown good performance, we observed two limitations in these approaches: (1) The recommendation performance of these models heavily relies on the coverage of the collected question titles proposed by developers; (2) These models ignore the API source code information. To overcome the two limitations, we propose a model named AnsAPIRec (Answer-directed API Recommendation), which leverages a pre-trained model and joint-attention mechanism in this paper. In addition to the fully qualified name of the API, AnsAPIRec extracts the corresponding source code from the JDK as an additional feature. AnsAPIRec adopts a direct API recommendation strategy, which directly calculates the similarity between user queries and API features, i.e., API fully qualified name and API source code, to find the target API, alleviating the reliance on question titles. To further enhance the model’s ability to understand the semantics of the inputs, we propose a joint-attention mechanism to learn the interdependent representations between the queries and API features. This deep semantic fusion mechanism enables AnsAPIRec to perform well in understanding user intent and API functionality. We reused the APIBench-Q dataset, containing 5885 queries for training and 653 queries for testing. The experimental result shows that AnsAPIRec achieved an MRR of 0.473, significantly outperforming the baseline models, BIKER and CLEAR.