Optimizing text-to-SQL conversion techniques through the integration of intelligent agents and large language models
Samuel Ojuri, The Anh Han, Raymond Chiong, Alessandro Di Stefano
Abstract
In many organizations, retrieving valuable information from complex databases has traditionally required specialized technical skills, often leaving non-technical professionals dependent on others for timely insights. This study presents an approach that allows anyone, even without knowledge of query languages, to directly interact with databases by asking questions in everyday language. We achieve this by combining advanced generative language models, such as a high-capacity Generative Pre-trained Transformer (GPT) model, with intelligent software agents that translate natural language queries into precise SQL statements. Our evaluation compares different strategies, including models specifically trained on a particular database domain versus those guided by only a handful of examples. The results show that training a model with tailored examples yields more accurate and reliable database queries than relying solely on minimal guidance for the given use case. This work highlights the practical value of refining model complexity and balancing computational costs to empower business users with easy, direct access to data. By reducing reliance on technical teams, organizations can enable faster, more informed decision-making and foster a more inclusive environment where everyone can uncover data-driven insights on their own. • Large language models (LLMs) can enhance real-time business analytics. • We integrate LLMs and intelligent agents for text-to-SQL conversion optimization. • Results show that GPT-4 and Llama-3.3-70B-Instruct-Turbo demonstrate superior syntax and semantic understanding. • Model fine-tuning outperforms few-shot learning for domain-specific SQL generation. • Balance between model sophistication, cost, and enterprise usability is crucial.