SQLens: An End-to-End Framework for Error Detection and Correction in Text-to-SQL

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Gong, Yue, Lei, Chuan, Qin, Xiao, Vaidya, Kapil, Narayanaswamy, Balakrishnan, Kraska, Tim
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866910988952928256
author Gong, Yue
Lei, Chuan
Qin, Xiao
Vaidya, Kapil
Narayanaswamy, Balakrishnan
Kraska, Tim
author_facet Gong, Yue
Lei, Chuan
Qin, Xiao
Vaidya, Kapil
Narayanaswamy, Balakrishnan
Kraska, Tim
contents Text-to-SQL systems translate natural language (NL) questions into SQL queries, enabling non-technical users to interact with structured data. While large language models (LLMs) have shown promising results on the text-to-SQL task, they often produce semantically incorrect yet syntactically valid queries, with limited insight into their reliability. We propose SQLens, an end-to-end framework for fine-grained detection and correction of semantic errors in LLM-generated SQL. SQLens integrates error signals from both the underlying database and the LLM to identify potential semantic errors within SQL clauses. It further leverages these signals to guide query correction. Empirical results on two public benchmarks show that SQLens outperforms the best LLM-based self-evaluation method by 25.78% in F1 for error detection, and improves execution accuracy of out-of-the-box text-to-SQL systems by up to 20%.
format Preprint
id arxiv_https___arxiv_org_abs_2506_04494
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle SQLens: An End-to-End Framework for Error Detection and Correction in Text-to-SQL
Gong, Yue
Lei, Chuan
Qin, Xiao
Vaidya, Kapil
Narayanaswamy, Balakrishnan
Kraska, Tim
Computation and Language
Text-to-SQL systems translate natural language (NL) questions into SQL queries, enabling non-technical users to interact with structured data. While large language models (LLMs) have shown promising results on the text-to-SQL task, they often produce semantically incorrect yet syntactically valid queries, with limited insight into their reliability. We propose SQLens, an end-to-end framework for fine-grained detection and correction of semantic errors in LLM-generated SQL. SQLens integrates error signals from both the underlying database and the LLM to identify potential semantic errors within SQL clauses. It further leverages these signals to guide query correction. Empirical results on two public benchmarks show that SQLens outperforms the best LLM-based self-evaluation method by 25.78% in F1 for error detection, and improves execution accuracy of out-of-the-box text-to-SQL systems by up to 20%.
title SQLens: An End-to-End Framework for Error Detection and Correction in Text-to-SQL
topic Computation and Language
url https://arxiv.org/abs/2506.04494