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

TL;DR

Diverse in-context example selection after program decomposition boosts semantic parsing accuracy.

cs.CL 🔴 Advanced 2025-04-04 53 views
Mayank Kothyari Sunita Sarawagi Soumen Chakrabarti Gaurav Arora Srujana Merugu
semantic parsing LLMs example selection program decomposition diversity

Key Findings

Methodology

SCUD4ICL decomposes training program trees into meaningful fragments, uses a syntax-constrained LLM to generate aligned sub-utterances, and extends diversity selection algorithms to include whole and fragmented examples. This reduces interference during in-context learning, especially in complex structured tasks. The system leverages a one-time decomposition of training data to create an augmented pool, then dynamically selects relevant, diverse examples based on similarity and structure. Experiments on SMCalFlow, GeoQuery, and MTOP demonstrate consistent improvements over baseline methods like CoverLS, particularly for small models, large trees, and low-resource languages.

Key Results

  • On SMCalFlow with T= T5, SCUD4ICL improved accuracy by 4.4%, outperforming CoverLS. In GeoQuery, across multiple splits, it achieved 3-5% higher accuracy, especially in low-resource settings. In MTOP, with M=5 and M=10, accuracy increased by 2-4% in English and French. Ablation studies confirmed that program decomposition and aligned sub-utterance generation significantly reduce interference, enhancing generalization.
  • The approach shows robustness across multiple languages and models, with notable gains in smaller models like Llama3-8B, where accuracy increased by 4%. The results highlight the importance of structured example augmentation and diverse selection for complex semantic tasks.
  • Overall, the experimental data validate that combining program decomposition with diverse, aligned demonstrations effectively mitigates irrelevant information interference, leading to higher accuracy and better generalization across datasets and languages.

Significance

This work advances semantic parsing by integrating program structure into example selection, addressing the limitations of traditional static or similarity-based methods. It offers a scalable, automated way to improve model performance in structured tasks, especially in low-resource or privacy-sensitive environments. The methodology enhances the interpretability and robustness of LLM-based semantic interpreters, paving the way for broader industrial adoption and multi-lingual applications. Its core innovation lies in leveraging program decomposition to create a richer, more relevant demonstration pool, which significantly reduces noise and improves model guidance, thus contributing to the evolution of structured language understanding.

Technical Contribution

SCUD4ICL introduces a novel framework combining program tree decomposition, syntax-constrained sub-utterance generation, and an extended diversity selection algorithm. This approach addresses the core challenge of irrelevant information interference in in-context learning for structured outputs. The system automates sub-program extraction, aligns sub-utterances via LLM prompting, and dynamically selects examples based on relevance and structural diversity. These innovations collectively improve the quality and relevance of in-context demonstrations, leading to substantial performance gains over existing methods like CoverLS and DPP. The work also provides a scalable pipeline adaptable to various structured tasks and languages.

Novelty

This is the first work to systematically incorporate program tree sub-structures into in-context example selection, combining automated sub-utterance generation with a structure-aware diversity algorithm. Unlike prior approaches that treat examples as monolithic, SCUD4ICL leverages hierarchical decomposition to enhance relevance and reduce interference, especially in low-resource and complex scenarios. Its dual focus on program structure and conversational alignment sets a new standard for structured demonstration selection, offering a significant leap over existing static or similarity-based methods.

Limitations

  • The program decomposition relies on predefined grammar and LLM-generated sub-utterances, which may introduce errors in highly complex or ambiguous programs, affecting overall performance.
  • Despite reducing interference, the method may still face challenges in extremely noisy or adversarial data, where irrelevant fragments could slip through the selection process.
  • Computational overhead increases with the size of the decomposed pool and the complexity of the diversity algorithm, potentially limiting real-time deployment in resource-constrained environments.

Future Work

Future directions include developing more robust, grammar-agnostic decomposition techniques, integrating reinforcement learning for adaptive example selection, and extending the framework to multi-modal tasks. Enhancing efficiency and scalability, especially for real-time applications, remains a priority. Additionally, exploring unsupervised or semi-supervised methods for sub-utterance generation could further reduce reliance on LLM prompts, making the system more autonomous and adaptable across diverse structured tasks.

AI Executive Summary

Semantic parsing with large language models (LLMs) has seen rapid progress, yet effective in-context example (ICE) selection remains a challenge, especially for complex structured outputs like programs. Traditional approaches often rely on selecting entire examples based on similarity, which can introduce irrelevant information and hinder model performance. This paper introduces SCUD4ICL, a novel system that enhances in-context learning by decomposing training programs into meaningful sub-programs, generating aligned sub-utterances via syntax-constrained LLM prompting, and employing an extended diversity selection algorithm. The core idea is to create a richer, more relevant demonstration pool that minimizes interference and maximizes coverage of structural variations.

The methodology hinges on three key innovations: first, a one-time program decomposition that splits complex trees into smaller, manageable fragments; second, an LLM-guided generation of sub-utterances that preserve natural language fluency and structural alignment; third, a structured diversity algorithm that selects examples based on relevance, structure, and coverage. These components work synergistically to produce high-quality, diverse demonstrations tailored to each test query, significantly improving model accuracy.

Experimental results on SMCalFlow, GeoQuery, and MTOP datasets demonstrate that SCUD4ICL outperforms existing methods like CoverLS and DPP, with accuracy improvements of up to 6%. Notably, the gains are more pronounced for smaller models, larger trees, and low-resource languages, highlighting the method’s robustness and broad applicability. Ablation studies confirm that program decomposition and aligned sub-utterance generation are critical for reducing interference and enhancing generalization.

This work offers a substantial step forward in structured semantic parsing, providing a scalable, automated framework that leverages program structure to improve in-context learning. Its implications extend to industrial applications such as enterprise data interpretation, multilingual NLP, and low-resource language processing. Future research will focus on refining decomposition techniques, reducing computational costs, and exploring multi-modal extensions, aiming to make structured language understanding more accurate, efficient, and versatile.

Deep Analysis

Background

Recent advances in LLMs, exemplified by GPT-4 and PaLM, have revolutionized NLP tasks, including semantic parsing and code generation. Early methods relied on template-based or supervised learning approaches, limited by data scarcity and poor generalization. Transformer-based models trained on massive corpora demonstrated remarkable zero-shot and few-shot capabilities, but struggled with complex, hierarchical outputs like programs. Prior works such as CodeX and T5 have shown that structured outputs benefit from explicit modeling of syntax and semantics. However, the challenge of selecting effective in-context examples (ICEs) persists, especially for tasks requiring understanding of program structure and multi-turn dialogues. Existing methods often use similarity metrics or random sampling, which fail to capture the nuanced relevance of structured sub-components, leading to interference and suboptimal performance. This gap motivates the development of more sophisticated, structure-aware ICE selection strategies that can leverage program decomposition and alignment to improve model guidance.

Core Problem

The core challenge is to improve the relevance and diversity of in-context examples for structured semantic parsing tasks. Traditional selection methods, based on simple similarity or random sampling, often include irrelevant or redundant information, which can mislead the model. This is particularly problematic when dealing with complex programs represented as Abstract Syntax Trees (ASTs), where irrelevant subtrees or unaligned utterances introduce noise. Moreover, the limited size of demonstration sets constrains coverage of the structural variability inherent in real-world data. The difficulty lies in balancing relevance, diversity, and computational efficiency, especially when the program structures are large and the language data is low-resource or noisy. Addressing this problem requires a method that can decompose programs, generate aligned natural language sub-utterances, and select examples that maximize coverage while minimizing interference.

Innovation

The paper introduces a three-pronged innovation: (1) program decomposition, which splits complex ASTs into meaningful subtrees; (2) syntax-constrained LLM prompting to generate fluent, aligned sub-utterances for each sub-program; (3) an extended diversity selection algorithm that considers structural relations and relevance to dynamically select a set of diverse, pertinent examples. This approach effectively reduces irrelevant information, enhances the relevance of demonstrations, and improves the model’s ability to generalize to unseen queries. Unlike prior work that treats examples as monolithic, this method leverages the hierarchical structure of programs, creating a richer demonstration pool that better captures the variability of real-world data. The integration of automatic sub-utterance generation and structure-aware selection marks a significant advancement in in-context learning for structured tasks.

Methodology

  • �� Decompose each training program tree into subtrees based on syntax rules, generating a set of sub-programs and associated sub-utterances.
  • �� Use a syntax-aware LLM with specific prompts to generate natural, fluent sub-utterances aligned with each sub-program, ensuring relevance and naturalness.
  • �� Build an augmented demonstration pool including both full and decomposed examples.
  • �� Implement a structured diversity algorithm that, for each test query, iteratively selects examples covering new tokens, structural relations, and maintaining relevance via BM25 similarity.
  • �� During inference, dynamically select a subset of examples from the augmented pool based on relevance and structural coverage, minimizing irrelevant interference.
  • �� Evaluate the system across multiple datasets, model sizes, and languages, comparing with baseline methods like CoverLS and DPP.

Experiments

The evaluation encompasses three datasets: SMCalFlow (calendar management), GeoQuery (geographical queries), and MTOP (multi-domain dialogue). Different training splits (T= T5, T= T10, D3, D4) were used to test robustness. Baselines include CoverLS, DPP, and TOPK. Metrics include execution accuracy and exact match. Experiments varied the number of in-context examples (M=5, 10), model types (GPT-3.5, GPT-4, Llama3-8B), and languages. Ablation studies examined the impact of program decomposition, sub-utterance generation, and diversity selection. Results consistently showed that SCUD4ICL outperformed baselines, with accuracy gains of 3-6%, especially in low-resource and small-model settings. The experiments validated the effectiveness of program decomposition and aligned sub-utterance generation in reducing interference and improving generalization.

Results

SCUD4ICL achieved an average accuracy increase of 4.4% on SMCalFlow T= T5, outperforming CoverLS. On GeoQuery, across various splits, it improved accuracy by 3-5%. In MTOP, accuracy increased by 2-4% in both English and French. Ablation results confirmed that program decomposition and sub-utterance alignment are critical for performance gains. The method showed particular strength in small models like Llama3-8B, where accuracy rose by 4%, and in low-resource languages, demonstrating robustness and scalability. These results underscore the importance of structure-aware, diverse demonstration selection in complex semantic tasks.

Applications

This approach benefits enterprise data interpretation, low-resource language processing, and multi-turn dialogue systems by providing more accurate and relevant in-context examples. It reduces manual effort in data annotation, enhances model robustness, and supports privacy-preserving applications where private schemas are involved. The automatic decomposition and selection pipeline can be integrated into existing NLP pipelines to improve semantic understanding and code generation tasks, enabling more reliable and scalable AI assistants.

Limitations & Outlook

The program decomposition relies on predefined grammar and LLM-generated sub-utterances, which may introduce errors in ambiguous or highly complex programs. The diversity selection algorithm, while effective, can be computationally intensive for large pools, limiting real-time deployment. Additionally, the method's performance depends on the quality of sub-utterance generation, which may vary across languages and domains. Future work should focus on improving robustness, efficiency, and extending the framework to multi-modal and multi-task settings.

Plain Language Accessible to non-experts

想象你在准备一场盛大的派对,邀请很多朋友,每个人都带来不同的建议和礼物。可是,如果你只听一个朋友的建议,可能会错过更好的点子。于是,你决定把每个建议拆开,挑出最有用的部分,再结合不同朋友的建议,确保派对丰富多彩。这就像论文里的方法,把复杂的程序拆成小块,挑选最相关的建议,让模型更聪明地理解和生成内容。这样做可以避免被无关信息干扰,让整个派对(任务)变得更完美。

ELI14 Explained like you're 14

想象你在组织一个学校活动,你需要安排时间、地点和邀请朋友。有时候信息太多,搞不清楚。于是你把大任务拆成几个小任务,比如先确定时间,再安排地点,然后邀请朋友。每个小任务都简单明了,不会搞混。这样一来,你就能更轻松地完成整个活动。论文的方法也是这样,把复杂的程序拆成小部分,挑选最相关的建议,再用它们帮助模型理解。这样,模型就能更准确地完成任务,就像你组织活动一样顺利。

Glossary

Abstract Syntax Tree (AST) (抽象语法树)

一种程序的树状结构,描述程序的语法层次,便于分析和分解。

用于将程序转化为结构化的树形表示,方便子程序提取和匹配。

In-Context Examples (ICEs) (上下文示例)

在模型推理中提供的示例,用于引导模型理解任务。

选择相关多样的ICEs能显著提升模型性能。

Diversity Selection (多样性筛选)

在示例中挑选既相关又多样的样本,减少干扰,提升泛化。

本文扩展了Levy等的多样性筛选算法,结合结构关系优化示例池。

Program Decomposition (程序分解)

将复杂程序拆解为子程序或子树,便于理解和匹配。

通过分解提升示范的相关性和多样性,减少干扰。

Open Questions Unanswered questions from this research

  • 1 如何在极端复杂或模糊的程序结构中保证分解的准确性?未来需研究更鲁棒的自动分解和映射机制。
  • 2 示范筛选在大规模多任务环境中的效率和效果仍需优化,特别是在多模态、多语言场景。
  • 3 如何结合自监督学习和强化学习,进一步提升示范选择的智能化和适应性?

Applications

Immediate Applications

企业私有数据的结构化语义解析

利用SCUD4ICL提升企业内部数据理解能力,减少人工标注,保护数据隐私。

低资源语言的语义理解

在低资源环境中,通过子程序分解和多样示例改善模型表现,支持多语种应用。

Long-term Vision

智能化人机交互系统

实现更自然、更准确的语义理解,推动智能助手和自动问答的普及,提升用户体验。

Abstract

LLMs are increasingly used as seq2seq translators from natural language utterances to structured programs, a process called semantic interpretation. Unlike atomic labels or token sequences, programs are naturally represented as abstract syntax trees (ASTs). Such structured representation raises novel issues related to the design and selection of in-context examples (ICEs) presented to the LLM. We focus on decomposing the pool of available ICE trees into fragments, some of which may be better suited to solving the test instance. Next, we propose how to use (additional invocations of) an LLM with prompted syntax constraints to automatically map the fragments to corresponding utterances. Finally, we adapt and extend a recent method for diverse ICE selection to work with whole and fragmented ICE instances. We evaluate our system, SCUD4ICL, on popular diverse semantic parsing benchmarks, showing visible accuracy gains from our proposed decomposed diverse demonstration method. Benefits are particularly notable for smaller LLMs, ICE pools having larger labeled trees, and programs in lower resource languages.

cs.CL