NODEMIND commited on
Commit
888f8e9
·
verified ·
1 Parent(s): aef5ed5

license: MIT

Browse files
Files changed (2) hide show
  1. LICENSE +21 -0
  2. README.md +233 -233
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NODEMIND
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,233 +1,233 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- viewer: false
4
- language:
5
- - en
6
- pipeline_tag: text-generation
7
- tags:
8
- - small
9
- - shadow
10
- - instruct
11
- - chat
12
- - long-context
13
- - retrieval
14
- - cpu
15
- ---
16
-
17
- <h1 align="center">SHADOW 250M Instruct</h1>
18
-
19
- ![shadow](banner.jpg)
20
-
21
- <p align="center">
22
- Instruct model of SHADOW 250M · 250M Parameters · 100M-Token Offline Context · 60 MB
23
- </p>
24
-
25
- **SHADOW 250M Instruct** is a 250 million parameter language model built from scratch,
26
- trained on 30 billion tokens of English text with about 0.7 billion further tokens of
27
- instruction tuning. The complete deployment is 60 MB, vocabulary included. It runs at about 400 tokens per
28
- second on a laptop CPU and uses about 80 MB of RAM.
29
-
30
- Language modeling quality of the base model, measured on held-out English web text that
31
- was never seen in training (educational web pages, 2,048 token windows): cross entropy
32
- 3.15 nats per token, perplexity 23.3, 0.99 bits per byte.
33
-
34
- Next to its 2,048 token attention window, SHADOW can use an offline archive: a compressed
35
- cache of up to 100 million tokens that stays on your hard disk. The model was trained from
36
- step 1 to retrieve from this archive, all the way up to 100 million tokens. Due to a
37
- limited budget it was not trained to reason over the tokens in the disk cache. It finds
38
- facts and reads them back; it does not think across them.
39
-
40
- For scale, the official released weight files of well-known small models, next to ours:
41
-
42
- | model | parameters | weights on disk |
43
- |---|---|---|
44
- | GPT-2 | 124M | 548 MB |
45
- | SmolLM2-135M-Instruct | 135M | 269 MB |
46
- | SmolLM2-360M-Instruct | 360M | 724 MB |
47
- | Qwen2.5-0.5B-Instruct | 494M | 988 MB |
48
- | **SHADOW 250M Instruct** | **250M** | **60 MB, vocabulary included** |
49
-
50
- Sizes are the main weight file of each official repository, as published. None of the
51
- models above reads a 100 million token archive from disk.
52
-
53
- *(The project was named after my first dog, Shadow, as it is my first big project.)*
54
-
55
- ---
56
-
57
- ## Some samples
58
-
59
- Every sample shows the exact settings it was generated with, using the files in this repo.
60
- Nothing on this page was made with settings other than the ones shown.
61
-
62
- ### 1.
63
-
64
- Prompt: "Explain photosynthesis in two sentences."<br>
65
- Settings: greedy decoding (temperature 0)<br>
66
- Answer:
67
- > Photosynthesis is a process in which plants convert sunlight into chemical energy, which
68
- > is then used to produce oxygen and other chemicals. This process is called photosynthesis.
69
-
70
- ### 2.
71
-
72
- Prompt: "Write a short poem about the sea."<br>
73
- Settings: temperature 0.25 · top-k 30 · repetition penalty 1.15 · seed 2<br>
74
- Answer:
75
- > The waves had swept over, and they were crashing against each other like rocks on top of
76
- > one another. The wind was strong but not very gentle as it tried to push them towards
77
- > their destination without lifting any weight or pulling away from those who stood in
78
- > front of her with a stiff smile that made the sea look even more majestic than before.
79
-
80
- ### 3. Reading its archive
81
-
82
- Prompt: "What is the serial number of device Grus-189?" The fact sits 50.6 million tokens
83
- deep in the 100M evaluation archive on disk.<br>
84
- Settings: archive mode as shipped, retrieval k=16<br>
85
- Answer:
86
- > SN-442976
87
-
88
- ---
89
-
90
- ## Benchmarks
91
-
92
- All numbers are our own, measured on held-out data with the harness shipped in
93
- `benchmarks/`, together with the raw results. We compare with nobody on this page; the
94
- harness runs on any archive of yours as well.
95
-
96
- Standard, acc_norm, zero-shot, full sets, greedy scoring:
97
-
98
- | PIQA | HellaSwag | ARC-Easy | ARC-Challenge |
99
- |---|---|---|---|
100
- | 0.60 | 0.34 | 0.41 | 0.24 |
101
-
102
- Long context, answered from the archive on disk. Settings: archive mode as shipped,
103
- retrieval k=16, exact match scoring, archives and facts held out from all training:
104
-
105
- | | 1M tokens | 10M tokens | 100M tokens |
106
- |---|---|---|---|
107
- | Needle in a haystack (5 depths) | 0.98 | 0.98 | 0.98 |
108
- | Needle with look-alike distractors | 1.00 | 1.00 | – |
109
- | Multi-key needles | 1.00 | 1.00 | – |
110
- | Two-hop variable tracking | 1.00 | 1.00 | – |
111
- | Scattered story facts, latest wins | 1.00 | 1.00 | – |
112
- | Fact QA, 6 task types with abstain | 0.97 | 0.95 | 0.83 |
113
-
114
- ## Architecture
115
-
116
- | Hyperparameter | Value |
117
- |---|---|
118
- | Hidden size | 1536 |
119
- | Layers | 10 |
120
- | Attention heads | 24 (GQA, 2 KV heads) |
121
- | Head dim | 64 |
122
- | Intermediate size (SwiGLU) | 4224 |
123
- | Vocab size | 131,072 (frozen, 0 trainable parameters) |
124
- | Positional encoding | RoPE θ=10,000 |
125
- | Normalization | RMSNorm, ε=10-6 (incl. QK-Norm) |
126
- | Tied embeddings | Yes (shared vocabulary table) |
127
- | Attention window | 2,048 tokens + offline archive up to 100M |
128
- | Body weight precision | under 2 bits per weight |
129
- | Parameters | 250M |
130
- | Runtime | bundled CPU kernel (AVX2/AVX-512), no framework needed |
131
-
132
- ![framework](framework.png)
133
-
134
- ## Performance
135
-
136
- Measured on a laptop CPU with 8 physical cores, using the exact files in this repo. The
137
- bundled kernel handles chat, the two-tier KV cache, and a live memory panel (`--status`).
138
-
139
- | | |
140
- |---|---|
141
- | decode speed, 8 threads | 402 tokens/s |
142
- | decode speed, 4 / 2 / 1 threads | 393 / 275 / 158 tokens/s |
143
- | prefill speed | 409 tokens/s |
144
- | RAM while chatting | ~80 MB |
145
- | archive index build (once per archive, at load) | 2 s at 1M · 21 s at 10M · 3.2 min at 100M |
146
- | retrieval per question | 37 ms at 10M · 435 ms at 100M |
147
- | archive question, end to end | 0.45 s at 100M |
148
-
149
- ## Fine-tuning
150
-
151
- Yes, you can fine-tune it, on one GPU, and export your own 52 MB model for CPU. We did it
152
- ourselves as a demonstration: 90 minutes on a laptop GPU turned SHADOW into a pirate
153
- assistant, with benchmark scores unchanged. The full guide with the commands, the dataset,
154
- and the before and after results is in [finetune/FINETUNING.md](finetune/FINETUNING.md).
155
-
156
- > The capital of France be Paris. It is a UNESCO World Heritage Site... Yarr!
157
-
158
- ## Repository layout
159
-
160
- deployment/ the model: weights, vocabulary, and the runtime binaries
161
- shadow250m_instruct.shdw 52 MB weights
162
- fp131072.npy 8.4 MB vocabulary
163
- bin/windows/ bin/linux/ prebuilt CPU runtimes (macOS on request)
164
- tokenizer/ 3 files, 5 MB
165
- finetune/ master weights, training script, exporter, guide, worked example
166
- benchmarks/ results, report, harness
167
- shadow_runtime/ archive question answering (Python)
168
-
169
- ## Usage
170
-
171
- Easiest start, any system:
172
-
173
- python shadow_chat.py
174
-
175
- Chat directly with the binary, no Python needed. Windows:
176
-
177
- deploymentin\windows\shadow.exe deployment\shadow250m_instruct.shdw deployment p131072.npy --chat
178
-
179
- Linux:
180
-
181
- deployment/bin/linux/shadow deployment/shadow250m_instruct.shdw deployment/fp131072.npy --chat
182
-
183
- Add --status to either for a live memory panel. Ask a question against an archive (a folder
184
- holding a tokens.u32 stream):
185
-
186
- python -m shadow_runtime --model shadow250m_instruct.shdw --table fp131072.npy \
187
- --archive path/to/archive --ask "your question"
188
-
189
- Python:
190
-
191
- from shadow_runtime import Engine
192
- eng = Engine("shadow250m_instruct.shdw", "fp131072.npy", archive="path/to/archive")
193
- print(eng.answer("your question"))
194
-
195
- ### Chat template
196
-
197
- <start_of_turn>user
198
- {message}<end_of_turn>
199
- <start_of_turn>model
200
- {response}<end_of_turn>
201
-
202
- ## Intended use
203
-
204
- Intended:
205
-
206
- * Local assistants on CPU-only hardware, fully offline
207
- * Question answering over large private text archives: logs, books, documentation
208
- * Fine-tuning your own small assistant on one GPU
209
- * Research and education on small models and long context
210
-
211
- Not intended:
212
-
213
- * Production or user-facing deployment without human review
214
- * Factual question answering from the model's own memory, advice, or decision support
215
- * Non-English text
216
-
217
- ## Limitations and bias
218
-
219
- * Small. At 250M parameters, open facts, arithmetic, and long answers are weak. Expect
220
- mistakes outside the archive.
221
- * The model retrieves and reads from its archive. It was not trained to reason across
222
- many archive documents; that needs a bigger training budget than this project had.
223
- Two-hop chains degrade at 100M tokens.
224
- * Trained on public web text, so its outputs can carry the biases of that text.
225
- * English only.
226
-
227
- ## Contact
228
-
229
- Questions, results, or something you built with it: saikiranbathula1@gmail.com
230
-
231
- ---
232
-
233
- *© NODEMIND 2026*
 
1
+ ---
2
+ license: mit
3
+ viewer: false
4
+ language:
5
+ - en
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - small
9
+ - shadow
10
+ - instruct
11
+ - chat
12
+ - long-context
13
+ - retrieval
14
+ - cpu
15
+ ---
16
+
17
+ <h1 align="center">SHADOW 250M Instruct</h1>
18
+
19
+ ![shadow](banner.jpg)
20
+
21
+ <p align="center">
22
+ Instruct model of SHADOW 250M · 250M Parameters · 100M-Token Offline Context · 60 MB
23
+ </p>
24
+
25
+ **SHADOW 250M Instruct** is a 250 million parameter language model built from scratch,
26
+ trained on 30 billion tokens of English text with about 0.7 billion further tokens of
27
+ instruction tuning. The complete deployment is 60 MB, vocabulary included. It runs at about 400 tokens per
28
+ second on a laptop CPU and uses about 80 MB of RAM.
29
+
30
+ Language modeling quality of the base model, measured on held-out English web text that
31
+ was never seen in training (educational web pages, 2,048 token windows): cross entropy
32
+ 3.15 nats per token, perplexity 23.3, 0.99 bits per byte.
33
+
34
+ Next to its 2,048 token attention window, SHADOW can use an offline archive: a compressed
35
+ cache of up to 100 million tokens that stays on your hard disk. The model was trained from
36
+ step 1 to retrieve from this archive, all the way up to 100 million tokens. Due to a
37
+ limited budget it was not trained to reason over the tokens in the disk cache. It finds
38
+ facts and reads them back; it does not think across them.
39
+
40
+ For scale, the official released weight files of well-known small models, next to ours:
41
+
42
+ | model | parameters | weights on disk |
43
+ |---|---|---|
44
+ | GPT-2 | 124M | 548 MB |
45
+ | SmolLM2-135M-Instruct | 135M | 269 MB |
46
+ | SmolLM2-360M-Instruct | 360M | 724 MB |
47
+ | Qwen2.5-0.5B-Instruct | 494M | 988 MB |
48
+ | **SHADOW 250M Instruct** | **250M** | **60 MB, vocabulary included** |
49
+
50
+ Sizes are the main weight file of each official repository, as published. None of the
51
+ models above reads a 100 million token archive from disk.
52
+
53
+ *(The project was named after my first dog, Shadow, as it is my first big project.)*
54
+
55
+ ---
56
+
57
+ ## Some samples
58
+
59
+ Every sample shows the exact settings it was generated with, using the files in this repo.
60
+ Nothing on this page was made with settings other than the ones shown.
61
+
62
+ ### 1.
63
+
64
+ Prompt: "Explain photosynthesis in two sentences."<br>
65
+ Settings: greedy decoding (temperature 0)<br>
66
+ Answer:
67
+ > Photosynthesis is a process in which plants convert sunlight into chemical energy, which
68
+ > is then used to produce oxygen and other chemicals. This process is called photosynthesis.
69
+
70
+ ### 2.
71
+
72
+ Prompt: "Write a short poem about the sea."<br>
73
+ Settings: temperature 0.25 · top-k 30 · repetition penalty 1.15 · seed 2<br>
74
+ Answer:
75
+ > The waves had swept over, and they were crashing against each other like rocks on top of
76
+ > one another. The wind was strong but not very gentle as it tried to push them towards
77
+ > their destination without lifting any weight or pulling away from those who stood in
78
+ > front of her with a stiff smile that made the sea look even more majestic than before.
79
+
80
+ ### 3. Reading its archive
81
+
82
+ Prompt: "What is the serial number of device Grus-189?" The fact sits 50.6 million tokens
83
+ deep in the 100M evaluation archive on disk.<br>
84
+ Settings: archive mode as shipped, retrieval k=16<br>
85
+ Answer:
86
+ > SN-442976
87
+
88
+ ---
89
+
90
+ ## Benchmarks
91
+
92
+ All numbers are our own, measured on held-out data with the harness shipped in
93
+ `benchmarks/`, together with the raw results. We compare with nobody on this page; the
94
+ harness runs on any archive of yours as well.
95
+
96
+ Standard, acc_norm, zero-shot, full sets, greedy scoring:
97
+
98
+ | PIQA | HellaSwag | ARC-Easy | ARC-Challenge |
99
+ |---|---|---|---|
100
+ | 0.60 | 0.34 | 0.41 | 0.24 |
101
+
102
+ Long context, answered from the archive on disk. Settings: archive mode as shipped,
103
+ retrieval k=16, exact match scoring, archives and facts held out from all training:
104
+
105
+ | | 1M tokens | 10M tokens | 100M tokens |
106
+ |---|---|---|---|
107
+ | Needle in a haystack (5 depths) | 0.98 | 0.98 | 0.98 |
108
+ | Needle with look-alike distractors | 1.00 | 1.00 | – |
109
+ | Multi-key needles | 1.00 | 1.00 | – |
110
+ | Two-hop variable tracking | 1.00 | 1.00 | – |
111
+ | Scattered story facts, latest wins | 1.00 | 1.00 | – |
112
+ | Fact QA, 6 task types with abstain | 0.97 | 0.95 | 0.83 |
113
+
114
+ ## Architecture
115
+
116
+ | Hyperparameter | Value |
117
+ |---|---|
118
+ | Hidden size | 1536 |
119
+ | Layers | 10 |
120
+ | Attention heads | 24 (GQA, 2 KV heads) |
121
+ | Head dim | 64 |
122
+ | Intermediate size (SwiGLU) | 4224 |
123
+ | Vocab size | 131,072 (frozen, 0 trainable parameters) |
124
+ | Positional encoding | RoPE θ=10,000 |
125
+ | Normalization | RMSNorm, ε=10-6 (incl. QK-Norm) |
126
+ | Tied embeddings | Yes (shared vocabulary table) |
127
+ | Attention window | 2,048 tokens + offline archive up to 100M |
128
+ | Body weight precision | under 2 bits per weight |
129
+ | Parameters | 250M |
130
+ | Runtime | bundled CPU kernel (AVX2/AVX-512), no framework needed |
131
+
132
+ ![framework](framework.png)
133
+
134
+ ## Performance
135
+
136
+ Measured on a laptop CPU with 8 physical cores, using the exact files in this repo. The
137
+ bundled kernel handles chat, the two-tier KV cache, and a live memory panel (`--status`).
138
+
139
+ | | |
140
+ |---|---|
141
+ | decode speed, 8 threads | 402 tokens/s |
142
+ | decode speed, 4 / 2 / 1 threads | 393 / 275 / 158 tokens/s |
143
+ | prefill speed | 409 tokens/s |
144
+ | RAM while chatting | ~80 MB |
145
+ | archive index build (once per archive, at load) | 2 s at 1M · 21 s at 10M · 3.2 min at 100M |
146
+ | retrieval per question | 37 ms at 10M · 435 ms at 100M |
147
+ | archive question, end to end | 0.45 s at 100M |
148
+
149
+ ## Fine-tuning
150
+
151
+ Yes, you can fine-tune it, on one GPU, and export your own 52 MB model for CPU. We did it
152
+ ourselves as a demonstration: 90 minutes on a laptop GPU turned SHADOW into a pirate
153
+ assistant, with benchmark scores unchanged. The full guide with the commands, the dataset,
154
+ and the before and after results is in [finetune/FINETUNING.md](finetune/FINETUNING.md).
155
+
156
+ > The capital of France be Paris. It is a UNESCO World Heritage Site... Yarr!
157
+
158
+ ## Repository layout
159
+
160
+ deployment/ the model: weights, vocabulary, and the runtime binaries
161
+ shadow250m_instruct.shdw 52 MB weights
162
+ fp131072.npy 8.4 MB vocabulary
163
+ bin/windows/ bin/linux/ prebuilt CPU runtimes (macOS on request)
164
+ tokenizer/ 3 files, 5 MB
165
+ finetune/ master weights, training script, exporter, guide, worked example
166
+ benchmarks/ results, report, harness
167
+ shadow_runtime/ archive question answering (Python)
168
+
169
+ ## Usage
170
+
171
+ Easiest start, any system:
172
+
173
+ python shadow_chat.py
174
+
175
+ Chat directly with the binary, no Python needed. Windows:
176
+
177
+ deploymentin\windows\shadow.exe deployment\shadow250m_instruct.shdw deployment p131072.npy --chat
178
+
179
+ Linux:
180
+
181
+ deployment/bin/linux/shadow deployment/shadow250m_instruct.shdw deployment/fp131072.npy --chat
182
+
183
+ Add --status to either for a live memory panel. Ask a question against an archive (a folder
184
+ holding a tokens.u32 stream):
185
+
186
+ python -m shadow_runtime --model shadow250m_instruct.shdw --table fp131072.npy \
187
+ --archive path/to/archive --ask "your question"
188
+
189
+ Python:
190
+
191
+ from shadow_runtime import Engine
192
+ eng = Engine("shadow250m_instruct.shdw", "fp131072.npy", archive="path/to/archive")
193
+ print(eng.answer("your question"))
194
+
195
+ ### Chat template
196
+
197
+ <start_of_turn>user
198
+ {message}<end_of_turn>
199
+ <start_of_turn>model
200
+ {response}<end_of_turn>
201
+
202
+ ## Intended use
203
+
204
+ Intended:
205
+
206
+ * Local assistants on CPU-only hardware, fully offline
207
+ * Question answering over large private text archives: logs, books, documentation
208
+ * Fine-tuning your own small assistant on one GPU
209
+ * Research and education on small models and long context
210
+
211
+ Not intended:
212
+
213
+ * Production or user-facing deployment without human review
214
+ * Factual question answering from the model's own memory, advice, or decision support
215
+ * Non-English text
216
+
217
+ ## Limitations and bias
218
+
219
+ * Small. At 250M parameters, open facts, arithmetic, and long answers are weak. Expect
220
+ mistakes outside the archive.
221
+ * The model retrieves and reads from its archive. It was not trained to reason across
222
+ many archive documents; that needs a bigger training budget than this project had.
223
+ Two-hop chains degrade at 100M tokens.
224
+ * Trained on public web text, so its outputs can carry the biases of that text.
225
+ * English only.
226
+
227
+ ## Contact
228
+
229
+ Questions, results, or something you built with it: saikiranbathula1@gmail.com
230
+
231
+ ---
232
+
233
+ *© NODEMIND 2026*