Abstract
Deploying Text-to-SQL models in production environments presents unique challenges beyond academic accuracy, specifically regarding latency, semantic ambiguity in database schemas, and the need for system robustness. This paper introduces SE-SQL (Semantic-Enriched SQL generator), a framework designed for "service-oriented" parsing. By decoupling question and schema encoding, SE-SQL achieves a 28x speedup in inference latency (from 170ms to 6ms) while reaching 88.3% execution accuracy on the WikiSQL dataset. The framework incorporates semantic enrichment, out-of-table rejection, and text normalization to bridge the gap between user intent and database execution.
Introduction
While state-of-the-art Text-to-SQL models have achieved high scores on academic benchmarks, their practical utility is often limited by three factors:
- Latency: Joint encoding of questions and schemas through heavy transformers is computationally expensive, especially as the number of tables grows.
- Semantic Gap: Real-world database column names are often cryptic (e.g., "No."), whereas users use natural language (e.g., "Player Number").
- Robustness: Production systems must handle out-of-domain queries that cannot be answered by the available tables, requiring a reliable "I don't know" response.
The SE-SQL Framework
To address these issues, the authors propose SE-SQL, which shifts from joint encoding to a separate encoding architecture. This allows for the pre-calculation and caching of table schema embeddings offline, leaving only the user's question to be encoded at runtime.
Key Architectural Components
- Separate Encoding: By decoupling the question and schema, the system drastically reduces the computational load during live inference. Schema embeddings are pre-calculated and stored.
- Semantic Enrichment: Schema embeddings are enriched with synonyms and actual table content samples. This helps the model map natural language terms to cryptic headers by understanding the data context.
- Out-of-Table Rejection: A non-parametric layer calculates cosine similarity between the question and schema. Queries falling below a threshold ($R_{threshold}$) are rejected to prevent model hallucinations.
- Text Normalization: Named Entity Recognition (NER) is used to regularize values (e.g., converting "till yesterday" to a standard date format) in the
WHEREclause, ensuring compatibility with the database's internal storage.
Evaluation
The model was evaluated on the WikiSQL (version 1.1) dataset. To test robustness, the authors utilized negative sampling to create a sub-dataset for evaluating the out-of-table rejection feature.
Performance and Efficiency
SE-SQL demonstrated significant improvements in both accuracy and speed. The model achieved an 88.3% execution accuracy (EX) and 83.3% logical form accuracy (LF) on the WikiSQL dev set, representing a 13% error reduction over the baseline.
The most notable gain was in inference speed. While conventional joint-encoding models required approximately 170ms per query, SE-SQL reduced this to just 6ms. Furthermore, the out-of-table rejection module achieved an 85% true positive rate and improved overall accuracy for accepted cases from 85% to 87%.
Conclusion
SE-SQL represents a shift toward practical, service-oriented NLP. By prioritizing low-latency architecture and semantic robustness, the framework makes Text-to-SQL technology viable for real-time production applications. Future work may involve extending these techniques to more complex multi-table schemas and refining the rejection logic to further reduce false positives.
Summary updated