GithubHelp home page GithubHelp logo

hhy5277 / mlsql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paulfitz/mlsql

0.0 1.0 0.0 119 KB

inferring sql queries from plain-text questions about tables

Dockerfile 25.17% Makefile 6.57% Shell 68.27%

mlsql's Introduction

Infer SQL queries from plain-text questions and table headers.

Requirements:

  • install docker
  • install curl
  • Make sure docker allows at least 3GB of RAM (see Docker>Preferences>Advanced or equivalent)

sqlova

This wraps up a published pretrained model for Sqlova (https://github.com/naver/sqlova/).

Fetch and start sqlova running as an api server on port 5050:

docker run --name sqlova -d -p 5050:5050 paulfitz/sqlova

Be patient, the image is about 4.2GB. Once it is running, it'll take a few seconds to load models and then you can start asking questions about CSV tables. For example:

curl -F "[email protected]" -F "q=how long is throgs neck" localhost:5050
# {"answer":[1800],"params":["throgs neck"],"sql":"SELECT (length) FROM bridges WHERE bridge = ?"}

This is using the sample bridges.csv included in this repo.

bridge designer length
Brooklyn J. A. Roebling 1595
Manhattan G. Lindenthal 1470
Williamsburg L. L. Buck 1600
Queensborough Palmer & Hornbostel 1182
Triborough O. H. Ammann 1380,383
Bronx Whitestone O. H. Ammann 2300
Throgs Neck O. H. Ammann 1800
George Washington O. H. Ammann 3500

Here are some examples of the answers and sql inferred for plain-text questions about this table:

question answer sql
how long is throgs neck 1800 SELECT (length) FROM bridges WHERE bridge = ? ['throgs neck']
who designed the george washington O. H. Ammann SELECT (designer) FROM bridges WHERE bridge = ? ['george washington']
how many bridges are there 8 SELECT count(bridge) FROM bridges
how many bridges are designed by O. H. Ammann 4 SELECT count(bridge) FROM bridges WHERE designer = ? ['O. H. Ammann']
which bridge are longer than 2000 Bronx Whitestone, George Washington SELECT (bridge) FROM bridges WHERE length > ? ['2000']
how many bridges are longer than 2000 2 SELECT count(bridge) FROM bridges WHERE length > ? ['2000']
what is the shortest length 1182 SELECT min(length) FROM bridges

Some questions about iris.csv:

question answer sql
what is the average petal width for virginica 2.026 SELECT avg(Petal.Width) FROM iris WHERE Species = ? ['virginica']
what is the longest sepal for versicolor 7.0 SELECT max(Sepal.Length) FROM iris WHERE Species = ? ['versicolor']
how many setosa rows are there 50 SELECT count(col0) FROM iris WHERE Species = ? ['setosa']

There are plenty of types of questions this model cannot answer (and that aren't covered in the dataset it is trained on, or in the sql it is permitted to generate). I hope to track research in the area and substitute in models as they become available. Things are moving fast!

mlsql's People

Contributors

paulfitz avatar

Watchers

 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.