SeqGenSQL - A Robust Sequence Generation Model for Structured
https://arxiv.org/abs/2011.03836
Implementation: https://github.com/louis-li/SeqGenSQL
Abstract
- 弱监督:直接将自然语言问题翻译成SQL语句(监督学习:先将问题转换成中间逻辑形式(LF)再生成查询)
- 预训练模型:T5
- 性能:在WikiSQL 测试集上达到了90.5%的执行精度,比先前最先进的弱监督系统 Hard-EM(A discrete hard em approach for weakly supervised question answering)高出6.6%
3 Model
3.1 Question Augmentation
- 编码column type
⟨ b o s ⟩ Natural question ⟨ s e p ⟩ table-id ⟨ s e p ⟩ col1 ⟨ s e p ⟩ type1 ⟨ s e p ⟩ col2 ⟨ s e p ⟩ type2 ⟨ s e p ⟩ ...coln ⟨ e o s ⟩ \left \langle bos \right \rangle \text{Natural question} \left \langle sep \right \rangle \text{table-id}\left \langle sep \right \rangle \text{col1}\left \langle sep \right \rangle \text{type1}\left \langle sep \right \rangle \text{col2}\left \langle sep \right \rangle \text{type2}\left \langle sep \right \rangle \text{...coln}\left \langle eos \right \rangle ⟨bos⟩Natural question⟨sep⟩table-id⟨sep⟩col1⟨sep⟩type1⟨sep⟩col2⟨sep⟩type2⟨sep⟩...coln⟨eos⟩ - 编码column value(对数据表内容采样,作为input的一部分)
3.2 Reversed Trainer Model(Data Augmentation)
- 训练逆向训练器模型20个epoch,从提供的表中随机生成SQL语句,通过逆向模型预测自然语言问题(silver data)。
随机生成SQL语句:- Replacing Select column from training data
- Replacing Condition value for where clause
- 使用这些 silver data 进一步微调主模型。
- 除了原来的56,355个训练样本外,额外生成了250,000个训练样本。
3.3 Gated Extraction Network
- 背景:输出是
由解码器生成(联想)
或从编码器提取
- 原因:联想可能导致预测出错,因此减少联想并鼓励提取
- 实现:与指针生成网络类似,在编码器和解码器之间实现了一个交叉层注意层。从注意层创建一个门层来控制输出是由解码器生成还是从编码器提取。
O f i n a l = ( 1 − P e x t ) ∗ O g e n + P e x t ∗ O e x t O_{final} = (1 − P_{ext}) ∗ O_{gen} + P_{ext} ∗ O_{ext} Ofinal=(1−Pext)∗Ogen+Pext∗Oext
3.4 Execution Guided Inference
执行引导模型将生成的SQL语句发送到SQL数据库引擎,并在数据库引擎返回运行错误(run-time errors)或空结果(empty result)时进行调整。