Introduction
Natural Language to SQL (NL2SQL) systems aim to bridge the gap between non-technical users and complex databases by allowing queries in everyday language. A significant hurdle in this domain is the joint encoding of user questions and database schemas. While current state-of-the-art models often represent these as heterogeneous graphs, they frequently suffer from poor word representation in the question utterance. This leads to errors where the model fails to grasp the latent semantic meaning of specific words, often becoming confused by coincidental overlaps between the question text and unrelated database fields. For instance, a model might incorrectly split a specific car name like "amc hornet sportabout (sw)" because a part of it matches a value in an unrelated table.
RaSaP: A Novel NL2SQL Framework
To address these challenges, we propose RaSaP (Relation aware Semi-autogressive Semantic Parsing), an encoder-decoder architecture designed to enhance token-level understanding and ensure structural query integrity.
Encoder: ELECTRA + RAT
RaSaP utilizes ELECTRA as its backbone encoder. Unlike traditional generative models, ELECTRA's discriminative pre-training makes it exceptionally adept at identifying the contextual importance of tokens, effectively filtering noise from meaningful query components. These embeddings are then processed by a Relation-Aware Transformer (RAT) layer, which integrates predefined schema relations—such as primary/foreign keys and string matches—to jointly encode the question and the database graph.
Decoder: Semi-autoregressive Bottom-Up Parsing
The decoder employs a tree-structured, bottom-up approach inspired by the SmBoP parser. Rather than generating SQL token-by-token, RaSaP constructs meaningful semantic sub-programs and combines them into a final query. This method uses semantic types to prevent invalid rule applications, ensuring that the generated SQL is both syntactically correct and executable.
Evaluation and Results
RaSaP was evaluated on the Spider dataset, a complex cross-domain benchmark requiring zero-shot generalization to unseen databases. The model achieved competitive performance, reaching 69.0% Exact Match (EM) accuracy and 70.0% Execution (EXEC) accuracy on the Spider development set.
As shown in the case studies, RaSaP successfully navigates semantic traps that trip up standard models. For example, it correctly maps "region" to the "continent" column based on context and accurately interprets "oldest to youngest" as a descending (DESC) order requirement. Despite being significantly smaller than massive models like T5-3B (approximately 4 times smaller at 770 million parameters), RaSaP demonstrates superior qualitative reasoning and efficiency.
Conclusion
RaSaP demonstrates that discriminative pre-training and bottom-up decoding are highly effective for NL2SQL tasks. By prioritizing semantic cohesion and structural validity, the framework provides an efficient alternative to larger models. Future work will focus on addressing "extra hard" cases involving deep nesting and complex logic that remain challenging for current parsing architectures.
Summary updated