Modular Enterprise Natural Language to SQL Using Small Language Models

Authors

DOI:

https://doi.org/10.34190/icair.7.1.5581

Keywords:

Natural language-to-SQL, Small language models, Enterprise AI, Schema retrieval, On-premises AI

Abstract

Enterprise organisations increasingly store critical data in relational databases, but business users often lack the SQL expertise to query them. This problem is acute in ERP/CRM systems with large, poorly documented schemas, multilingual requests, and constraints that may preclude proprietary cloud models. This work evaluates a modular Natural Language-to-SQL architecture built from small, locally deployable open-weight models. Its stages are query normalisation, intent classification, embedding-based schema retrieval with graph expansion, and LoRA-fine-tuned skeleton generation and query completion. A 9-billion-parameter model achieved over 80% recall across all intent classes, without consistent gains from larger models or ensembles. A 0.6-billion-parameter embedding model matched larger alternatives for broad candidate retrieval. In an isolated gold-grounded evaluation, the 9B skeleton model achieved 84.2% execution accuracy on the Spider test comparison split; a 0.8B model reached 80.3%. The 9B checkpoint achieved only 34.9% zero-shot on BIRD, with failures concentrated in structurally complex queries. Translation of noisy multilingual ERP metadata produced a median cosine similarity above 0.79. An end-to-end test achieved 26.0% execution accuracy with retrieved tables and 82.0% with correct tables, identifying schema retrieval as the dominant bottleneck. Although the components can run locally, this 50-query evaluation on one ERP demonstration database does not yet establish production readiness.

Author Biographies

Rodrigo Fernandes, University of Leiria and Oeste

I'm a final-year Master's student in Data Science with an interest in AI and machine learning. I'm currently exploring applications of AI in Enterprise Resource Planning (ERP) systems.

Ricardo Malheiro, Universiry of Leiria and Oeste, Centre for Informatics and Systems of the University of Coimbra

Ricardo Malheiro holds a PhD in Informatics Engineering from the University of Coimbra, where he also completed his MSc and BSc degrees. He is a researcher at CISUC and teaches at the Polytechnic Institute of Leiria. His research focuses on Natural Language Processing, Music Generation, Emotion Recognition, and Text Mining.

Downloads

Published

2026-11-18