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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
```python
|
| 28 |
import torch
|
|
@@ -30,6 +197,10 @@ from huggingface_hub import hf_hub_download
|
|
| 30 |
from src.model import MicroMixerV2, MicroMixerV2Config
|
| 31 |
from src.tokenizer import ByteTokenizer
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
config = MicroMixerV2Config(
|
| 34 |
max_seq_len=256,
|
| 35 |
hidden_dim=224,
|
|
@@ -52,17 +223,15 @@ with torch.no_grad():
|
|
| 52 |
print(tokenizer.decode(output[0].tolist()))
|
| 53 |
```
|
| 54 |
|
| 55 |
-
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
- **RoPE** (Rotary Position Embedding) for position encoding
|
| 59 |
-
- **HyperMixing** for token mixing (O(S) complexity)
|
| 60 |
-
- **MlpBlock** for channel mixing
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
|
|
|
| 9 |
license: apache-2.0
|
| 10 |
---
|
| 11 |
|
| 12 |
+
<div align="center">
|
| 13 |
+
|
| 14 |
+
<img src="https://raw.githubusercontent.com/llaa33219/MicroMixer-1/main/logo.svg" width="300" alt="MicroMixer-1 Logo"/>
|
| 15 |
+
|
| 16 |
# MicroMixer-1-1M-TinyStories
|
| 17 |
|
| 18 |
+
<img src="https://img.shields.io/badge/Parameters-967%2C584-blue?style=for-the-badge&logo=python&logoColor=white&color=%23007BFF" alt="Parameters"/>
|
| 19 |
+
<img src="https://img.shields.io/badge/Architecture-MLP--Mixer-purple?style=for-the-badge&color=%23AE00FF" alt="Architecture"/>
|
| 20 |
+
<img src="https://img.shields.io/badge/Dataset-TinyStories-green?style=for-the-badge&color=%2300D620" alt="Dataset"/>
|
| 21 |
+
|
| 22 |
+
<br/>
|
| 23 |
+
<br/>
|
| 24 |
+
|
| 25 |
+
<table>
|
| 26 |
+
<tr>
|
| 27 |
+
<td align="center" style="padding: 20px;">
|
| 28 |
+
<strong style="color: #007BFF; font-size: 1.2em;">Micro Language Model</strong><br/>
|
| 29 |
+
<em>Attention-Free β’ MLP-Only β’ Byte-Level</em>
|
| 30 |
+
</td>
|
| 31 |
+
</tr>
|
| 32 |
+
</table>
|
| 33 |
+
|
| 34 |
+
[](https://github.com/llaa33219/MicroMixer-1)
|
| 35 |
+
|
| 36 |
+
</div>
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
<div style="background: linear-gradient(135deg, #007BFF22, #AE00FF22); padding: 20px; border-radius: 10px; border-left: 4px solid #007BFF;">
|
| 41 |
+
|
| 42 |
+
## π Overview
|
| 43 |
+
|
| 44 |
+
**MicroMixer-1-1M** is the largest model in the series with ~1M parameters. It can generate sentences like "Once upon a time there was a little girl named Lily" with reasonable fluency. Supports the longest sequence length of 256 tokens.
|
| 45 |
+
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## ποΈ Architecture
|
| 51 |
+
|
| 52 |
+
<div align="center">
|
| 53 |
+
|
| 54 |
+
```mermaid
|
| 55 |
+
graph TD
|
| 56 |
+
A[Byte Input] --> B[Token Embedding]
|
| 57 |
+
B --> C[RoPE Position Encoding]
|
| 58 |
+
C --> D[ImprovedMixerLayer Γ3]
|
| 59 |
+
D --> E[LayerNorm]
|
| 60 |
+
E --> F[LM Head]
|
| 61 |
+
F --> G[Byte Output]
|
| 62 |
+
|
| 63 |
+
style A fill:#007BFF,color:#fff
|
| 64 |
+
style G fill:#00D620,color:#fff
|
| 65 |
+
style D fill:#AE00FF,color:#fff
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
</div>
|
| 69 |
+
|
| 70 |
+
### Model Configuration
|
| 71 |
+
|
| 72 |
+
<table>
|
| 73 |
+
<tr>
|
| 74 |
+
<th style="background-color: #007BFF; color: white;">Parameter</th>
|
| 75 |
+
<th style="background-color: #AE00FF; color: white;">Value</th>
|
| 76 |
+
</tr>
|
| 77 |
+
<tr><td>Total Parameters</td><td><code>967,584</code></td></tr>
|
| 78 |
+
<tr><td>Hidden Dimension</td><td><code>224</code></td></tr>
|
| 79 |
+
<tr><td>Channel MLP Dimension</td><td><code>576</code></td></tr>
|
| 80 |
+
<tr><td>Number of Layers</td><td><code>3</code></td></tr>
|
| 81 |
+
<tr><td>Max Sequence Length</td><td><code>256</code></td></tr>
|
| 82 |
+
<tr><td>Vocabulary Size</td><td><code>256</code> (Byte-level)</td></tr>
|
| 83 |
+
</table>
|
| 84 |
+
|
| 85 |
+
### Core Components
|
| 86 |
+
|
| 87 |
+
<div style="background-color: #1a1a2e; padding: 15px; border-radius: 8px;">
|
| 88 |
+
|
| 89 |
+
```
|
| 90 |
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 91 |
+
β ImprovedMixerLayer β
|
| 92 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
| 93 |
+
β β LayerNorm β HyperMixing β Residual β β β Token Mixing
|
| 94 |
+
β βββββββββββββββββββββββββββββββββββββββ€ β
|
| 95 |
+
β β LayerNorm β MlpBlock β Residual β β β Channel Mixing
|
| 96 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
| 97 |
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
#### 1οΈβ£ RoPE (Rotary Position Embedding)
|
| 103 |
+
- Encodes positions via **rotation transformations**
|
| 104 |
+
- Enables length extrapolation beyond training sequences
|
| 105 |
+
|
| 106 |
+
#### 2οΈβ£ HyperMixing (Token Mixing)
|
| 107 |
+
- Compresses past context via **cumulative average pooling**
|
| 108 |
+
- Hypernetwork generates adaptive weights
|
| 109 |
+
- O(S) complexity token mixing without attention
|
| 110 |
+
|
| 111 |
+
#### 3οΈβ£ MlpBlock (Channel Mixing)
|
| 112 |
+
- Non-linear transformation of feature dimensions
|
| 113 |
+
- Structure: `Linear β GELU β Linear`
|
| 114 |
+
|
| 115 |
+
---
|
| 116 |
+
|
| 117 |
+
## π Key Differences from 500K
|
| 118 |
+
|
| 119 |
+
<div style="background-color: #FFEA0015; padding: 15px; border-radius: 8px; border-left: 4px solid #FFEA00;">
|
| 120 |
+
|
| 121 |
+
| Metric | 500K | 1M | Change |
|
| 122 |
+
|--------|------|-----|--------|
|
| 123 |
+
| Parameters | 557,328 | 967,584 | **1.7x** |
|
| 124 |
+
| Hidden Dim | 176 | 224 | 1.3x |
|
| 125 |
+
| Channel MLP | 384 | 576 | 1.5x |
|
| 126 |
+
| Sequence Length | 128 | 256 | **2x** |
|
| 127 |
|
| 128 |
+
</div>
|
| 129 |
|
| 130 |
+
---
|
| 131 |
+
|
| 132 |
+
## π― Generation Examples
|
| 133 |
+
|
| 134 |
+
<div style="background-color: #AE00FF15; padding: 15px; border-radius: 8px; border-left: 4px solid #AE00FF;">
|
| 135 |
+
|
| 136 |
+
```
|
| 137 |
+
Prompt: "Once upon a time"
|
| 138 |
+
Output: "Once upon a time there was a little girl named Lily. She loved t..."
|
| 139 |
+
|
| 140 |
+
Prompt: "Hello"
|
| 141 |
+
Output: "Hellog ann he grit litle girls. She love loved in the"
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
</div>
|
| 145 |
+
|
| 146 |
+
---
|
| 147 |
+
|
| 148 |
+
## π Model Comparison
|
| 149 |
+
|
| 150 |
+
<div style="background-color: #007BFF15; padding: 15px; border-radius: 8px; border-left: 4px solid #007BFF;">
|
| 151 |
+
|
| 152 |
+
| Model | Parameters | Hidden | Seq Len | Quality |
|
| 153 |
+
|-------|------------|--------|---------|---------|
|
| 154 |
+
| 100K | 136,908 | 84 | 64 | β |
|
| 155 |
+
| 300K | 331,680 | 128 | 128 | ββ |
|
| 156 |
+
| 500K | 557,328 | 176 | 128 | βββ |
|
| 157 |
+
| **1M** | **967,584** | **224** | **256** | ββββ |
|
| 158 |
+
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
## β οΈ Limitations
|
| 164 |
|
| 165 |
+
<div style="background-color: #FF050515; padding: 15px; border-radius: 8px; border-left: 4px solid #FF0505;">
|
| 166 |
+
|
| 167 |
+
| Limitation | Description |
|
| 168 |
+
|------------|-------------|
|
| 169 |
+
| **Grammatical Errors** | Fully grammatical sentences still difficult |
|
| 170 |
+
| **Name Instability** | Same name varies: "Lily", "Limmy", "Amby" |
|
| 171 |
+
| **Short Prompt Issues** | "Hello", "The weather is" produce near-random output |
|
| 172 |
+
| **Overfitting** | Overfits to specific TinyStories phrases |
|
| 173 |
+
|
| 174 |
+
</div>
|
| 175 |
+
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
+
## π Training Data
|
| 179 |
+
|
| 180 |
+
<div style="background-color: #00D62015; padding: 15px; border-radius: 8px; border-left: 4px solid #00D620;">
|
| 181 |
+
|
| 182 |
+
**Dataset**: [TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories)
|
| 183 |
+
|
| 184 |
+
- Simple children's stories dataset
|
| 185 |
+
- Learns basic grammar and vocabulary
|
| 186 |
+
- Contains many patterns like "Once upon a time", "little girl/boy"
|
| 187 |
+
|
| 188 |
+
</div>
|
| 189 |
+
|
| 190 |
+
---
|
| 191 |
+
|
| 192 |
+
## π§ Usage
|
| 193 |
|
| 194 |
```python
|
| 195 |
import torch
|
|
|
|
| 197 |
from src.model import MicroMixerV2, MicroMixerV2Config
|
| 198 |
from src.tokenizer import ByteTokenizer
|
| 199 |
|
| 200 |
+
# Clone the repository first:
|
| 201 |
+
# git clone https://github.com/llaa33219/MicroMixer-1.git
|
| 202 |
+
# cd MicroMixer-1
|
| 203 |
+
|
| 204 |
config = MicroMixerV2Config(
|
| 205 |
max_seq_len=256,
|
| 206 |
hidden_dim=224,
|
|
|
|
| 223 |
print(tokenizer.decode(output[0].tolist()))
|
| 224 |
```
|
| 225 |
|
| 226 |
+
---
|
| 227 |
+
|
| 228 |
|
| 229 |
+
---
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
+
<div align="center">
|
| 232 |
|
| 233 |
+
[](https://github.com/llaa33219/MicroMixer-1)
|
| 234 |
|
| 235 |
+
<sub>Part of the <a href="https://github.com/llaa33219/MicroMixer-1">MicroMixer-1</a> research project</sub>
|
| 236 |
|
| 237 |
+
</div>
|