GithubHelp home page GithubHelp logo

hhy5277 / nl2sql_baseline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhuiyitechnology/nl2sql_baseline

0.0 2.0 0.0 577 KB

License: BSD 3-Clause "New" or "Revised" License

Python 99.77% Shell 0.23%

nl2sql_baseline's Introduction

***** New June 18st, 2019 *****

This version of release supports execution accuracy, which gets the execution result of predicted SQL. This requires records==0.5.3 before running.

Introduction

This baseline method is developed and refined based on code of SQLNet, which is a baseline model in WikiSQL.

The model decouples the task of generating a whole SQL into several sub-tasks, including select-number, select-column, select-aggregation, condition-number, condition-column and so on.

Simple model structure shows here, implementation details could refer to the origin paper.

The difference between SQLNet and this baseline model is, Select-Number and Where-Relationship sub-tasks are added to adapt this Chinese NL2SQL dataset better.

Dependencies

  • Python 2.7
  • torch 1.0.1
  • records 0.5.3
  • tqdm

Start to train

Firstly, download the provided datasets at ~/data_nl2sql/, which should include train.json, train.tables.json, val.json, val.tables.json and char_embedding, and divide them in following structure.

├── data_nl2sql
│ ├── train
│ │ ├── train.db
│ │ ├── train.json
│ │ ├── train.tables.json
│ ├── val
│ │ ├── val.db
│ │ ├── val.json
│ │ ├── val.tables.json
│ ├── test
│ │ ├── test.db
│ │ ├── test.json
│ │ ├── test.tables.json
│ ├── char_embedding

and then

mkdir ~/nl2sql
cd ~/nl2sql/
git clone https://github.com/ZhuiyiTechnology/nl2sql_baseline.git

cp -r ~/data_nl2sql/* ~/nl2sql/nl2sql_baseline/data/
cd ~/nl2sql/nl2sql_baseline/

sh ./start_train.sh 0 128

while the first parameter 0 means gpu number, the second parameter means batch size.

Start to evaluate

To evaluate on val.json or test.json, make sure trained model is ready, then run

cd ~/nl2sql/nl2sql_baseline/
sh ./start_test.sh 0 pred_example

while the first parameter 0 means gpu number, the second parameter means the output path of prediction.

Experiment result

We have run experiments several times, achiving avegrage 27.5% logic form accuracy on the val dataset, with 128 batch size.

Experiment analysis

We found the main challenges of this datasets containing poor condition value prediction, select column and condition column not mentioned in NL question, inconsistent condition relationship representation between NL question and SQL, etc. All these challenges could not be solved by existing baseline and SOTA models.

Correspondingly, this baseline model achieves only 77% accuracy on condition column and 62% accuracy on condition value respectively even on the training set, and the overall logic form is only around 50% as well, indicating these problems are challenging for contestants to solve.

Related resources:

https://github.com/salesforce/WikiSQL

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

Semantic Parsing with Syntax- and Table-Aware SQL Generation

nl2sql_baseline's People

Watchers

 avatar  avatar

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.