Database reasoning over text

James Thorne, Majid Yazdani, Marzieh Saeidi, Fabrizio Silvestri, Sebastian Riedel, Alon Y. Halevy

Abstract

This paper introduces a modular architecture designed to treat unstructured text like a database, enabling complex queries—such as "How many female athletes were born in the 20th century?"—that require joining, filtering, and aggregating facts across multiple documents. By combining neural "reasoning" on small sets of facts with symbolic "computation" for math, the authors achieve 90% accuracy on complex queries and scale to databases containing thousands of facts where standard Transformer models fail.

Introduction

Traditional Question Answering (QA) models are highly effective at "needle in a haystack" tasks—extracting a single span of text to answer a specific question. However, they frequently struggle with "database-style" reasoning. When asked to count items, identify the maximum value in a list, or join disparate facts (e.g., "Who is the spouse of a doctor?"), standard neural models often collapse.

The core challenges in bridging the gap between natural language and database reasoning include:

  1. Scale: Transformers have limited context windows (typically 512 or 1024 tokens), making it impossible to process large corpora in a single pass.
  2. Aggregation: Neural networks struggle with precise arithmetic, such as counting or finding an ARGMAX across numerous results.
  3. Locality: While standard QA assumes the answer resides in a single paragraph, a "Natural Language Database" (NLDB) requires linking facts scattered across different documents.

Methodology: A Modular Pipeline

The authors propose a three-stage pipeline that leverages the strengths of both neural and symbolic systems.

The modular architecture of the proposed system, showing the flow from facts and queries through the Support Set Generator and Neural SPJ to final aggregation.
  1. Support Set Generator (SSG): An intelligent retriever that uses a bi-encoder and Maximum Inner Product Search (MIPS) to iteratively retrieve "support sets"—small groups of 1-2 facts that potentially contribute to an answer.
  2. Neural SPJ (Select-Project-Join) Operator: A sequence-to-sequence model (e.g., T5) that "projects" a query and a support set into a machine-readable intermediate format. For instance, for a query about "highest yearly attendance," the SPJ might output [ARGMAX] Museum of History [SEP] 93976.
  3. Symbolic Aggregation: Structured data from the SPJ is processed using conventional code to perform mathematical operations (counting, comparisons, or unions), ensuring 100% arithmetic accuracy.

The WIKINLDB Benchmark

To evaluate this approach, the authors introduced WIKINLDB. This benchmark converts structured Wikidata triples (e.g., [Sheryl, spouse, Nicholas]) into natural language sentences using the KELM model. It features databases ranging from 25 to 1,000 facts and includes four query types: Set (listing entities), Boolean (True/False), Aggregation (count, min, max), and Join (linking multiple facts).

Key Results and Scaling

The modular approach demonstrates significant advantages over monolithic Transformer baselines, particularly as the complexity and scale of the data increase.

Comparison of answer accuracy across different models as the number of support sets increases.
  • Superior Accuracy: On a 25-fact database, the architecture reached 90.1% accuracy, outperforming a vanilla T5 model (85.6%).
  • Robust Scaling: As the database grew to 1,000 facts, standard Transformer performance plummeted due to memory constraints and signal-to-noise issues. The modular approach maintained accuracy because its retrieval-based support sets remained focused.
  • Join Performance: The model proved exceptionally effective at "Join" queries, which typically baffle traditional retrieval systems, by iteratively fetching related facts.

Discussion and Future Work

The "aha moment" of this research is that Transformers should be used for perception (extracting numbers/entities) rather than math. However, the system's performance is currently capped by the retriever; retrieval errors drop overall accuracy from 90% (with perfect retrieval) to approximately 67%. Future work will focus on deeper joins (beyond 2 facts), handling conflicting or temporal facts, and improving retrieval robustness.

Summary updated

BibTeX
@inproceedings{thorne2021database,
  author = {James Thorne and Majid Yazdani and Marzieh Saeidi and Fabrizio Silvestri and Sebastian Riedel and Alon Y. Halevy},
  title = {{Database reasoning over text}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-long.241},
}
Figure