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:
- Domain Generalization: The ability to handle unseen database schemas (e.g., transitioning from entertainment to flight data).
- 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_managementbecomesdepartment _ management. - Dot Notation Expansion:
farm.cowsbecomesfarm . cows. - Keyword Expansion: Abbreviations like
avganddescare expanded toaverageanddescending.
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.
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