ASKSQL: Enabling cost-effective natural language to SQL conversion for enhanced analytics and search

Arpit Bajgoti, Rishik Gupta, Rinky Dwivedi · Machine Learning with Applications · 2025

Natural Language to SQL (NL2SQL) for database query and search has been a significant research focus in recent years. However, existing methods have predominantly concentrated on SQL query generation, overlooking critical aspects such as enterprise cost, latency, and the overall analytical search experience. This paper presents an end-to-end NL2SQL pipeline named ASKSQL that integrates optimized and adaptable query recommendation, entity-swapping module, and skeleton-based caching to enhance the search experience. The pipeline also incorporates an intelligent schema selector for efficiently handling large schema entity selection and a fast and scalable adapter-based query generator. The proposed pipeline emphasizes minimizing Large Language Model (LLM) costs by finding search patterns in previously requested or generated queries. The pipeline can also be tuned to adapt to trends and common patterns observed from the daily search analytics. Experimental results demonstrate an average increase in accuracy by 5.83% and an overall decrease in latency by 32.6% as the usage count of this search pipeline increases highlighting its effectiveness in improving the NL2SQL search experience. • ANN index when used with Vector DB ensures speed and reliability. • Semantic Caching Module reduces LLM operations for query generation. • Small language model trained on large-scale SQL gives better accuracy. • Pipeline can toggle between response time and accuracy according to preference.

Read the paper · More papers on PaperTik