NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

GEMMA-SQL: A Novel Text-to-SQL Model Based on Large Language Models

Johannes Schneider, Hari Mohan Pandey, Anshul Gupta, Subham Sarkar, Minakshi Tomer, Schneider Johannes, Yan GongarXiv 2025 · DOI

Introduction

Translating natural language into structured SQL queries (Text-to-SQL) is essential for democratizing data access. However, the field currently faces a "size and access" dilemma. State-of-the-art performance usually requires massive, proprietary models like GPT-4 or PaLM-2, which are expensive to run, raise privacy concerns, and operate as "black boxes."

On the other end of the spectrum, smaller open-source models often struggle with "schema linking"—the ability to correctly map a user's vague question to specific table names and columns—and complex logical structures like nested queries or multi-table joins. GEMMA-SQL is a lightweight, open-source framework built on the 2-billion-parameter Gemma architecture designed to bridge this gap.

Methods

The authors adapted the Gemma 2B model using several key techniques to maximize its reasoning capabilities without bloating its computational footprint:

  1. Parameter-Efficient Fine-Tuning (LoRA): Instead of updating all 2 billion parameters, they used Low-Rank Adaptation (LoRA). This allowed fine-tuning on a single NVIDIA P100 GPU, making training accessible to researchers without massive server clusters.
  2. Structured Prompting: The strategy uses a consistent Instruction → Schema → SQL format. By explicitly feeding the database schema (tables, columns, and foreign keys) into the prompt, the model is provided with a "map" to navigate the data.
  3. Iterative Refinement Loop: If the model generates a query with low confidence or one that fails a syntactic check, the system triggers a re-evaluation. It modifies the prompt with explicit clarifications and tries again—up to five times—to self-correct.
  4. Instruction Tuning: A specialized variant, GEMMA-SQL Instruct, was further refined on the SPIDER dataset to better align responses with user intent and SQL grammar constraints.
Comparison of established Text-to-SQL methods (2019-2023) highlighting common weaknesses like schema linking and complexity.

Datasets

The primary engine for training and evaluation was the SPIDER benchmark, a widely recognized, large-scale, cross-domain dataset. It includes over 8,000 training instances and 166 heterogeneous databases, testing "zero-shot" generalization on databases the model never saw during training. The paper also references performance against variants like Spider-DK and Spider-Realistic to provide a broader context of the model's robustness.

Key Insights and Ideas

  • Small Models, Big Brains: A 2B parameter model can outperform 7B and 13B variants (like LLaMA) if the fine-tuning is task-specific and the prompting is "schema-aware."
  • The Power of "Thinking Twice": The iterative refinement process alone boosted accuracy by approximately 6%, suggesting that internal heuristics can effectively trigger "system 2" thinking for structured tasks.
  • Schema Linking is the Bottleneck: Most errors stem from misidentifying columns or failing to understand table relationships. Emphasizing the schema in the prompt significantly reduces these "hallucinations."

Key Results

GEMMA-SQL Instruct achieved 66.8% Test-Suite (TS) accuracy and 63.3% Exact Set Match (EM). It significantly outperformed established baselines such as IRNet (53.2% EM) and RYANSQL (43.4% EM), as well as larger models like LLaMA-7B and LLaMA-13B variants.

Recent advancements in Text-to-SQL models (2023-2024), including state-of-the-art benchmarks like DIN-SQL.

Limitations and Future Work

While GEMMA-SQL is impressive, it has not yet reached the absolute ceiling of the field; for instance, DIN-SQL (using GPT-4) still holds a lead with 74.2% TS accuracy. Performance can also degrade when dealing with exceptionally large or "noisy" database schemas where the number of columns exceeds the model's effective context window.

Future directions include: * Multilingual Support: Handling natural language queries in languages other than English. * Interactive Querying: Integrating the model into chat-based data assistants that can ask clarifying questions. * Domain Adaptation: Specializing the model for technical industries like healthcare or finance.

Summary updated

BibTeX
@misc{schneider2025gemma,
  author = {Johannes Schneider and Hari Mohan Pandey and Anshul Gupta and Subham Sarkar and Minakshi Tomer and Schneider Johannes and Yan Gong},
  title = {{GEMMA-SQL: A Novel Text-to-SQL Model Based on Large Language Models}},
  year = {2025},
  eprint = {2511.04710},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.04710},
}
Figure