[论文解读] Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learning
Seq2SQL 通过利用 SQL 结构并在环执行奖励下训练策略,将自然语言问题转换为 SQL 查询,在 WikiSQL 上达到最先进的结果。
A significant amount of the world's knowledge is stored in relational databases. However, the ability for users to retrieve facts from a database is limited due to a lack of understanding of query languages such as SQL. We propose Seq2SQL, a deep neural network for translating natural language questions to corresponding SQL queries. Our model leverages the structure of SQL queries to significantly reduce the output space of generated queries. Moreover, we use rewards from in-the-loop query execution over the database to learn a policy to generate unordered parts of the query, which we show are less suitable for optimization via cross entropy loss. In addition, we will publish WikiSQL, a dataset of 80654 hand-annotated examples of questions and SQL queries distributed across 24241 tables from Wikipedia. This dataset is required to train our model and is an order of magnitude larger than comparable datasets. By applying policy-based reinforcement learning with a query execution environment to WikiSQL, our model Seq2SQL outperforms attentional sequence to sequence models, improving execution accuracy from 35.9% to 59.4% and logical form accuracy from 23.4% to 48.3%.
研究动机与目标
- 激发数据库的自然语言接口,降低查询关系型数据的门槛。
- 提出一种利用 SQL 结构来剪枝输出空间的神经模型。
- 使用在环查询执行奖励的强化学习来处理无序的 WHERE 子句生成。
- 发布 WikiSQL,这是一个包含 SQL 查询和表模式的大型现实世界的 NL 问题数据集。
提出的方法
- 使用一个增强的指针网络,通过从输入中选择标记(列、问题和 SQL 词汇表)来生成 SQL。
- 将 SQL 分解为三个组成部分:聚合操作符、SELECT 列和 WHERE 子句;用交叉熵损失监督聚合和 SELECT。
- 使用环内查询执行的奖励,通过策略梯度训练 WHERE 子句,以处理无序条件。
- 利用 SQL 结构来剪枝输出空间,并改善对稀有词汇/列的生成。
- 使用混合目标进行训练,结合 L_agg、L_sel(交叉熵)和 L_whe(强化学习)。
- 提供 WikiSQL 数据集(80,654 个示例,覆盖 24,241 张表)以及用于训练与评估的执行引擎。
实验结果
研究问题
- RQ1一个神经模型是否能够从未见过的表架构的自然语言问题中生成正确的 SQL 查询?
- RQ2将 SQL 结构和强化学习结合起来是否比现有语义分析器提升执行准确性?
- RQ3一个大型现实世界的 NLQ-to-SQL 数据集(WikiSQL)在实现跨表泛化方面,与先前的语义解析数据集相比如何?
主要发现
| 模型 | Dev Acc_lf | Dev Acc_ex | Test Acc_lf | Test Acc_ex |
|---|---|---|---|---|
| 基线(Dong & Lapata,2016) | 23.3% | 37.0% | 23.4% | 35.9% |
| 增强指针网络 | 44.1% | 53.8% | 43.3% | 53.3% |
| Seq2SQL(无 RL) | 48.2% | 58.1% | 47.4% | 57.1% |
| Seq2SQL | 49.5% | 60.8% | 48.3% | 59.4% |
- Seq2SQL 在 WikiSQL 上的执行准确率超过了时下最先进的语义解析器(从 35.9% 提升到 59.4%)。
- Seq2SQL 还提高了逻辑形式准确率(从 23.4% 提升到 48.3%)。
- 增强指针网络(不含 RL)在执行准确率上已比基线高出 17.4%。
- 引入 SQL 结构(三部分分解)再带来额外 3.8% 的提升。
- 在 WHERE 子句上的策略梯度 RL 额外带来 2.3% 的提升。
- 在 COUNT 操作符上,Seq2SQL 的精确率、召回率和 F1 分别高于增强指针基线(分别为 72.6、66.2、69.2)。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。