Enterprise Text-to-SQL + Voice -- QLoRA fine-tuned Qwen3-8B

Strict execution accuracy: 43.71% to 70.86% on 453 held-out questions.

By

Garvit Audichya - HuggingFace

Features

  • Voice input -- speak your question, Whisper transcribes it
  • Fine-tuned Qwen3-8B -- QLoRA r=16, 4-bit NF4
  • Self-correction loop -- feeds DB errors back to model, retries once
  • Static SQL validation -- sqlglot catches bad queries before execution
  • PostgreSQL execution -- read-only, statement timeout, no writes possible

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch

BASE    = "Qwen/Qwen3-8B"
ADAPTER = "garvit-010/qwen3-8b-text2sql-qlora-v3"

bnb = BitsAndBytesConfig(
    load_in_4bit=True, bnb_4bit_quant_type="nf4",
    bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.float16,
)
base  = AutoModelForCausalLM.from_pretrained(BASE, quantization_config=bnb, device_map={"":0})
model = PeftModel.from_pretrained(base, ADAPTER).eval()
tokenizer = AutoTokenizer.from_pretrained(ADAPTER)

IMPORTANT: Always use enable_thinking=False in apply_chat_template.

Results

Configuration Strict accuracy
Base Qwen3-8B 43.71%
Fine-tuned (this adapter) 68.43%
Fine-tuned + self-correction 70.86%

Training

  • Base: Qwen/Qwen3-8B @ b968826d9c46, 4-bit NF4
  • LoRA r=16, alpha=32, 43.6M trainable params (0.917%)
  • Completion-only loss on SQL tokens only
  • Kaggle T4, 1 epoch, 135 steps, ~7 hours

License

Apache 2.0 - all training data is synthetic

Downloads last month
55
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for garvit-010/qwen3-8b-text2sql-qlora-v3

Finetuned
Qwen/Qwen3-8B
Finetuned
(2251)
this model

Space using garvit-010/qwen3-8b-text2sql-qlora-v3 1