API Reranking for Automatic Code Completion: Leveraging Explicit Intent and Implicit Cues from Code Context

ACL ARR 2025 May Submission5675 Authors

20 May 2025 (modified: 03 Jul 2025)ACL ARR 2025 May SubmissionEveryoneRevisionsBibTeXCC BY 4.0
Abstract: Large Language Models (LLMs) have significantly advanced software development, particularly in automatic code completion, where selecting suitable APIs from vast third-party libraries plays a critical role. However, current solutions either focus on recommending APIs based on user queries or code context, without considering both aspects simultaneously. To bridge this gap, we propose a novel framework APIRanker to rerank candidate API documents based on both the explicit developer intent and implicit cues in the incomplete code context. To generate training data for this task, we introduce a self-supervised ranking framework that automatically constructs data by assessing the relevance of API documents to code context with a perplexity-driven approach via comments. To enhance API relevance detection, we propose a novel reranking model that predicts relevance scores by capturing a hidden reasoning state to estimate relevance. The experimental results show the effectiveness of our approach, in both recommending more accurate APIs and enhancing automatic code completion.
Paper Type: Long
Research Area: NLP Applications
Research Area Keywords: code generation and understanding
Contribution Types: NLP engineering experiment, Approaches to low-resource settings
Languages Studied: English,Programming language
Submission Number: 5675
Loading