Querying NoSQL with Deep Learning to Answer Natural Language Questions

Sebastian Blank, Florian Wilhelm, Hans-Peter Zorn, Achim RettingerAAAI 2019 · DOI

Abstract

This paper introduces SeqPolicyNet, an end-to-end trainable system designed to bridge the gap between natural language and NoSQL databases. Unlike traditional Knowledge Base Question Answering (KBQA) systems that require expensive, manually-labeled query data, SeqPolicyNet translates questions into executable Elasticsearch queries using reinforcement learning (REINFORCE) with a custom exploration bonus. By learning directly from question-answer pairs, the system achieves 84.2% accuracy on the bAbI Movie Dialog dataset, demonstrating the effectiveness of "Hard-KB" lookups without intermediate supervision.

Introduction

Most structured knowledge is stored in databases accessible only via domain-specific languages like SQL or NoSQL. For non-technical users, KBQA systems provide a vital interface. Existing approaches generally fall into two categories: Soft-KB lookups, which ingest data into a neural network's memory (limiting scalability and security), and Hard-KB lookups, which generate actual queries. However, training Hard-KB systems typically requires "intermediate labels"—human-written queries for every training instance—which is prohibitively expensive. This research proposes a Hard-KB system that is end-to-end trainable, learning to write queries based solely on the final answer.

Methodology

The proposed system, SeqPolicyNet, utilizes a sequence-to-sequence architecture enhanced with a Pointer Network. This allows the model to either select column names from a database schema or extract specific text spans (e.g., movie titles) directly from the user's question.

Architecture of SeqPolicyNet showing the flow from natural language question to executable query and KB lookup.

Query Generation and Reinforcement Learning

To simplify query generation, the model fills slots in a predefined Elasticsearch (ES) template, identifying the "Query Field," "Query Condition," and "Response Field." Because database execution is a discrete, non-differentiable step, the authors employ the REINFORCE algorithm. The model receives rewards based on query outcomes:

  • -2 for malformed queries.
  • -1 for valid queries returning incorrect answers.
  • +z for correct answers.

A critical finding was that a high success reward ($z=25$) was necessary to overcome sparse feedback. Additionally, a count-based Exploration Bonus ($R^+$) was implemented to prevent the model from converging on "safe" but incorrect strategies, such as always selecting the most common column name.

Experimental Results

The model was evaluated on the bAbI Movie Dialog dataset, containing metadata for over 17,000 movies and 96,000 training question-answer pairs.

Performance comparison of SeqPolicyNet against baseline methods on the bAbI Movie Dialog dataset.

SeqPolicyNet achieved a competitive 84.2% accuracy and a 91.3% valid query rate. As shown in the results table, it significantly outperformed standard LSTMs and supervised embeddings. Notably, it also surpassed an ensemble of Memory Networks (MemNN), which represent the state-of-the-art in "Soft-KB" approaches, while maintaining the security and scalability advantages of a production database.

Discussion and Conclusion

While SeqPolicyNet demonstrates strong performance, it faces challenges regarding sample efficiency; accuracy drops significantly when training data is limited. Furthermore, the system currently struggles with ambiguity (e.g., multiple movies with the same title) and relies on fixed query templates.

In conclusion, SeqPolicyNet proves that Hard-KB systems can be trained effectively using reinforcement learning without query-level supervision. This approach offers a scalable and secure path forward for natural language interfaces to large-scale NoSQL databases.

Summary updated

BibTeX
@inproceedings{blank2019querying,
  author = {Sebastian Blank and Florian Wilhelm and Hans-Peter Zorn and Achim Rettinger},
  title = {{Querying NoSQL with Deep Learning to Answer Natural Language Questions}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.1609/aaai.v33i01.33019416},
}
Figure