Abstract
Knowledge Base Question Answering (KBQA) systems often struggle to generalize to unseen entities and complex compositional queries. This paper introduces SG-KBQA, a framework designed to bridge the generalization gap by leveraging the underlying schema of Knowledge Bases (KBs). By integrating structural rules—specifically domain and range constraints—into the logical form generation process of a Large Language Model (LLM), SG-KBQA achieves state-of-the-art performance on challenging benchmarks like GrailQA, particularly in zero-shot and compositional scenarios.
Introduction
Knowledge Base Question Answering (KBQA) involves translating natural language questions into executable structured queries, such as SPARQL, to retrieve precise answers from large-scale databases like Freebase. While existing models perform well on data similar to their training sets, they frequently encounter an "Achilles' heel": generalization. Real-world KBs contain millions of entities and thousands of relations, making it impossible for a model to see every possible combination during training.
Current systems fail primarily in two areas: zero-shot scenarios, where questions involve relations or entities never encountered before, and compositional scenarios, where known elements are combined in novel ways. Without a deep understanding of the database's logic, models often "hallucinate" invalid queries, such as attempting to link a "book series" entity to a relation that requires a specific "book" entity. SG-KBQA addresses these issues by treating the KB schema as a logical map to guide the generation process.
The SG-KBQA Framework
SG-KBQA moves away from simple pattern matching toward schema-aware reasoning. The framework utilizes a modular pipeline consisting of three primary stages:
1. Relation Retrieval
The process begins by identifying a set of candidate relations from the KB that are semantically relevant to the user's question. This is achieved using a BERT-based retriever, which narrows the search space from thousands of potential relations to a manageable subset.
2. Schema-Guided Entity Retrieval (SER)
To handle entities the model may not have seen during training, SG-KBQA employs a "sketch parser." Instead of performing standard entity linking immediately, the model generates a template (or sketch) of the logical form where relations are masked. This helps the system precisely identify where entity mentions begin and end within a sentence, reducing the risk of confusing a new relation name with an entity name.
3. Schema-Guided Logical Form Generation (SLFG)
This stage is the core innovation of the framework. The system fine-tunes an LLM (specifically LLaMA-3.1-8B) to generate the final SPARQL query. Crucially, the LLM is provided with schema contexts: the domain and range classes for every candidate relation. For example, if the relation is written_by, the schema specifies that the domain must be a Work and the range must be an Author. By deferring the final entity selection to this stage, the LLM can use these logical guardrails to filter out candidates that do not fit the structural requirements of the database.
Experimental Evaluation
The researchers evaluated SG-KBQA on three major benchmarks designed to test different aspects of KBQA performance:
- GrailQA: A benchmark specifically designed to test generalization, featuring over 64,000 questions that include zero-shot and compositional logic.
- WebQuestionsSP (WebQSP): A standard dataset based on real-world Google search queries.
- ComplexWebQuestions (CWQ): A dataset requiring multi-hop reasoning to answer questions that link multiple facts.
Key Results
SG-KBQA achieved state-of-the-art (SOTA) results, most notably on the GrailQA leaderboard, where it outperformed previous models by 3.3% in overall F1 score. The improvements were most significant in generalization categories:
- Zero-Shot Generalization: A 2.9% improvement on entirely unseen elements.
- Compositional Generalization: A 4.0% improvement in combining known elements in new ways.
Despite the use of a large language model, the system remains computationally competitive, with an average processing time of 13.6 seconds per query.
Discussion and Insights
The success of SG-KBQA highlights that LLMs do not necessarily need to memorize every fact in a database to reason about them; they simply need to understand the "rules of the map." By providing domain and range constraints, the framework prevents the generation of unexecutable queries. Furthermore, the "late disambiguation" strategy—keeping multiple entity candidates alive until the final generation stage—allows the LLM to use the full context of the query to make more accurate choices.
Limitations and Future Work
While SG-KBQA represents a significant step forward, it faces certain limitations. The system is highly dependent on the initial relation retrieval step; if the retriever fails to identify the correct relation (accounting for 35% of current errors), the subsequent stages cannot recover. Additionally, the model still struggles with ambiguity when two different entities share the same name and schema class.
Future research will focus on improving the initial retrieval phase, exploring the use of LLMs to generate synthetic training data to reduce reliance on human annotations, and testing the framework on larger, noisier Knowledge Bases.
Summary updated