PhysiQuanty commited on
Commit
948d6da
·
verified ·
1 Parent(s): a943b5c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +302 -0
README.md CHANGED
@@ -1,3 +1,305 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - slm
7
+ - arithmetic
8
+ - math
9
+ - causal-lm
10
+ - text-generation
11
+ - custom_code
12
+ - safetensors
13
+ library_name: transformers
14
+ pipeline_tag: text-generation
15
+ metrics:
16
+ - accuracy
17
+ model-index:
18
+ - name: Arithmetic-SLM
19
+ results:
20
+ - task:
21
+ type: text-generation
22
+ name: Arithmetic continuation
23
+ dataset:
24
+ type: AxiomicLabs/ArithMark-2.0
25
+ name: ArithMark-2
26
+ metrics:
27
+ - type: accuracy
28
+ name: Overall
29
+ value: 78.60
30
  ---
31
+
32
+
33
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/6975505c60cf607407afe2c0/g4yF4mQR39XYMoUehSTsX.png)
34
+
35
+ # Arithmetic-SLM
36
+
37
+ Arithmetic-SLM is a small language model specialized for arithmetic continuation. It is designed to be highly efficient on numerical operations with mostly two-digit numbers in patterns such as:
38
+
39
+ ```text
40
+ a op b op c op d
41
+ ```
42
+
43
+ where:
44
+
45
+ ```text
46
+ op = +, -, *, /
47
+ ```
48
+
49
+ The goal is not to make a general chatbot. The goal is to train a compact model that can learn arithmetic patterns, operator priority, parentheses, and numerical continuation with very few parameters.
50
+
51
+
52
+ ## Scores
53
+
54
+ <div align="center">
55
+
56
+ <table>
57
+ <tr>
58
+ <th align="center">Model</th>
59
+ <th align="center">Parameters</th>
60
+ <th align="center">Overall Score</th>
61
+ </tr>
62
+ <tr>
63
+ <td align="center"><code>Qwen/Qwen2.5-Math-1.5B</code></td>
64
+ <td align="center">1.54B</td>
65
+ <td align="center"><strong>82.08%</strong></td>
66
+ </tr>
67
+ <tr>
68
+ <td align="center"><code>PhysiQuanty/Arithmetic-SLM</code></td>
69
+ <td align="center">31.70M</td>
70
+ <td align="center"><strong>78.60%</strong></td>
71
+ </tr>
72
+ <tr>
73
+ <td align="center"><code>Qwen/Qwen2.5-3B</code></td>
74
+ <td align="center">3.09B</td>
75
+ <td align="center">78.44%</td>
76
+ </tr>
77
+ <tr>
78
+ <td align="center"><code>Qwen/Qwen2.5-1.5B</code></td>
79
+ <td align="center">1.54B</td>
80
+ <td align="center">77.72%</td>
81
+ </tr>
82
+ <tr>
83
+ <td align="center"><code>Qwen/Qwen2.5-Coder-1.5B</code></td>
84
+ <td align="center">1.54B</td>
85
+ <td align="center">74.88%</td>
86
+ </tr>
87
+ <tr>
88
+ <td align="center"><code>HuggingFaceTB/SmolLM2-1.7B</code></td>
89
+ <td align="center">1.71B</td>
90
+ <td align="center">66.12%</td>
91
+ </tr>
92
+ <tr>
93
+ <td align="center"><code>Qwen/Qwen2.5-0.5B</code></td>
94
+ <td align="center">494M</td>
95
+ <td align="center">63.04%</td>
96
+ </tr>
97
+ <tr>
98
+ <td align="center"><code>facebook/MobileLLM-R1-140M-base</code></td>
99
+ <td align="center">140M</td>
100
+ <td align="center">53.88%</td>
101
+ </tr>
102
+ <tr>
103
+ <td align="center"><code>SupraLabs/Supra-50M-Base</code></td>
104
+ <td align="center">52M</td>
105
+ <td align="center">27.12%</td>
106
+ </tr>
107
+ </table>
108
+
109
+ </div>
110
+
111
+ ## Calculation Patterns
112
+
113
+ ### 1. Single operation
114
+
115
+ ```text
116
+ 59 + 45 = 104
117
+ 26 - 2 = 24
118
+ 12 * 7 = 84
119
+ 84 / 12 = 7
120
+ ```
121
+
122
+ ### 2. Two operations without parentheses
123
+
124
+ ```text
125
+ 16 + 4 * 3 = 28
126
+ 95 - 8 * 0 = 95
127
+ 84 / 12 - 3 = 4
128
+ ```
129
+
130
+ ### 3. Two operations with parentheses
131
+
132
+ ```text
133
+ (16 / 4) + 44 = 48
134
+ (10 + 28) * 3 = 114
135
+ 1 * (16 + 28) = 44
136
+ ```
137
+
138
+ ### 4. Three operations without parentheses
139
+
140
+ ```text
141
+ 3 * 9 + 12 / 1 = 39
142
+ 60 + 49 - 18 + 8 = 99
143
+ 43 + 10 * 2 - 8 = 55
144
+ ```
145
+
146
+ ### 5. Three operations with parentheses
147
+
148
+ ```text
149
+ (132 / 12) + (46 - 15) = 42
150
+ (46 + 34) - (1 + 7) = 72
151
+ (21 + 27) * (14 - 7) = 336
152
+ ```
153
+
154
+ ### 6. Decimal arithmetic
155
+
156
+ ```text
157
+ 0.5 * 0.5 = 0.25
158
+ 1 / 10 = 0.1
159
+ 7 / 2 = 3.5
160
+ ```
161
+
162
+ ## Example Outputs with `inference.py`
163
+
164
+ ### Example 1 — Raw arithmetic prompt
165
+
166
+ ```bash
167
+ python3 inference.py \
168
+ --model PhysiQuanty/Arithmetic-SLM \
169
+ --prompt "59 + 45 =" \
170
+ --max-new-tokens 32 \
171
+ --temperature 0.6 \
172
+ --top-k 50 \
173
+ --top-p 0.97 \
174
+ --print-full
175
+ ```
176
+
177
+ Expected style:
178
+
179
+ ```text
180
+ 59 + 45 = 104
181
+ ```
182
+
183
+ ### Example 2 — Production `/no think` format
184
+
185
+ ```bash
186
+ python3 inference.py \
187
+ --model PhysiQuanty/Arithmetic-SLM \
188
+ --prompt "0.5 * 0.5 =" \
189
+ --no-think \
190
+ --max-new-tokens 48 \
191
+ --temperature 0.6 \
192
+ --top-k 50 \
193
+ --top-p 0.97 \
194
+ --repetition-penalty 1 \
195
+ --frequency-penalty 0.0 \
196
+ --no-repeat-ngram-size 0 \
197
+ --seed -1 \
198
+ --print-full
199
+ ```
200
+
201
+ Example output:
202
+
203
+ ```text
204
+ [IM_START]user
205
+ 0.5 * 0.5 = /no think[IM_END]
206
+ [IM_START]assistant
207
+ <think>
208
+ </think>
209
+ 0.5 * 0.5 = 0.25[IM_END]
210
+ ```
211
+
212
+ ### Example 3 — Operator priority
213
+
214
+ ```bash
215
+ python3 inference.py \
216
+ --model PhysiQuanty/Arithmetic-SLM \
217
+ --prompt "8 * 5 + 4 / 4 =" \
218
+ --no-think \
219
+ --max-new-tokens 48 \
220
+ --temperature 0.6 \
221
+ --top-k 50 \
222
+ --top-p 0.97 \
223
+ --print-full
224
+ ```
225
+
226
+ Expected style:
227
+
228
+ ```text
229
+ 8 * 5 + 4 / 4 = 41
230
+ ```
231
+
232
+ ### Example 4 — Parentheses
233
+
234
+ ```bash
235
+ python3 inference.py \
236
+ --model PhysiQuanty/Arithmetic-SLM \
237
+ --prompt "(85 - 45) + 56 =" \
238
+ --no-think \
239
+ --max-new-tokens 48 \
240
+ --temperature 0.5 \
241
+ --top-k 40 \
242
+ --top-p 0.95 \
243
+ --print-full
244
+ ```
245
+
246
+ Expected style:
247
+
248
+ ```text
249
+ (85 - 45) + 56 = 96
250
+ ```
251
+
252
+ ### Example 5 — Three-operation expression
253
+
254
+ ```bash
255
+ python3 inference.py \
256
+ --model PhysiQuanty/Arithmetic-SLM \
257
+ --prompt "3 * 9 + 12 / 1 =" \
258
+ --no-think \
259
+ --max-new-tokens 48 \
260
+ --temperature 0.4 \
261
+ --top-k 20 \
262
+ --top-p 0.85 \
263
+ --print-full
264
+ ```
265
+
266
+ Expected style:
267
+
268
+ ```text
269
+ 3 * 9 + 12 / 1 = 39
270
+ ```
271
+
272
+ ### Example 6 — BOS/EOS base mode for base models
273
+
274
+ Use this mode for base models that were not trained with the Qwen-style `[IM_START]user ... /no think[IM_END]` format.
275
+
276
+ ```bash
277
+ python3 inference.py \
278
+ --model Supra-50M-Base-local \
279
+ --prompt "8 * 5 + 4 / 4 =" \
280
+ --no-qwen-format \
281
+ --max-new-tokens 32 \
282
+ --temperature 0.6 \
283
+ --top-k 50 \
284
+ --top-p 0.97 \
285
+ --repetition-penalty 1 \
286
+ --frequency-penalty 0.0 \
287
+ --no-repeat-ngram-size 0 \
288
+ --seed -1 \
289
+ --print-full
290
+ ```
291
+
292
+ ## Next Research Directions
293
+
294
+ We will continue improving our dataset engineering, but more importantly, we want to teach the model what most models are never explicitly taught:
295
+
296
+ - **Binary calculation:** Neural Application Binary Interface, or **NABI**, with 16-bit numerical structures, including floats.
297
+ - **FP16 to base-65k conversion:** a `float16` value is represented by 2 bytes, meaning 65,536 possible bit patterns. Base 65,536 also contains 65,536 possible integer values, making exact bit-level mapping possible.
298
+ - **Dot-product learning:** explicit learning of scalar products on `float16` vectors with 16, 8, 4, and 2 dimensions.
299
+ - **Learning the dynamics of its own learning:** training the model to predict its own weights and gradients over time, including its own gradient descent dynamics.
300
+
301
+ This project does not claim to be a revolution.
302
+
303
+ It is an experiment in making small models learn precise arithmetic, numerical structure, and eventually parts of their own learning dynamics.
304
+
305
+ **By Science AND FOR SCIENCE <3**