Run this model with HF Jobs
Run griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker") model = AutoModelForCausalLM.from_pretrained("griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Improve model card with metadata, paper link, and usage example (#1)
Browse files- Improve model card with metadata, paper link, and usage example (90d89c64867fd7cd9c50f11d329751316c594fea)
Co-authored-by: Niels Rogge <nielsr@users.noreply.huggingface.co>
1Github: https://github.com/thanhdath/grast-sql123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384---pipeline_tag: text-rankinglibrary_name: transformers---# GRAST-SQL: Scaling Text-to-SQL via LLM-efficient Schema Filtering with Functional Dependency Graph RerankersGRAST-SQL is a lightweight, open-source schema-filtering framework that scales Text-to-SQL to real-world, very wide schemas by compacting prompts without sacrificing accuracy. It ranks columns with a query-aware LLM encoder enriched by values/metadata, reranks them via a graph transformer over a functional-dependency (FD) graph to capture inter-column structure, and then guarantees joinability with a Steiner-tree spanner to produce a small, connected sub-schema. Across Spider, BIRD, and Spider-2.0-lite, GRAST-SQL delivers near-perfect recall with substantially higher precision than CodeS, SchemaExP, Qwen rerankers, and embedding retrievers, maintains sub-second median latency on typical databases, scales to 23K+ columns, and cuts prompt tokens by up to 50% in end-to-end systems—often with slight accuracy gains—all while using compact models.This model was presented in the paper [Scaling Text2SQL via LLM-efficient Schema Filtering with Functional Dependency Graph Rerankers](https://huggingface.co/papers/2512.16083).Code: https://github.com/thanhdath/grast-sql## System flow### Datasets- **Spider**: [Spider Evaluation Dataset](https://huggingface.co/datasets/griffith-bigdata/GRAST-SQL-Spider)- **BIRD**: [BIRD Training/Evaluation Dataset](https://huggingface.co/datasets/griffith-bigdata/GRAST-SQL-BIRD)- **Spider-2.0-lite**: [Spider 2.0-lite Eval Dataset](https://huggingface.co/datasets/griffith-bigdata/GRAST-SQL-Spider2.0-lite)### Models- **GRAST-SQL 0.6B**: [GRAST-SQL 0.6B BIRD](https://huggingface.co/griffith-bigdata/GRAST-SQL-0.6B-BIRD-Reranker)- **GRAST-SQL 4B**: [GRAST-SQL 4B BIRD](https://huggingface.co/griffith-bigdata/GRAST-SQL-4B-BIRD-Reranker)- **GRAST-SQL 8B**: [GRAST-SQL 8B BIRD](https://huggingface.co/griffith-bigdata/GRAST-SQL-8B-BIRD-Reranker)More models can be found in [Huggingface collection](https://huggingface.co/collections/griffith-bigdata/grast-sql)## Sample UsageTo apply GRAST-SQL to your own database, follow these two simple steps:### Step 1: Initialize (ONE-TIME per database) - Functional Dependency Graph Construction & Metadata CompletionExtract schema information, generate table/column meanings, predict missing keys, and build the functional dependency graph:```bashpython init_schema.py \--db-path /home/datht/mats/data/spider/database/concert_singer/concert_singer.sqlite \--output concert_singer.pkl \--model gpt-4.1-mini```**Arguments:**- `--db-path`: Path to your SQLite database file (required)- `--output`: Output path for the graph pickle file (default: `schema_graph.pkl`)- `--model`: OpenAI model to use for meaning generation and key prediction (default: `gpt-4.1-mini`)**Note:** Make sure your OpenAI API key is set in `.env`.### Step 2: Filter Top-K ColumnsUse the GRAST-SQL model to filter the most relevant columns for a given question:```bashpython filter_columns.py \--graph concert_singer.pkl \--question "Show name, country, age for all singers ordered by age from the oldest to the youngest." \--top-k 5```**Arguments:**- `--graph`: Path to the graph pickle file from Step 1 (required)- `--question`: Natural language question about the database (required)- `--top-k`: Number of top columns to retrieve (default: 10)- `--checkpoint`: Path to GNN checkpoint (default: `griffith-bigdata/GRAST-SQL-0.6B-BIRD-Reranker/layer-3-hidden-2048.pt`)- `--encoder-path`: Path to encoder model (default: `griffith-bigdata/GRAST-SQL-0.6B-BIRD-Reranker`)- `--max-length`: Maximum sequence length (default: 4096)- `--batch-size`: Batch size for embedding generation (default: 32)- `--hidden-dim`: Hidden dimension for GNN (default: 2048)- `--num-layers`: Number of GNN layers (default: 3)## Citation```bibtex@misc{hoang2025scalingtext2sqlllmefficientschema,title={Scaling Text2SQL via LLM-efficient Schema Filtering with Functional Dependency Graph Rerankers},author={Thanh Dat Hoang and Thanh Tam Nguyen and Thanh Trung Huynh and Hongzhi Yin and Quoc Viet Hung Nguyen},year={2025},eprint={2512.16083},archivePrefix={arXiv},primaryClass={cs.DB},url={https://arxiv.org/abs/2512.16083},}```
README.md+84-1