SPINACH: SPARQL-Based Information Navigation for Challenging Real-World Questions

Shicheng Liu, Sina J. Semnani, Harold Triedman, Jialiang Xu, Isaac Dan Zhao, Monica S. Lam

Abstract

Large Language Models (LLMs) have led to significant improvements in the Knowledge Base Question Answering (KBQA) task. However, datasets used in KBQA studies do not capture the true complexity of KBQA tasks. They either have simple questions, use synthetically generated logical forms, or are based on small knowledge base (KB) schemas. We introduce the SPINACH dataset, an expert-annotated KBQA dataset collected from discussions on Wikidata’s “Request a Query” forum with 320 decontextualized question-SPARQL pairs. The complexity of these in-the-wild queries calls for a KBQA system that can dynamically explore large and often incomplete schemas and reason about them, as it is infeasible to create a comprehensive training dataset. We also introduce an in-context learning KBQA agent, also called SPINACH, that mimics how a human expert would write SPARQLs to handle challenging questions. SPINACH achieves a new state of the art on the QALD-7, QALD-9 Plus and QALD-10 datasets by 31.0%, 27.0%, and 10.0% in F1, respectively, and coming within 1.6% of the fine-tuned LLaMA SOTA model on WikiWebQuestions. On our new SPINACH dataset, the SPINACH agent outperforms all baselines, including the best GPT-4-based KBQA agent, by at least 38.1% in F1.

Introduction

Knowledge Base Question Answering (KBQA) has seen rapid progress with the advent of Large Language Models (LLMs). However, a significant "simplicity gap" remains between academic benchmarks and real-world information needs. Most existing datasets rely on simple questions or synthetic logical forms that do not reflect the complexity of massive, evolving knowledge bases like Wikidata. With over 15 billion facts and an often inconsistent schema, Wikidata is too large for LLMs to memorize, making one-shot SPARQL generation unreliable for complex queries.

The SPINACH Dataset

To address this, we present the SPINACH dataset, a collection of 320 expert-annotated question-SPARQL pairs derived from Wikidata’s “Request a Query” forum. These queries represent organic, complex information needs from real users. Unlike synthetic datasets where patterns repeat, 100% of the queries in the SPINACH dataset are structurally unique, requiring a system that can navigate "anomalous structures" and incomplete schemas.

A real-world query request and refinement process from the Wikidata forum, illustrating the complexity of the SPINACH dataset.

The SPINACH Agent

We also introduce the SPINACH Agent, an LLM-augmented exploration agent that uses ReAct prompting to solve questions through iterative reasoning. Rather than attempting to generate a perfect query in one shot, the agent mimics a human expert by exploring the schema, checking property examples, and debugging queries based on execution feedback.

The agent utilizes five specialized tools:

  1. search_wikidata: Locates relevant entities (QIDs) and properties (PIDs).
  2. get_wikidata_entry: Retrieves outgoing edges for specific entities to understand local schema.
  3. get_property_examples: Provides context on how specific properties are used in practice.
  4. execute_sparql: Runs queries and returns results, syntax errors, or timeouts for iterative refinement.
  5. stop: Finalizes the answer.
The SPINACH agent navigating a complex query by iteratively searching Wikidata, debugging errors, and refining SPARQL code.

Results and Insights

The SPINACH agent demonstrates superior performance across multiple benchmarks, setting new state-of-the-art (SOTA) F1 scores on QALD-7 (+31.0%), QALD-9 Plus (+27.0%), and QALD-10 (+10.0%). On the challenging SPINACH dataset, the agent achieved an F1 score of 45.3%, while direct GPT-4o baselines struggled at approximately 4.0%.

A key finding is that LLM failure in KBQA is often due to a lack of schema knowledge rather than an inability to write SPARQL. By allowing the agent to look up property examples, it can distinguish between similar properties (e.g., "narrative location" vs. "filming location"). Ablation studies confirmed that search_wikidata is the most critical tool; finding the correct QIDs and PIDs remains the primary bottleneck in the pipeline.

Conclusion

SPINACH highlights the necessity of dynamic exploration for real-world KBQA. While the agent's multi-step approach involves higher cost and latency than one-shot models, its robustness on complex, unique queries proves the value of mimicking expert behavior. Future research will explore model distillation to transfer these exploration capabilities into smaller, more efficient models.

Summary updated

BibTeX
@inproceedings{liu2024spinach,
  author = {Shicheng Liu and Sina J. Semnani and Harold Triedman and Jialiang Xu and Isaac Dan Zhao and Monica S. Lam},
  title = {{SPINACH: SPARQL-Based Information Navigation for Challenging Real-World Questions}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  url = {https://openreview.net/forum?id=vndMuzGrcB},
}
Figure