Text Generation
Transformers
Safetensors
GGUF
English
llama
tinybrainbot
small-language-model
from-scratch
gqa
math
arithmetic
reasoning
conversational
text-generation-inference
Instructions to use nkthebass/tinybrainbot-320mV2-math with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nkthebass/tinybrainbot-320mV2-math with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nkthebass/tinybrainbot-320mV2-math") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nkthebass/tinybrainbot-320mV2-math") model = AutoModelForCausalLM.from_pretrained("nkthebass/tinybrainbot-320mV2-math", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use nkthebass/tinybrainbot-320mV2-math with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf nkthebass/tinybrainbot-320mV2-math:F16 # Run inference directly in the terminal: llama cli -hf nkthebass/tinybrainbot-320mV2-math:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf nkthebass/tinybrainbot-320mV2-math:F16 # Run inference directly in the terminal: llama cli -hf nkthebass/tinybrainbot-320mV2-math:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf nkthebass/tinybrainbot-320mV2-math:F16 # Run inference directly in the terminal: ./llama-cli -hf nkthebass/tinybrainbot-320mV2-math:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf nkthebass/tinybrainbot-320mV2-math:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf nkthebass/tinybrainbot-320mV2-math:F16
Use Docker
docker model run hf.co/nkthebass/tinybrainbot-320mV2-math:F16
- LM Studio
- Jan
- vLLM
How to use nkthebass/tinybrainbot-320mV2-math with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nkthebass/tinybrainbot-320mV2-math" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nkthebass/tinybrainbot-320mV2-math", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nkthebass/tinybrainbot-320mV2-math:F16
- SGLang
How to use nkthebass/tinybrainbot-320mV2-math with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nkthebass/tinybrainbot-320mV2-math" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nkthebass/tinybrainbot-320mV2-math", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nkthebass/tinybrainbot-320mV2-math" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nkthebass/tinybrainbot-320mV2-math", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use nkthebass/tinybrainbot-320mV2-math with Ollama:
ollama run hf.co/nkthebass/tinybrainbot-320mV2-math:F16
- Unsloth Studio
How to use nkthebass/tinybrainbot-320mV2-math with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nkthebass/tinybrainbot-320mV2-math to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nkthebass/tinybrainbot-320mV2-math to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for nkthebass/tinybrainbot-320mV2-math to start chatting
- Docker Model Runner
How to use nkthebass/tinybrainbot-320mV2-math with Docker Model Runner:
docker model run hf.co/nkthebass/tinybrainbot-320mV2-math:F16
- Lemonade
How to use nkthebass/tinybrainbot-320mV2-math with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull nkthebass/tinybrainbot-320mV2-math:F16
Run and chat with the model
lemonade run user.tinybrainbot-320mV2-math-F16
List all available models
lemonade list
- Atomic Chat
TinyBrainBot 320M V2 Math (final5): fp16 + F16 GGUF
Browse files- .gitattributes +1 -0
- README.md +116 -0
- added_tokens.json +11 -0
- config.json +23 -0
- model.safetensors +3 -0
- tinybrainbot-320mV2-math-F16.gguf +3 -0
- tokenizer.model +3 -0
- tokenizer_config.json +10 -0
.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 |
+
}
|