TL;DR
Researchers have developed KAHAID, a dialogue-based agent that helps developers clarify vague API queries through multi-round Q&A. By leveraging a custom-built Knowledge Graph of API behaviors, it doesn't just find the "best" result—it explains why an API fits and suggests related tools the developer might not have known they needed.
What Problem Does This Paper Address?
Most API search tools (like BIKER or CLEAR) treat the process as a one-shot game: you provide a query, and the tool returns a ranked list based on keyword or embedding similarity. However, real-world developer queries are often "under-specified" or "uncertain." For example, a developer asking "how to get the current working directory" might actually need a File path, a Path object, or a URI, each with different trade-offs.
Existing tools struggle with:
- Intent Ambiguity: They can't ask clarifying questions to narrow down what the user actually wants.
- Lack of Context: They treat APIs as independent entities, ignoring functional relationships (e.g., "this API is an alternative to that one").
- The "Black Box" Problem: They rarely explain why a specific API was recommended, making it hard for developers to trust the result.
Methods
The authors propose KAHAID (Knowledge-Aware Human-AI Dialogue), which operates in three main stages:
- Knowledge Graph (KG) Construction: The team parsed the Java SDK documentation to build a "Behavior KG." This graph maps APIs to specific Actions (e.g., "convert"), Objects ("path string"), and Constraints ("absolute"). It also captures "inter-relations" like Function Similarity, Collaboration, and Behavior Difference.
- Information-Gain Dialogue: When a user submits a vague query, KAHAID doesn't just guess. It uses an ID3 decision tree algorithm over the KG to identify which "aspect" (action, object, or constraint) would most efficiently narrow down the search. It then generates a clarification question (e.g., "What kind of path string do you want? A. absolute, B. canonical").
- Explainable Recommendation: Once the intent is clarified, KAHAID provides the target API along with "Extended Suggestions." Crucially, it provides a natural language explanation by highlighting keywords from the documentation that matched the user’s clarified intent.
Datasets
The authors evaluated KAHAID using three distinct datasets:
- BIKER Test Dataset: 413 manually verified Stack Overflow (SO) queries with single ground-truth APIs.
- Random Test Dataset: 1,000 randomly selected SO posts to minimize selection bias.
- Multi-API SO Dataset (New): A manually curated set of 60 queries paired with 298 ground-truth APIs (including the "best" API and several related/extended APIs) to test the system's ability to discover broader knowledge.
Key Insights and Ideas
- Dialogue as Discovery: The most striking insight is that dialogue isn't just a hurdle to get to the answer; it's an educational tool. By presenting options like "return filesystem" vs. "return codesource," the agent prompts developers to think about architectural choices they might have overlooked.
- Breaking the Similarity Trap: Traditional search relies on the query being similar to the documentation. KAHAID uses the KG to find "cooperative" APIs that might have totally different descriptions but are functionally linked (e.g., one API produces the input that another API requires).
- Efficiency via Information Gain: By using ID3 to pick questions, the system minimizes "dialogue fatigue." On average, it takes fewer than three rounds to find the correct API.
Key Results
KAHAID significantly outperformed state-of-the-art baselines in both search accuracy and knowledge expansion:
- Search Accuracy: In API recommendation, KAHAID achieved an MRR of 0.769, outperforming BIKER and CLEAR by at least 47%.
- Knowledge Extension: When tasked with finding related/alternative APIs, it surpassed the conversational baseline (ZaCQ) by 42% in MRR and 45.2% in MAP.
- User Study: A study with 12 developers showed that KAHAID improved the "Inspiration" score of clarification options by 20.83% and the "Extensibility" of results by 12.5% compared to existing tools. Developers reported feeling more confident in their final choice because of the provided explanations.
Limitations and Future Work
- Language Specificity: Currently, the system is implemented only for the Java SDK. Expanding this to Python, Go, or Ruby would require re-parsing those specific documentations into the KG format.
- NLP Fragility: The system relies on AllenNLP for parsing documentation. The authors noted that "incomplete sentences" in docs (e.g., starting with a verb) can sometimes confuse the parser, requiring custom heuristic rules to fix.
- LLM Integration: The authors suggest that while KAHAID uses a structured KG, future versions could "teach" Large Language Models (LLMs) to use this KG-dialogue approach to make AI-generated code more grounded and less prone to "hallucinating" non-existent APIs.
Summary updated