Ranking-enhanced Encoding plus a Skeleton-aware
Decoding framework for Text-to-SQL(RESDSQL)[1] is a simple, but powerful Text2SQL model.
As its name suggests, it is composed of two main components:
A descent understanding on Transformers is recommended for the subsequent sections.
Instead of injecting all schema items, only the most relevant schema items in the input of the encoder will be considered.
For this purpose, cross-encoder is used to classify the tables and columns simultaneously and then rank them based on their probabilities. Based on the ranking order, on one hand,
we filter out the irrelevant schema items
The input is represented as follows:
Where
Some questions only mention the column name rather than the table
name. This may compromise the ranking of the tables, since in that case, the table is still required in the SQL query.
Question: What are flight numbers of flights departing from City "Aberdeen"?
Schema:
Note: Table airports
is required since its column city
is mentionned
To mitigate this, we regroup the column outputs of
To reduce the learning difficulty, the original SQL queries are normalized before training by:
ASC
keyword after the ORDER BY
clause if it does not specify the order.AS
clause and replacing all table aliases with their original namesBased on the normalized SQL queries, their skeletons will be extracted which only contain
SQL keywords and slots. Specifically, given a normalized SQL query, only the the keywords will be left, and the other tokens will be replace by a symbol.
Normalized SQL:
select files.duration, files.file size, files.formats
from files join song on files.f id = song.f id where
song.genre is = ‘pop’ order by song.song name asc
SQL Skeleton:
select _ from _ where _ order by _ asc
Since the decoder is not constrained with SQL grammar, the model is susceptible to generate illegal SQL queries.