ErrorLLM: Modeling SQL Errors for Text-to-SQL Refinement

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Hong, Zijin, Chen, Hao, Yuan, Zheng, Zhang, Qinggang, Zhuang, Luyao, Liao, Qing, Huang, Feiran, Song, Yangqiu, Huang, Xiao
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917312491159552
author Hong, Zijin
Chen, Hao
Yuan, Zheng
Zhang, Qinggang
Zhuang, Luyao
Liao, Qing
Huang, Feiran
Song, Yangqiu
Huang, Xiao
author_facet Hong, Zijin
Chen, Hao
Yuan, Zheng
Zhang, Qinggang
Zhuang, Luyao
Liao, Qing
Huang, Feiran
Song, Yangqiu
Huang, Xiao
contents Despite the remarkable performance of large language models (LLMs) in text-to-SQL (SQL generation), correctly producing SQL queries remains challenging during initial generation. The SQL refinement task is subsequently introduced to correct syntactic and semantic errors in generated SQL queries. However, existing paradigms face two major limitations: (i) self-debugging becomes increasingly ineffective as modern LLMs rarely produce explicit execution errors that can trigger debugging signals; (ii) self-correction exhibits low detection precision due to the lack of explicit error modeling grounded in the question and schema, and suffers from severe hallucination that frequently corrupts correct SQLs. In this paper, we propose ErrorLLM, a framework that explicitly models text-to-SQL Errors within a dedicated LLM for text-to-SQL refinement. Specifically, we represent the user question and database schema as structural features, employ static detection to identify execution failures and surface mismatches, and extend ErrorLLM's semantic space with dedicated error tokens that capture categorized implicit semantic error types. Through a well-designed training strategy, we explicitly model these errors with structural representations, enabling the LLM to detect complex implicit errors by predicting dedicated error tokens. Guided by the detected errors, we perform error-guided refinement on the SQL structure by prompting LLMs. Extensive experiments demonstrate that ErrorLLM achieves the most significant improvements over backbone initial generation. Further analysis reveals that detection quality directly determines refinement effectiveness, and ErrorLLM addresses both sides by high detection F1 score while maintain refinement effectiveness.
format Preprint
id arxiv_https___arxiv_org_abs_2603_03742
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle ErrorLLM: Modeling SQL Errors for Text-to-SQL Refinement
Hong, Zijin
Chen, Hao
Yuan, Zheng
Zhang, Qinggang
Zhuang, Luyao
Liao, Qing
Huang, Feiran
Song, Yangqiu
Huang, Xiao
Computation and Language
Databases
Despite the remarkable performance of large language models (LLMs) in text-to-SQL (SQL generation), correctly producing SQL queries remains challenging during initial generation. The SQL refinement task is subsequently introduced to correct syntactic and semantic errors in generated SQL queries. However, existing paradigms face two major limitations: (i) self-debugging becomes increasingly ineffective as modern LLMs rarely produce explicit execution errors that can trigger debugging signals; (ii) self-correction exhibits low detection precision due to the lack of explicit error modeling grounded in the question and schema, and suffers from severe hallucination that frequently corrupts correct SQLs. In this paper, we propose ErrorLLM, a framework that explicitly models text-to-SQL Errors within a dedicated LLM for text-to-SQL refinement. Specifically, we represent the user question and database schema as structural features, employ static detection to identify execution failures and surface mismatches, and extend ErrorLLM's semantic space with dedicated error tokens that capture categorized implicit semantic error types. Through a well-designed training strategy, we explicitly model these errors with structural representations, enabling the LLM to detect complex implicit errors by predicting dedicated error tokens. Guided by the detected errors, we perform error-guided refinement on the SQL structure by prompting LLMs. Extensive experiments demonstrate that ErrorLLM achieves the most significant improvements over backbone initial generation. Further analysis reveals that detection quality directly determines refinement effectiveness, and ErrorLLM addresses both sides by high detection F1 score while maintain refinement effectiveness.
title ErrorLLM: Modeling SQL Errors for Text-to-SQL Refinement
topic Computation and Language
Databases
url https://arxiv.org/abs/2603.03742