Compositional Semantic Parsing with Large Language Models

Andrew Drozdov, Nathanael Schärli, Ekin Akyürek, Nathan Scales, Xinying Song, Xinyun Chen, Olivier Bousquet, Denny Zhou

TL;DR Researchers from Google, UMass, and MIT have introduced Dynamic Least-to-Most Prompting, a technique that enables Large Language Models (LLMs) to solve complex, realistic semantic parsing tasks. By decomposing sentences into syntactic trees and dynamically selecting relevant examples, they achieved a new state-of-the-art on the CFQ benchmark using only 1% of the training data required by previous methods.

The Challenge of Compositionality in Semantic Parsing

Compositionality—the ability to understand a whole by understanding its parts and how they combine—is a hallmark of human intelligence but a persistent challenge for standard neural networks. While LLMs have shown promise in solving artificial benchmarks like SCAN, they often struggle with realistic semantic parsing, where natural language must be translated into formal code (like SPARQL).

The authors identify three major hurdles in scaling previous prompting techniques to real-world tasks:

  1. Decomposition Complexity: Real sentences are much harder to break down than synthetic ones.
  2. The "Label Space" Problem: Realistic tasks have massive vocabularies (hundreds of verbs or relations) that cannot fit into a single prompt.
  3. Context Dependency: In complex language, the meaning of a phrase often changes based on its surroundings, making "isolated" translation impossible.

Dynamic Least-to-Most Prompting

To overcome these hurdles, the authors propose Dynamic Least-to-Most Prompting. This method evolves the standard "least-to-most" approach into a robust three-stage pipeline.

Dynamic Least-to-Most Prompting Pipeline
  1. Decomposition via LM-based Syntactic Parsing: Instead of relying on a simple list, the model uses a series of prompts to perform a hierarchical syntactic parse of the input. It identifies noun phrases, subclauses, and verb phrases to build a tree-structured decomposition.
  2. Dynamic Exemplar Selection: Because the full "knowledge base" of a realistic task is too large for one prompt, the system uses the generated decomposition tree to "retrieve" the most relevant examples from a small pool of training data. This ensures the prompt contains the specific vocabulary and structures needed for that exact sentence.
  3. Sequential Solution: The decomposition tree is linearized into a sequence of increasingly complex subproblems. The model solves these one by one, using the answers from previous steps as context to handle context-dependent translations.

The experiments were primarily conducted using OpenAI’s code-davinci-002 (Codex) model.

Datasets Evaluated

The study evaluates the method on two challenging benchmarks designed to test compositional generalization:

  • CFQ (Compositional Freebase Questions): Translating natural language questions into SPARQL queries. It features a large vocabulary and complex linguistic structures.
  • COGS: A semantic parsing dataset that requires mapping sentences to a formal logic representation, specifically designed to catch models that rely on shallow patterns rather than structural understanding.

Key Insights

  • The Power of "Dynamic" Context: LLMs do not need to see the entire training set; they just need to see the right examples at the right time. By selecting exemplars based on the syntactic structure of the query, the model can generalize to unseen combinations.
  • LLMs as Their Own Parsers: The paper demonstrates that LLMs can be prompted to perform highly effective syntactic decomposition, which then serves as a roadmap for the more difficult translation task.
  • Context is King: Previous "least-to-most" methods tried to translate subproblems in isolation. This paper proves that for realistic language, subproblems must be solved sequentially so the model can maintain the "thread" of variables and references.

Key Results

Accuracy on CFQ vs Exemplar Pool Size
  • New State-of-the-Art: On the CFQ benchmark, the method achieved 95% accuracy (averaged across MCD splits), representing a massive leap over the previous best of 91.7%.
  • Extreme Data Efficiency: The method reduced the error rate by 45% while using only 1% of the training data (as exemplar candidates) compared to traditional fully-supervised fine-tuning.
  • Robustness on COGS: The model achieved 99.2% accuracy on the COGS generalization set, performing on par with specialized, task-specific architectures.
  • Speed vs. Accuracy: While the sequential nature of the approach might seem slow, it was actually 2x faster than Chain-of-Thought (CoT) prompting because it didn't require the multiple "self-consistency" samples that CoT needs to reach high accuracy.

Limitations and Future Work

  • Inference Cost: The multi-step prompting process (decomposition -> retrieval -> sequential solving) requires multiple calls to the LLM, which is more computationally expensive than a single-shot pass.
  • Dependency on Exemplar Quality: The performance is sensitive to the "exemplar pool." While the pool is small (1% of data), it still requires a representative set of primitives to be effective.
  • Future Directions: The authors suggest applying this "dynamic" logic to other knowledge-intensive tasks beyond semantic parsing, such as complex question answering or multi-step reasoning in specialized domains like law or medicine.

Summary updated

BibTeX
@inproceedings{drozdov2023compositional,
  author = {Andrew Drozdov and Nathanael Schärli and Ekin Akyürek and Nathan Scales and Xinying Song and Xinyun Chen and Olivier Bousquet and Denny Zhou},
  title = {{Compositional Semantic Parsing with Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=gJW8hSGBys8},
}
Figure