File size: 3,590 Bytes
55fcadb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
language:
- en
license: apache-2.0
library_name: transformers
pipeline_tag: text-generation
base_model: Qwen/Qwen3.8-27B
tags:
- flintglass
- prismsql
- qwen3
- text-to-sql
- sql
- sqlite
- rlvr
- grpo
- apache-2.0
---

# Flintglass PrismSQL-27B

**Flagship 27B Pure On-Policy Live-SQLite Execution-Verified Text-to-SQL Specialist on Apache-2.0 `Qwen/Qwen3.8-27B`** — achieving **`81.90%` Overall SQLite Execution Accuracy (+2.40 pts)**, **`73.86%` Complex SQL (+5.01 pts)**, **`65.03%` Macro Complexity (+4.02 pts)**, **`+14.29 pts` on Set Operations**, **`+7.59 pts` on Aggregations**, **`+5.88 pts` on Multi-Joins**, **`+84.5 pts` Clean Raw SQL (`4.0% -> 88.5%`)**, and **`-27%` output tokens (`37.1 -> 27.0`)**!

> **Completes the Flagship Flintglass 27B Trio:** [`PrismAgent-27B`](https://huggingface.co/flintglass/PrismAgent-27B) · [`PrismVerify-27B`](https://huggingface.co/flintglass/PrismVerify-27B) · [`PrismSQL-27B`](https://huggingface.co/flintglass/PrismSQL-27B) · **GGUF Quantizations:** [`flintglass/PrismSQL-27B-GGUF`](https://huggingface.co/flintglass/PrismSQL-27B-GGUF) (`Q4_K_M`, `Q5_K_M`, `Q6_K`)

---

## Verified Zero-Leakage Live-SQLite Execution Results (1,000 Held-Out Schemas)

Every prediction is executed against an isolated in-memory SQLite database populated with schema DDL + sample rows, and verified by normalized result-set equivalence against gold SQL (`enable_thinking=False`, greedy decoding):

| SQL Category | Tasks | `Qwen/Qwen3.8-27B` (Base) | **`flintglass/PrismSQL-27B`** | Delta |
|---|---:|---:|---:|---:|
| **Overall SQLite Execution Accuracy** | **1,000** | 79.50% | **81.90%** | **+2.40 pts** |
| **Complex SQL (Non-Basic, 459 tasks)** | **459** | 68.85% | **73.86%** | **+5.01 pts** |
| **Macro Complexity Avg (7 cats)** | **1,000** | 61.01% | **65.03%** | **+4.02 pts** |
| `aggregation` | 224 | 67.41% | **75.00%** | **+7.59 pts** |
| `set operations` | 7 | 28.57% | **42.86%** | **+14.29 pts** |
| `multiple_joins` | 17 | 52.94% | **58.82%** | **+5.88 pts** |
| `single join` | 140 | 79.29% | **83.57%** | **+4.28 pts** |
| `basic SQL` | 541 | 88.54% | **88.72%** | +0.18 pts |
| `window functions` | 22 | 40.91% | 40.91% | 0.00 pts |
| `subqueries` | 49 | **69.39%** | 65.31% | -4.08 pts |
| **Clean Raw SQL Rate** | 1,000 | 4.0% | **88.5%** | **+84.5 pts** |
| **Avg Output Tokens** | 1,000 | 37.1 | **27.0** | **-27%** |

---

## Quickstart (`transformers`)

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "flintglass/PrismSQL-27B"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16, device_map="auto")

messages = [
    {"role": "system", "content": "Return ONLY a valid SQLite SELECT query."},
    {"role": "user", "content": "Schema:\nCREATE TABLE orders(id INT, customer_id INT, total REAL);\nCREATE TABLE customers(id INT, country TEXT);\n\nQuestion: Top 5 countries by total revenue."},
]
prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=192, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
```

## Training & Provenance

- **Base Model:** `Qwen/Qwen3.8-27B` (Apache-2.0)
- **Algorithm:** Pure On-Policy PPO-Clipped GRPO (`r=32`, 25 steps, `K=8` rollouts/prompt, live in-memory SQLite execution reward). Zero synthetic SFT, zero proprietary distillation.
- **License:** Apache-2.0