What are some of the ways to convert NLP to SQL? [closed]

Recently, have started working on the idea of conversational chatbot and have been thinking of different ways to convert Natural Language query to SQL. These are some of the libraries I have shortlisted to evaluate before writing from scratch. Any other ideas or suggestions?

  • https://github.com/FerreroJeremy/ln2sql
  • https://github.com/dadashkarimi/seq2sql
  • https://github.com/xiaojunxu/SQLNet
  • http://www.ling.helsinki.fi/kit/2009s/clt231/NLTK/book/ch10-AnalyzingTheMeaningOfSentences.html#querying-a-database

check this demo from AllenNLP: https://demo.allennlp.org/atis-parser

Which converts Natural Language text into SQL queries. They also have python library allennlp.

Here is their github repo: https://github.com/allenai/allennlp

For documentation regarding semantic_parsing:

https://allenai.github.io/allennlp-docs/api/allennlp.data.dataset_readers.semantic_parsing.html


The main challenge here is to fit end-user needs. Most of the end-users are not technically skilled enough and they don't know database schema.

All open-sourced libraries mentioned here requires to use column names inside input requests, so end-user should design request as "give me count for column_name where column_name is lower than 120". This assumption is wrong because end-users usually don't care about database structure and column names. With open-source libraries, you can create another Structure Query Language layer on top of the usual SQL.

I would recommend having a look at NLP libraries before building your service:

BERT ==== https://github.com/hanxiao/bert-as-service

Sentence Transformers ==== https://github.com/UKPLab/sentence-transformers

VaderSentiment ==== https://github.com/cjhutto/vaderSentiment

Also, I would recommend having a look at NLP to SQL software architecture and existing commercial software for Natural Language to SQL


Check this open source Python framework (started in 2014):

  • https://pypi.org/project/quepy/
  • https://quepy.readthedocs.io/en/latest/

Quepy is a framework to convert natural language to database queries. It can be easily customized to different kinds of questions in natural language and database queries. So, with little coding you can build your own system for natural language access to your database.