Uma API integrada com o GPT 3.5 para consultas SQL por meio de linguagem natural (NL2SQL) - Cenci, Tiago (2024)
The swift and accurate retrieval of information from a database is crucial in various real-world scenarios. However, within the realm of relational databases, extracting desired data requires proficiency in Structured Query Language (SQL), thereby limiting access to a specialized audience. With the advancement of Artificial Intelligence and the availability of pre-trained models such as the Generative Pre-Trained Transformer (GPT), an opportunity arises to make a significant contribution to this scenario. In this context, this work aims at developing an application that translates user-supplied natural language text into SQL commands, and then run these commands in a database that contains a dictionary of specific data containing information about its tables and fields, to finally present the result to the user in an accessible and friendly way. To achieve this, an Application Programming Interface (API) was developed in python to facilitate message exchange between users and the application, leveraging the GPT model API from OpenAI, and utilizing the Firebird relational database. The evaluation of the proposed work will assess the accuracy of SQL translation, the system’s ability to recognize out-of-context inputs, response time performance, and tolerance to errors in received text.