Reliable Answers for Recurring Questions: Boosting Text-to-SQL Accuracy with Template Constrained Decoding
摘要
Large language models (LLMs) have revolutionised Text-to-SQL generation, allowing users to query structured data using natural language with growing ease. Yet, real-world deployment remains challenging, especially in complex or unseen schemas, due to inconsistent accuracy and the risk of generating invalid SQL.
We introduce Template Constrained Decoding (TeCoD), a system that addresses these limitations by harnessing the recurrence of query patterns in labeled workloads. TeCoD converts historical NL-SQL pairs into reusable templates and introduces a robust template selection module that uses a fine-tuned natural language inference model to match or reject queries efficiently. Once the template is selected, TeCoD enforces it during SQL generation through grammar-constrained decoding, implemented via a novel partitioned strategy that ensures both syntactic validity and efficiency. Together, these components yield up to 36% higher execution accuracy than in-context learning (ICL) and 2.2× lower latency on matched queries.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
脉络
- DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction 引用了 Language Models are Few-Shot Learners
- Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation 引用了 RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
- Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation 引用了 DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
- CodeS: Towards Building Open-source Language Models for Text-to-SQL 引用了 RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
- CodeS: Towards Building Open-source Language Models for Text-to-SQL 引用了 DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
- CodeS: Towards Building Open-source Language Models for Text-to-SQL 引用了 Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation
- CodeS: Towards Building Open-source Language Models for Text-to-SQL 引用了 Language Models are Few-Shot Learners
它引用的 Paper19
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-CorrectionMohammadreza Pourreza, Davood RafieiNeurIPS 2023 · 909 次引用
- Text-to-SQL Empowered by Large Language Models: A Benchmark EvaluationDawei Gao, Haibin Wang, Yaliang Li, Xiuyu Sun 等VLDB 2024 · 609 次引用
- RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQLHaoyang Li, Jing Zhang, Cuiping Li, Hong ChenAAAI 2023 · 343 次引用
- CodeS: Towards Building Open-source Language Models for Text-to-SQLHaoyang Li, Jing Zhang, Hanbing Liu, Ju Fan 等SIGMOD 2024 · 124 次引用
相关 Paper
- Structure-Guided Large Language Models for Text-to-SQL GenerationQinggang Zhang, Hao Chen, Junnan Dong, Shengyuan Chen 等ICML 2025
- TranSQL + : Serving Large Language Models with SQL on Low-Resource HardwareWenbo Sun, Qiming Guo, Wenlu Wang, Rihan HaiSIGMOD 2026 · 1 次引用
- SQLBarber: A System Leveraging Large Language Models to Generate Customized and Realistic SQL WorkloadsJiale Lao, Immanuel TrummerSIGMOD 2026 · 11 次引用
- CogSQL: A Cognitive Framework for Enhancing Large Language Models in Text-to-SQL TranslationHongwei Yuan, Xiu Tang, Ke Chen, Lidan Shou 等AAAI 2025 · 12 次引用
- Benchmarking and Improving Text-to-SQL Generation under AmbiguityAdithya Bhaskar, Tushar Tomar, Ashutosh Sathe, Sunita SarawagiEMNLP 2023 · 13 次引用
