Improving Generalization in Language Model-based Text-to-SQL Semantic Parsing: Two Simple Semantic Boundary-based Techniques

Daking Rai, Bailin Wang, Yilun Zhou, Ziyu Yao

Abstract

State-of-the-art language models (LMs) often struggle with text-to-SQL tasks when encountering unfamiliar database domains or complex, novel query structures. This paper presents two straightforward "boundary-based" techniques—token preprocessing and component boundary marking—designed to enhance model generalization. By aligning the model's tokenizer with semantic boundaries, these methods achieve significant performance improvements on the Spider benchmark without requiring architectural modifications.

Introduction

The primary hurdle in Text-to-SQL parsing is generalization, specifically across two dimensions:

  1. Domain Generalization: The ability to handle unseen database schemas (e.g., transitioning from entertainment to flight data).
  2. Compositional Generalization: The ability to combine known primitives into novel complex queries (e.g., combining "heads of departments" and "older than 56").

While pre-trained LMs like T5 are robust, they frequently fail on out-of-distribution (OOD) samples. This failure is partly attributed to tokenizers mangling semantic boundaries. For instance, a tokenizer might split pet_age into nonsensical fragments like pe, t_a, and ge, severing the link to pre-trained concepts of "pet" and "age."

Methodology

The authors propose two primary interventions to address these boundary issues.

Token Preprocessing

This token-level technique ensures the LM processes meaningful words rather than arbitrary fragments. It includes:

  • Snake Case Expansion: department_management becomes department _ management.
  • Dot Notation Expansion: farm.cows becomes farm . cows.
  • Keyword Expansion: Abbreviations like avg and desc are expanded to average and descending.

These adjustments align the input with the model's pre-trained vocabulary, leveraging existing semantic knowledge.

Component Boundary Marking

At the sequence level, special separator tokens are used to explicitly define the mapping between natural language (NL) questions and SQL components. For example, [sep0] How many heads [/sep0] [sep1] are older than 56? [/sep1] maps to [sep0] select count(head.*) [/sep0] [sep1] where head.age > 56 [/sep1]. These markers provide explicit hints for semantic alignment.

Examples of Token Preprocessing and Component Boundary Marking techniques applied to schemas, SQL, and NL inputs.

Experimental Setup

The methods were evaluated on:

  • Spider: A standard cross-database benchmark for domain generalization.
  • Spider-CG: A variant focused on compositional generalization via component substitution.
  • SMCalFlow-CS: A text-to-LISP dataset to test cross-task applicability.

Key Results and Insights

Experiments using T5-base revealed several critical findings:

  • Significant Performance Gains: Token preprocessing alone (T5-base + Tok) improved Exact Match (EM) scores by 5-7% for domain generalization and 9% for compositional cases.
  • Closing the OOD Gap: The combination of "Tok + Comp" significantly reduced the performance disparity between seen and unseen data distributions.
  • Competitive Efficiency: The enhanced T5-base model achieved results comparable to more complex, specialized architectures like RATSQL.
  • Broad Applicability: A 3.8% absolute improvement in EM on SMCalFlow-CS demonstrates that these techniques are not limited to SQL.

Conclusion and Future Work

The study highlights that tokenization is a significant bottleneck in semantic parsing. By simply fixing how models "read" schemas and queries, substantial gains are possible. However, Component Boundary Marking currently depends on alignment annotations, which may not always be available. Future research could explore extending boundary markers to the database schema itself to further reduce hallucinations and testing these techniques on larger models like GPT-4.

Summary updated

BibTeX
@inproceedings{rai2023improving,
  author = {Daking Rai and Bailin Wang and Yilun Zhou and Ziyu Yao},
  title = {{Improving Generalization in Language Model-based Text-to-SQL Semantic Parsing: Two Simple Semantic Boundary-based Techniques}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-short.15},
}
Figure