QUERION v0.6.0
Browse files
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- text-to-sql
|
| 7 |
+
- sql
|
| 8 |
+
- from-scratch
|
| 9 |
+
- custom-architecture
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# QUERION 100M (v0.6.0)
|
| 13 |
+
|
| 14 |
+
A 101,026,560-parameter decoder-only language model trained from scratch for
|
| 15 |
+
text-to-SQL, on a single laptop GPU (RTX 4050, 6 GB). Code, training logs and
|
| 16 |
+
evaluation harness: https://github.com/AmanSingh-404/QUERION
|
| 17 |
+
|
| 18 |
+
## Architecture
|
| 19 |
+
|
| 20 |
+
12 layers, grouped-query attention (12 query heads, 4 KV heads), RoPE, RMSNorm,
|
| 21 |
+
SwiGLU, tied input/output embeddings. Context length 2048. Custom 24k byte-level BPE
|
| 22 |
+
tokenizer (`tokenizer.json`).
|
| 23 |
+
|
| 24 |
+
## Training
|
| 25 |
+
|
| 26 |
+
- Pretraining: 2B tokens (59% FineWeb-Edu, 40% SQL from The Stack, 1% verified
|
| 27 |
+
text-to-SQL pairs), 43.3 compute hours.
|
| 28 |
+
- Fine-tuning: 1,597 steps over 130,748 examples from Spider train, Gretel and
|
| 29 |
+
synthetic pairs, with loss on the SQL tokens only. Spider schemas are augmented with
|
| 30 |
+
identifier variants (case style, plural flips, optional quote stripping, table order).
|
| 31 |
+
|
| 32 |
+
## Evaluation
|
| 33 |
+
|
| 34 |
+
Spider dev, 1,034 questions. Metric: plain execution accuracy on the original dev
|
| 35 |
+
databases (read-only SQLite). This is not Spider's official test-suite accuracy, which is
|
| 36 |
+
stricter, so it is not comparable to leaderboard scores. Greedy decoding.
|
| 37 |
+
|
| 38 |
+
| Model | Execution accuracy |
|
| 39 |
+
|---|---|
|
| 40 |
+
| Pretrained, zero-shot | 4.84% |
|
| 41 |
+
| + SFT | 17.7% |
|
| 42 |
+
| + SFT with identifier augmentation (this model) | 21.5% |
|
| 43 |
+
|
| 44 |
+
Standard error is about 1.2 points. Most failures are schema errors: 533 of 674
|
| 45 |
+
failing predictions name a column that does not exist.
|
| 46 |
+
|
| 47 |
+
## Prompt format
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
+
<|bos|><|schema|>{CREATE TABLE statements, one per line}<|question|>{question}<|sql|>
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
The model generates SQL until `<|eos|>`.
|
| 54 |
+
|
| 55 |
+
## Usage
|
| 56 |
+
|
| 57 |
+
The architecture is custom, so it does not load through `transformers`. Use the
|
| 58 |
+
`model/` package from the GitHub repo:
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
from safetensors.torch import load_file
|
| 62 |
+
from model.config import QUERION_100M
|
| 63 |
+
from model.transformer import Transformer
|
| 64 |
+
|
| 65 |
+
model = Transformer(QUERION_100M)
|
| 66 |
+
model.load_state_dict(load_file("model.safetensors"), strict=False) # lm_head is tied
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
`scripts/eval_spider.py` in the repo shows full generation and scoring.
|
| 70 |
+
|
| 71 |
+
## Limitations
|
| 72 |
+
|
| 73 |
+
A small model with little multi-table training data. It reads schemas it has seen
|
| 74 |
+
far better than new ones (91% vs 18% in an earlier probe), often invents column names,
|
| 75 |
+
and is not a general-purpose assistant. Do not run its SQL on databases you cannot
|
| 76 |
+
afford to change, and always run it on read-only connections first.
|