MTC-SQL: a memory-enhanced and task-decomposed correction method for text-to-SQL
摘要
Currently, text-to-SQL methods still struggle with structurally complex queries, multi-table joins, and semantic ambiguities, which hinders both accuracy and interpretability. To address common issues in large language models, such as limited context understanding, weak structure control, and insufficient error correction, we propose MTC-SQL, a method combining memory enhancement and task decomposition. MTC-SQL operates through four key stages: (1) dynamic task decomposition based on query intent, which splits the input into controllable sub-tasks; (2) construction of a multi-source memory knowledge base integrating historical QA pairs and database schemas for contextual support; (3) hybrid semantic-structural retrieval that combines vector search and keyword matching to improve prompt quality; and (4) a recursive generation and correction strategy to progressively generate subqueries and refine the final SQL through multi-round feedback. Experiments on the Spider dataset show that MTC-SQL with GPT-4 outperforms the baseline approach, achieving 80.6% exact match (EM) on the development set and 75.0% EM along with 80.2% execution accuracy (EX) on the test set. BLEU scores of 76.7 (Dev) and 77.0 (Test) further validate the structural and semantic alignment.