File size: 2,821 Bytes
f523756
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d99a6ad
 
 
f523756
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
---
license: mit
language:
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- text-to-sql
- sql
- bird-bench
datasets:
- HuggingFaceFW/fineweb-edu
- bigcode/starcoderdata
---

# sqlpup-394m-sft

Supervised fine-tuning of a from-scratch 394M text-to-SQL decoder. 22.84% execution accuracy on BIRD dev.

Pretrained from scratch on 9.67B tokens, then supervised fine-tuned on filtered natural-language-to-SQL pairs.

Code, configs, and the per-run artifacts behind every number here:
[github.com/shivenkk/sqlpup](https://github.com/shivenkk/sqlpup).

## What it is

A 394M-parameter decoder trained from scratch for text-to-SQL: no pretrained
initialisation, no distillation from a larger model. The corpus (9.67B tokens) and
the 32,768-entry byte-level BPE tokenizer were built for this task.

Architecture: Llama-style, 1024 wide by 32 layers, grouped-query attention with 16
query heads and 4 key/value heads, RoPE, SwiGLU, RMSNorm, 2048-token context.

## Measured accuracy

Execution accuracy on the BIRD development split, all 1534 questions:

| decoding | **this model** | `sqlpup-394m-sft-grpo` |
|---|---|---|
| greedy | 17.41% | 18.12% |
| + schema compaction | 17.86% | 19.23% |
| + compaction, 7-sample voting | 22.84% | 23.51% |

The voting rows are means over sampling seeds 0/101/202. Absolute accuracy is far
from frontier systems; the point of the project was a controlled measurement of
what from-scratch pretraining at this scale buys, not a leaderboard score.

## Prompt format

The model expects the schema's `CREATE TABLE` statements verbatim, then the
question, then BIRD's `evidence` string. It emits a short comment block naming the
tables and columns it intends to use, then the SQL. Use the accompanying code so
the format and the SQL extraction match what the numbers were measured with.

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("shivenkk/sqlpup-394m-sft")
tok = AutoTokenizer.from_pretrained("shivenkk/sqlpup-394m-sft")
```

For evaluation, prefer the project's own harness, which handles the prompt spec,
over-context schema compaction, and execution-guided voting:

```bash
python -m sqlpup.cli eval predict --model-dir <dir> --examples dev.json \
  --db-root dev_databases --out-dir out --compact-overflow --self-consistency 7
```

## Limitations

- 2048-token context. Large schemas need the compaction pass to fit.
- Trained and measured on BIRD only. No test-split number, no second dataset.
- Roughly 1% of dev questions produce no parseable SQL in the voting
  configuration, recorded as errors rather than dropped.

## Training data

FineWeb-Edu, StarCoder, the Python subset of The Stack, SynSQL-2.5M, and
SchemaPile, deduplicated and decontaminated against the evaluation sets.