Abstract
Recent research showed promising results on combining pretrained language models (LMs) with canonical utterance for few-shot semantic parsing. The canonical utterance is often lengthy and complex due to the compositional structure of formal languages. Learning to generate such canonical utterance requires significant amount of data to reach high performance. Fine-tuning with only few-shot samples, the LMs can easily forget pretrained knowledge, overfit spurious biases, and suffer from compositionally out-of-distribution generalization errors. To tackle these issues, we propose a novel few-shot semantic parsing method – SEQZERO. SEQZERO decomposes the problem into a sequence of sub-problems, which corresponds to the sub-clauses of the formal language. Based on the decomposition, the LMs only need to generate short answers using prompts for predicting sub-clauses. Thus, SEQZERO avoids generating a long canonical utterance at once. Moreover, SEQZERO employs not only a few-shot model but also a zero-shot model to alleviate the overfitting. In particular, SEQZERO brings out the merits from both models via ensemble equipped with our proposed constrained rescaling. SEQZERO achieves SOTA performance of BART-based models on GeoQuery and EcommerceQuery, which are two few-shot datasets with compositional data split.
Introduction: The Challenge of Compositional Generalization
Semantic parsing—the process of converting natural language into formal code like SQL—is a cornerstone of modern human-computer interaction. However, achieving high performance in "few-shot" scenarios, where training data is extremely limited, remains a significant hurdle.
The primary obstacle is compositional out-of-distribution (OOD) generalization. When trained on small datasets, language models often become "lazy," overfitting to spurious biases rather than learning underlying logic. For instance, if a training set consistently associates population queries with a "city" table, the model may fail to generalize when asked for the population of a "state." Research indicates that such errors account for approximately 75% of prediction failures in standard baseline models. To address this, we introduce SEQZERO, a framework designed to leverage pretrained knowledge more effectively while resisting training-set biases.
The SEQZERO Framework
SEQZERO addresses the complexity of semantic parsing through two primary innovations: Sequential Prompt Decomposition and a Zero-Shot Ensemble mechanism.
1. Sequential Prompt Decomposition
Rather than forcing a model to generate a long, complex SQL query in a single pass, SEQZERO breaks the task down into sub-clauses (e.g., FROM, SELECT, WHERE). By using natural language "slots" as prompts—such as "the sentence talks about [SLOT]" for a FROM clause—the model performs simpler, shorter generation tasks. This allows the LM to better utilize its pre-existing linguistic knowledge.
2. Zero-Shot Ensemble with Constrained Rescaling
To mitigate spurious bias, SEQZERO ensembles a fine-tuned "few-shot" model with an untrained "zero-shot" pretrained LM. The zero-shot model acts as an unbiased anchor because it has not seen the biased training data.
A key challenge in ensembling is that zero-shot probability distributions are often too thin to influence a confident, fine-tuned model. SEQZERO solves this with constrained rescaling, which forces the zero-shot model to distribute its probability only over a valid vocabulary of SQL keywords and schema elements. This allows the zero-shot model to effectively "veto" biased mistakes made by the few-shot component.
Experimental Evaluation
We evaluated SEQZERO on two benchmark datasets: GeoQuery (US geography) and EcoQuery (a new e-commerce dataset designed for OOD challenges). Both utilize compositional splits to ensure test templates are unseen during training.
SEQZERO-Large achieved state-of-the-art results for BART-based architectures. On GeoQuery, it reached 74.7% exact match accuracy, outperforming standard BART-Large (72.5%). The gains were even more pronounced on the challenging EcoQuery dataset, where SEQZERO achieved 46.2%, an 8.5% absolute improvement over the baseline. Notably, the ensemble model reached 88.5% accuracy in the FROM clause, demonstrating the zero-shot component's success in filtering out spurious table-mapping biases.
Conclusion
SEQZERO demonstrates that decomposing complex parsing tasks into prompted sub-problems and ensembling with zero-shot models can significantly improve few-shot performance and OOD generalization. While issues like error propagation across sequential clauses remain, the framework provides a robust path forward for building more reliable semantic parsers with minimal data. Future work will explore extending this approach to other architectures like T5 and improving entity identification in complex domains.
Summary updated