RGISQL: Integrating Refined Grammatical Information into Relational Graph Neural Network for Text-to-SQL Task
Abstract
:1. Introduction
- For text-to-SQL tasks, we propose RGISQL, which incorporates grammatical information and utilizes segmentation processing to effectively handle long queries. It represents grammatical information in natural language questions by using a grammatical dependency tree, refining the relationships between different words in the question. This approach enhances the model’s understanding of grammatical information and improves its generalizability.
- We introduce dynamic edge attention pooling in the Relational Graph Attention Network (RGAT), which reduces the over-coupling of edge embeddings during training. Additionally, we incorporate recursive decoding with the ASTormer decoder, thereby enhancing the model’s expressiveness and performance.
- We conduct extensive experiments on the Spider and Spider-Syn datasets to evaluate RGISQL, and the results indicate that RGISQL outperforms baseline methods. Moreover, we perform ablation studies across multiple dimensions, demonstrating the effectiveness of the proposed approach.
2. Related Studies
3. Background
3.1. Problem Definition
3.2. Graph Attention Network
3.3. Relation-Aware Transformer
4. Model
4.1. Interaction Graph
4.1.1. Schema Encoding
4.1.2. Schema Linking
4.1.3. Segmentation Processing
4.2. Question Relation Analysis
4.3. Input Module
4.4. Relational Graph Attention Network
4.5. Reduce Coupling
4.6. RAT Layer
4.7. Decoder
5. Experiment
5.1. Experimental Setup
5.1.1. Dataset
5.1.2. Evaluation Metrics
5.2. Implementation
5.3. Baseline Models
- RAT-SQL [7] is a relational schema encoding model.
- ShadowGNN [20] addresses schemata at both the abstract and semantic levels to reduce inter-domain discrepancies.
- LGESQL [8] is a Text-to-SQL model enhanced by line graph embedding, which classifies relations into local and non-local categories.
- RASAT [9] incorporates the dependency structure of natural language questions and introduces multi-head relation-aware attention into the T5 model.
- S2SQL [31] incorporates syntactic information into the model and decouples constraints.
5.4. Main Result
5.5. Ablation Experiments
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Deng, X.; Awadallah, A.H.; Meek, C.; Polozov, O.; Sun, H.; Richardson, M. Structure-Grounded Pretraining for Text-to-SQL. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Online, 6–11 June 2021. [Google Scholar]
- Kamath, A.; Das, R. A Survey on Semantic Parsing. arXiv 2018, arXiv:1812.00978. [Google Scholar]
- Yu, T.; Zhang, R.; Yang, K.; Yasunaga, M.; Wang, D.X.; Li, Z.F.; Ma, J.; Li, I.; Yao, Q.N.; Roman, S.; et al. Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, Brussels, Belgium, 31 October–4 November 2018. [Google Scholar]
- Gan, Y.J.; Chen, X.Y.; Huang, Q.P.; Purver, M.; John, W.; Xie, J.X.; Huang, P.S. Towards Robustness of Text-to-SQL Models against Synonym Substitution. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), Online, 1–6 August 2021. [Google Scholar]
- Scarselli, F.; Gori, M.; Tsoi, A.C.; Hagenbuchner, M.; Monfardini, G. The Graph Neural Network Model. IEEE Trans. Neural Netw. 2009, 20, 61–80. [Google Scholar] [CrossRef] [PubMed]
- Schlichtkrull, M.; Kipf, T.N.; Bloem, P.; Berg, R.V.D.; Titov, I.; Welling, M. Modeling Relational Data with Graph Convolutional Networks. In Proceedings of the 15th International Semantic Web Conference, Heraklion, Greece, 3–7 June 2018. [Google Scholar]
- Wang, B.L.; Shin, R.; Liu, X.D.; Polozov, O.; Richardson, M. RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parsers. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, Online, 5–10 July 2021. [Google Scholar]
- Cao, R.S.; Chen, L.; Chen, Z.; Zhao, Y.B.; Zhu, S.; Yu, K. LGESQL: Line Graph Enhanced Text-to-SQL Model with Mixed Local and NonLocal Relations. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, Online, 1–6 August 2021. [Google Scholar]
- Qi, J.X.; Tang, J.Y.; He, Z.W.; Wan, X.P.; Cheng, Y.; Zhou, C.H.; Wang, X.B.; Zhang, Q.S.; Lin, Z.H. RASAT: Integrating Relational Structures into Pretrained Seq2Seq Model for Text-to-SQL. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, Abu Dhabi, United Arab Emirates, 7–11 December 2022. [Google Scholar]
- Zelle, J.M.; Mooney, R.J. Learning to parse database queries using inductive logic programming. In Proceedings of the National Conference on Artificial Intelligence, Philadelphia, PA, USA, 4–9 August 1996. [Google Scholar]
- Zettlemoyer, L.S.; Collins, M. Learning to map sentences to logical form: Structured classification with probabilistic categorial grammars. In Proceedings of the Twenty-First Conference on Uncertainty in Artificial Intelligence, Arlington, VA, USA, 22–26 July 2005. [Google Scholar]
- Xu, X.J.; Liu, C.; Song, D. SQLNet: Generating Structured Queries from Natural Language Without Reinforcement Learning. arXiv 2017, arXiv:1711.04436. [Google Scholar]
- Yu, T.; Yasunaga, M.; Yang, K.; Zhang, R.; Wang, D.X.; Li, Z.F.; Radev, D. SyntaxSQLNet: Syntax Tree Networks for Complex and Cross-Domain Text-to-SQL Task. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, Brussels, Belgium, 31 October–4 November 2018. [Google Scholar]
- Choi, D.H.; Shin, M.C.; Kim, E.G.; Shin, D.R. RYANSQL: Recursively Applying Sketch-Based Slot Fillings for Complex Text-to-SQL in Cross-Domain Databases; Computational Linguistics: Cambridge, MA, USA, 2021; pp. 309–332. [Google Scholar]
- Hui, B.Y.; Shi, X.; Geng, R.Y.; Li, B.H.; Li, Y.B.; Sun, J.; Zhu, X.D. Improving Text-to-SQL with Schema Dependency Learning. arXiv 2021, arXiv:2103.04399. [Google Scholar]
- Kelkar, A.; Relan, R.; Bhardwaj, V.; Vaichal, S.; Relan, P.A. Bertrand-DR: Improving Text-to-SQL using a Discriminative Reranker. arXiv 2020, arXiv:2002.00557. [Google Scholar]
- Rubin, O.; Berant, J. SmBoP: Semi-autoregressive Bottomup Semantic Parsing. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Online, 6–11 June 2021. [Google Scholar]
- Bogin, B.; Berant, J.; Gardner, M. Representing Schema Structure with Graph Neural Networks for Text-to-SQL Parsing. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, Florence, Italy, 28 July–2 August 2019. [Google Scholar]
- Scholak, T.; Li, R.; Bahdanau, D.; Vries, H.D.; Pal, C. DuoRAT: Towards Simpler Text-to-SQL Models. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Online, 6–11 June 2021. [Google Scholar]
- Chen, Z.; Chen, L.; Zhao, Y.B.; Cao, R.S.; Xu, Z.H.; Zhu, S.; Yu, K. ShadowGNN: Graph Projection Neural Network for Text-to-SQL Parser. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Online, 6–11 June 2021. [Google Scholar]
- Veličković, P.; Cucurull, G.; Casanova, A.; Romero, A.; Lio, P.; Bengio, Y.S. Graph attention networks. arXiv 2017, arXiv:1710.10903. [Google Scholar]
- Shaw, P.; Uszkoreit, J.; Vaswani, A. Self-Attention with Relative Position Representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, New Orleans, LO, USA, 1–6 June 2018. [Google Scholar]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, Red Hook, NY, USA, 4–9 December 2017. [Google Scholar]
- Guo, J.Q.; Zhan, Z.C.; Gao, Y.; Xiao, Y.; Lou, J.G.; Liu, T.; Zhang, D.M. Towards Complex Text-to-SQL in Cross-Domain Database with Intermediate Representation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, Florence, Italy, 28 July–2 August 2019. [Google Scholar]
- Lei, W.Q.; Wang, W.X.; Ma, Z.X.; Gan, T.; Lu, W.; Kan, M.Y.; Chua, T.S. Re-examining the Role of Schema Linking in Text-to-SQL. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing, Online, 16–20 November 2020. [Google Scholar]
- Ishiwatari, T.C.; Yasuda, Y.; Miyazaki, T.; Goto, J. Relation-aware Graph Attention Networks with Relational Position Encodings for Emotion Recognition in Conversations. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing, Online, 16–20 November 2020. [Google Scholar]
- Wang, Y.; Sun, Y.B.; Liu, Z.W.; Sarma, S.E.; Bronstein, M.; Solomon, J.M. Dynamic Graph CNN for Learning on Point Clouds; Association for Computing Machinery: New York, NY, USA, 2019; pp. 1–12. [Google Scholar]
- Cao, R.; Zhang, H.; Xu, H. ASTormer: An AST Structure-aware Transformer Decoder for Text-to-SQL. arXiv 2023, arXiv:2310.18662. [Google Scholar]
- Peng, Q.; Zhang, Y.H.; Zhang, Y.H.; Bolton, J.; Manning, C.D. Stanza: A Python Natural Language Processing Toolkit for Many Human Languages. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, Online, 5–10 July 2020. [Google Scholar]
- Clark, K.; Luong, M.T.; Le, Q.V.; Manning, C.D. Electra: Pre-training text encoders as discriminators rather than generators. In Proceedings of the International Conference on Learning Representations. International Conference on Learning Representations, Online, 26 April–1 May 2020. [Google Scholar]
- Hui, B.Y.; Geng, R.Y.; Wang, L.H.; Qin, B.W.; Li, Y.Y.; Li, B.W.; Sun, J.; Li, Y.B. S2SQL: Injecting Syntax to Question-Schema Interaction Graph Encoder for Text-to-SQL Parsers. In Proceedings of the Association for Computational Linguistics: ACL 2022, Dublin, Ireland, 22–27 May 2022. [Google Scholar]
- Lin, X.V.; Socher, R.; Xiong, C.M. Bridging textual and tabular data for crossdomain text-to-SQL semantic parsing. In Proceedings of the Association for Computational Linguistics, Online, 5–10 July 2020. [Google Scholar]
- Huang, J.; Wang, Y.; Wang, Y.; Dong, Y.; Xiao, Y. Relation Aware Semi-autoregressive Semantic Parsing for NL2SQL. arXiv 2021, arXiv:2108.00804. [Google Scholar]
- Gan, Y.J.; Chen, X.Y.; Xie, J.X.; Purver, M.; Woodward, J.R.; Drake, J.; Zhang, Q.F. Natural SQL: Making SQL easier to infer from natural language specifications. In Proceedings of the Association for Computational Linguistics, Punta Cana, Dominican Republic, 6–11 June 2021. [Google Scholar]
Type | Head H | Tail T | Edge Label | Description |
---|---|---|---|---|
Schema encoding | PRIMARY-KEY | T is the primary key for H | ||
BELONGS-TO | T is a column in H | |||
FOREIGN-KEY | H is the foreign key for T | |||
Schema linking | EXACT-MATCH | H is part of T, and T is a span of question | ||
PARTIAL-MATCH | H is part of T, and question does not contain T | |||
Question relation | Q-Q-DIST | The distance relationship between H and T | ||
Q-Q-DEPENCY | H has a grammatical dependency with T | |||
Segmentation | INCLUDE | Seg has T or C |
Hyperparameters | Values |
---|---|
PLM | 512 |
GNN layers | 8 |
Dropout rate | 0.1 |
Hidden state dimension | 512 |
Inner layer dimension | 1024 |
Relation embedding | 128 |
Node embedding | 64 |
Dropout probability | 0.2 |
Models | Dev | Test |
---|---|---|
Global-GNN [18] | 52.7 | 47.4 |
IRNet [24] | 64.9 | 55.0 |
RATSQL+BERT [7] | 69.7 | 65.6 |
ShadowGNN+RoBERTa-large [20] | 72.3 | 66.1 |
RATSQL+ELECTRA+ASTormer [28] | 74.6 | - |
RASAT+PICARD [9] | 75.3 | 70.9 |
LGESQL+ELECTRA [8] | 75.1 | 72.0 |
S2SQL+ELECTRA [31] | 76.4 | 72.1 |
RGISQL+ELECTRA | 77.2 | 73.6 |
Models | Dev | Test |
---|---|---|
BRIDGE+BERT [32] | 70.3 | 68.3 |
RaSaP+ELECTRA [33] | - | 70.0 |
SmBoP+GraPPa [17] | 75.0 | 71.1 |
RATSQL+GAP+NatSQL [34] | 75.0 | 73.3 |
RASAT+PICARD [9] | 80.5 | 75.5 |
RGISQL+ELECTRA | 82.6 | 77.3 |
Approach | Easy | Medium | Hard | Extra Hard |
---|---|---|---|---|
LGESQL [8] | 86.3 | 69.5 | 61.5 | 41.0 |
LGESQL+ELECTRA [8] | 91.5 | 76.7 | 66.7 | 48.8 |
RGISQL | 86.5 | 69.8 | 63.0 | 42.3 |
RGISQL+ELECTRA | 93.0 | 77.0 | 67.7 | 50.5 |
Models | Acc |
---|---|
Global-GNN [18] | 23.6 |
IRNet [24] | 28.4 |
RATSQL+Grappa [7] | 49.1 |
S2SQL+Grappa [30] | 51.4 |
RGISQL+Grappa | 52.6 |
Models | Dev |
---|---|
RAT+RoBERTa | 69.7 |
S2SQL+RoBERTa | 71.4 |
RGISQL+RoBERTa | 72.0 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Li, S.; He, Y.; Ao, L.; Qi, R. RGISQL: Integrating Refined Grammatical Information into Relational Graph Neural Network for Text-to-SQL Task. Appl. Sci. 2024, 14, 10359. https://doi.org/10.3390/app142210359
Li S, He Y, Ao L, Qi R. RGISQL: Integrating Refined Grammatical Information into Relational Graph Neural Network for Text-to-SQL Task. Applied Sciences. 2024; 14(22):10359. https://doi.org/10.3390/app142210359
Chicago/Turabian StyleLi, Shuiyan, Yaozhen He, Longhao Ao, and Rongzhi Qi. 2024. "RGISQL: Integrating Refined Grammatical Information into Relational Graph Neural Network for Text-to-SQL Task" Applied Sciences 14, no. 22: 10359. https://doi.org/10.3390/app142210359
APA StyleLi, S., He, Y., Ao, L., & Qi, R. (2024). RGISQL: Integrating Refined Grammatical Information into Relational Graph Neural Network for Text-to-SQL Task. Applied Sciences, 14(22), 10359. https://doi.org/10.3390/app142210359