adiitya0929 commited on
Commit
88c56c9
·
verified ·
1 Parent(s): f9880f3

SmolLM2-135M fine-tuned with the TinySQL recipe

Browse files
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ base_model: HuggingFaceTB/SmolLM2-135M
8
+ datasets:
9
+ - Salesforce/wikisql
10
+ tags:
11
+ - text-to-sql
12
+ - sql
13
+ - wikisql
14
+ - baseline
15
+ ---
16
+
17
+ # SmolLM2-135M-WikiSQL-baseline
18
+
19
+ [SmolLM2-135M](https://huggingface.co/HuggingFaceTB/SmolLM2-135M) (by Hugging Face) fine-tuned on WikiSQL with exactly the recipe used for TinySQL-125M, as a baseline in the TinySQL paper. It answers the question "what does the same fine-tuning give on a model pretrained on about 2T tokens instead of 4.5B?". For the from-scratch model, see [adiitya0929/TinySQL-125M-WikiSQL](https://huggingface.co/adiitya0929/TinySQL-125M-WikiSQL).
20
+
21
+ - **Paper:** [TinySQL: A 125M-Parameter Text-to-SQL Model Built and Pretrained From Scratch on 4.5B Tokens](https://doi.org/10.5281/zenodo.23396770) (Zenodo, 2026)
22
+ - **Code:** [github.com/aditya0929/tinysql](https://github.com/aditya0929/tinysql) (`eval/baselines/finetune_hf.py`)
23
+
24
+ ## Quick start
25
+
26
+ ```python
27
+ from transformers import AutoModelForCausalLM, AutoTokenizer
28
+
29
+ repo = "adiitya0929/SmolLM2-135M-WikiSQL-baseline"
30
+ tok = AutoTokenizer.from_pretrained(repo)
31
+ model = AutoModelForCausalLM.from_pretrained(repo)
32
+
33
+ prompt = ('<schema>CREATE TABLE t ("Player" TEXT, "Position" TEXT, "School/Club Team" TEXT);</schema>\n'
34
+ '<question>What position does the player who played for butler cc (ks) play?</question>\n<sql>')
35
+ ids = tok(prompt, return_tensors="pt", add_special_tokens=False).input_ids
36
+ out = model.generate(ids, max_new_tokens=64, do_sample=False, stop_strings=["</sql>"], tokenizer=tok)
37
+ print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True).split("</sql>")[0])
38
+ # SELECT "Position" FROM t WHERE "School/Club Team" = 'butler cc (ks)';
39
+ ```
40
+
41
+ The prompt format is the same as TinySQL's. Here `<schema>`, `<question>` and `<sql>` are plain text, not special tokens.
42
+
43
+ ## Training
44
+
45
+ WikiSQL train (56,355 examples), loss on the SQL only, batch 32, AdamW (the repository's own), peak LR 1e-4 with warmup and cosine decay, 3 epochs, seed 0. The best epoch was picked by execution accuracy on the first 1,000 dev questions: 76.3 / **78.3** / 77.1%, so epoch 2.
46
+
47
+ ## Results (WikiSQL dev, 8,421 questions)
48
+
49
+ | Decoding | Execution accuracy | Exact match |
50
+ |---|---|---|
51
+ | Greedy | 82.72% | 74.79% |
52
+ | Schema constraints | 83.46% | 75.05% |
53
+ | Schema + values constraints | 85.19% | 76.62% |
54
+
55
+ The constrained decoder for Hugging Face models is `eval/baselines/constrained_hf.py` in the repository.
56
+
57
+ This is the dev-phase run. The paper's test-set numbers for SmolLM2-135M (82.57 ± 0.37% greedy, 85.22 ± 0.21% constrained) come from three later runs with the same recipe and LR (seeds 0, 1 and 2), whose weights were not kept.
58
+
59
+ ## Citation
60
+
61
+ ```bibtex
62
+ @techreport{jha2026tinysql,
63
+ title = {{TinySQL}: A 125M-Parameter Text-to-SQL Model Built and Pretrained From Scratch on 4.5B Tokens},
64
+ author = {Jha, Aditya Narayan},
65
+ year = {2026},
66
+ institution = {Zenodo},
67
+ doi = {10.5281/zenodo.23396770},
68
+ url = {https://doi.org/10.5281/zenodo.23396770}
69
+ }
70
+ ```
71
+
72
+ SmolLM2 itself: Ben Allal et al., [*SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model*](https://arxiv.org/abs/2502.02737), 2025.
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "dtype": "float32",
9
+ "eos_token_id": 0,
10
+ "head_dim": 64,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 576,
13
+ "initializer_range": 0.041666666666666664,
14
+ "intermediate_size": 1536,
15
+ "is_llama_config": true,
16
+ "max_position_embeddings": 8192,
17
+ "mlp_bias": false,
18
+ "model_type": "llama",
19
+ "num_attention_heads": 9,
20
+ "num_hidden_layers": 30,
21
+ "num_key_value_heads": 3,
22
+ "pad_token_id": null,
23
+ "pretraining_tp": 1,
24
+ "rms_norm_eps": 1e-05,
25
+ "rope_interleaved": false,
26
+ "rope_parameters": {
27
+ "rope_theta": 100000,
28
+ "rope_type": "default"
29
+ },
30
+ "tie_word_embeddings": true,
31
+ "transformers_version": "5.19.0",
32
+ "use_cache": true,
33
+ "vocab_size": 49152
34
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "5.19.0"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ad1fbb7ae9e6716adf3a8adc7a1d03058c8f78d5fd1c9840bc5672cf733ab3d
3
+ size 538090408
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<|endoftext|>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|endoftext|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|endoftext|>",
10
+ "<|im_start|>",
11
+ "<|im_end|>",
12
+ "<repo_name>",
13
+ "<reponame>",
14
+ "<file_sep>",
15
+ "<filename>",
16
+ "<gh_stars>",
17
+ "<issue_start>",
18
+ "<issue_comment>",
19
+ "<issue_closed>",
20
+ "<jupyter_start>",
21
+ "<jupyter_text>",
22
+ "<jupyter_code>",
23
+ "<jupyter_output>",
24
+ "<jupyter_script>",
25
+ "<empty_output>"
26
+ ],
27
+ "is_local": false,
28
+ "local_files_only": false,
29
+ "model_max_length": 8192,
30
+ "pad_token": "<|endoftext|>",
31
+ "tokenizer_class": "GPT2Tokenizer",
32
+ "unk_token": "<|endoftext|>",
33
+ "vocab_size": 49152
34
+ }