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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- moe
|
| 5 |
+
- deepseek
|
| 6 |
+
- nvidia-h200
|
| 7 |
+
- fineweb-edu
|
| 8 |
+
- pytorch
|
| 9 |
+
- text-generation
|
| 10 |
+
- nano-lm
|
| 11 |
+
- edge-ai
|
| 12 |
+
- rope
|
| 13 |
+
language:
|
| 14 |
+
- en
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
datasets:
|
| 17 |
+
- HuggingFaceFW/fineweb-edu
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# Eve-2-MoE-272M
|
| 21 |
+
|
| 22 |
+
A custom 272M-parameter Mixture-of-Experts language model trained from scratch on **8Γ NVIDIA H200** GPUs. Implements a DeepSeek-V3 style architecture with a shared expert, top-k routed experts, RoPE positional encoding, and SwiGLU activations.
|
| 23 |
+
|
| 24 |
+
Eve-2 is a **base model for specialized fine-tuning** β not a chatbot. Fine-tune it in ~20 minutes on consumer hardware for narrow tasks like PII redaction, text classification, semantic compression cleanup, or lightweight routing in multi-agent pipelines. Runs on a Raspberry Pi.
|
| 25 |
+
|
| 26 |
+
**Author:** [Anthony Maio](https://making-minds.ai) / Making Minds AI (Independent)
|
| 27 |
+
https://www.github.com/anthony-maio
|
| 28 |
+
https://www.linkedin.com/in/anthony-maio
|
| 29 |
+
|
| 30 |
+
## Architecture
|
| 31 |
+
|
| 32 |
+
| | |
|
| 33 |
+
|---|---|
|
| 34 |
+
| **Total Parameters** | 272M |
|
| 35 |
+
| **Type** | Mixture of Experts (MoE) |
|
| 36 |
+
| **Routed Experts** | 8 |
|
| 37 |
+
| **Shared Experts** | 1 (always active) |
|
| 38 |
+
| **Active Params/Token** | ~80M (top-2 routing) |
|
| 39 |
+
| **Routing** | Top-2 gate with load-balancing aux loss |
|
| 40 |
+
| **Layers** | 12 transformer blocks |
|
| 41 |
+
| **Hidden Dim** | 512 |
|
| 42 |
+
| **Attention Heads** | 8 (64-dim each) |
|
| 43 |
+
| **Expert FFN Dim** | 1408 (SwiGLU) |
|
| 44 |
+
| **Position Encoding** | Rotary Position Embeddings (RoPE) |
|
| 45 |
+
| **Context Length** | 2048 tokens |
|
| 46 |
+
| **Vocab** | 50,304 (GPT-2 tokenizer, padded) |
|
| 47 |
+
| **Norm** | RMSNorm |
|
| 48 |
+
| **Precision** | BFloat16 (native) |
|
| 49 |
+
| **Weight Tying** | Embeddings tied with LM head |
|
| 50 |
+
|
| 51 |
+
### Design Rationale
|
| 52 |
+
|
| 53 |
+
MoE at this scale is a deliberate choice. With 8 experts but only 2 active per token, inference cost is roughly equivalent to a 80M dense model while the total parameter budget gives each expert room to specialize. The shared expert handles common patterns across all tokens; the routed experts develop narrow competencies during fine-tuning.
|
| 54 |
+
|
| 55 |
+
This makes Eve-2 a natural base for **nano-LM swarms** β fine-tune copies for specific tasks, deploy at the edge, coordinate through lightweight protocols.
|
| 56 |
+
|
| 57 |
+
## Training
|
| 58 |
+
|
| 59 |
+
| | |
|
| 60 |
+
|---|---|
|
| 61 |
+
| **Hardware** | 8Γ NVIDIA H200 (141 GB VRAM each) |
|
| 62 |
+
| **Throughput** | ~1.26M tokens/sec |
|
| 63 |
+
| **Steps** | 40,000 |
|
| 64 |
+
| **Tokens** | ~10.5B |
|
| 65 |
+
| **Wall Time** | ~2.5 hours |
|
| 66 |
+
| **Data** | [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) (Sample-10BT) |
|
| 67 |
+
| **Optimizer** | AdamW (Ξ²β=0.9, Ξ²β=0.95, weight decay 0.1) |
|
| 68 |
+
| **Schedule** | Cosine decay with 200-step linear warmup |
|
| 69 |
+
| **Peak LR** | 5e-4 β decays to 5e-5 |
|
| 70 |
+
| **Batch** | 128 Γ 2048 tokens (16/GPU Γ 8 GPUs) |
|
| 71 |
+
| **Gradient Clipping** | 1.0 |
|
| 72 |
+
| **Distributed** | PyTorch DDP |
|
| 73 |
+
|
| 74 |
+
### Convergence
|
| 75 |
+
|
| 76 |
+
| Step | Tokens Seen | Train Loss | Val Loss (WikiText-2) |
|
| 77 |
+
|------|------------|-----------|----------------------|
|
| 78 |
+
| 500 | 131M | 4.82 | 6.35 |
|
| 79 |
+
| 1,000 | 262M | 4.09 | 4.84 |
|
| 80 |
+
| 1,500 | 393M | 3.95 | 4.36 |
|
| 81 |
+
| 5,000 | 1.3B | 3.47 | 3.89 |
|
| 82 |
+
| 13,000 | 3.4B | 3.05 | 3.61 |
|
| 83 |
+
| 25,000 | 6.6B | 2.90 | 3.51 |
|
| 84 |
+
| 37,000 | 9.7B | 2.80 | 3.42 |
|
| 85 |
+
| 40,000 | 10.5B | 2.78 | **3.40** |
|
| 86 |
+
|
| 87 |
+
**Final Perplexity (WikiText-2): ~30**
|
| 88 |
+
|
| 89 |
+
Training logs: [Weights & Biases](https://wandb.ai/anthony-maio-making-minds/Eve-2-MoE)
|
| 90 |
+
|
| 91 |
+
## Quick Start
|
| 92 |
+
|
| 93 |
+
This is a custom architecture β you need the model class to load it. Download `modeling_eve.py` from this repo.
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
import torch
|
| 97 |
+
import tiktoken
|
| 98 |
+
from modeling_eve import ModelConfig, DeepSeekMoE
|
| 99 |
+
from huggingface_hub import hf_hub_download
|
| 100 |
+
|
| 101 |
+
# Load
|
| 102 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 103 |
+
config = ModelConfig()
|
| 104 |
+
model = DeepSeekMoE(config)
|
| 105 |
+
|
| 106 |
+
weights = hf_hub_download(repo_id="anthonym21/Eve-2-MoE-272M", filename="pytorch_model.bin")
|
| 107 |
+
model.load_state_dict(torch.load(weights, map_location=device))
|
| 108 |
+
model.to(device).eval()
|
| 109 |
+
|
| 110 |
+
# Generate
|
| 111 |
+
enc = tiktoken.get_encoding("gpt2")
|
| 112 |
+
tokens = torch.tensor(enc.encode("The future of artificial intelligence is"),
|
| 113 |
+
dtype=torch.long, device=device).unsqueeze(0)
|
| 114 |
+
|
| 115 |
+
output = model.generate(tokens, max_new_tokens=100, temperature=0.8, top_k=50)
|
| 116 |
+
print(enc.decode(output[0].tolist()))
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### CPU / Raspberry Pi
|
| 120 |
+
|
| 121 |
+
The model runs on CPU at ~272M parameters. Inference is slower but functional β memory footprint is under 1 GB.
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
device = "cpu"
|
| 125 |
+
# Everything else stays the same
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
## Intended Use
|
| 129 |
+
|
| 130 |
+
Eve-2 is a **fine-tuning base**, not a finished product. Out of the box it produces coherent English but has no instruction-following capability. The workflow:
|
| 131 |
+
|
| 132 |
+
1. Take this base model
|
| 133 |
+
2. Fine-tune on a narrow task (~20 min on consumer GPU)
|
| 134 |
+
3. Deploy at the edge as part of a specialized nano-LM swarm
|
| 135 |
+
|
| 136 |
+
**Target applications:** Data cleaning, PII redaction, text classification, semantic compression repair, lightweight routing/triage in multi-agent pipelines.
|
| 137 |
+
|
| 138 |
+
## Limitations
|
| 139 |
+
|
| 140 |
+
This is a 272M model. It will not write essays, follow complex instructions, or compete with larger models on general benchmarks. That's by design β it's a small, fast, cheap-to-tune specialist base.
|
| 141 |
+
|
| 142 |
+
The train/val gap of ~0.62 at convergence suggests the model could benefit from additional data diversity beyond FineWeb-Edu for downstream generalization.
|
| 143 |
+
|
| 144 |
+
## Files
|
| 145 |
+
|
| 146 |
+
```
|
| 147 |
+
βββ pytorch_model.bin # Model weights
|
| 148 |
+
βββ config.json # Architecture config
|
| 149 |
+
βββ modeling_eve.py # Model class definitions (required to load)
|
| 150 |
+
βββ generate.py # Standalone inference script
|
| 151 |
+
βββ train.py # DDP training script
|
| 152 |
+
βββ requirements.txt # Dependencies
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
## Citation
|
| 156 |
+
|
| 157 |
+
```bibtex
|
| 158 |
+
@misc{maio2026eve2moe,
|
| 159 |
+
author = {Maio, Anthony},
|
| 160 |
+
title = {Eve-2-MoE-272M: A Nano-Scale Mixture of Experts Base Model for SLM Swarms & Edge Deployment},
|
| 161 |
+
year = {2026},
|
| 162 |
+
publisher = {Hugging Face},
|
| 163 |
+
url = {https://huggingface.co/anthonym21/Eve-2-MoE-272M}
|
| 164 |
+
}
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
## License
|
| 168 |
+
|
| 169 |
+
MIT β free for research and commercial use.
|