KQA Pro: A Dataset with Explicit Compositional Programs for Complex Question Answering over Knowledge Base

Shulin Cao, Jiaxin Shi, Liangming Pan, Lunyiu Nie, Yutong Xiang, Lei Hou, Juanzi Li, Bin He, Hanwang Zhang

Abstract

Answering complex questions over a Knowledge Base (KB) requires multi-step reasoning, attribute comparisons, and set operations. Traditional datasets often lack intermediate supervision, making it difficult to diagnose model failures or teach compositional reasoning. We present KQA Pro, a massive dataset of 117,970 diverse natural language questions. Its core innovation is KoPL (Knowledge-oriented Programming Language), a symbolic language that provides explicit, step-by-step reasoning paths. By providing both SPARQL and KoPL programs for every question, KQA Pro enables the development of more interpretable and robust KBQA systems.

Introduction

While simple KBQA (e.g., "Where was LeBron James born?") is largely considered a solved problem, Complex KBQA remains a significant hurdle. Complex queries involve multi-hop inference, numerical comparisons, and temporal reasoning. Existing benchmarks suffer from two main issues: a lack of intermediate supervision (providing only Question-Answer pairs) and limited scale or linguistic variety due to reliance on rigid templates. KQA Pro addresses these gaps by providing a large-scale, human-paraphrased dataset with full symbolic program supervision.

Methodology

KoPL: A Symbolic Reasoning Language

To move beyond the "black box" nature of standard QA, the researchers introduced KoPL. Unlike SPARQL, which can be opaque, KoPL is designed to be compositional and interpretable. Each program is a tree of symbolic functions—such as Find, Relate, and FilterNum—that directly mimic human reasoning steps. This structure allows models to learn a "recipe" for the answer, making the learning process more efficient and diagnosable.

Examples of KoPL programs and SPARQL queries for complex questions.

The "Synthesize-then-Paraphrase" Pipeline

Generating a large, natural dataset requires balancing scale with linguistic variety. KQA Pro utilizes a two-step generation process:

  1. Locating & Asking: Templates generate "canonical" questions and their corresponding KoPL/SPARQL programs based on KB subgraphs.
  2. Crowdsourced Paraphrasing: These robotic-sounding canonical questions are rewritten by human workers on Amazon Mechanical Turk to ensure naturalness and diversity. Quality is maintained through edit-distance filters and human verification.
The KQA Pro data generation pipeline.

The KQA Pro Dataset

The final dataset contains 117,970 instances based on a dense subset of Wikidata, featuring over 16,000 entities and 794 concepts. Each entry includes a natural language question, a canonical template question, a KoPL program, a SPARQL query, and multiple-choice options. The dataset is highly complex, with 73.7% of questions requiring multiple reasoning hops.

Results and Key Insights

Benchmarking various models, including IR-based methods and sequence-to-sequence parsers, revealed several critical findings:

  • Intermediate Supervision is Essential: Semantic parsers (like BART) that predict KoPL programs significantly outperform IR-based models (like KVMemNet or EmbedKGQA) that learn only from QA pairs. The BART-based parser achieved an impressive 90.55% accuracy.
  • The "Literal" Bottleneck: Current state-of-the-art models struggle significantly with "literal" knowledge, such as comparing heights, weights, or dates.
  • Generalization Challenges: Accuracy drops significantly when models are tested on programs longer than those seen during training (from 90.55% to 77.86%), indicating a "productivity gap" in compositional generalization.

Conclusion

KQA Pro provides a new frontier for Complex KBQA by offering explicit reasoning paths through KoPL. While semantic parsing shows great promise, the dataset highlights ongoing challenges in literal reasoning and zero-shot generalization. Future work will likely focus on improving numerical and temporal reasoning and leveraging the human-readable nature of KoPL for interactive model training and error correction.

Summary updated

BibTeX
@inproceedings{cao2022kqa,
  author = {Shulin Cao and Jiaxin Shi and Liangming Pan and Lunyiu Nie and Yutong Xiang and Lei Hou and Juanzi Li and Bin He and Hanwang Zhang},
  title = {{KQA Pro: A Dataset with Explicit Compositional Programs for Complex Question Answering over Knowledge Base}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.422},
}
Figure