Views
No views yet
|
Micro Language Model Attention-Free • MLP-Only • Byte-Level |
1graph TD
2 A[Byte Input] --> B[Token Embedding]
3 B --> C[RoPE Position Encoding]
4 C --> D[ImprovedMixerLayer ×3]
5 D --> E[LayerNorm]
6 E --> F[LM Head]
7 F --> G[Byte Output]
8
9 style A fill:#007BFF,color:#fff
10 style G fill:#00D620,color:#fff
11 style D fill:#AE00FF,color:#fff| Parameter | Value |
|---|---|
| Total Parameters | 331,680 |
| Hidden Dimension | 128 |
| Channel MLP Dimension | 288 |
| Number of Layers | 3 |
| Max Sequence Length | 128 |
| Vocabulary Size | 256 (Byte-level) |
┌─────────────────────────────────────────────┐
│ ImprovedMixerLayer │
│ ┌─────────────────────────────────────┐ │
│ │ LayerNorm → HyperMixing → Residual │ │ ← Token Mixing
│ ├─────────────────────────────────────┤ │
│ │ LayerNorm → MlpBlock → Residual │ │ ← Channel Mixing
│ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────┘Linear → GELU → Linear| Metric | 100K | 300K | Change |
|---|---|---|---|
| Parameters | 136,908 | 331,680 | 2.4x |
| Hidden Dim | 84 | 128 | 1.5x |
| Channel MLP | 128 | 288 | 2.3x |
| Sequence Length | 64 | 128 | 2x |
| Limitation | Description |
|---|---|
| Limited Context | 128 tokens still insufficient for complex context |
| Unstable Generation | Word patterns appear but sentence completion is poor |
| Vocabulary Gaps | Rare characters handled poorly despite byte-level encoding |
| Repetitive Output | Repeats patterns like "little girl named Timmy" |
1import torch
2from huggingface_hub import hf_hub_download
3from src.model import MicroMixerV2, MicroMixerV2Config
4from src.tokenizer import ByteTokenizer
5
6# Clone the repository first:
7# git clone https://github.com/llaa33219/MicroMixer-1.git
8# cd MicroMixer-1
9
10config = MicroMixerV2Config(
11 max_seq_len=128,
12 hidden_dim=128,
13 channel_mlp_dim=288,
14 num_layers=3,
15 use_hyper=True,
16)
17
18model = MicroMixerV2(config)
19weights_path = hf_hub_download("llaa33219/MicroMixer-1-300K-TinyStories", "model.pt")
20model.load_state_dict(torch.load(weights_path, map_location="cpu"))
21model.eval()
22
23tokenizer = ByteTokenizer()
24input_ids = torch.tensor([tokenizer.encode("Once upon a time")])
25
26with torch.no_grad():
27 output = model.generate(input_ids, max_new_tokens=64, temperature=0.8, top_k=40)
28
29print(tokenizer.decode(output[0].tolist()))