Alpericon commited on
Commit
122222a
·
verified ·
1 Parent(s): 730d879

Model card: held-out Spider test results and recommended inference configuration

Browse files
Files changed (1) hide show
  1. README.md +92 -43
README.md CHANGED
@@ -30,40 +30,70 @@ Code, training logs and every number below: https://github.com/alpericon/tiny-sq
30
 
31
  ## Results
32
 
33
- **Spider dev, 1,034 questions** (greedy decoding, thinking off, 256 new tokens). "Official" is
34
- Spider's official evaluation script (exec EX on the standard databases). "Ours" is the project's
35
- column-permutation-tolerant multiset EX.
36
 
37
- | Model | Ours | Official |
 
 
 
 
 
 
38
  |---|---|---|
39
- | Qwen3-1.7B zero-shot (nf4) | 53.7% | 54.1% |
40
- | + GRPO, unfiltered data (nf4) | 57.1% | 58.1% |
41
- | **+ GRPO, pass-rate-filtered data (this model, nf4 + adapter)** | **58.5%** | **59.0%** |
42
- | this model + one retry on SQL errors (see Usage) | 60.3% | 60.8% |
43
-
44
- - **vs zero-shot:** 84 wins / 33 losses on the same questions (official metric, exact McNemar p<0.0001).
45
- - **vs the unfiltered run:** 39 / 30, p=0.34. That gap is not significant.
46
- - **This release:**
47
- - merged bf16: 59.7% (ours);
48
- - merged and re-quantised to nf4: 57.5%;
49
- - Q8_0 GGUF: 63.5% on a 200-question subset vs 64.5% for bf16 (they disagree on 6 of 200; no
50
- detectable difference).
51
- - **Q4_K_M is not provided.** It breaks the model's output format: −12.5 points on the same subset.
52
-
53
- **Spoken questions** (100 SpokenSpider queries with ASR transcripts, compared with SQLCoder-7B as
54
- used in a voice-to-SQL pipeline):
55
-
56
- | Input | this model | SQLCoder-7B |
57
  |---|---|---|
58
- | clean | 52% | 52% |
59
- | 20 dB SNR | 55% | 50% |
60
- | 10 dB SNR | 52% | 48% |
61
- | 0 dB SNR | 38% | 44% |
 
 
 
 
 
 
 
62
 
63
- None of these differences is significant (n=100, 3 databases).
64
 
65
- **Latency** (RTX 3070 Ti Laptop, nf4, batch 1): 1.42 s median per query, vs 2.08 s for SQLCoder-7B
66
- measured in the same session. Peak VRAM is 1.4 GiB vs 4.0 GiB.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  ## Training
69
 
@@ -79,23 +109,42 @@ measured in the same session. Peak VRAM is 1.4 GiB vs 4.0 GiB.
79
 
80
  ## Usage
81
 
82
- The prompt format matters. Use the chat template with `enable_thinking=False`, and give the schema
83
- as `CREATE TABLE` statements followed by the question. The exact prompt is `tinysql.prompt.build_messages`
84
- in the repository. The model answers with a ```sql block. Decode greedily, with no repetition penalty:
85
- llama-cpp-python's default `repeat_penalty=1.1` noticeably hurts it.
86
-
87
- **Repair:** if the SQL fails to run, or there is no block, one follow-up turn helps. Add the model's
88
- answer as the assistant turn, then the user turn *"That SQL failed: `<error>`. Write a corrected
89
- SQLite query that answers the question, in a ```sql block."*. This rescued 19 of 133 failures on
90
- Spider dev. In 53 of the 133 retries the model repeated the same SQL.
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  ## Limitations
93
 
94
- - **Single seed per run.** The McNemar tests cover question sampling, not training variance.
95
- - **English only, SQLite only.** It is evaluated only on Spider-style databases. About 4 in 10 Spider
96
- dev questions are still answered wrongly, mostly with valid SQL that returns the wrong result.
97
- - **Spoken input loses literal formatting** (case, quotes, "1,000"), which costs ~5 points even on
98
- clean ASR.
 
 
 
 
 
 
99
  - **The official metric's default removes DISTINCT**, which makes it slightly more lenient than ours.
100
  Both are reported.
101
 
 
30
 
31
  ## Results
32
 
33
+ All numbers are execution accuracy (EX) with greedy decoding, thinking off, 256 new tokens and nf4.
34
+ "Official" is Spider's official evaluation script. "Ours" is the project's
35
+ column-permutation-tolerant multiset EX. All comparisons are paired (exact McNemar on the same questions).
36
 
37
+ ### Held-out Spider test (2,147 questions, 40 unseen databases)
38
+
39
+ Every inference step below was chosen on Spider dev. The final configuration was then run **once** on
40
+ the Spider test set (released 2024). None of its databases appear in train or dev, and nothing was
41
+ tuned on it.
42
+
43
+ | Configuration | Official EX, test | Official EX, dev |
44
  |---|---|---|
45
+ | Qwen3-1.7B zero-shot | 56.3% | 54.1% |
46
+ | **this model** (GRPO) | 61.7% | 59.0% |
47
+ | + one retry on SQL errors + literal grounding | 64.2% | 60.9% |
48
+ | + 3 example rows per table in the prompt | 65.7% | 63.4% |
49
+ | **+ schema pruning (recommended)** | **66.3%** | 65.9% |
50
+
51
+ - **Confirmed on test:**
52
+ - GRPO over zero-shot: +5.4 points, 160 wins / 44 losses, p<0.0001.
53
+ - The whole recommended configuration over zero-shot: +10.1 points, 308 / 92, p<0.0001.
54
+ - **Same direction on test but not significant:**
55
+ - example rows: +1.5, p=0.073;
56
+ - schema pruning: +0.6, p=0.28.
57
+ - Both were adopted because they were significant on dev, and both gain less on test.
58
+
59
+ ### Training ablations (Spider dev, 1,034 questions)
60
+
61
+ | Model | Ours | Official |
 
62
  |---|---|---|
63
+ | Qwen3-1.7B zero-shot | 53.7% | 54.1% |
64
+ | + GRPO, unfiltered data | 57.1% | 58.1% |
65
+ | **+ GRPO, pass-rate-filtered data (this model)** | **58.5%** | **59.0%** |
66
+
67
+ - **Filtered vs unfiltered data:** 39 / 30, p=0.34, so the difference is not significant.
68
+ - **Two further training runs gave null results**, so this model stays the release:
69
+ - training on repair turns (dev 62.8 vs 60.8 official with retry, confounded with extra steps);
70
+ - training with example rows in the prompt (63.9% vs 63.4%, p=0.58).
71
+ - **This release, merged:** bf16 59.7% (ours); re-quantised to nf4 57.5%.
72
+ - **Q8_0 GGUF:** 63.5% on a 200-question subset vs 64.5% for bf16 (no detectable difference).
73
+ - **Q4_K_M is not provided.** It breaks the output format (−12.5 points on the same subset).
74
 
75
+ ### Spoken questions
76
 
77
+ 100 SpokenSpider queries with ASR transcripts, compared with SQLCoder-7B as used in a voice-to-SQL
78
+ pipeline. Both systems use the same literal grounding.
79
+
80
+ | Input | this model, recommended configuration | SQLCoder-7B (+ grounding) | wins / losses, p |
81
+ |---|---|---|---|
82
+ | clean | 68% | 55% | 21 / 8, 0.024 |
83
+ | 20 dB SNR | 67% | 53% | 22 / 8, 0.016 |
84
+ | 10 dB SNR | 65% | 51% | 22 / 8, 0.016 |
85
+ | 0 dB SNR | 46% | 45% | 11 / 10, 1.0 |
86
+
87
+ The data is only 100 questions on 3 databases, and the four conditions are separate tests. With a
88
+ Bonferroni correction (α = 0.0125), none is significant on its own. The 1.7B model is ahead from clean
89
+ speech to 10 dB, and level at 0 dB.
90
+
91
+ ### Latency
92
+
93
+ - **GPU** (RTX 3070 Ti Laptop, nf4, batch 1, merged model, schema-only prompt): 1.42 s median per
94
+ query, vs 2.08 s for SQLCoder-7B in the same session. Peak VRAM is 1.4 GiB vs 4.0 GiB.
95
+ - **CPU** (Q8_0 GGUF, 2 threads, recommended configuration): 6.8 s median for a first question on a
96
+ database, and 2.6 s for a follow-up on the same database.
97
 
98
  ## Training
99
 
 
109
 
110
  ## Usage
111
 
112
+ **Prompt:**
113
+ - The model was trained with a schema-only prompt. Use the chat template with
114
+ `enable_thinking=False`, and give the schema as `CREATE TABLE` statements followed by the question.
115
+ The exact prompt is `tinysql.prompt.build_messages` in the repository.
116
+ - The model answers with a ```sql block.
117
+ - Decode greedily, with no repetition penalty. llama-cpp-python's default `repeat_penalty=1.1`
118
+ noticeably hurts it.
119
+
120
+ **Recommended configuration.** Each step is inference-only and implemented in the repository.
121
+ 1. **Example rows:** after each `CREATE TABLE`, add the table's first 3 rows as
122
+ `-- Example rows from <table>:` comment lines (`serialize_schema(db, sample_rows=3)`). It mainly
123
+ reduces wrong-column errors. On CPU it roughly doubles the cold prompt cost.
124
+ 2. **Schema pruning:** show only the tables the question mentions, by name, column word or stored
125
+ value, plus the foreign-key bridge tables between them (`tinysql.prune.select_tables`). When fewer
126
+ than 2 tables match, show the full schema. The pruner was tuned on Spider train and keeps every
127
+ needed table for 98.9% of dev and 98.5% of test questions.
128
+ 3. **Repair:** if the SQL fails to run, or there is no block, give one follow-up turn on the **full**
129
+ schema. Add the model's answer as the assistant turn, then the user turn *"That SQL failed:
130
+ `<error>`. Write a corrected SQLite query that answers the question, in a ```sql block."*.
131
+ 4. **Literal grounding:** before executing, replace a string literal with the database's own value
132
+ when exactly one value matches it, ignoring case and whitespace. This mainly matters for spoken
133
+ input, where ASR loses capitalisation.
134
 
135
  ## Limitations
136
 
137
+ - **Single seed per training run.** The McNemar tests cover question sampling, not training variance.
138
+ - **English only, SQLite only, Spider-style schemas.**
139
+ - About a third of Spider test questions are still answered wrongly, mostly with valid SQL that
140
+ returns the wrong result.
141
+ - An error analysis of 100 such failures on dev found that 45% pick the wrong table, column or
142
+ join path.
143
+ - The pruner relies on question words matching schema names, so it may help less on schemas with
144
+ cryptic names.
145
+ - **Spider's gold queries have errors.** On dev, about 15% of the remaining wrong-result failures
146
+ came from a wrong gold query or an ambiguous question.
147
+ - **Spoken input:** ASR word errors ("ID" heard as "it") and number formats ("1,000") are not handled.
148
  - **The official metric's default removes DISTINCT**, which makes it slightly more lenient than ours.
149
  Both are reported.
150