RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
Haoyang Li1,2,3, Jing Zhang1,2,3, Cuiping Li1,2,3, Hong Chen1,2,3 Jing Zhang is the corresponding author.
Abstract
One of the recent best attempts at Text-to-SQL is the pre-trained language model. Due to the structural property of the SQL queries, the seq2seq model takes the responsibility of parsing both the schema items (i.e., tables and columns) and the skeleton (i.e., SQL keywords). Such coupled targets increase the difficulty of parsing the correct SQL queries especially when they involve many schema items and logic operators. This paper proposes a ranking-enhanced encoding and skeleton-aware decoding framework to decouple the schema linking and the skeleton parsing. Specifically, for a seq2seq encoder-decode model, its encoder is injected by the most relevant schema items instead of the whole unordered ones, which could alleviate the schema linking effort during SQL parsing, and its decoder first generates the skeleton and then the actual SQL query, which could implicitly constrain the SQL parsing. We evaluate our proposed framework on Spider and its three robustness variants: Spider-DK, Spider-Syn, and Spider-Realistic. The experimental results show that our framework delivers promising performance and robustness. Our code is available at https://github.com/RUCKBReasoning/RESDSQL.
中文速览
把自然语言问题自动转成SQL查询(Text-to-SQL)时,模型需要同时完成两件事:找到问题里提到的数据库表和字段(schema linking),以及推断出SQL的逻辑骨架(skeleton parsing),两者纠缠在一起让学习变得很困难。作者提出了RESDSQL框架,把这两个目标拆开来做:先用一个额外训练的交叉编码器(cross-encoder)对所有表和字段打分排名,只把最相关的少数几个输入给seq2seq模型,减轻模型自己做schema链接的负担;再让解码器先生成SQL骨架(比如"SELECT _ FROM _ WHERE _"),再在骨架的引导下填入具体的表名、字段名,从而隐式约束SQL的生成过程。在主流难度最高的Text-to-SQL基准Spider及其三个鲁棒性变体(Spider-DK、Spider-Syn、Spider-Realistic)上,RESDSQL达到了当时的最优性能,并表现出更强的泛化鲁棒性,验证了"解耦"这一思路的有效性,为后续复杂SQL生成研究提供了一个简洁且有竞争力的基线框架。
原文 arXiv:2302.05965;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2302.05965v3