4

I have been reading about NLP but got confused and not able to figure out - if it is feasible for NLP to convert questions in natural language to transform into SQL queries (so that it can execute on concerned database and fetch the output).

Ex. If the user raises a question to the AI engine (application) -

How many new customers have registered on my website this month?

The AI should parse this using NLP techniques and convert it into SQL and execute on database table say "User_management" -

select count(1) from User_management
where joining_month = 'Oct' and joining_year = 2019

Please share your thoughts and advice.

Update 1) Got this SO link and this NLTK chapter as starting point

ranit.b
  • 451
  • 5
  • 18

3 Answers3

1

Yes it is possible. You can train end to end an RNN over the training data. It means input the user query as an input and set the output for the sql query. Definitely the most challenging part is preparing the training set as RNN needs a lot of data to be learned.

Also, for the training set, it might you can use a GAN‌ to generate more queries for the users' query dataset that you have. Notice that, as you want the query generator for the specific schema of the database, you need your own training data and it could not be generalized over all kinda schemas.

OmG
  • 1,249
  • 9
  • 19
0

Some time has passed since this question was posed, and AI has advanced. There are companies that offer this service now, e.g. AI2sql.

The algorithm behind is not RNN anymore, but transformers like GPT-3.

Steven
  • 101
0

Check out http://beta.metatable.ai/ - it is a free beta version. They have text 2 SQL and you can execute it right there on an SQL database.