NLSQL: Generating and Executing SQL Queries via Natural Language Using Large Language Models

Ayush Attawar, Shivam Vora, Parth Narechania, Vinaya Sawant, Heli Vora · 2023

The goal of data management has long been to make data more approachable for non-technical users. Natural language interfaces (NLIs), which let users interact with data by asking questions in natural language, have become more popular in recent years. Natural language is often vague, and user queries often don’t give enough information. This makes it hard to use NLIs for database querying. In order to solve this problem, this study suggests using large language models (LLMs) to turn free-form natural language queries into SQL statements that can then be run on databases. The proposed system, NLSQL, makes use of LLMs like GPT-3 and shows how efficiently prompt engineering can be done in order to extract from LLMs the desired code for SQL queries. NLSQL shows that using pre-trained LLMs along with the suggested priming prompts is an accurate and reliable way to create and run SQL queries in natural language, even if the queries aren’t very well written or are missing important information. Unlike traditional methods, which involve making grammar rules by hand, this method improves query inference and makes the development of NLIs faster and cheaper. The study shows that the suggested method is safe, protects privacy, and can be used with many different databases. If NLSQL is used to make databases easier for people who aren’t tech-savvy to use, they may not need as much training in SQL and related technologies, which would save a company both time and money.

Read the paper · More papers on PaperTik