SeqZero: Few-shot Compositional Semantic Parsing with Sequential Prompts and Zero-shot Models

Jingfeng Yang, Haoming Jiang, Qingyu Yin, Danqing Zhang, Bing Yin, Diyi Yang · DOI

Abstract

Semantic parsing—the translation of natural language into formal representations like SQL—remains a significant challenge in low-resource settings. In few-shot scenarios, models often suffer from spurious biases and a failure to generalize compositionally. We present SeqZero, a framework that decomposes complex parsing tasks into a sequence of simpler sub-problems using natural language prompts. By ensembling a fine-tuned few-shot model with a rescaled zero-shot model, SeqZero leverages the specific task knowledge of the former and the unbiased linguistic priors of the latter. Our results on GeoQuery and a new EcommerceQuery dataset demonstrate that SeqZero achieves state-of-the-art performance, particularly in overcoming common overfitting patterns.

1. Introduction

The ability to interface with databases using natural language is a cornerstone of modern AI. However, the development of semantic parsers typically requires extensive expert-annotated datasets. In "few-shot" scenarios, where only a handful of examples are available, even powerful Large Language Models (LLMs) encounter two primary obstacles:

  1. Spurious Biases: Models often learn accidental correlations in the training data. For example, if a small training set primarily queries a "city" table, the model may default to that table even when the natural language clearly refers to a "state."
  2. Compositional Generalization: Models struggle to combine known elements in novel ways. While a model might understand individual filters for price or location, it may fail to synthesize them into a single, complex query it hasn't seen before.

SeqZero addresses these issues by moving away from monolithic, one-shot generation toward a decomposed, sequential prompting strategy.

2. The SeqZero Framework

SeqZero is built upon two fundamental pillars: sequential decomposition and a hybrid ensemble of few-shot and zero-shot models.

2.1 Sequential Prompting and Decomposition

Rather than generating an entire SQL statement in a single pass, SeqZero breaks the task into distinct sub-clauses (e.g., FROM, SELECT, WHERE). This decomposition is facilitated by natural language "slot-filling" prompts. For instance, to identify the relevant table, the framework might utilize a prompt such as: "the sentence talks about [slot]." By focusing the model on one specific component of the query at a time, SeqZero reduces the likelihood of the model drifting off-track or hallucinating complex, incorrect syntax.

2.2 The Few-Shot + Zero-Shot Ensemble

A core innovation of SeqZero is the combination of two distinct models:

  • Few-shot Model: A BART model fine-tuned on the limited available task-specific data.
  • Zero-shot Model: A raw, pre-trained BART model that retains general linguistic knowledge without task-specific fine-tuning.

To ensure these models work in harmony, SeqZero employs Constrained Rescaling. Typically, a fine-tuned model exhibits high confidence (probability mass) on its predictions, while a zero-shot model’s probability is spread across a vast vocabulary. A simple average would allow the biased few-shot model to dominate. SeqZero restricts the zero-shot model to a "constrained vocabulary" of valid SQL keywords and schema elements, then rescales its probabilities. This allows the zero-shot model to act as a "sanity check," anchoring the ensemble with unbiased knowledge.

3. Experimental Setup

The researchers evaluated SeqZero on two primary benchmarks:

  • GeoQuery: A standard dataset involving US geography. The authors utilized a specific "compositional split" designed to test the model's ability to handle unseen structural patterns.
  • EcommerceQuery: A new dataset introduced in this work, consisting of real-world user queries from an e-commerce platform. This dataset focuses on practical attributes such as price ranges, delivery specifications, and product categories.

To further improve reliability, the framework utilizes a trie (prefix tree) to ensure the model only predicts tokens that are valid within the database schema, effectively eliminating syntax errors.

4. Results and Discussion

SeqZero demonstrated significant performance improvements over standard BART baselines across both datasets:

  • GeoQuery: The framework reached 74.7% accuracy, surpassing the direct fine-tuning baseline of 72.5%. Crucially, SeqZero corrected the "table name error"—the most frequent spurious bias error—in approximately 75% of the cases where the base model failed.
  • EcommerceQuery: SeqZero achieved 46.2% accuracy, a substantial increase from the 37.7% achieved by standard fine-tuned BART.
  • Data Efficiency: The framework proved robust in extreme low-data regimes. Even with only 50 training samples, SeqZero maintained a significant lead over traditional methods, highlighting its utility for rapid deployment in new domains.

5. Conclusion and Future Work

SeqZero demonstrates that the challenges of few-shot semantic parsing can be mitigated by decomposing the generation process and anchoring fine-tuned models with zero-shot priors. While the framework excels at identifying schema components (slots), it still faces difficulties with complex logic within WHERE clauses, such as specific product size filtering in the EcommerceQuery set. Future research will explore extending this sequential approach to other architectures like T5 and automating prompt design to reduce sensitivity to phrasing.

Summary updated

BibTeX
@misc{yang2022seqzero,
  author = {Jingfeng Yang and Haoming Jiang and Qingyu Yin and Danqing Zhang and Bing Yin and Diyi Yang},
  title = {{SeqZero: Few-shot Compositional Semantic Parsing with Sequential Prompts and Zero-shot Models}},
  year = {2022},
  eprint = {2205.07381},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.07381},
}
Figure