RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parsers
Bailin Wang University of Edinburgh、Richard Shin UC Berkeley \ANDXiaodong Liu Oleksandr Polozov Matthew Richardson Microsoft Research, Redmond Equal contribution. Order decided by a coin toss. Work done during an internship at Microsoft Research. Work done partly affiliated with Microsoft Research. Now at Microsoft:
Abstract
When translating natural language questions into SQL queries to answer questions from a database,contemporary semantic parsing models struggle to generalize to unseen database schemas.The generalization challenge lies in (a) encoding the database relations in an accessible way for the semanticparser, and (b) modeling alignment between database columns and their mentions in a given query.We present a unified framework, based on the relation-aware self-attention mechanism, to address schema encoding,schema linking, and feature representation within a text-to-SQL encoder.On the challenging Spider dataset this framework boosts the exact match accuracy to 57.2%, surpassing its best counterparts by 8.7% absolute improvement.Further augmented with BERT, it achieves the new state-of-the-art performance of 65.6% on the Spider leaderboard.In addition, we observe qualitative improvements in the model’s understanding of schema linking and alignment.Our implementation will be open-sourced at https://github.com/Microsoft/rat-sql.
中文速览
自然语言转SQL(text-to-SQL)面临的核心难题是:模型训练时见过的数据库在测试时全部换新,如何让模型理解从未见过的数据库结构,并准确识别用户问题中的词语究竟指向哪张表、哪个字段。为此,研究者提出了RAT-SQL框架,其核心思想是用"关系感知自注意力(relation-aware self-attention)"机制,把问题中的词语和数据库的表、字段统一放进同一个编码器里联合建模,同时将外键、主键等已知数据库结构关系也以显式"关系向量"的形式注入注意力计算,让模型在全局推理的同时兼顾结构约束。在公认最难的Spider基准测试上,RAT-SQL将精确匹配准确率提升至57.2%,比此前最佳方法绝对提升8.7%;结合预训练模型BERT后进一步达到65.6%的新纪录。这项工作的重要性在于,它用一个统一框架同时解决了数据库结构编码和问题-字段对齐两大难题,为让普通用户用自然语言查询任意数据库这一目标迈出了关键一步。
原文 arXiv:1911.04942;中英对照 + 大白话阅读 https://aha.fim.ai/paper/1911.04942v5