Abstract
Converting natural language into executable SQL (Text-to-SQL) is essential for making databases accessible to non-experts. However, existing semantic parsers often struggle with complex nested queries. We introduce RECPARSER, a recursive framework that decomposes nested SQL generation into a series of simpler, non-nested sub-problems. By utilizing a novel Question Decomposer to shift focus across different parts of an utterance and a slot-filling SQL Generator, RECPARSER achieves state-of-the-art results on the Spider benchmark, significantly improving accuracy on nested queries.
Introduction
The primary challenge in modern Text-to-SQL tasks is handling structural complexity, particularly nested queries like SELECT ... WHERE x IN (SELECT ...). Standard neural parsers face a massive search space when generating long SQL strings, often leading to compounded errors. Furthermore, "utterance confusion" occurs when a model cannot distinguish which part of a question refers to the outer query versus the inner subquery. RECPARSER addresses these issues through a "divide-and-conquer" strategy that mimics human logical decomposition.
Methodology
RECPARSER breaks the generation process into modular, recursive rounds. The framework consists of four key components:
- Initial Encoder: Uses Bi-LSTM or BERT to create a joint representation of the question and database schema.
- Iterative Encoder: Updates schema representations at each round to maintain alignment with the current question focus.
- SQL Generator: Employs a multi-task classification (slot-filling) approach to predict aggregators, operators, and nesting flags, drastically reducing the search space compared to free-form generation.
- Question Decomposer: This core innovation ensures the model focuses on different parts of the utterance in each round. It uses a Soft Attention Mask to hide previously processed words and a Recursive Attention Divergence Loss to penalize repetitive attention patterns.
The process repeats until the model predicts that no further nesting or set operations are required.
Experimental Results
RECPARSER was evaluated on the Spider benchmark, the standard for large-scale, cross-domain Text-to-SQL. The framework specifically excels at handling nested queries, where it outperformed previous state-of-the-art models by a significant margin.
Without BERT, RECPARSER achieved 39.3% accuracy on nested queries, representing a 5.1% absolute improvement over IRNet. When augmented with BERT-base, accuracy on nested queries reached 46.8%, and overall accuracy on the Spider development set hit 63.1%. Ablation studies confirmed that the Question Decomposer's attention divergence strategy is critical for multi-layered logic.
Conclusion
RECPARSER demonstrates that a recursive, layer-by-layer approach is highly effective for complex semantic parsing. By simplifying SQL generation into slot-filling and explicitly managing attention across recursion rounds, it overcomes the limitations of traditional sequence-to-sequence models. Future work will explore more advanced schema-linking techniques and refined heuristics for FROM clause generation to further enhance robustness across diverse database environments.
Summary updated