Compositional Generalization and Natural Language Variation: Can a Semantic Parsing Approach Handle Both?

Peter Shaw, Ming-Wei Chang, Panupong Pasupat, Kristina Toutanova

TL;DR

This paper tackles the challenge of building semantic parsers that can both handle the natural variations in human language and generalize to novel combinations of known concepts (compositional generalization). They introduce new, more realistic evaluation benchmarks and propose NQG-T5, a hybrid model that combines a grammar-based approach with a powerful pre-trained language model, achieving state-of-the-art results on these challenging tasks.

What Problem Does This Paper Address?

Semantic parsing aims to convert natural language into structured meaning representations (like logical forms or SQL queries). While sequence-to-sequence (seq2seq) models excel at handling the diverse ways humans express themselves (natural language variation), they often falter when faced with compositional generalization. This means they struggle to understand novel combinations of words or phrases they've seen separately during training. For instance, a model might understand "jump" and "twice" individually but fail to correctly interpret "jump twice" if it hasn't seen this specific combination.

Existing research often evaluates these capabilities separately: either on synthetic datasets designed to test compositional generalization or on real-world datasets that focus on natural language variation. This paper argues that a truly robust semantic parser needs to excel at both. The challenge lies in developing models that can generalize to new combinations while still handling the messiness of human language, and in creating evaluation methods that accurately reflect this dual requirement.

Methods

The authors propose a novel hybrid approach called NQG-T5. It combines two key components:

  1. NQG (Neural Grammar-based Output): This component is a grammar-based semantic parser. It uses a quasi-synchronous context-free grammar (QCFG) induction algorithm to learn a grammar from data. This grammar is then used by a discriminative neural parsing model. The strength of NQG lies in its potential for higher precision, especially for out-of-distribution examples, due to its structured, grammar-driven nature. However, NQG can sometimes fail to produce an output if the input doesn't fit its learned grammar.
  2. T5: This is a powerful, pre-trained general-purpose sequence-to-sequence model. T5 is known for its strong performance on a wide range of natural language tasks, including handling in-distribution variation.

The NQG-T5 model works by first attempting to parse the input with NQG. If NQG successfully produces an output, it's returned. If NQG fails (i.e., cannot find a valid derivation within its grammar), the input is passed to T5, and T5's output is returned. This "fallback" mechanism leverages T5's broad coverage while benefiting from NQG's potential precision.

The paper also introduces Target Maximum Compound Divergence (TMCD) splits for existing datasets. These splits are designed to create challenging evaluations of compositional generalization on non-synthetic data by maximizing the divergence of compound distributions between training and test sets, while ensuring atoms (basic units) are still present.

Datasets

The paper evaluates its approach on several datasets and splits:

  • SCAN: A synthetic dataset widely used for evaluating compositional generalization.
  • GEOQUERY: A non-synthetic dataset for text-to-SQL that includes natural language variation.
  • SPIDER-SSP: A subset of the SPIDER dataset, adapted for evaluating compositional generalization on text-to-SQL.

The authors introduce TMCD splits for GEOQUERY and SPIDER-SSP, which are designed to be more challenging for compositional generalization than standard splits. They also utilize template splits for GEOQUERY and SPIDER-SSP.

Key Insights and Ideas

  • Compositional generalization and natural language variation are distinct but equally important challenges. Performance on synthetic compositional generalization benchmarks (like SCAN) doesn't reliably predict performance on real-world, varied language.
  • Hybrid models can be powerful. Combining a structured, grammar-based approach (NQG) with a flexible, pre-trained seq2seq model (T5) offers a promising path to address both challenges simultaneously. NQG provides precision, while T5 provides coverage.
  • Existing evaluations are insufficient. Standard benchmarks often focus on only one aspect (compositionality or variation). New, more challenging splits like TMCD are needed for a comprehensive evaluation.
  • Pre-trained models alone aren't a silver bullet for compositional generalization. While T5 performs well on many tasks, it still struggles with out-of-distribution compositional generalization, highlighting the need for more structured approaches.

Key Results

  • NQG-T5 significantly outperforms existing approaches on a diverse set of evaluations, achieving an average rank of 1.0 across 8 evaluations compared to 2.9 for T5.
  • NQG-T5 achieves state-of-the-art accuracy on the standard split of GEOQUERY.
  • Performance on SCAN is not well-correlated with performance on non-synthetic tasks. This underscores the need for diverse evaluation strategies.
  • NQG-T5 is competitive with state-of-the-art models on SPIDER-SSP, demonstrating its ability to handle complex, non-synthetic data, even when its grammar component is less effective (as in text-to-SQL).
  • T5 exhibits predictable error patterns on length splits, often producing outputs that are not significantly longer than training examples, leading to poor performance.

Limitations and Future Work

  • NQG's grammar induction is limited. The QCFG formalism and greedy search algorithm can lead to sub-optimal grammars, and QCFGs cannot directly represent certain logical relations (e.g., commutativity). Future work could explore more flexible grammar formalisms and induction techniques.
  • NQG's coverage can be low. When NQG fails to produce an output, the system relies on T5, which may not always be optimal.
  • The text-to-SQL domain is challenging for NQG's grammar. The complex syntax of SQL makes it difficult for the current grammar induction method to capture effectively.
  • Computational cost: While NQG-T5 offers relative savings by using pre-trained T5, fine-tuning large T5 models is still computationally expensive.
  • Future work should focus on developing more robust grammar induction methods, exploring alternative formalisms, and further improving the hybrid NQG-T5 architecture to better handle out-of-distribution examples where NQG currently lacks coverage. The authors also suggest exploring different choices for constructing template and TMCD splits.

Summary updated

BibTeX
@inproceedings{shaw2021compositional,
  author = {Peter Shaw and Ming-Wei Chang and Panupong Pasupat and Kristina Toutanova},
  title = {{Compositional Generalization and Natural Language Variation: Can a Semantic Parsing Approach Handle Both?}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  url = {https://openreview.net/forum?id=DGXeg6BOqh},
}
Figure