Diverse In-Context Example Selection After Decomposing Programs and Aligned Utterances Improves Semantic Parsing

Mayank Kothyari, Sunita Sarawagi, Soumen Chakrabarti, Gaurav Arora, Srujana Merugu

Abstract

Semantic parsing—the conversion of natural language into executable code—is a fundamental task for modern AI assistants. While Large Language Models (LLMs) excel at this via In-Context Learning (ICL), they often struggle with "interference" when provided with complex, multi-faceted examples. This paper introduces SCUD4ICL (Sub-Code + Utterance Decomposition for In-Context Learning), a framework that decomposes training examples into focused fragments and generates natural sub-utterances using a novel "subsumption" technique. By selecting diverse, relevant fragments rather than whole examples, SCUD4ICL significantly improves parsing accuracy, particularly for smaller models and low-resource languages.

Introduction

In-Context Learning (ICL) has become the standard paradigm for semantic parsing, allowing LLMs to generalize to new tasks by observing a few demonstrations in the prompt. However, standard ICL typically utilizes "whole" training examples. This approach introduces a significant challenge: interference. When a test query is simple but the provided examples are long and complex, the LLM may become distracted by irrelevant logic. Conversely, if a query requires a specific logic combination buried within a massive training example, the model may fail to extract the relevant pattern.

To address this, researchers from IIT Bombay and Amazon propose shifting from a library of monolithic examples to a library of "meaningful fragments." Their method, SCUD4ICL, ensures that the prompt contains only the most relevant, distilled information needed to solve the specific user request.

The SCUD4ICL Framework

The SCUD4ICL method operates through a three-stage pipeline designed to maximize the utility of the demonstration pool.

1. Program Decomposition

The process begins by treating programs as Abstract Syntax Trees (ASTs). These trees are broken down into smaller, self-contained sub-trees or fragments. For instance, a complex program designed to "Create a meeting with Sarah at 2 PM" is decomposed into discrete fragments handling specific components like "Subject," "Time," and "Attendees."

2. Subsumed Utterance Decomposition

Once the code is fragmented, it requires corresponding natural language descriptions. The authors identify a "secret sauce" here: Subsumed Utterance Decomposition. Rather than asking an LLM to describe a code fragment from scratch—which often results in robotic or unnatural language—they instruct the LLM to generate a snippet that is a direct sub-part of the original human-written sentence. This ensures the fragments remain fluent and accurately reflect the nuances of human speech.

3. Diverse Selection

When a new test query is received, the system does not simply retrieve the most similar fragments. Instead, it employs an adapted "diverse selection" algorithm based on CoverLS. This algorithm selects a set of fragments that collectively cover the vocabulary of the test query while ensuring the selected program structures are diverse and non-redundant. This prevents the LLM from being biased toward a single logical pattern.

Experimental Evaluation

The researchers evaluated SCUD4ICL across several prominent semantic parsing benchmarks:

  • SMCalFlow: A large-scale dataset for task and calendar management.
  • GeoQuery: A classic benchmark for geographical database queries.
  • MTOP: A multilingual task-oriented parsing dataset.
  • Synthetic Low-Resource Variants: Versions of these datasets using non-English names (Hindi, French, Russian) to simulate private or niche schemas.

Key Results

The improvements across these benchmarks were consistent and often dramatic:

  • Generalization Performance: On the GeoQuery "length split" (where test queries are significantly longer than training examples), Mistral-7B's execution accuracy jumped from 32.3% to 50.6%.
  • Low-Resource Robustness: On a Hindi version of SMCalFlow, GPT-3.5 achieved an absolute accuracy increase of over 6% compared to standard selection methods.
  • Model Sensitivity: While large models like GPT-4o show some resilience to noise, smaller models (such as Mistral-7B and Llama-3-8B) benefit the most from the clean, decomposed fragments provided by SCUD4ICL.

Discussion and Insights

The success of SCUD4ICL highlights several critical insights for the future of ICL:

  • "Less is More": Providing a fragment that exactly matches a specific part of a user's request is more effective than providing a complex example where that same logic is obscured by irrelevant data.
  • The Importance of Subsumption: The empirical finding that "subsumed" utterances outperform independently generated ones suggests that maintaining the stylistic and linguistic context of the original human input is vital for teaching LLMs effectively.
  • Structural Diversity: Ensuring the prompt contains a variety of logical structures prevents the model from over-fitting to a single pattern, improving its ability to compose complex solutions from simple building blocks.

Conclusion

SCUD4ICL demonstrates that the quality and granularity of the example pool are just as important as the selection algorithm itself. By decomposing complex programs and utterances into clean, diverse fragments, the framework mitigates interference and empowers smaller LLMs to perform at levels previously reserved for much larger models. Future work may explore applying these high-quality decomposed pairs to fine-tune specialized models, potentially further closing the gap between general-purpose LLMs and expert semantic parsers.

Summary updated

BibTeX
@inproceedings{kothyari2025diverse,
  author = {Mayank Kothyari and Sunita Sarawagi and Soumen Chakrabarti and Gaurav Arora and Srujana Merugu},
  title = {{Diverse In-Context Example Selection After Decomposing Programs and Aligned Utterances Improves Semantic Parsing}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-long.289},
}
Figure