flashvenom commited on
Commit
3852c07
Β·
verified Β·
1 Parent(s): 0b79309

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +115 -64
  2. results.png +0 -0
README.md CHANGED
@@ -9,6 +9,7 @@ tags:
9
  - on-device
10
  - small-model
11
  - grammar-constrained-decoding
 
12
  library_name: pytorch
13
  model-index:
14
  - name: thimble-v6
@@ -23,6 +24,16 @@ model-index:
23
  - type: exact_match
24
  value: 33.1
25
  name: Seal-Tools in-domain
 
 
 
 
 
 
 
 
 
 
26
  - task:
27
  type: text-generation
28
  name: Function calling (ordered strict exact match)
@@ -43,78 +54,118 @@ model-index:
43
  - type: exact_match
44
  value: 52.5
45
  name: DroidCall
 
 
 
 
 
 
 
 
 
 
46
  ---
47
 
48
- # Thimble v6
49
-
50
- **Thimble** is a **48.12M-parameter** factorized tool-calling model that beats
51
- [Needle 2](https://cactuscompute.com/needle) (Cactus Compute, 45M, 153B training
52
- tokens) on **three of its five published benchmark tables** β€” including
53
- Seal-Tools, the suite its evaluation is built around β€” while training on
54
- **~1B tokens (150x less)** for a total cost of about $260.
55
-
56
- | Suite | Thimble v6 | Needle 2 (45M) |
57
- |---|---|---|
58
- | **Seal-Tools in-domain** | **33.1** | 32.6 |
59
- | **Mobile Actions** | **86.3** | 63.7 |
60
- | **DroidCall** | **52.5** | 17.0 |
61
- | Seal-Tools out-of-domain | 28.1 | **28.7** |
62
- | BFCL v4 single-turn | 23.5 | **42.6** |
63
-
64
- Metric: ordered strict exact match β€” a row passes only if function names, call
65
- order, and every argument value match exactly. Needle 2's numbers are from
66
- their published tables. The Seal-in margin (+0.5 on 700 rows) is within
67
- sampling noise and is stated as measured, not as a decisive gap. Full
68
- disclosures (parameter-class matching, a champion-selection protocol failure,
69
- the DroidCall split caveat) live in the
70
- [GitHub repo](https://github.com/nikshepsvn/tiny-toolcall)'s RESULTS.md.
71
-
72
- ## How it works
73
-
74
- - **Deep-thin gated trunk**: d=448, 20 layers, GQA 8/4, SwiGLU x2.0, QK-norm,
75
- sandwich RMSNorm, tied embeddings; 16,384-token BPE with digits as
76
- singletons.
77
- - **Grammar-constrained decoding**: JSON structure and argument keys are
78
- force-fed from the tool schemas; the model is consulted at exactly five
79
- choice points (refuse, tool name, optional-include, value, stop). Malformed
80
- JSON and hallucinated parameter names are unreachable by construction β€”
81
- 100% well-formed output.
82
- - **Plan-conditioned retrieval**: the legal tool-name set is re-retrieved
83
- between emitted calls, conditioned on the calls already made.
84
- - **Error-driven training data**: the v6 corpus was synthesized against the
85
- measured failure buckets of the previous version (spurious optional
86
- arguments, wrong-slot entity binding, date canonicalization), then
87
- **annealed into the learning-rate decay phase** of a continued run β€” the
88
- controlled twin experiment showing anneal-beats-scratch for corrective data
89
- is in the repo.
90
-
91
- ## Files
92
-
93
- - `thimble-v6.pt` β€” the released checkpoint (`v6c_ema`): PyTorch
94
- `state_dict` plus config dict (`torch.load(..., weights_only=False)`,
95
- keys: `model`, `cfg`).
96
- - `tokenizer.json` β€” 16,384-entry BPE vocabulary + merges.
97
-
98
- ## Usage
99
-
100
- Inference requires the grammar decoder from the repo (the checkpoint is a
101
- plain transformer; the decoding harness is where the guarantees live):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  ```bash
104
  git clone https://github.com/nikshepsvn/tiny-toolcall
105
  cd tiny-toolcall && uv venv && uv pip install -e .
106
- # place thimble-v6.pt in checkpoints/, tokenizer.json in data/
107
  python scripts/final_eval.py --ckpt thimble-v6 --suite seal-tools-in
108
  ```
109
 
110
- ## Training provenance
111
 
112
- Trained on public function-calling corpora (xlam, ToolACE, Dolci, Glaive,
113
- official benchmark train splits) plus validated synthetic data
114
- (deepseek-v4-flash teacher, stepwise-validated, evidence-filtered). Every
115
- training row passed an 8-gram contamination firewall against every evaluation
116
- query of every reported suite, BFCL included. Nothing was ever tuned on an
117
- eval set; the full experimental record β€” including every negative result β€”
118
- is in the repo.
119
 
120
- MIT. Built by one person and an AI assistant in about a week of evenings.
 
 
9
  - on-device
10
  - small-model
11
  - grammar-constrained-decoding
12
+ - edge
13
  library_name: pytorch
14
  model-index:
15
  - name: thimble-v6
 
24
  - type: exact_match
25
  value: 33.1
26
  name: Seal-Tools in-domain
27
+ - task:
28
+ type: text-generation
29
+ name: Function calling (ordered strict exact match)
30
+ dataset:
31
+ name: Seal-Tools out-of-domain
32
+ type: seal-tools
33
+ metrics:
34
+ - type: exact_match
35
+ value: 28.1
36
+ name: Seal-Tools out-of-domain
37
  - task:
38
  type: text-generation
39
  name: Function calling (ordered strict exact match)
 
54
  - type: exact_match
55
  value: 52.5
56
  name: DroidCall
57
+ - task:
58
+ type: text-generation
59
+ name: Function calling (ordered strict exact match)
60
+ dataset:
61
+ name: BFCL v4 single-turn
62
+ type: bfcl
63
+ metrics:
64
+ - type: exact_match
65
+ value: 23.5
66
+ name: BFCL v4 single-turn
67
  ---
68
 
69
+ # 🧡 Thimble
70
+
71
+ **A 48M-parameter tool-calling model that beats [Needle 2](https://cactuscompute.com/needle)
72
+ on 3 of its 5 published benchmarks β€” including the one it's named after β€” with 150Γ— less training data.**
73
+
74
+ [**GitHub (code, evals, full experimental record)**](https://github.com/nikshepsvn/tiny-toolcall) Β· MIT Β· 48.12M params Β· 11.5MB at 2-bit Β· $260 total build cost
75
+
76
+ ![Results](results.png)
77
+
78
+ ## TL;DR
79
+
80
+ | Suite | Thimble v6 | Needle 2 (45M) | |
81
+ |---|---:|---:|---|
82
+ | Seal-Tools in-domain (700) | **33.1** | 32.6 | βœ… their flagship suite |
83
+ | Mobile Actions (961) | **86.3** | 63.7 | βœ… +22.6 |
84
+ | DroidCall (200) | **52.5** | 17.0 | βœ… 3.1Γ— |
85
+ | Well-formed JSON | **100.0** | 93.4 | βœ… by construction |
86
+ | Seal-Tools out-of-domain (654) | 28.1 | **28.7** | ❌ βˆ’0.6 |
87
+ | BFCL v4 single-turn (3,641) | 23.5 | **42.6** | ❌ their data moat |
88
+
89
+ Metric: **ordered strict exact match** β€” a row passes only if the function names,
90
+ call order, and *every* argument value match. Their metric, their published
91
+ numbers, unmodified. Needle 2 trained on **153B tokens**; Thimble saw **~1B**.
92
+
93
+ Two things to know before quoting the table: the Seal-in margin (+0.5 on 700
94
+ rows) is within sampling noise and we say so, and the pre-registered model
95
+ selector actually picked a sibling checkpoint that scored worse β€” the failure is
96
+ diagnosed, both models' results are published, and the full story is in
97
+ [RESULTS.md](https://github.com/nikshepsvn/tiny-toolcall/blob/master/RESULTS.md).
98
+
99
+ ## Why a thimble beats a needle
100
+
101
+ **1. Tool calling is five decisions, not a generation problem.** A grammar
102
+ compiled from the tool schemas force-feeds all JSON structure β€” braces, quotes,
103
+ and every argument key. The model is consulted at exactly five choice points:
104
+ *refuse or call Β· which tool Β· include this optional? Β· what value Β· stop or
105
+ continue*. Malformed JSON, hallucinated parameter names, and calls to
106
+ nonexistent tools are **unreachable, not unlikely**. At 45M parameters, capacity
107
+ spent learning that `{` follows `[` is capacity wasted.
108
+
109
+ **2. Every training example earns its place.** Row accuracy factors as
110
+ `P(name sequence) Γ— pⁿ`. Each version measured which factor was binding and
111
+ attacked only that. The final data round was synthesized directly against the
112
+ previous model's diagnosed failure buckets β€” spurious optional arguments,
113
+ wrong-slot entity binding, date canonicalization β€” with a mid-training causal
114
+ check (+3.3 points at constant LR, attributable to the corrective data alone).
115
+
116
+ **3. Anneal, don't retrain.** A controlled twin experiment: the corrective
117
+ corpus fed from scratch *diluted* (28.4); the same corpus **annealed into the
118
+ learning-rate decay phase** of a continued run *concentrated* (33.1). The decay
119
+ phase is where a WSD-trained model crystallizes β€” that's where the good data
120
+ belongs.
121
+
122
+ ## What didn't work (measured, not guessed)
123
+
124
+ The most reusable part of the project. Each idea was killed by an A/B, not an argument:
125
+
126
+ | idea | result |
127
+ |---|---|
128
+ | Span-copy heads | βˆ’30 pts |
129
+ | Pointer/copy head | βˆ’16 pts |
130
+ | Down-weighting grammar-forced tokens (RFT-style) | βˆ’12 pts β€” structure tokens carry call-sequencing signal |
131
+ | From-scratch retrain on corrective data | βˆ’4.7 vs annealing |
132
+ | Field-set reranking | βˆ’1.4 β€” training had already fixed its target bucket |
133
+ | Beam / RL / best-of-N | oracle-capped below target |
134
+ | RLOO fine-tune on the annealed checkpoint | diverges at every LR β€” sharp minima and policy gradients don't mix |
135
+ | Matching Seal's gold numeric typing | not learnable β€” 74% of params are mixed-convention noise |
136
+
137
+ ## Model details
138
+
139
+ | | |
140
+ |---|---|
141
+ | Parameters | 48.12M (fp32; ~11.5MB at Needle's own 2-bit standard vs their 14MB) |
142
+ | Architecture | deep-thin gated trunk: d=448, 20 layers, GQA 8/4, SwiGLU Γ—2.0, QK-norm, sandwich RMSNorm, tied embeddings |
143
+ | Tokenizer | 16,384 BPE, digits as singletons, JSON structural chars as singletons |
144
+ | Context | 768 tokens |
145
+ | Decoding | grammar-constrained, five choice points, plan-conditioned retrieval between calls |
146
+ | Training | Muon (trunk) + AdamW, WSD schedule, EMA, weighted CE matched to the error distribution, decay-phase data annealing |
147
+
148
+ ## Files & usage
149
+
150
+ - `thimble-v6.pt` β€” checkpoint (`torch.load(..., weights_only=False)` β†’ `{"model": state_dict, "cfg": dict}`)
151
+ - `tokenizer.json` β€” BPE vocab + merges
152
+
153
+ The guarantees live in the decoding harness, so inference goes through the repo:
154
 
155
  ```bash
156
  git clone https://github.com/nikshepsvn/tiny-toolcall
157
  cd tiny-toolcall && uv venv && uv pip install -e .
158
+ # put thimble-v6.pt in checkpoints/, tokenizer.json in data/
159
  python scripts/final_eval.py --ckpt thimble-v6 --suite seal-tools-in
160
  ```
161
 
162
+ ## Integrity
163
 
164
+ Public corpora (xlam, ToolACE, Dolci, Glaive, official benchmark train splits)
165
+ plus stepwise-validated, evidence-filtered synthetic data. Every training row
166
+ passed an **8-gram contamination firewall against every evaluation query of
167
+ every reported suite** (BFCL included). Champion selection by held-out dev loss
168
+ only; nothing was ever tuned on an eval set; every negative result is published.
 
 
169
 
170
+ *Built by one person and an AI assistant in about a week of evenings, for about
171
+ the price of a game console. The failures are the useful part.*
results.png ADDED