Abstract
Generalization of models to out-of-distribution (OOD) data has captured tremendous attention recently. Specifically, compositional generalization, i.e., whether a model generalizes to new structures built of components observed during training, has sparked substantial interest. In this work, we investigate compositional generalization in semantic parsing, a natural test-bed for compositional generalization, as output programs are constructed from sub-components. We analyze a wide variety of models and propose multiple extensions to the attention module of the semantic parser, aiming to improve compositional generalization. We find that the following factors improve compositional generalization: (a) using contextual representations, such as ELMo and BERT, (b) informing the decoder what input tokens have previously been attended to, (c) training the decoder attention to agree with pre-computed token alignments, and (d) downsampling examples corresponding to frequent program templates. While we substantially reduce the gap between in-distribution and OOD generalization, performance on OOD compositions is still substantially lower.
The Challenge of Compositional Generalization
Semantic parsing involves converting natural language utterances into machine-readable programs, such as SQL queries. While modern neural models achieve high accuracy on standard independent and identically distributed (i.i.d.) test sets, they often fail when required to generalize to new combinations of familiar components—a phenomenon known as the "compositional generalization gap."
To study this, researchers use "program splits" where the program templates in the test set are entirely unobserved during training. For example, a model might see "What is the population of Spain?" and "What is the capital of France?" during training but must generalize to "What is the population of the capital of France?" at test time. Current models tend to memorize specific templates rather than learning the underlying rules of composition.
Architectural and Data-Driven Interventions
This research evaluates whether standard best practices and novel architectural extensions can force models to learn robust alignment rules rather than template memorization. The interventions tested include:
- Contextualized Representations: Replacing static embeddings with ELMo and BERT to provide richer linguistic context and reduce language variability.
- Grammar-Based Decoding: Constraining the decoder to output only syntactically valid programs based on a formal grammar.
- Attention Extensions:
- Attention Supervision: Using word aligners to provide "gold" alignments during training, guiding the model to focus on the correct input tokens for specific logical operators.
- Coverage Mechanism: Implementing a memory module in the decoder to track which parts of the input question have already been processed, preventing omissions or repetitions.
- Data Downsampling: Reducing the frequency of dominant program templates in the training set to prevent the model from developing a bias toward common structures.
Experimental Results
The study utilized five benchmarks, including SQL datasets (ATIS, GEOQUERY, ADVISING, SCHOLAR) and the DROP reading comprehension dataset. The results demonstrate that the proposed interventions significantly narrow the generalization gap.
On SQL datasets, the relative generalization gap was reduced from 84.6% to 62.2%. The most effective configuration typically combined ELMo with Attention Supervision and the Coverage mechanism. For the DROP dataset, the relative gap was reduced from 96.4% to 77.1%, with data downsampling and grammar-based decoding proving particularly impactful.
Discussion and Future Work
While these architectural tweaks provide substantial improvements, a significant performance disparity remains between i.i.d. and OOD splits. On the SQL program split, even the best-performing models only reach approximately 25% exact match accuracy, compared to over 70% on i.i.d. data.
These findings suggest that while improved alignment and contextualization help, the standard encoder-decoder paradigm may require more fundamental shifts. Future research may need to explore explicit modularity or neuro-symbolic approaches that more cleanly separate linguistic understanding from logical execution to achieve human-like systematic generalization.
Summary updated