brulee-1 commited on
Commit
011504b
·
verified ·
1 Parent(s): 726254a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +159 -0
README.md ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ tags:
5
+ - pytorch
6
+ - moe
7
+ - sparse-moe
8
+ - bitnet
9
+ - 1-bit
10
+ - 4-bit
11
+ - scratch
12
+ - turbowarp
13
+ - instruct
14
+ base_model: brulee-1/SSMoELM-Base
15
+ ---
16
+
17
+ # SSMoELM-it
18
+
19
+ **Scratch Small MoE Language Model — Instruct** — instruction-tuned version of [SSMoELM-Base](https://huggingface.co/brulee-1/SSMoELM-Base).
20
+
21
+ - **47M total / 25.8M active parameters** (top-2 sparse routing)
22
+ - **12.1 MB** packed weights (1-bit routed experts, 4-bit attention & embedding)
23
+ - Fine-tuned on [Dolly-15k](https://huggingface.co/datasets/databricks/databricks-dolly-15k) + [oasst1 EN](https://huggingface.co/datasets/OpenAssistant/oasst1)
24
+
25
+ > **Note:** The HuggingFace model card may display ~12M parameters and an "8-bit" quantization badge. Both are artifacts of reading the packed `model.safetensors` directly. The actual model has **47M parameters** quantized to **1-bit and 4-bit**.
26
+
27
+ > "Scratch" carries two meanings: built *for Scratch*, trained *from scratch*.
28
+
29
+ ---
30
+
31
+ ## Model Details
32
+
33
+ | | |
34
+ |---|---|
35
+ | Architecture | Decoder-only Transformer + Sparse MoE FFN |
36
+ | Total params | 47.04M |
37
+ | Active params | 25.80M (per forward pass) |
38
+ | d_model | 768 |
39
+ | Layers | 6 |
40
+ | Attention | GQA — 12 heads, kv_heads=3, head_dim=64 |
41
+ | Positional encoding | RoPE |
42
+ | Normalization | RMSNorm |
43
+ | Activation | SwiGLU |
44
+ | MoE | 8 routed experts + 1 shared expert, top-2 routing |
45
+ | d_ff (per expert) | 256 |
46
+ | Vocabulary | 8,192 (BPE, byte-fallback, English-optimized) |
47
+ | Context length | 2,048 tokens |
48
+ | Base model | SSMoELM-Base (900M token pretrain) |
49
+ | Framework | MLX (training) / PyTorch (inference) |
50
+
51
+ ---
52
+
53
+ ## Quantization Scheme
54
+
55
+ Same as SSMoELM-Base. See [SSMoELM-Base](https://huggingface.co/brulee-1/SSMoELM-Base) for details.
56
+
57
+ ---
58
+
59
+ ## Training
60
+
61
+ ### Pretraining
62
+ | | |
63
+ |---|---|
64
+ | Dataset | FineWeb-Edu-score-2 (60%) + FineWeb (40%) |
65
+ | Tokens | 900M |
66
+
67
+ ### Instruction Tuning (SFT)
68
+ | | |
69
+ |---|---|
70
+ | Base checkpoint | SSMoELM-Base (step 013734) |
71
+ | Dataset | Dolly-15k (CC BY-SA 3.0) + oasst1 EN (Apache 2.0) |
72
+ | Samples | ~39K (14.8K Dolly + 24K oasst1) |
73
+ | Steps | 20,000 |
74
+ | Learning rate | 1e-5 (constant) |
75
+ | Loss | Assistant tokens only |
76
+
77
+ ---
78
+
79
+ ## Benchmark Results (0-shot, 500 samples)
80
+
81
+ | Task | Shot | Metric | Samples | Random | Base | **Instruct** | Δ |
82
+ |---|---|---|---|---|---|---|---|
83
+ | HellaSwag | 0-shot | acc_norm | 500 | 25% | 33.4% | **33.2%** | -0.2% |
84
+ | LAMBADA | 0-shot | acc | 500 | N/A | 13.8% | **14.8%** | +1.0% |
85
+ | PIQA | 0-shot | acc_norm | 500 | 50% | 53.2% | **55.4%** | +2.2% |
86
+ | WinoGrande | 0-shot | acc | 500 | 50% | 49.6% | **49.6%** | 0% |
87
+ | ARC-Easy | 0-shot | acc_norm | 500 | 25% | 35.0% | **35.2%** | +0.2% |
88
+ | ARC-Challenge | 0-shot | acc_norm | 500 | 25% | 21.0% | **24.0%** | +3.0% |
89
+ | BoolQ | 0-shot | acc | 500 | 50% | 36.2% | **44.4%** | +8.2% |
90
+ | MMLU (57 tasks avg) | 0-shot | acc | up to 500/task | 25% | 23.4% | **23.2%** | -0.2% |
91
+
92
+ ---
93
+
94
+ ## Tokenizer
95
+
96
+ - BPE, vocabulary size = 8,192
97
+ - Byte fallback enabled (no `<unk>`)
98
+ - ASCII/English-optimized segmentation
99
+
100
+ ### Special Tokens
101
+
102
+ | Token | ID | Role |
103
+ |---|---|---|
104
+ | `<bos>` | 0 | sequence start |
105
+ | `<eos>` | 1 | end of sequence |
106
+ | `<pad>` | 2 | padding |
107
+ | `<\|system\|>` | 3 | system turn |
108
+ | `<\|user\|>` | 4 | user turn |
109
+ | `<\|assistant\|>` | 5 | assistant turn |
110
+ | `<\|eot\|>` | 6 | end of turn |
111
+
112
+ ### Chat Template
113
+
114
+ ```
115
+ <bos><|user|>
116
+ {user}<|eot|>
117
+ <|assistant|>
118
+ {response}<|eot|><eos>
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Usage
124
+
125
+ Download `inference.py` and `tokenizer.json` from this repo. Requires: `torch`, `safetensors`, `tokenizers`.
126
+
127
+ ```bash
128
+ pip install torch safetensors tokenizers
129
+ ```
130
+
131
+ ```python
132
+ from inference import load_packed_model
133
+ from tokenizers import Tokenizer
134
+
135
+ model = load_packed_model("model.safetensors")
136
+ tok = Tokenizer.from_file("tokenizer.json")
137
+
138
+ # Build prompt manually
139
+ BOS, USER, ASSISTANT, EOT = 0, 4, 5, 6
140
+ ids = [BOS] + [USER] + tok.encode("\nHello, how are you?").ids + [EOT, ASSISTANT]
141
+ out = model.generate(ids, max_new_tokens=100, temperature=0.8)
142
+ print(tok.decode(out))
143
+ ```
144
+
145
+ CLI:
146
+ ```bash
147
+ python inference.py \
148
+ --ckpt model.safetensors \
149
+ --prompt "What is the capital of France?" \
150
+ --max-tokens 100
151
+ ```
152
+
153
+ > **Memory:** Weights stay in packed uint8 format (12.1 MB). Peak RAM ~18 MB during inference.
154
+
155
+ ---
156
+
157
+ ## License
158
+
159
+ Apache 2.0