Abstract
Compositional generalization is one of the important abilities that large language models (LLMs) need to have for semantic parsing. Previous research typically relies on dataset-specific designs or a large number of samples in demonstrations to improve the compositional generalization of LLMs on semantic parsing. We revisit this issue and find that when the number of samples in a demonstration is limited to a lower bound for achieving compositional generalization (minimum-coverage), current advanced LLMs cannot arbitrarily achieve good compositional generalization generically on different semantic parsing datasets without dataset-specific designs. To solve this problem, we propose Multi-level Component Composition ($MC^2$), a minimum-coverage and dataset-agnostic framework based on input primitives, which aims to generically help LLMs achieve compositional generalization by selecting and organizing samples from multiple compositional levels that satisfy the primitive coverage. Experiments and analysis show that $MC^2$ can effectively improve the compositional generalization of LLMs on different semantic parsing datasets in the minimum-coverage setting.
Introduction: The Challenge of Compositional Generalization
Semantic parsing involves translating natural language into formal representations like SQL or SPARQL. A core requirement for success is compositional generalization: the ability of a model to understand and generate new combinations of known components (primitives). For instance, if a model knows "jump" and "left," it should be able to parse "jump left" even if that specific combination was absent from its training data.
Current LLMs often struggle with this when provided with limited examples. The authors define a "minimum-coverage" setting, where the demonstration set is restricted to the smallest number of training samples required to cover all primitives in the test input. In this constrained environment, even powerful models like GPT-4o fail to generalize effectively when examples are selected randomly. $MC^2$ aims to bridge this gap using a dataset-agnostic approach.
The $MC^2$ Framework
To address this, the authors propose Multi-level Component Composition ($MC^2$), a framework designed to be dataset-agnostic and efficient. $MC^2$ constructs a "path of thinking" for the LLM through a three-stage process:
1. Chunking
The input sentence is decomposed into a hierarchical tree structure. This can be achieved using either a Perplexity (PPL)-based approach (finding natural split points using a small language model) or an off-the-shelf constituent parser (like BENEPAR). This step identifies the structural components that need to be mapped to formal logic.
2. Matching
For each component in the tree, $MC^2$ searches the training set for examples that contain the relevant primitives and share structural similarity. Unlike "Global Matching," which looks for similar full sentences, $MC^2$ matches at the component level. This ensures the model sees how each specific part of the input should be handled in a context similar to the target.
3. Ordering
The selected examples are arranged using an inverted Breadth-First Search (BFS) order. This sequence presents simpler components first, followed by increasingly complex ones, effectively providing a tutorial on how to compose the final output from its constituent parts.
Experimental Evaluation
The framework was tested on three benchmarks known for their compositional difficulty: SCAN (navigation), COGS (linguistic variety), and CFQ (complex SPARQL queries). The researchers used "Maximum Compound Divergence" (MCD) splits to ensure the test set contained novel combinations of primitives.
Key Results
- Significant Performance Boost: On the SCAN dataset, GPT-4o's accuracy improved from 71.7% (random selection) to 90.8% with $MC^2$.
- Consistency Across Models: $MC^2$ consistently outperformed standard similarity-based "Global Matching." For DeepSeek-2.5 on CFQ, accuracy rose from 63.8% to 79.8%.
- Efficiency: By adhering to the minimum-coverage rule, $MC^2$ achieves these gains with a minimal token footprint, making it highly efficient for few-shot prompting compared to traditional methods that require massive demonstrations.
Conclusion
$MC^2$ demonstrates that smart, hierarchical data selection can significantly bridge the compositional gap in LLMs without the need for dataset-specific engineering. By breaking down inputs into primitives and providing a structured "path of thinking," $MC^2$ enables LLMs to perform complex semantic parsing tasks even in low-resource settings.
Summary updated