Manuscript Offprint

arXiv:2610.17305

Reliable Text-to-SQL in Resource-Constrained Settings with Small LLMs via Iterative Retry Workflows

Bilel Abderrahmane Benziane, Xavier Schepler

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Bilel Abderrahmane Benziane 1^{1} and Xavier Schepler 1^{1}

1^{1}Data Lab, Generix Group, Paris, France

Emails: babenziane@generixgroup.com, xschepler@generixgroup.com

Abstract—Large Language Models (LLMs) have recently improved Text-to-SQL generation, but their computational cost can hinder deployment in resource-constrained settings. This paper evaluates the Text-to-SQL capabilities of small and medium open-source LLMs (1B–8B parameters) under a controlled inference budget, focusing on how model specialization and prompt formulation affect performance. Using the Spider benchmark, we compare multiple prompt representations and assess the accuracy of generated queries. Our results show that SQL-specialized models are consistently more reliable than general-purpose and chat-oriented models at small scales, and that performance can vary substantially depending on the prompt used. To reduce this variability without resorting to larger models, we introduce three lightweight inference workflows that automatically retry with alternative prompts and/or models when failures occur, including an optional syntax-correction step. These workflows significantly improve end-to-end success rates, with a trade-off in additional inference calls. These results demonstrate a practical path to stronger Text-to-SQL performance with small LLMs, by trading modest additional inference cost for higher reliability.

Index Terms—Text-to-SQL, Large Language Models, Resource-Constrained Inference, Prompting, Spider Benchmark

I. INTRODUCTION

With the abundance of data in the last few years, artificial intelligence has witnessed rapid growth in the use of foundation models [1]. Training a model on a wide range of data can help improve generalization and offer better inference on unseen data. One AI subfield that has witnessed a rapid increase in performance is natural language processing, where the use of large language models (LLMs) has rapidly increased in the last few years [2], [3].

However, a major limitation of LLMs is their lack of knowledge on specific tasks. To increase the performance of an LLM, it has to be tuned on a specific type of data or field [4]. As a result of fine-tuning LLMs, many specialized models have emerged in the last few years, such as instruction-tuned/chat LLMs, code LLMs, and domain-specific LLMs [5]–[9]. One special type of code LLM is Text-to-SQL. The importance of these specialized models specifically lies in their direct impact on democratizing data access by offering a means for people with a non-technical background to query complex databases.

Although LLMs are important in facilitating tasks, they tend to be resource-hungry. Unlike traditional smaller models, LLMs require much more expensive resources [10]. This could lead to an exponential increase in the business cost of any given software solution making use of an LLM. Previous work tackled this problem by compressing the models to lower numerical precision. One example is the Q8BERT model, an 8-bit quantized version of BERT obtained via quantization-aware fine-tuning, achieving roughly 4×4\times compression and potential inference speedups with negligible accuracy loss [11]. While these methods reduce memory use, they degrade performance, usually require tuning quantization further after training, and have only been studied for models with fewer than 350M parameters.

Previous research tackled the same problem on a larger scale by carrying out more extensive experimentation on large and medium-sized LLMs [12]. The results showcased a positive correlation between model scale and performance, where the larger version of fine-tuned LLaMA-2 (CodeLLaMA-34B) achieved an average execution accuracy of 39.6% compared to the smaller version (LLaMA-2-CHAT-13B), which achieved an average execution accuracy of 19.4%. This work also showed that question representation plays an important role in improving performance. Building on previous work, this study focuses on assessing the performance of medium and small LLMs for the Text-to-SQL task. In order to improve the performance of smaller LLMs, this work suggests three different workflows to improve accuracy.

The remainder of this paper is organized as follows. Section II presents the related work. Section III describes the proposed methodology. Section IV reports and discusses the experimental results. Finally, Section V concludes this work and outlines possible directions for future research.

References (32)