TL;DR
This paper introduces SoAy, a novel methodology that enables Large Language Models (LLMs) to effectively use academic APIs for information seeking. SoAy addresses the challenges of complex API coupling and inference efficiency by generating a "solution" (an API calling sequence) and then using it to guide code generation, significantly outperforming existing LLM API-usage methods.
What Problem Does This Paper Address?
Researchers frequently need to access academic information like paper metadata, author publication records, and scholarly connections. While academic information retrieval systems and mining platforms have improved access, they often lack the flexibility to handle complex user queries. Existing LLM approaches to using academic APIs struggle with two main issues:
- API Coupling: Academic APIs often have interdependent parameters and outputs. For example, to find a scholar's most cited paper, one must first find the scholar, then their papers, and then sort by citation count. Current methods often call APIs independently, failing to grasp these dependencies, leading to incorrect API invocations (e.g., needing a
person_idfrom one API to call another). - Efficiency: Some methods use step-by-step reasoning (like depth-first search) to handle couplings, but this can lead to multiple inference steps, making the process too slow for users accustomed to rapid search results. For instance, determining the most cited paper might require an LLM inference for each paper to get its citation count.
Methods
SoAy proposes a "solution-based, code-based reasoning" methodology. The core idea is to guide LLMs through a two-step process:
- Solution Generation: The LLM first generates a "solution," which is a pre-constructed API calling sequence (e.g.,
searchPerson -> getPersonPubs -> getPublication). This solution simplifies the LLM's understanding of complex API relationships. - Code Generation: Based on this solution, the LLM then generates executable Python code to invoke the APIs. This code-based reasoning enhances efficiency by allowing the LLM to generate the entire API calling code in a single inference process.
To facilitate this, the authors developed a data generation pipeline:
- Solution Library Construction: They build an API graph representing dependencies between AMiner APIs and derive valid, concise API calling sequences (solutions).
- Combination Formulation: They bind head API inputs, solutions, and tail API outputs to refine specific user intents.
- Query Generation: They use ChatGPT to create template questions and then instantiate them with real academic entities to form specific queries and their ground truth answers.
- Code Generation: They use ChatGPT again to generate Python code for each combination, ensuring correctness through execution and verification against ground truth.
This process results in a dataset called SoArBench, containing (Query, Solution, Code) triplets.
Datasets
- SoArBench: A newly introduced benchmark dataset consisting of 3,960 (Query, Solution, Code) triplets. It's derived from AMiner APIs and includes queries categorized by hop count (one-hop, two-hop, three-hop). A subset of this dataset is publicly available.
- AMiner Database: Used for generating queries and ground truth answers. The authors cloned AMiner's APIs at a specific point in time to create a static evaluation environment.
Key Insights and Ideas
- Solution as a Mediator: The "solution" acts as an intermediate representation, bridging the gap between a natural language query and executable code. This significantly simplifies the LLM's task of understanding complex API dependencies.
- Code Generation for Efficiency: Generating executable code directly, guided by the solution, allows for a single inference pass, drastically improving efficiency compared to multi-step reasoning approaches.
- Data-Driven Approach: The creation of SoArBench is crucial. By automatically generating a large dataset of (Query, Solution, Code) triplets, they enable effective LLM alignment through fine-tuning or in-context learning.
- Domain-Specific vs. General APIs: The paper highlights that LLMs trained on general APIs struggle with the intricate couplings found in specialized domains like academic information seeking. SoAy's solution-based approach is tailored for such domains.
Key Results
- Effectiveness (RQ1): SoAYGPT (using GPT-4) achieved the highest overall score (92.74%) on SoArBench, significantly outperforming baselines like GPT-DFSDT and ToolLLaMA. SoAYLLAMA also showed strong performance.
- Efficiency (RQ2): SoAYLLAMA demonstrated significantly lower response times (e.g., 1.12 seconds for Code-7B) compared to baselines like ToolLLaMA (45.10 seconds for 7B) and GPT-DFSDT. Even SoAYGPT with GPT-4 was about one-third the execution time of GPT-DFSDT with GPT-4.
- Usability/Deployment (RQ3): In a real-world deployment evaluation with 52 user queries, SoAy's responses were preferred by human annotators over direct GPT-4 responses, especially for questions with exact answers.
Limitations and Future Work
- Ambiguous Queries: SoAy's performance was less pronounced for ambiguous questions in the deployment evaluation, suggesting a need to integrate API calls with model-intrinsic functions for more robust handling of such queries.
- Domain Specificity: While SoAy is designed for academic APIs, its effectiveness relies on the quality and structure of the API library and the generated solutions.
- Future Work: The authors plan to enlarge SoArBench, enrich queries based on real-world application logs, and apply SoAy to more scenarios and domains. They also suggest exploring the integration of API calls with model-intrinsic functions.
Summary updated