In recent years, there has been growing interest in text-to-SQL translation, which is the task of converting natural language questions into executable SQL queries. This technology is important for its potential to democratize data extraction from databases. However, some of its key hurdles include domain generalisation, which is the ability to adapt to previously unseen databases, and alignment of natural language questions with the corresponding SQL queries. To overcome these challenges, we introduce SQLformer, a novel Transformer architecture specifically crafted to perform text-to-SQL translation tasks. Our model predicts SQL queries as abstract syntax trees (ASTs) in an autoregressive way, incorporating structural inductive bias in the encoder and decoder layers. This bias, guided by database table and column selection, aids the decoder in generating SQL query ASTs represented as graphs in a Breadth-First Search canonical order. Comprehensive experiments illustrate the state-of-the-art performance of SQLformer in the challenging text-to-SQL Spider benchmark. Our implementation is available at https://github.com/AdrianBZG/SQLformer.
翻译:近年来,文本到SQL翻译任务(将自然语言问题转换为可执行的SQL查询)日益受到关注。该技术因其能够推动数据库数据提取的民主化而具有重要意义。然而,该领域的关键挑战包括域泛化(即适应未见过的数据库的能力)以及自然语言问题与对应SQL查询的对齐。为克服这些难题,我们提出SQLformer——一种专为文本到SQL翻译任务设计的新型Transformer架构。该模型以自回归方式将SQL查询预测为抽象语法树(AST),并在编码器与解码器层中融入结构性归纳偏置。这种由数据库表及列选择引导的偏置,有助于解码器以广度优先搜索规范序的图形式生成SQL查询AST。综合实验表明,SQLformer在具有挑战性的文本到SQL Spider基准测试中达到了顶尖性能。我们的实现代码已开源至https://github.com/AdrianBZG/SQLformer。