arrow
Return

QA-SQL: query-augmented SQL generation using few-shot prompting with data augmentation

delete2026-02-11
delete0
PRE
AI
S
Sokheang Chan
V
Vungsovanreach Kong
A
Anand Nayyar
T
Tae-Kyung Kim *
DOI:10.7717/peerj-cs.3525delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Natural Language to Structured Query Language (NL-to-SQL) models make it easier to retrieve data from structured databases by converting plain language queries into Structured Query Language (SQL) commands. However, current methods often struggle with complex database structures, unclear user questions, and generating efficient SQL queries. These issues make it hard to use them effectively in real-world, large-scale databases. To tackle these problems, a novel framework titled Query-Augmented SQL Generation (QA-SQL), is introduced that combines retrieval augmented generation (RAG) with data augmentation with advanced techniques to enhance the accuracy and efficiency of natural language to SQL (NL-to-SQL) generation. The proposed approach uses Schema Linking, RAG, and Dynamic Prompt Engineering along with few-shot learning and vector database retrieval, to enhance SQL query generation through query augmentation. To test and validate the proposed model, extensive experimentations were conducted on the BIg Bench for LaRge-scale Database Grounded Text-to-SQL Evaluation (BIRD) benchmark, which includes 1,534 natural language queries across various relational databases and the results highlighted a execution accuracy of 46.68% and a valid efficiency score of 87.66%, outperforming existing methods. The proposed research introduces a context-aware retrieval system that significantly enhances SQL accuracy, paving the way for more scalable and reliable NL-to-SQL solutions.
Keywords:
Text-to-SQL
Retrieval-augmented generation
Data augmentation
Large language models

Journal

PeerJ Computer Science cover
PeerJ Computer Science
IF:
2.5
Papers:
3.4K
Citations:
6.9K

Organization

D
Duy Tan University
Scholars:
447
Papers: 327
Citations: 6.6K
C
chungbuk national university
Scholars:
1.5K
Papers: 689
Citations: 0