File size: 1,562 Bytes
5206e1e
9546d85
 
 
 
5206e1e
9546d85
 
 
 
5206e1e
 
9546d85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
title: SQLForge  Text-to-SQL
emoji: 🛠️
colorFrom: yellow
colorTo: indigo
sdk: docker
app_port: 8000
pinned: true
license: mit
short_description: Fine-tuned text-to-SQL LLM with a self-correcting demo
---

# SQLForge 🛠️ — Text-to-SQL

Ask a question in plain English → SQLForge writes the SQL, **runs it against a real SQLite database**, and shows you the results. When a query crashes, it reads the database error and **self-corrects**.

This Space runs a **Qwen2.5-Coder-1.5B** model fine-tuned with QLoRA on the [Spider](https://yale-lily.github.io/spider) benchmark.

| | Execution accuracy (full Spider dev set) |
|---|:---:|
| Base model (zero-shot) | 57.45% |
| **Fine-tuned (SQLForge)** | **65.57%****+8.1 pts** |

## How to use

1. Pick one of the example databases.
2. Click an example question or type your own.
3. Hit **Generate SQL** — you'll see the query, the live results, and (on hard questions) the self-correction trace.

> ⏱️ This Space runs on **CPU**, so generation takes a few seconds per query (the model itself runs in ~1–3s on a GPU). Accuracy is identical — only speed differs.

## Links

- 💻 **Source & training pipeline:** [github.com/abdullahkousa2/sqlforge](https://github.com/abdullahkousa2/sqlforge)
- 📦 **Library:** `pip install sqlforge`
- 📈 **Experiment tracking:** [Weights & Biases](https://wandb.ai/akousa360-arab-international-university-/sqlforge-text2sql)

Built with QLoRA · 🤗 Transformers · PEFT · FastAPI. Evaluated with real execution accuracy, not string matching.