2
$\begingroup$

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

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Thanks. I see where you are coming from. I'll study tinker about it. Do you have any blog reference or post about it? Will be easier if I have a reference. $\endgroup$ – ranit.b Oct 15 at 11:02
  • $\begingroup$ (+1) I agree that it's possible to try, but I doubt it would perform very well in general. Also the system would have to deal with the case of questions which cannot be converted. $\endgroup$ – Erwan Oct 15 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.