Abstract
Semantic parsing is essential for natural language interfaces to structured data, yet Knowledge Base Question Answering (KBQA) and Text-to-SQL are typically treated as distinct tasks. Existing "rank-then-generate" methods often struggle with exponential candidate growth as query complexity increases. This paper introduces Uni-Parser, a unified framework that shifts the focus from ranking complex logical forms to ranking atomic "primitives." By reducing the search space to a linear scale, Uni-Parser achieves superior efficiency and generalization. Evaluations on benchmarks like GrailQA and Spider demonstrate state-of-the-art performance and significant speedups.
Introduction
The goal of semantic parsing is to translate natural language questions into executable queries, such as SQL for databases (DB) or S-expressions for knowledge bases (KB). Historically, these two domains have been siloed. Furthermore, many high-performing models rely on enumerating thousands of potential query candidates and ranking them. This approach is computationally expensive and scales poorly; as questions require more reasoning steps, the number of candidate queries grows exponentially. This complexity hinders real-time performance and the ability to generalize to unseen schemas.
The Uni-Parser Framework
Uni-Parser addresses these challenges by decomposing the parsing process into three efficient stages: Primitive Enumeration, Contrastive Primitive Ranking, and Compositional Generation.
1. Primitive Enumeration
Instead of generating full queries, Uni-Parser identifies "primitives"—the fundamental components of a query. In a KB context, these are entities and relations. In a DB context, they include table names, column names, and cell values. This shift ensures that the number of candidates grows linearly ($N+M$) rather than exponentially.
2. Contrastive Primitive Ranker
A BERT-based cross-encoder ranks these primitives by their relevance to the input question. To improve precision, the model is trained using "hard negative sampling," where it must distinguish between the correct primitive and similar but incorrect alternatives.
3. Compositional Generator
A T5-based model takes the question and the top-ranked primitives as input to assemble the final logical form. To prevent the generator from over-relying on the ranker's order, the primitives are shuffled during training, forcing the model to perform true semantic grounding.
Key Results and Insights
Uni-Parser demonstrates that graph-based KBs and tabular DBs can be treated under a single "primitive + operation" framework. This unification allows for better generalization, particularly in zero-shot settings where the model encounters entirely new database schemas.
In terms of efficiency, Uni-Parser is significantly faster than previous methods. On the GrailQA benchmark, it averaged 19.4 seconds per question, a substantial improvement over RnG-KBQA (53.5s) and BERT+Ranking methods (76.3s). Performance-wise, it achieved a new state-of-the-art on WikiSQL (86.9% EM) and outperformed other T5-based models on the complex Spider dataset by approximately 3%.
Conclusion
Uni-Parser provides a scalable and unified solution for semantic parsing across different data modalities. By focusing on primitives, it overcomes the exponential complexity of traditional ranking methods. Future work includes developing a single model capable of handling multiple datasets simultaneously and automatically detecting whether a question should be directed to a KB or a DB in open-domain scenarios.
Summary updated