Grounded SQL / Run it Yourself

Before you start

  • Python 3.10+ and pip install -r requirements.txt
  • An NVIDIA GPU for fine-tuning (QLoRA's 4-bit quantization fits on a single consumer GPU); inference falls back to CPU automatically if no CUDA device is found
  • ~7GB free for the INT8-quantized model at serve time, more if you train your own adapter
1

Clone the repo

Full source: data pipeline, training, retrieval, evaluation, and serving.

git clone https://github.com/vrhsr/grounded-sql.git cd grounded-sql pip install -r requirements.txt
2

Download the dataset

Training used the Spider benchmark: 8,659 question/SQL pairs across 166 databases. Grab the official release, or bring your own .sqlite files and schema.

# after placing Spider under dataset/spider/ python data_pipeline.py --config training/config.yaml
3

Get the model

Download the fine-tuned LoRA adapter directly, or train your own overnight run from scratch on a single GPU.

python training/train.py --config training/ablations/rank_64_v2.yaml
4

Serve it

Redis-cached FastAPI backend, GPU-enabled via Docker Compose, or run the API directly.

docker-compose up # or, without Docker: MODEL_ADAPTER_PATH=checkpoints/rank_64/final_adapter \ uvicorn serving.main:app --host 0.0.0.0 --port 8000
5

Ask it anything

Launch the Gradio UI, paste your own schema (or upload your own .sqlite file) instead of the demo databases, and ask questions about your own data in plain English.

python app.py # โ†’ opens at localhost:7860