gap text2sql
1.0.0
我们AAAI 2021论文的代码和模型
[2020/02/05]支持在自己的数据库和查询上运行模型。查看笔记本。
最近,通过利用大规模文本语料库来培训具有自我监督的学习目标(例如蒙版语言模型(MLM))的大规模神经语言模型,对学习各种NLP任务的上下文表示有重大兴趣。但是,基于一项试点研究,当将它们应用于文本到SQL语义解析器时,我们会观察到现有通用语言模型的三个问题:无法检测到列表中的列提及,无法从单元格值中推断列提及,并且无法构成复杂的SQL查询。为了减轻这些问题,我们提出了一个模型预训练框架,即生成增强的预训练(GAP),该框架共同学习了通过利用生成模型生成预训练数据的自然语言话语和表格模式的表示。 GAP模型经过2m tustrance-Schema对和30k Tusterance-Schema-Sql三元组的训练,其发音是由生成模型产生的。基于实验结果,利用差距模型作为表示编码器的神经语义解析器获得了蜘蛛和标准至SQL基准的新最新结果。
conda create --name gap-text2sql python=3.7
source activate gap-text2sql
conda install pytorch=1.5 cudatoolkit=10.2 -c pytorch
pip install -r requirements.txt
python -c " import nltk; nltk.download('stopwords'); nltk.download('punkt') "pip install gdown
cd rat-sql-gap
gdown --id 1_AckYkinAnhqmRQtGsQgUKAnTHxxX5J0
unzip spider.zip
bash data/spider/generate.sh ./spidermkdir data/spider-bart
cp ./spider/tables.json data/spider-bart/
cp ./spider/train_spider.json data/spider-bart/
cp ./spider/train_others.json data/spider-bart/
cp ./spider/dev.json data/spider-bart/
ln -s $( pwd ) /spider/database data/spider-bart/databasemkdir third_party
wget http://nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip
unzip stanford-corenlp-full-2018-10-05.zip -d third_party/ pushd third_party/stanford-corenlp-full-2018-10-05
nohup java -mx4g -cp " * " edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 8999 -timeout 15000 > server.log &
popdmkdir -p logdir/bart_run_1/bs = 12 , lr = 1.0e-04 , bert_lr = 1.0e-05 , end_lr = 0e0 , att = 1/
mkdir ie_dirs
aws s3 cp s3://gap-text2sql-public/checkpoint-artifacts/gap-finetuned-checkpoint logdir/bart_run_1/bs = 12 , lr = 1.0e-04 , bert_lr = 1.0e-05 , end_lr = 0e0 , att = 1/model_checkpoint-00041000
mkdir -p pretrained_checkpoint
aws s3 cp s3://gap-text2sql-public/checkpoint-artifacts/pretrained-checkpoint pretrained_checkpoint/pytorch_model.bin另外,如果您没有AWSCLI:GAP-FINETNETED-CHACKPOINT和审计的检查点,则可以在此处下载它们
curl https://gap-text2sql-public.s3.amazonaws.com/checkpoint-artifacts/gap-finetuned-checkpoint -o logdir/bart_run_1/bs = 12 , lr = 1.0e-04 , bert_lr = 1.0e-05 , end_lr = 0e0 , att = 1/model_checkpoint-00041000
curl https://gap-text2sql-public.s3.amazonaws.com/checkpoint-artifacts/pretrained-checkpoint -o pretrained_checkpoint/pytorch_model.binpython run.py preprocess experiments/spider-configs/gap-run.jsonnetpython run.py eval experiments/spider-configs/gap-run.jsonnet然后,您可以在路径中获得推理结果和评估结果: ie_dirs/bart_run_1_true_1-step41000.infer和ie_dirs/bart_run_1_true_1-step41000.eval 。
python run.py train experiments/spider-configs/gap-run.jsonnet有关更多信息,请参见贡献。
该项目已根据APACHE-2.0许可获得许可。