Table of Contents
Fetching ...

Memo-SQL: Structured Decomposition and Experience-Driven Self-Correction for Training-Free NL2SQL

Zerui Yang, Weichuan Wang, Yanwei Xu, Linqi Song, Yudai Matsuda, Wei Han, Bo Bai

TL;DR

Mozo-SQL is presented, a training-free framework that addresses issues through two simple ideas: structured decomposition and experience-aware self-correction, and sets a new state of the art among open, zero-fine-tuning methods, while using over 10 times fewer resources than prior TTS approaches.

Abstract

Existing NL2SQL systems face two critical limitations: (1) they rely on in-context learning with only correct examples, overlooking the rich signal in historical error-fix pairs that could guide more robust self-correction; and (2) test-time scaling approaches often decompose questions arbitrarily, producing near-identical SQL candidates across runs and diminishing ensemble gains. Moreover, these methods suffer from a stark accuracy-efficiency trade-off: high performance demands excessive computation, while fast variants compromise quality. We present Memo-SQL, a training-free framework that addresses these issues through two simple ideas: structured decomposition and experience-aware self-correction. Instead of leaving decomposition to chance, we apply three clear strategies, entity-wise, hierarchical, and atomic sequential, to encourage diverse reasoning. For correction, we build a dynamic memory of both successful queries and historical error-fix pairs, and use retrieval-augmented prompting to bring relevant examples into context at inference time, no fine-tuning or external APIs required. On BIRD, Memo-SQL achieves 68.5% execution accuracy, setting a new state of the art among open, zero-fine-tuning methods, while using over 10 times fewer resources than prior TTS approaches.

Memo-SQL: Structured Decomposition and Experience-Driven Self-Correction for Training-Free NL2SQL

TL;DR

Mozo-SQL is presented, a training-free framework that addresses issues through two simple ideas: structured decomposition and experience-aware self-correction, and sets a new state of the art among open, zero-fine-tuning methods, while using over 10 times fewer resources than prior TTS approaches.

Abstract

Existing NL2SQL systems face two critical limitations: (1) they rely on in-context learning with only correct examples, overlooking the rich signal in historical error-fix pairs that could guide more robust self-correction; and (2) test-time scaling approaches often decompose questions arbitrarily, producing near-identical SQL candidates across runs and diminishing ensemble gains. Moreover, these methods suffer from a stark accuracy-efficiency trade-off: high performance demands excessive computation, while fast variants compromise quality. We present Memo-SQL, a training-free framework that addresses these issues through two simple ideas: structured decomposition and experience-aware self-correction. Instead of leaving decomposition to chance, we apply three clear strategies, entity-wise, hierarchical, and atomic sequential, to encourage diverse reasoning. For correction, we build a dynamic memory of both successful queries and historical error-fix pairs, and use retrieval-augmented prompting to bring relevant examples into context at inference time, no fine-tuning or external APIs required. On BIRD, Memo-SQL achieves 68.5% execution accuracy, setting a new state of the art among open, zero-fine-tuning methods, while using over 10 times fewer resources than prior TTS approaches.
Paper Structure (37 sections, 4 equations, 7 figures, 8 tables)

This paper contains 37 sections, 4 equations, 7 figures, 8 tables.

Figures (7)

  • Figure 1: Conceptual comparison between a standard user-in-the-loop NL2SQL workflow and our proposed self-correction framework. In the standard approach, the model generates an initial SQL query, which is then revised through explicit user feedback, a process that typically stores only correct examples in the experience repository. In contrast, our framework introduces an automatic self-correction step after generation: it retrieves relevant error--correction pairs from a dynamic error-correction memory (including past failures) and refines the output without requiring user intervention, enabling fully training-free adaptation.
  • Figure 2: Overview of the Memo-SQL framework, which integrates problem decomposition, ReAct+Reflection reasoning, and self-correction to generate accurate SQL queries. The pipeline begins with preprocessing and multi-strategy question decomposition. Each sub-problem is solved via an iterative ReAct+Reflection loop: (1) reasoning about semantics, (2) generating a sub-SQL query, (3) observing execution results, and (4) reflecting on potential errors to enable one-step correction. Finally, multiple SQL candidates are synthesized using few-shot in-context learning across three syntactic styles (CTE, flat JOIN, nested), followed by error-aware refinement, guided by a error-correction memory, and selection via self-consistency scoring.
  • Figure 3: Illustration of the three complementary question decomposition strategies.
  • Figure 4: Construction pipeline of the error-correction memory.
  • Figure 5: Illustration of three complementary question decomposition strategies in Memo-SQL, demonstrated on a sample query: "Find customers who spent more than 1000 on Electronics products in 2024." The methods include (1) Table-wise/Entity-wise, decomposing the query by relevant database entities; (2) Hierarchical, modeling nested logic through layered sub-questions; and (3) Atomic Sequential, breaking down the query into a pipeline of fundamental relational operations. Each strategy generates a unique set of sub-questions, enabling flexible and robust reasoning for complex multi-table SQL generation.
  • ...and 2 more figures