Learning an Executable Neural Semantic Parser

Jianpeng Cheng, Siva Reddy, Vijay A. Saraswat, Mirella Lapata

Abstract

This paper introduces a Transition-based Neural Semantic Parser (TNSP) designed to map natural language into executable, tree-structured logical forms. By integrating recurrent neural networks with a formal transition system and exploring various attention mechanisms, the authors demonstrate a robust framework that performs well across full, weak, and distant supervision settings. The model effectively addresses the limitations of sequence-to-sequence models by enforcing structural constraints during generation.

Introduction

Semantic parsing—the task of translating human language into machine-executable code like SQL or FunQL—is a cornerstone of natural language interfaces. Historically, this required heavy feature engineering and domain-specific grammars. While recent neural sequence-to-sequence (seq2seq) models have simplified the process, they often treat logical forms as flat strings. This "flat" approach ignores the inherent hierarchical structure of logic, frequently resulting in syntactically invalid outputs. Furthermore, mapping natural language words to specific database predicates (the "lexicon" problem) remains difficult when explicit mapping rules are unavailable.

The Transition-based Neural Semantic Parser (TNSP)

The authors propose a Transition-based Neural Semantic Parser (TNSP). Instead of generating a string, the model generates a sequence of actions that incrementally build a tree. This approach ensures that every generated logical form is syntactically valid and executable by design.

Key Technical Components

  • Transition System: The model supports both top-down (pre-order) and bottom-up (post-order) tree generation. It uses structural constraints to guide the generation process, as illustrated in the transition rules below.
  • Stack-LSTM: To maintain the generation history, the model utilizes a Stack-LSTM. This architecture allows the model to "remember" the state of the partially completed tree, providing a rich context for predicting the next action.
Top-down and Bottom-up transition rules used by the TNSP to build executable logical forms.

Neural Lexicon and Attention

To handle the mismatch between words and database predicates without a manual lexicon, the authors explore four attention variants:

  1. Soft Attention: The standard approach, attending to the whole sentence.
  2. Structured Soft Attention: Uses a Conditional Random Field (CRF) to encourage the model to attend to contiguous phrases.
  3. Hard Attention: Samples a single token from the input.
  4. Binomial Hard Attention: Samples a set of tokens (a phrase) to trigger a predicate.

Training Regimes

The paper evaluates the model under three distinct supervision levels:

  1. Full Supervision: Utterances are paired with gold-standard logical forms (e.g., GEOQUERY).
  2. Weak Supervision: Utterances are paired only with the final answer (denotation). The model must search for a logical form that yields that answer (e.g., WEBQUESTIONS).
  3. Distant Supervision: Only unlabeled sentences and a Knowledge Base (KB) are provided; the model creates its own training data by masking entities in declarative sentences (e.g., SPADES).

Experimental Results and Insights

The model was evaluated on four diverse benchmarks, showing competitive performance across the board:

  • GEOQUERY: Achieved 87.1% accuracy, matching high-performing symbolic systems.
  • WEBQUESTIONS: Reached an F1 of 50.1, significantly better than the seq2seq baseline of 48.3.
  • SPADES: Achieved an F1 of 32.4, outperforming previous CCG-based parsers.

Key Insights

  • Structure as a Constraint: By using a transition system with a small set of grammar rules, the model cannot produce a syntax error, a major advantage over vanilla seq2seq models.
  • Top-Down vs. Bottom-Up: Top-down generation generally provides a slight edge, likely because "parent" information (the context of the subtree) is more useful for prediction than "sibling" information.
  • Distant Supervision Efficacy: Training on "artificial" data (masking entities in sentences) can improve performance on real-world question-answering tasks, acting as a form of data augmentation.

Limitations and Future Work

Despite its strengths, the model faces challenges with spuriousness in weak supervision, where it may find logical forms that return the correct answer for the wrong reason. Additionally, there is a domain mismatch between the declarative sentences used in distant supervision and the interrogative queries users actually ask. Future work may explore self-attention mechanisms to handle long-range dependencies and multi-domain parsers where tree-generation logic is shared across different databases.

Summary updated

BibTeX
@article{cheng2019learning,
  author = {Jianpeng Cheng and Siva Reddy and Vijay A. Saraswat and Mirella Lapata},
  title = {{Learning an Executable Neural Semantic Parser}},
  journal = {Comput. Linguistics},
  year = {2019},
  doi = {10.1162/coli\_a\_00342},
}
Figure