nkthebass commited on
Commit
6e7bc72
·
verified ·
1 Parent(s): 05baf2b

TinyBrainBot 320M V2 Math (final5): fp16 + F16 GGUF

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tinybrainbot-320mV2-math-F16.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ base_model: nkthebass/tinybrainbot-320mV2-base
8
+ tags:
9
+ - tinybrainbot
10
+ - small-language-model
11
+ - from-scratch
12
+ - gqa
13
+ - math
14
+ - arithmetic
15
+ - reasoning
16
+ - gguf
17
+ ---
18
+
19
+ # TinyBrainBot 320M V2 — Math
20
+
21
+ A **~326M-parameter** decoder-only model, trained from scratch on ~10B tokens (2× Tesla V100), then fine-tuned to be a **math-reasoning model**: multi-digit arithmetic and grade-school word problems, solved by **showing the work** (column arithmetic, long division, partial-product multiplication) rather than guessing.
22
+
23
+ - Base model: **`tinybrainbot-320mV2-base`**.
24
+ - **fp16 safetensors** (`AutoModelForCausalLM`) **and F16 GGUF** (LM Studio / Ollama / llama.cpp) both provided.
25
+
26
+ **TL;DR:** For its size it does arithmetic and structured word problems *far* above its weight — it **beats GPT-3-175B on 3–5-digit arithmetic** (both tool-free) and solves multi-step word problems with commas and mixed operations. It is **not** a general-knowledge model — treat it as a compact math engine that also chats a little.
27
+
28
+ ---
29
+
30
+ ## What it does well
31
+
32
+ | Skill | Method | Result |
33
+ |---|---|---|
34
+ | Multi-digit **add / subtract** (2–10 digit, comma-formatted) | column-by-column with carries/borrows | ~90–100% |
35
+ | **Word problems** (large numbers, multi-step, mixed verbs) | reads the problem → delegates to column / partial-product computation | solves the full target set |
36
+ | **2-digit multiplication** | partial products + column addition | ~88% |
37
+ | **Division** | long division | reliable on simple cases |
38
+ | Greetings / short answers | — | fine |
39
+
40
+ It **reads the problem and computes** — e.g. *"A store had 56,321 items and sold 28,479. How many remain?"* →
41
+ ```
42
+ <think> Start with 56321. Then subtract 28479. Subtract column by column:
43
+ ones: 11 - 9 = 2, borrow 1. ... So 56321 - 28479 = 27842. </think>
44
+ The answer is 27842.
45
+ ```
46
+
47
+ ## Evaluation
48
+
49
+ **GPT-3 Arithmetic protocol (exact-match) — vs GPT-3-175B (few-shot, direct):**
50
+
51
+ | Task | GPT-3 175B | **This model** |
52
+ |---|:--:|:--:|
53
+ | 2-digit add | ~100% | 100% |
54
+ | 2-digit sub | ~99% | 95% |
55
+ | 3-digit add | 80.4% | **100%** |
56
+ | 3-digit sub | 94.2% | 95% |
57
+ | 4-digit add | 25.5% | **100%** |
58
+ | 4-digit sub | 26.8% | **98%** |
59
+ | 5-digit add | 9.3% | **100%** |
60
+ | 5-digit sub | 9.9% | **88%** |
61
+ | 2-digit mult | 29.2% | **88%** |
62
+ | 1-digit composite | 21.3% | **92%** |
63
+
64
+ *Ours uses trained-in worked steps; GPT-3's numbers are direct-answer. Both are pure LMs with **no external tools/calculators**. The point is about method: teaching a 326M model the algorithm beats a 175B model guessing — decisively on 4–5-digit arithmetic.*
65
+
66
+ - **Word-problem set** (large-number add/sub with commas, multi-step, 2-digit multiply, first-person phrasings): **solves essentially all of a 20-problem targeted set** by reading the problem and computing the steps.
67
+ - **GSM8K:** ~3–4% (zero-shot CoT, n=500) — off the base instruct's 0.53% floor, at roughly the SmolLM2-360M-Instruct tier. Arbitrary hard multi-step word problems remain **scale-limited** at 326M.
68
+
69
+ **General benchmarks** (log-likelihood MC, our harness; the math SFT did **not** erode general ability):
70
+
71
+ | HellaSwag | ARC-Easy | ARC-Challenge | OpenBookQA | WinoGrande | MMLU |
72
+ |:--:|:--:|:--:|:--:|:--:|:--:|
73
+ | 35.0 | 49.2 | 30.5 | 32.0 | 54.9 | 27.3 |
74
+
75
+ Reaches the **Pythia-410M tier** — a model trained on ~30× more tokens — while being math-specialized.
76
+
77
+ ## Usage
78
+
79
+ Chat format:
80
+ ```
81
+ <|user|>
82
+ {question}
83
+ <|end|>
84
+ <|assistant|>
85
+ {answer}
86
+ <|end|>
87
+ ```
88
+
89
+ ```python
90
+ from transformers import AutoModelForCausalLM, AutoTokenizer
91
+ import torch
92
+ tok = AutoTokenizer.from_pretrained("nkthebass/tinybrainbot-320mV2-math")
93
+ m = AutoModelForCausalLM.from_pretrained("nkthebass/tinybrainbot-320mV2-math", torch_dtype=torch.float16)
94
+ ids = tok.apply_chat_template([{"role":"user","content":"A theater has 56 rows with 27 seats in each row. How many seats?"}],
95
+ add_generation_prompt=True, return_tensors="pt")
96
+ print(tok.decode(m.generate(ids, max_new_tokens=256, do_sample=False)[0][ids.shape[1]:], skip_special_tokens=True))
97
+ ```
98
+ GGUF file (`*-F16.gguf`) works directly in LM Studio / Ollama / llama.cpp.
99
+
100
+ ## Model details
101
+ | | |
102
+ |---|---|
103
+ | Parameters | ~325.9M (1024 hidden · 26 layers · 16h / 4kv GQA · ffn 2816 · ctx 1024) |
104
+ | Vocab / tokenizer | 32,000 · `tbb-32k-v2` (BPE) |
105
+ | Precision | fp16 |
106
+ | Training | from-scratch pretrain (~10B tokens, WSD) → math/reasoning SFT (assistant-masked, chat format). Arithmetic taught as explicit worked steps. |
107
+
108
+ ## Limitations
109
+ - **General knowledge is weak** — it can drift into confident errors on factual/open-ended questions. This is a fundamental 326M capacity limit, not a bug. Use it for math, not facts.
110
+ - **Novel word-problem phrasings** can still trip it (it may drop a step on unusual structures).
111
+ - **Hard multi-step reasoning (GSM8K/MATH)** caps at this scale.
112
+ - 3+ digit multiplication and large-number division are soft spots.
113
+ - English only, 1024-token context, no RLHF/safety tuning — outputs may be wrong or inappropriate; don't rely on them unchecked.
114
+
115
+ ## Hardware & framework
116
+ 2× NVIDIA Tesla V100-PCIE-16GB · Windows · PyTorch DDP (gloo) · fp16 · custom TinyBrainBot trainer.
added_tokens.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|user|>": 4,
3
+ "<|assistant|>": 5,
4
+ "<|system|>": 6,
5
+ "<|end|>": 7,
6
+ "<|mem_l1|>": 8,
7
+ "<|mem_l2|>": 9,
8
+ "<|mem_l3|>": 10,
9
+ "<|sep|>": 11,
10
+ "<|summary|>": 12
11
+ }
config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "model_type": "llama",
6
+ "hidden_size": 1024,
7
+ "intermediate_size": 2816,
8
+ "num_hidden_layers": 26,
9
+ "num_attention_heads": 16,
10
+ "num_key_value_heads": 4,
11
+ "head_dim": 64,
12
+ "hidden_act": "silu",
13
+ "max_position_embeddings": 1024,
14
+ "rope_theta": 10000.0,
15
+ "rms_norm_eps": 1e-05,
16
+ "vocab_size": 32000,
17
+ "tie_word_embeddings": true,
18
+ "torch_dtype": "float16",
19
+ "bos_token_id": 0,
20
+ "eos_token_id": 7,
21
+ "pad_token_id": 2,
22
+ "unk_token_id": 3
23
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfb5961bfc6ee8ce92d7ca128601f35de29f119d208ab2224340004a2bf85cd0
3
+ size 651825128
tinybrainbot-320mV2-math-F16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:619060c3f1251b6ebd989106809c6c3d3d0c57b10ddfbc9afccd0ba16b4996e6
3
+ size 652680256
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa18b4f4dfa6e52d24b70ae1e001319b0392049798b956fbdd4c54e04df5a5d1
3
+ size 774527
tokenizer_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "LlamaTokenizer",
3
+ "bos_token": "<s>",
4
+ "eos_token": "<|end|>",
5
+ "pad_token": "<pad>",
6
+ "unk_token": "<unk>",
7
+ "add_bos_token": false,
8
+ "add_eos_token": false,
9
+ "chat_template": "{%- for m in messages -%}{{- '<|' + m['role'] + '|> ' + m['content'] + ' <|end|> ' -}}{%- endfor -%}{%- if add_generation_prompt -%}{{- '<|assistant|>' -}}{%- endif -%}"
10
+ }