Enhancing API Recommendations with Attention Fusion and Human Feedback
摘要
Selecting the right APIs from a vast array is challenging for developers. Traditional methods, relying on natural language queries and SO(Stack Overflow) discussions, often struggle with query ambiguity and a wide array of potential APIs, impacting the accuracy of API selection and ranking. Large language models(LLMs) like GPT-4 and Gemini-1.5pro, though advanced in understanding and generating code, also face issues with semantic ambiguity in user queries, leading to hallucinations. To address these issues, we propose EARTH, an enhanced API recommendation system utilizing Attention Fusion and Human Feedback. First, EARTH leverages textual data analysis with a pre-trained model and integrates human feedback from Stack Overflow. By employing BERT embeddings and using Stack Overflow’s upvote metrics for training, EARTH significantly improves API recommendation precision, addressing query ambiguity and the abundance of API options. Second, EARTH introduces an advanced re-ranking model with attention fusion. This new model employs cross-attention mechanisms to capture the semantic relationships between natural language descriptions and API documentation. Comparative experiments with various methods across multiple datasets demonstrate our model’s superiority, boosting Mean Average Precision (MAP) by 5.7% at the method level and 3.3% at the class level, affirming its efficiency and impact in API recommendation endeavors.