llaa33219 commited on
Commit
f2e19a2
·
verified ·
1 Parent(s): 6fe1887

Add MicroMixer-4-100K-TinyStories: TinyStories pretrain card + 3 epoch safetensors

Browse files
Files changed (4) hide show
  1. README.md +305 -0
  2. epoch_0.safetensors +3 -0
  3. epoch_1.safetensors +3 -0
  4. epoch_2.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: pytorch
4
+ language:
5
+ - en
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - mlp-mixer
9
+ - byte-level
10
+ - causal-lm
11
+ - attention-free
12
+ - ccd-mixer
13
+ - content-gated-dilated-conv
14
+ - tiny-stories
15
+ - pretrained-backbone
16
+ - micro-language-model
17
+ - sub-1m-parameters
18
+ model_name: MicroMixer-4-100K-TinyStories
19
+ datasets:
20
+ - roneneldan/TinyStories
21
+ metrics:
22
+ - perplexity
23
+ ---
24
+
25
+ <div align="center">
26
+
27
+ <img src="https://raw.githubusercontent.com/llaa33219/MicroMixer-4/main/logo.svg" width="300" alt="MicroMixer-4 Logo"/>
28
+
29
+ # MicroMixer-4-100K-TinyStories
30
+
31
+ <img src="https://img.shields.io/badge/Parameters-95%2C084-blue?style=for-the-badge&logo=python&logoColor=white&color=%23007BFF" alt="Parameters"/>
32
+ <img src="https://img.shields.io/badge/Architecture-CCD--Mixer-purple?style=for-the-badge&color=%23AE00FF" alt="Architecture"/>
33
+ <img src="https://img.shields.io/badge/Stage-Pretrain-green?style=for-the-badge&color=%2300D620" alt="Pretrain"/>
34
+
35
+ <br/>
36
+ <br/>
37
+
38
+ <table>
39
+ <tr>
40
+ <td align="center" style="padding: 20px;">
41
+ <strong style="color: #007BFF; font-size: 1.2em;">Micro Language Model</strong><br/><em>Attention-Free • MLP-Only • Byte-Level • Content-Gated Dilated Convolution</em>
42
+ </td>
43
+ </tr>
44
+ </table>
45
+
46
+ [![GitHub](https://img.shields.io/badge/GitHub-MicroMixer--4-blue?style=for-the-badge&logo=github&color=%23007BFF)](https://github.com/llaa33219/MicroMixer-4)
47
+
48
+ </div>
49
+
50
+ <div style="background: linear-gradient(135deg, #007BFF22, #AE00FF22); padding: 20px; border-radius: 10px; border-left: 4px solid #007BFF;">
51
+
52
+ ## 📋 Overview
53
+
54
+ **MicroMixer-4-100K-TinyStories** is a **95,084-parameter** pure MLP-Mixer causal language model — **no attention, no recurrence, no SSM** — **pretrained on [TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories)** as part of the MicroMixer-4 **dataset-efficiency comparison study** ([analysis](https://github.com/llaa33219/MicroMixer-4/blob/main/DATASET_COMPARISON_ANALYSIS.md)). TinyStories is a corpus of ~200K short synthetic children's stories (GPT-3.5/4-generated, constrained grammar and vocabulary).
55
+
56
+ ⚠️ This repo is **pretrain-only** — it is **NOT FMSP-fine-tuned**. TinyStories contains free-flowing prose with no `User:`/`Assistant:` dialogue markers, so the FMSP answer-only cross-entropy recipe does not apply (there is no answer region to isolate). What you get is the **raw pretrained backbone** (seed 42, V76 recipe, 3 epochs). It continues stories; it does not answer questions or follow instructions.
57
+
58
+ The backbone is **V87 Final**, the project's champion CCD-Mixer architecture (the V83-RPG champion frozen and scaled to six budgets). The 100K preset reproduces the champion recipe at its budget.
59
+
60
+ </div>
61
+
62
+ ## 🏗️ Architecture
63
+
64
+ <div align="center">
65
+
66
+ ```mermaid
67
+ graph TD
68
+ A[Byte Input] --> B[Embed 256→48 NoPE]
69
+ B --> C[CCD-Mixer Block × 4]
70
+ C --> D[RMSNorm]
71
+ D --> E[LM Head Tied with Embed]
72
+ E --> F[Byte Output]
73
+
74
+ subgraph "CCD-Mixer Block"
75
+ X[Input 48] --> U["Linear d→2d → split v, g"]
76
+ U --> RP[Full RoPE on v AND g]
77
+ RP --> M["Shared-weight dilated conv<br/>dilations 1·2·4·8, k=65"]
78
+ M --> G["Per-position 4-way gate<br/>softmax(Linear_dil(x)/τ)"]
79
+ G --> O["W_o(v ⊙ g) — zero-init"]
80
+ O --> SW[SwiGLU Channel-Mix]
81
+ SW --> RM[ReMixerLayer sidecar]
82
+ end
83
+
84
+ style A fill:#007BFF,color:#fff
85
+ style F fill:#00D620,color:#fff
86
+ style G fill:#AE00FF,color:#fff
87
+ style M fill:#FF6600,color:#fff
88
+ ```
89
+
90
+ </div>
91
+
92
+ ### Model Configuration
93
+
94
+ <table>
95
+ <tr>
96
+ <th style="background-color: #007BFF; color: white;">Parameter</th>
97
+ <th style="background-color: #AE00FF; color: white;">Value</th>
98
+ </tr>
99
+ <tr><td>Hidden Dimension (d_model)</td><td><code>48</code></td></tr>
100
+ <tr><td>Number of Blocks</td><td><code>4</code></td></tr>
101
+ <tr><td>Token-Mix</td><td><code>GLCTokenMixCCD</code> (content-gated mixture of shared-weight dilated causal conv)</td></tr>
102
+ <tr><td>Dilations</td><td><code>(1, 2, 4, 8)</code> — one shared depthwise kernel, zero extra conv params</td></tr>
103
+ <tr><td>Depthwise Kernel Size</td><td><code>65</code></td></tr>
104
+ <tr><td>RoPE</td><td>Full RoPE on <b>both</b> v and g (V76 "RPG" pattern)</td></tr>
105
+ <tr><td>Channel-Mix</td><td><code>SwiGLU</code></td></tr>
106
+ <tr><td>Sidecar</td><td><code>ReMixerLayer</code> per block (label_dim 16, pool_heads 4)</td></tr>
107
+ <tr><td>Max Sequence Length</td><td><code>1024</code></td></tr>
108
+ <tr><td>Vocabulary Size</td><td><code>256</code> (byte-level)</td></tr>
109
+ <tr><td>Position Encoding</td><td>RoPE inside token-mix only; no position embedding table</td></tr>
110
+ <tr><td>Normalization</td><td><code>RMSNorm</code> (pre-norm)</td></tr>
111
+ <tr><td>Output Head</td><td>Tied with input embedding</td></tr>
112
+ <tr><td>Zero-Init</td><td><code>W_o</code>, <code>dil_gate</code>, <code>log_τ</code> — silent at init</td></tr>
113
+ </table>
114
+
115
+ ### Core Components
116
+
117
+ ```
118
+ ┌────────────────────────────────���─────────────────────────────┐
119
+ │ CCD-Mixer Block (×4) │
120
+ │ u = Linear(d → 2d)(x) │
121
+ │ v, g = u.chunk(2) │
122
+ │ v = RoPE(v) g = RoPE(g) ← full-RoPE (RPG) │
123
+ │ y_d = CausalDSConv(v, dilation=d) for d ∈ (1,2,4,8) │
124
+ │ └── ONE shared depthwise kernel │
125
+ │ w(t) = softmax(Linear_dil(x)_t / τ) ← per-position │
126
+ │ v = Σ_d w_d(t) · y_d(t) time-varying filter │
127
+ │ out = W_o(v ⊙ g) ← W_o zero-init │
128
+ │ then SwiGLU channel-mix + ReMixerLayer sidecar │
129
+ └──────────────────────────────────────────────────────────────┘
130
+ ```
131
+
132
+ The token-mix is **non-LTI** (time-varying): the per-position gate remixes four dilated views of the same kernel at every byte, which is the mechanism that breaks the periodic-orbit collapse that pure LTI mixers fall into — without attention and without a position table.
133
+
134
+ ---
135
+
136
+ ## 🎯 Generation Examples
137
+
138
+ <div style="background-color: #FF050515; padding: 15px; border-radius: 8px; border-left: 4px solid #FF6600;">
139
+
140
+ **Story-continuation probes** (raw text — no `User:/Assistant:` prefix, since TinyStories is a plain LM; greedy decoding, `repetition_penalty=1.2`, `no_repeat_ngram_size=4`, `max_new_tokens=200`):
141
+
142
+ ```
143
+ [Prompt] Once upon a time, there was a little girl named Lily.
144
+ [Output] She loved to play with her toys and she loved to play with her toys. One day, she was three yea…
145
+ ```
146
+
147
+ <sub>coherent — on-topic story continuation in the TinyStories register</sub>
148
+
149
+ ```
150
+ [Prompt] One day, a boy named Tom found a big red balloon.
151
+ [Output] He was very happy and he wanted to go to the park. He was so happy and said, "I want to play wi…
152
+ ```
153
+
154
+ <sub>coherent — on-topic story continuation in the TinyStories register</sub>
155
+
156
+ ```
157
+ [Prompt] The sun was shining and the birds were singing.
158
+ [Output] The bird was so happy and the birds were so happy. They were so happy to see a big box and the …
159
+ ```
160
+
161
+ <sub>drifts — starts as story but falls into a repetitive loop</sub>
162
+
163
+ ```
164
+ [Prompt] A little dog ran into the garden and saw
165
+ [Output] a big box. It was a big box and said, "It's okay, I want to be careful."
166
+
167
+ The bird said, "I wan…
168
+ ```
169
+
170
+ <sub>drifts — starts as story but falls into a repetitive loop</sub>
171
+
172
+
173
+ </div>
174
+
175
+ ---
176
+
177
+ ## 📊 Results
178
+
179
+ <div style="background-color: #007BFF15; padding: 15px; border-radius: 8px; border-left: 4px solid #007BFF;">
180
+
181
+ ### Pretraining (TinyStories, V76 recipe, 3 epochs)
182
+
183
+ | Metric | 1 ep | 2 ep | 3 ep |
184
+ |--------|------|------|------|
185
+ | Val PPL | 2.51 | 2.44 | **2.31** |
186
+
187
+ AdamW lr 3e-3 · WSD (warmup 500) · wd 0.01 · bs 16 · seq 1024 · seed 42 · plain CE on non-pad bytes.
188
+
189
+ ### MicroMixer-4 TinyStories family (pretrain-only, all sizes)
190
+
191
+ | Size | Params | 3ep Val PPL |
192
+ |------|--------|------------|
193
+ | 1M | 996,873 | **1.78** |
194
+ | 500K | 491,742 | **1.90** |
195
+ | 300K | 292,525 | **2.00** |
196
+ | **100K** | 95,084 | **2.31** |
197
+ | 50K | 48,684 | **2.60** |
198
+ | 10K | 9,666 | **4.06** |
199
+
200
+ <sub>Pretrain-only family — FMSP-based axes (chatter fluency, full-988 EM, q-relevance, OOD, unanswerable fabrication) are N/A: TinyStories has no `User:/Assistant:` markers, so the answer-only-CE recipe does not apply.</sub>
201
+
202
+ </div>
203
+
204
+ ---
205
+
206
+ ## 📚 Training Data
207
+
208
+ <div style="background-color: #00D62015; padding: 15px; border-radius: 8px; border-left: 4px solid #00D620;">
209
+
210
+ 1. **Pretraining**: [TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories) — synthetic short stories generated by GPT-3.5/4 with a constrained vocabulary and simple grammar, ~200K stories sampled, flattened to 1024-byte sequences, 3 epochs. No `User:/Assistant:` dialogue structure.
211
+
212
+ </div>
213
+
214
+ ---
215
+
216
+ ## 🔧 Usage
217
+
218
+ ### Files in this repository
219
+ - `epoch_{0,1,2}.safetensors` — per-epoch pretrained backbone weights (pickle-free safetensors). **`epoch_2.safetensors` is the final (3rd-epoch) checkpoint.** No FMSP adapter — this is the plain backbone.
220
+
221
+ ### Load and generate (local clone)
222
+
223
+ ```python
224
+ import torch
225
+ from safetensors.torch import load_file
226
+ from src.model_v87_final import MicroMixerV87Final, v87_final_100k
227
+ from src.tokenizer import ByteTokenizer
228
+
229
+ # Clone the code repository first:
230
+ # git clone https://github.com/llaa33219/MicroMixer-4.git && cd MicroMixer-4
231
+
232
+ cfg = v87_final_100k()
233
+ model = MicroMixerV87Final(cfg) # plain backbone — NO attach_adapter (pretrain-only)
234
+ model.load_state_dict(load_file("epoch_2.safetensors"), strict=True)
235
+ model.eval()
236
+
237
+ tok = ByteTokenizer()
238
+ prompt = "Once upon a time, there was a little girl named Lily."
239
+ ids = tok.encode(prompt)
240
+ if ids and ids[-1] == tok.eos_token_id:
241
+ ids = ids[:-1] # ByteTokenizer appends EOS; the prompt must end open
242
+ ids = torch.tensor([ids])
243
+ with torch.no_grad():
244
+ out = model.generate(
245
+ ids, max_new_tokens=200,
246
+ temperature=0.0, # greedy
247
+ repetition_penalty=1.2,
248
+ no_repeat_ngram_size=4,
249
+ eos_token_id=tok.eos_token_id,
250
+ )
251
+ print(prompt + tok.decode(out[0].tolist()[len(ids):]))
252
+ ```
253
+
254
+ > Note the differences from the FMSP cards: (1) **no `attach_adapter`** — the backbone is loaded
255
+ > as-is; (2) the prompt is **raw story text**, not the `User: …\n\nAssistant: ` dialogue format.
256
+
257
+ ### Load from Hugging Face Hub (no clone of the weights needed)
258
+
259
+ ```python
260
+ import torch
261
+ from huggingface_hub import hf_hub_download
262
+ from safetensors.torch import load_file
263
+ from src.model_v87_final import MicroMixerV87Final, v87_final_100k
264
+
265
+ REPO = "llaa33219/MicroMixer-4-100K-TinyStories"
266
+
267
+ cfg = v87_final_100k()
268
+ model = MicroMixerV87Final(cfg)
269
+ model.load_state_dict(
270
+ load_file(hf_hub_download(REPO, "epoch_2.safetensors")), strict=True)
271
+ model.eval()
272
+ # ... continue a story as above
273
+ ```
274
+
275
+ ---
276
+
277
+ ## ⚠️ Limitations
278
+
279
+ <div style="background-color: #FF050515; padding: 15px; border-radius: 8px; border-left: 4px solid #FF0505;">
280
+
281
+ | Limitation | Description |
282
+ |------------|-------------|
283
+ | **Pretrain-only — no instruction/QA ability** | Not FMSP-fine-tuned; it only continues TinyStories-style prose. It cannot answer questions or follow instructions. |
284
+ | **Micro parameters** | 95,084 parameters; capacity is the binding constraint |
285
+ | **Knows only TinyStories** | Distribution is synthetic children's stories; no real-world knowledge |
286
+ | **Byte-level noise** | 256-vocab byte tokenizer; PPL not comparable to BPE baselines |
287
+ | **Research use only** | Architecture/pretraining research artifact, not a production model |
288
+
289
+ </div>
290
+
291
+ ---
292
+
293
+ ## 🧬 Context
294
+
295
+ This is the **100K** TinyStories-pretrained arm of the **dataset-efficiency comparison study** in the [MicroMixer-4](https://github.com/llaa33219/MicroMixer-4) project — the pretrain-only third corpus alongside the UltraChat and SmolTalk2 FMSP arms (TinyStories is excluded from the FMSP/eval battery because it has no `User:/Assistant:` markers). Sibling repos: `llaa33219/{MicroMixer-4,MicroT-test1}-{1M..10K}-TinyStories`, plus the UltraChat/SmolTalk2 arms `…-{UltraChat,SmolTalk2}` and the discord-pretrained baselines `llaa33219/{MicroMixer-4,MicroT-test1}-{1M..10K}`. Full analysis: [DATASET_COMPARISON_ANALYSIS.md](https://github.com/llaa33219/MicroMixer-4/blob/main/DATASET_COMPARISON_ANALYSIS.md).
296
+
297
+ ---
298
+
299
+ <div align="center">
300
+
301
+ [![GitHub](https://img.shields.io/badge/Back_to_Repository-MicroMixer--4-blue?style=for-the-badge&logo=github&color=%23007BFF)](https://github.com/llaa33219/MicroMixer-4)
302
+
303
+ <sub>Part of the <a href="https://github.com/llaa33219/MicroMixer-4">MicroMixer-4</a> research project — V87 Final (CCD-Mixer) family, 100K preset, TinyStories pretraining (pretrain-only)</sub>
304
+
305
+ </div>
epoch_0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76ae9183fec5c2c1557fc4f83fedd10608e44f74d6061dc476829ac2990b744c
3
+ size 407168
epoch_1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37081ee660d21309a1ee417702632ae2b061f3e0040c9f46fe47c04f31b0b189
3
+ size 407168
epoch_2.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c680a44e23bdca7c6934181782ff70d1d07c104a918f7393f14fecda064866c
3
+ size 407168