GithubHelp home page GithubHelp logo

thu-bpm / isesl-sql Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 1.0 85 KB

The source code of paper "Semantic Enhanced Text-to-SQL Parsing via Iteratively Learning Schema Linking Graph" in KDD2022.

Python 100.00%

isesl-sql's Introduction

ISESL-SQL

The source code of paper "Semantic Enhanced Text-to-SQL Parsing via Iteratively Learning Schema Linking Graph" published at KDD 2022.

download data

spider: https://yale-lily.github.io/spider

put the data into the data/ directory

preprocess data

python3 -u preprocess/process_dataset.py --dataset_path data/train.json --raw_table_path data/tables.json --table_path data/tables.bin --output_path 'data/train.bin' --skip_large --semantic_graph
python3 -u preprocess/process_dataset.py --dataset_path data/dev.json --table_path data/tables.bin --output_path 'data/dev.bin' --skip_large --semantic_graph
python3 -u preprocess/process_graphs.py --dataset_path 'data/train.bin' --table_path data/tables.bin --output_path  data/train.rgatsql.bin
python3 -u preprocess/process_graphs.py --dataset_path 'data/dev.bin' --table_path data/tables.bin --output_path  data/dev.rgatsql.bin

train model

CUDA_VISIBLE_DEVICES=0 python scripts/text2sql.py --task lgesql_large --seed 999 --device 0 --plm google/electra-large-discriminator --gnn_hidden_size 512 --dropout 0.2 --attn_drop 0.0 --att_vec_size 512 --model rgatsql --output_model without_pruning --score_function affine --relation_share_heads --subword_aggregation attentive-pooling --schema_aggregation head+tail --gnn_num_layers 8 --num_heads 8 --lstm onlstm --chunk_size 8 --drop_connect 0.2 --lstm_hidden_size 512 --lstm_num_layers 1 --action_embed_size 128 --field_embed_size 64 --type_embed_size 64 --no_context_feeding --batch_size 35 --grad_accumulate 5 --lr 1e-4 --l2 0.1 --warmup_ratio 0.1 --lr_schedule linear --eval_after_epoch 120 --smoothing 0.15 --layerwise_decay 0.8 --max_epoch 200 --max_norm 5 --beam_size 5 --logdir logdir/run --train_path train --dev_path dev --training --optimize_graph --schema_loss 

Reference

@inproceedings{liu2022semantic,
  title={Semantic Enhanced Text-to-SQL Parsing via Iteratively Learning Schema Linking Graph},
  author={Liu, Aiwei and Hu, Xuming and Lin, Li and Wen, Lijie},
  booktitle={Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  pages={1021--1030},
  year={2022}
}

isesl-sql's People

Contributors

exlaw avatar

Stargazers

 avatar Alfredo Serafini avatar  avatar usoon avatar Jeff Carpenter avatar  avatar  avatar Jinchuan Zhang avatar Wen Qiao avatar Jian Wu avatar Xuming Hu avatar Nixon avatar liuhuadai avatar  avatar

Watchers

 avatar

Forkers

kellygong

isesl-sql's Issues

#ISESL-SQL-main

Hello, when I was training the model, the step was always 0, right? At the same time, the training accuracy was 0:
image
image
image
image
image
image

Another question is, if the model is trained well, how can I input text and output SQL? thanks

script for inference

Which script can be used for inference, i.e. loading the best model and then getting the final SQL file?

Original Spider Dataset used in the Paper + Setup Instructions to Run on a New Database

Hey,

I tried following the setup instructions given in README.md but I think because of some changes in the Spider dataset these instructions are no longer valid.

For example,

python3 -u preprocess/process_dataset.py --dataset_path data/train.json --raw_table_path data/tables.json --table_path data/tables.bin --output_path 'data/train.bin' --skip_large --semantic_graph

There is no 'data/train.json' file in the Spider dataset. But it has 'data/train_spider.json' and 'data/train_others.json' files.

I tried changing the file name, but I get the following error.

Firstly, preprocess the original databases ... Traceback (most recent call last): File "/sensei-fs/users/saudi/text2sql/ISESL-SQL/preprocess/process_dataset.py", line 74, in <module> tables = process_tables(processor, tables_list, args.table_path, args.verbose) File "/sensei-fs/users/saudi/text2sql/ISESL-SQL/preprocess/process_dataset.py", line 26, in process_tables tables[each['db_id']] = processor.preprocess_database(each, verbose=verbose) File "/sensei-fs/users/saudi/text2sql/ISESL-SQL/preprocess/common_utils.py", line 100, in preprocess_database c = [w.lemma.lower() for s in doc.sentences for w in s.words] File "/sensei-fs/users/saudi/text2sql/ISESL-SQL/preprocess/common_utils.py", line 100, in <listcomp> c = [w.lemma.lower() for s in doc.sentences for w in s.words] AttributeError: 'NoneType' object has no attribute 'lower'

If possible, please upload the original dataset used in google drive and share the link.

Also, please provide the instructions to run the pipeline on a new database. Like what files need to be created in the data folder and what scripts to use.

Your help on this is much appreciated.

Best,
Saud Iqbal

#ISESL-SQL

According to README.md, when training the model, there is a problem, as follows:
image
But the “tables.bin” does not exist in the original spider dataset.
Thank you!

Question about oracle schema linking

Nice work!
I have noticed that the oracle schema linking information could bring a huge improvement for Spider and Spider-SYN in section3.6, I wonder that where does the oracle schema information come from for both of two datasets. Could you offer a link please?
(I guess that the oracle schema information of Spider come from SLSQL(EMNLP2020), and how about Spider-SYN? )

Besides, could you please offer more details about how you directly change the implicit graph matrix A(𝑡) in Eq. 7 based on the oracle information, becaucse I want to try this by myself. Thanks a lot.

Best wishes!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.