Table of Contents
Fetching ...

Schema-Aware Multi-Task Learning for Complex Text-to-SQL

Yangjun Wu, Han Wang

TL;DR

A schema-aware multi-task learning framework (named MTSQL) for complicated SQL queries, which designs a schema linking discriminator module to distinguish the valid question-schema linkings, which explicitly instructs the encoder by distinctive linking relations to enhance the alignment quality.

Abstract

Conventional text-to-SQL parsers are not good at synthesizing complex SQL queries that involve multiple tables or columns, due to the challenges inherent in identifying the correct schema items and performing accurate alignment between question and schema items. To address the above issue, we present a schema-aware multi-task learning framework (named MTSQL) for complicated SQL queries. Specifically, we design a schema linking discriminator module to distinguish the valid question-schema linkings, which explicitly instructs the encoder by distinctive linking relations to enhance the alignment quality. On the decoder side, we define 6-type relationships to describe the connections between tables and columns (e.g., WHERE_TC), and introduce an operator-centric triple extractor to recognize those associated schema items with the predefined relationship. Also, we establish a rule set of grammar constraints via the predicted triples to filter the proper SQL operators and schema items during the SQL generation. On Spider, a cross-domain challenging text-to-SQL benchmark, experimental results indicate that MTSQL is more effective than baselines, especially in extremely hard scenarios. Moreover, further analyses verify that our approach leads to promising improvements for complicated SQL queries.

Schema-Aware Multi-Task Learning for Complex Text-to-SQL

TL;DR

A schema-aware multi-task learning framework (named MTSQL) for complicated SQL queries, which designs a schema linking discriminator module to distinguish the valid question-schema linkings, which explicitly instructs the encoder by distinctive linking relations to enhance the alignment quality.

Abstract

Conventional text-to-SQL parsers are not good at synthesizing complex SQL queries that involve multiple tables or columns, due to the challenges inherent in identifying the correct schema items and performing accurate alignment between question and schema items. To address the above issue, we present a schema-aware multi-task learning framework (named MTSQL) for complicated SQL queries. Specifically, we design a schema linking discriminator module to distinguish the valid question-schema linkings, which explicitly instructs the encoder by distinctive linking relations to enhance the alignment quality. On the decoder side, we define 6-type relationships to describe the connections between tables and columns (e.g., WHERE_TC), and introduce an operator-centric triple extractor to recognize those associated schema items with the predefined relationship. Also, we establish a rule set of grammar constraints via the predicted triples to filter the proper SQL operators and schema items during the SQL generation. On Spider, a cross-domain challenging text-to-SQL benchmark, experimental results indicate that MTSQL is more effective than baselines, especially in extremely hard scenarios. Moreover, further analyses verify that our approach leads to promising improvements for complicated SQL queries.
Paper Structure (29 sections, 8 equations, 3 figures, 8 tables)

This paper contains 29 sections, 8 equations, 3 figures, 8 tables.

Figures (3)

  • Figure 1: An example from Spider dataset illustrates the existence of valid and invalid alignment to the question word 'name', caused by greedy string matching in the procedure of schema linking.
  • Figure 2: Two error cases to illustrate the obstacles to choosing the correct or complete tables and columns when generating the complicated SQL with JOIN.
  • Figure 3: Main MTSQL Architecture. MTSQL contains four core modules: Question-Schema Encoder (QSE), Schema Linking Discriminator module (SLD), Operator-centric Triple Extractor (OTE), SQL Syntax Tree Generation Module (SQLG). In the initialization stage, we apply QSE based on Roberta Liu2019 with GRAPPA yu2021grappa to obtain the joint question-schema feature vector $\chi$. Meanwhile, the correct linkings are filtered by SLD. To better represent the distinct relations among input nodes, the input embedding $\chi$ and the learnable relation matrix $R$ are calculated together during the schema-aware self-attention computation process. At the decoding phase, OTE extracts the significant operator-centric triples (e.g., (table, column, order_by)). Subsequently, we establish a rule set as grammar constraints by the predicted triples, which drives the bottom-up SQLG to filter the correct SQL operators and schema items. Finally, the SQL sub-trees are synthesized like beam search, and we produce the top-1 SQL tree as the final SQL.