赞
踩
Text-to-SQL任务的输入是数据库D和自然语言问题Q,输出为对应的SQL查询语句Y。每一个样本是一个三元组,其中,数据库D={T(1),T(2),…,T(n)}, T(i)=name:{column(1),column(2),…,column(m)}。样例如下:
数据库D:{“中国城市”: {名称, 人口, 面积, 绿化率}, “2019年宜居城市”:{城市, 票数, 排名}}
问题Q:前10最宜居的城市有哪些,常住人口分别有多少?
SQL查询语句Y:Select T1.名称, T1.人口 From 中国城市 As T1 Join 2019年宜居城市 As T2 On T1.名称 = T2.城市 Order By 排名 Asc Limit 10
根据数据库中包含表的数量,语义解析数据集分为单表和多表两种模式;根据SQL查询语句的复杂度,分为简单和复杂两种模式,其中简单语句仅包含select和where从句,复杂语句包含group by、order by等高级从句。
数据集上的表现[1]
WikiSQL上的模型成绩
数据集上的表现[2]
Spider上的模型成绩
数据集上的表现[3]
数据集上的表现[4]
背景:比如问题中的model在多个表car_name和model_list的字段model、model_id中出现,应该链接到哪一个字段。比如问题中的car在多个表cars_data和car_names出现,应该链接到哪一个表。从而展开研究。
研究背景
预定义关系类型(来自:Text-to-SQL论文阅读笔记:RATSQL - 伊森的文章 - 知乎https://zhuanlan.zhihu.com/p/143400912
方法:对schema(表明、字段名)和question各个字之间拆成一个个token表示,然后token之间的关系由上图定义。通过RAT层,在自注意力公式上加入了相对位置向量表示token之间的关系。论文称为关系感知的自注意力,具体看论文。由此编码器encoder,就能把schema信息,以及question和schema的关系信息融合,解码器的部分采用另一个模型AST(抽象语法树),生成select的字段,select的表以及select的条件和操作。
模型框架(来自Text-to-SQL论文阅读笔记:RATSQL - 伊森的文章 - 知乎https://zhuanlan.zhihu.com/p/143400912
模型表现:
Spider的实验结果
Spider dev上的错误分析:
(1)18%的错误预测是因为SQL表达不同,而执行结果是正确的。如ORDER BY C LIMIT 1 vs. SELECT MIN(C)
(2)39%的错误预测是因为select错误/缺失/多余的column。按论文观点,部分错误较难解决,因为一些questions中并未明确所需column。
(3)29%的错误是因为WHERE语句不完整。
背景:虽然RATSQL等融合了关系信息,但目前仍有两点限制,一是无法发现有效的源路径(RATSQL是预先定义好的关系),二是相邻两个点,无法区分是不是local,即同一个表内。
研究背景
方法:编码器用的是双塔的关系图注意力网络(即不直接cross交互的分别编码的结构,推理速度更快),去编码scheme的表信息、字段信息以及问题信息。然后同样使用和RATSQL一样的解码器AST抽象语法树。两个方法的区别在于编码器,前者是相对位置编码的自注意力层,后者是图注意力层,均融合了关系信息,才利用了Glove嵌入,和PLM的迁移学习能力。从实验结果上看后者表示能力更强。
模型框架
表现:文本详细列出与此前的SOTA(RATSQL)在不同难度问题上的比较。
Spider的实验结果(与RATSQL比较)
背景:结构化知识落地(SKG)意在使用结构化知识以完成用户请求,例如在数据库(database)上解析语义和在知识库(Knowledge-base)基础上回答问题。由于SKG任务的输入和输出是异构的,被单独研究。由于输入输出异构,导致各种特定的编码器、解码器产生。这限制了对SKG系统地研究。
研究背景
方法:基于T5(encoder-decoder的PLM),规范不同的结构输入为4类,规范输出为4类。把结构化输入平铺成一个文本序列。21个SKG任务被分为语义解析(Text2SQL)、QA、Data2Text、对话、事实判断、SQL2Text
模型方法
表现:
实验结果
测试了几个Spider的样本,其中,request是模型输入,answer是模型的输出
- 简单(单表):
- =====❓Request===== what is the minimum, average, and maximum age of all singers from France?; structed knowledge: | concert_singer | stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country ( France ) , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id
- ===== Answer===== ['select min(age), avg(age), max(age) from singer where country = "France"']`
-
- 中等(多表)
- =====❓Request===== Show the stadium name and the number of concerts in each stadium .; structed knowledge: | concert_singer | stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country ( France ) , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id
- ===== Answer===== ['select t2.name, count(*) from concert as t1 join stadium as t2 on t1.stadium_id = t2.stadium_id group by t1.stadium_id']
-
- 中等(单表、聚合)
- =====❓Request===== Which year has most number of concerts ?; structed knowledge: | concert_singer | stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country ( France ) , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id
- ===== Answer===== ['select year from concert group by year order by count(*) desc limit 1']
-
- 困难(多表、聚合)
- =====❓Request===== Show the stadium name and capacity with most number of concerts in year 2014 or after .; structed knowledge: | concert_singer | stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country ( France ) , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id
- ===== Answer===== ['select t2.name, t2.capacity from concert as t1 join stadium as t2 on t1.stadium_id = t2.stadium_id where t1.year >= 2014 group by t1.stadium_id order by count(*) desc limit 1']
中文单表数据集TableQA
中文Text2SQL任务数据集
参考:
[1]https://paperswithcode.com/sota/semantic-parsing-on-wikisql-1
[2]https://paperswithcode.com/sota/semantic-parsing-on-wikitablequestions
[3]https://paperswithcode.com/sota/semantic-parsing-on-spider
[4]https://taolusi.github.io/CSpider-explorer/
[5]https://aclanthology.org/2020.acl-main.677/
[6]https://arxiv.org/pdf/2201.05966v3.pdf
[7]https://github.com/nudtnlp/tianchi-nl2sql-top1
[8]https://aistudio.baidu.com/aistudio/competition/detail/47/0/datasets
[9]https://arxiv.org/pdf/2106.0109
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。