Navigation menu
MEM-SQL: Memory-Empowered Text-to-SQL
MEM-SQL: Memory-Empowered Text-to-SQL
Xiaoqi Wang, Wenqi Pei, Shizheng Hou, Yilai Liu, Han Chen, Boyan Li et al.
2026-11-16▲ 17arXiv 2611.18338v1Hugging Face
AI-generated from the full paper (deepseek-flash). It may contain mistakes; check the original.
TL;DR
The paper introduces HARE, a 1,600-request history-aware Text-to-SQL benchmark, and MEM-SQL, a layered memory system with coverage-gated retrieval and on-demand schema linking that improves accuracy and reduces generation cost across six models.
Problem
Widely used Text-to-SQL benchmarks evaluate questions independently even though users repeatedly query the same database, so earlier verified queries may supply joins or calculations for a new question. Prior work does not provide controlled labels for what carries over between requests or measure accuracy and generation cost across different edit types. HARE is introduced to identify retained components and required edits, and MEM-SQL is proposed to decide what to remember and when to consult the schema.
Method
HARE derives 1,600 requests from 823 verified queries in Spider, BIRD, Spider 2.0, and BEAVER, annotating retained components and permitted edits across six primitive and six composite categories. MEM-SQL stores whole-query templates, reusable SQL blocks, and schema concepts; each item pairs a searchable description with SQL structure or schema mapping. At inference, a decomposer creates layer-specific retrieval atoms, each retrieving its own nearest items, and a layer contributes only if every assigned requirement has a match above that layer's threshold. With On-demand Schema Linking, the generator first tries from accepted memory evidence and runs schema linking only when no layer qualifies or the generator judges evidence insufficient. The resulting SQL is checked with a database dry run and repaired if validation fails.
Results
- HARE contains 1,600 requests built from a fixed pool of 823 verified historical queries, with 1,300 single-category and 300 composite requests. §3.2
- Across six language models, mean execution accuracy rises from 37.1% for Direct Generation without history to 50.0% for MEM-SQL, with 76.6% fewer input tokens and 68.8% lower latency on average. §Abstract
- MEM-SQL completes 95.4% of requests from memory on average, helping explain the cost reduction. §5.2
- Removing templates costs the most accuracy, 5.3 EX points on average, and raises tokens on all backbones; removing components costs 3.7 points on composite requests versus 1.1 on single-category ones. §5.3.2
- Retrieval atoms raise micro recall from 56.67% to 94.58% over full-question retrieval, and layered atoms return 37.7% fewer items per question than flat retrieval. §5.3.1
- Multi-source requests are at least 21.7 EX points lower on every backbone, and for P+J accuracy falls from 81.5% to 46.7% even when all sources are retrieved. §5.4.2
Limitations
- HARE does not model schema drift, such as a change in the month a fiscal year starts; the paper says future work could add such changes.
- MEM-SQL is evaluated with static memory, so how adding, updating, and retiring memory affects performance in dynamic settings remains open.
- Execution accuracy rejects answers that differ only in format, such as rounding, and cannot detect SQL that returns the right rows for the wrong reason; future evaluation should also assess intent.
Key points
- HARE records retained components and required edits, with six primitive and six composite categories spanning whole-query, component, and schema-level reuse. §3.1
- A memory item couples a natural language description, a structured payload, and a dense embedding; the payload preserves exact SQL syntax, subquery structure, or schema mapping. §4.2.1
- A decomposer maps the question to layer-specific retrieval atoms, each atom retrieves its own nearest items, and a layer is accepted only if its worst-covered atom clears the threshold. §4.2.2
- With OSL, schema linking runs immediately only if every layer fails the gate and the evidence bundle is empty; otherwise generation is attempted from memory first. §4.2.3
- MEM-SQL leads the three memory baselines on every backbone, while those baselines use the Unconditional Schema Linking policy. §5.2
- Removing schema concepts changes EX little but raises tokens on all backbones and latency on five, consistent with their mappings avoiding extra schema access. §5.3.2
- MEM-SQL escalates 4.3% of requests, 1.1% through the coverage gate and 3.2% through the generator; shared-concept requests have a 33.1% incomplete-evidence rate and escalate 16.4% of the time. §5.4.1
- OSL cuts input tokens by at least 60% and latency by at least 34% for every memory design, but its accuracy benefit depends on whether retrieval returns complete evidence. §6
Mind map
Sign In
Choose a method to continue
By signing in, you agree to our Terms and Privacy Policy

