[Paper Review] Relation Aware Semi-autoregressive Semantic Parsing for NL2SQL
This paper proposes RaSaP, a relation-aware semi-autoregressive semantic parsing framework for NL2SQL that jointly encodes database schema and natural language questions using ELECTRA-based relation-aware transformers. By learning discriminative word representations and leveraging semi-autoregressive decoding with predefined SQL syntax, RaSaP achieves state-of-the-art performance on the Spider benchmark, with 69.0% exact match and 70.0% execution accuracy.
Natural language to SQL (NL2SQL) aims to parse a natural language with a given database into a SQL query, which widely appears in practical Internet applications. Jointly encode database schema and question utterance is a difficult but important task in NL2SQL. One solution is to treat the input as a heterogeneous graph. However, it failed to learn good word representation in question utterance. Learning better word representation is important for constructing a well-designed NL2SQL system. To solve the challenging task, we present a Relation aware Semi-autogressive Semantic Parsing (\MODN) ~framework, which is more adaptable for NL2SQL. It first learns relation embedding over the schema entities and question words with predefined schema relations with ELECTRA and relation aware transformer layer as backbone. Then we decode the query SQL with a semi-autoregressive parser and predefined SQL syntax. From empirical results and case study, our model shows its effectiveness in learning better word representation in NL2SQL.
Motivation & Objective
- Address the challenge of learning effective word representations in NL2SQL, especially for ambiguous or semantically complex tokens.
- Improve joint encoding of database schema and natural language questions to enhance semantic parsing accuracy.
- Overcome limitations in existing models that fail to distinguish semantically relevant from irrelevant tokens in questions.
- Develop a more adaptable and accurate NL2SQL framework through relation-aware attention and semi-autoregressive decoding.
- Demonstrate the effectiveness of discriminative pre-training (ELECTRA) in improving NL2SQL performance on complex, real-world benchmarks.
Proposed method
- Use ELECTRA as the backbone encoder to learn contextualized, discriminative word representations with a focus on token importance.
- Apply relation-aware self-attention layers to model predefined schema relations between question tokens and schema elements (e.g., columns, tables).
- Construct a heterogeneous graph of question tokens and schema entities with 12 distinct relation types, including foreign key, primary key, and column-table relationships.
- Implement a semi-autoregressive bottom-up decoder that generates SQL by building meaningful semantic sub-programs step-by-step.
- Leverage predefined SQL syntax and tree-structured representations to guide decoding and improve structural correctness.
- Fine-tune the model end-to-end using a sequence-to-sequence framework with beam search (beam size K=30) and gradient accumulation over 520 epochs.
Experimental results
Research questions
- RQ1Can relation-aware attention improve word representation learning in NL2SQL, especially for ambiguous or contextually sensitive tokens?
- RQ2How effective is a semi-autoregressive decoding strategy with structured SQL syntax in reducing generation errors?
- RQ3Does using a discriminative pre-trained model like ELECTRA enhance performance on complex NL2SQL benchmarks compared to standard BERT-based models?
- RQ4To what extent can joint encoding of schema and question improve generalization on unseen database schemas?
- RQ5Can the model correctly identify and preserve semantically meaningful phrases (e.g., 'amc hornet sportabout (sw)') that are often misparsed by existing models?
Key findings
- RaSaP achieves 69.0% exact match (EM) and 70.0% execution accuracy (EXEC) on the Spider development set, outperforming previous methods like RAT-SQL variants and BRIDGE+BERT.
- The model demonstrates superior performance on complex cases, such as correctly grouping by country instead of ID, and correctly ordering results by age in descending order.
- Case studies show RaSaP correctly parses ambiguous phrases like 'amc hornet sportabout (sw)' by preserving the full value as a single unit, avoiding erroneous tokenization.
- The use of ELECTRA as the backbone enables better discrimination of important vs. irrelevant tokens, reducing hallucination and misinterpretation.
- The semi-autoregressive decoder with structured sub-program generation leads to more accurate and semantically coherent SQL outputs.
- Even with a smaller backbone (ELECTRA-base), RaSaP achieves competitive results compared to larger models like T5-3B+PICARD, suggesting efficiency and effectiveness trade-offs can be optimized.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.