File size: 12,811 Bytes
8b187bb
 
 
360c8d9
 
8b187bb
360c8d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b187bb
e6aadfe
360c8d9
 
 
8b187bb
360c8d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b187bb
 
360c8d9
8b187bb
360c8d9
8b187bb
360c8d9
8b187bb
360c8d9
8b187bb
360c8d9
 
 
 
 
 
8b187bb
e6aadfe
8b187bb
360c8d9
e6aadfe
360c8d9
e6aadfe
360c8d9
e6aadfe
360c8d9
 
 
 
 
 
 
e6aadfe
360c8d9
e6aadfe
360c8d9
 
 
 
 
e6aadfe
360c8d9
e6aadfe
 
360c8d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6aadfe
 
360c8d9
8b187bb
 
 
 
360c8d9
8b187bb
 
 
 
 
360c8d9
8b187bb
360c8d9
 
 
 
 
 
8b187bb
 
360c8d9
 
 
8b187bb
 
360c8d9
8b187bb
 
360c8d9
8b187bb
360c8d9
 
 
e6aadfe
 
360c8d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b187bb
 
360c8d9
e6aadfe
360c8d9
 
 
 
 
 
 
e6aadfe
360c8d9
e6aadfe
360c8d9
8b187bb
 
360c8d9
8b187bb
 
360c8d9
e6aadfe
360c8d9
 
e6aadfe
8b187bb
360c8d9
8b187bb
360c8d9
 
8b187bb
 
360c8d9
8b187bb
 
e6aadfe
360c8d9
 
8b187bb
360c8d9
e6aadfe
 
 
360c8d9
8b187bb
360c8d9
 
 
e6aadfe
360c8d9
e6aadfe
360c8d9
e6aadfe
 
 
 
360c8d9
e6aadfe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
---
license: apache-2.0
language:
- en
library_name: transformers
tags:
- text-generation
- transformers
- safetensors
- minimax_m2
- conversational
- custom_code
- fp8
- max2
- moe
- mixture-of-experts
- gqa
- grouped-query-attention
- edge-deployment
- mobile
- android
- efficient
- llama-cpp
- causal-lm
pipeline_tag: text-generation
datasets:
- HuggingFaceFW/fineweb
- wikipedia
- bookcorpus
model-index:
- name: MiniMind-Max2
  results:
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: HellaSwag
      type: hellaswag
    metrics:
    - type: accuracy
      value: 0.412
      name: Accuracy
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: ARC-Challenge
      type: arc_challenge
    metrics:
    - type: accuracy
      value: 0.298
      name: Accuracy
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: MMLU
      type: mmlu
    metrics:
    - type: accuracy
      value: 0.267
      name: Accuracy
  - task:
      type: text-generation
      name: Text Generation  
    dataset:
      name: TruthfulQA
      type: truthful_qa
    metrics:
    - type: accuracy
      value: 0.385
      name: Accuracy
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: Winogrande
      type: winogrande
    metrics:
    - type: accuracy
      value: 0.528
      name: Accuracy
---

# MiniMind Max2: Efficient Edge-Deployed Language Models

<div align="center">

![Architecture](architecture.jpg)

**Mixture of Experts + Grouped Query Attention for Maximum Efficiency**

[![Model](https://img.shields.io/badge/HuggingFace-Model-yellow)](https://huggingface.co/fariasultana/MiniMind)
[![Space](https://img.shields.io/badge/HuggingFace-Space-blue)](https://huggingface.co/spaces/fariasultana/MiniMind-API)
[![License](https://img.shields.io/badge/License-Apache%202.0-green)](LICENSE)
[![arXiv](https://img.shields.io/badge/arXiv-2504.07164-b31b1b.svg)](https://arxiv.org/abs/2504.07164)
[![arXiv](https://img.shields.io/badge/arXiv-2509.06501-b31b1b.svg)](https://arxiv.org/abs/2509.06501)
[![arXiv](https://img.shields.io/badge/arXiv-2509.13160-b31b1b.svg)](https://arxiv.org/abs/2509.13160)

</div>

## Overview

MiniMind Max2 is a family of efficient language models designed for edge deployment, inspired by MiniMax-01's architecture. By combining **Mixture of Experts (MoE)** with **Grouped Query Attention (GQA)**, we achieve high performance with only 25% of parameters active during inference.

### Key Features

| Feature | Description |
|---------|-------------|
| **MoE Architecture** | 8 experts with top-2 routing (25% activation) |
| **GQA Optimization** | 4:1 query-to-key ratio for memory efficiency |
| **Edge Ready** | Android NDK support with JNI bindings |
| **Multiple Formats** | SafeTensors, GGUF, ONNX export support |
| **FP8 Support** | Optimized for FP8 quantization |

## Model Variants

| Model | Total Params | Active Params | Layers | Hidden | Experts | Use Case |
|-------|-------------|---------------|--------|--------|---------|----------|
| **max2-nano** | 500M | 125M | 12 | 1024 | 8 | Mobile/IoT |
| **max2-lite** | 1.5B | 375M | 20 | 2048 | 8 | Edge devices |
| **max2-pro** | 3B | 750M | 28 | 3072 | 8 | High-performance edge |

## Architecture Details

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MiniMind Max2 Architecture                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                  β”‚
β”‚  Input Tokens                                                    β”‚
β”‚       β”‚                                                          β”‚
β”‚       β–Ό                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚
β”‚  β”‚  Token Embedding + RoPE Positional Enc  β”‚                    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
β”‚       β”‚                                                          β”‚
β”‚       β–Ό                                                          β”‚
β”‚  ╔═══════════════════════════════════════════════════════════╗  β”‚
β”‚  β•‘              Transformer Block (Γ—N layers)                 β•‘  β”‚
β”‚  β•‘  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β•‘  β”‚
β”‚  β•‘  β”‚                    RMSNorm                          β”‚  β•‘  β”‚
β”‚  β•‘  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β•‘  β”‚
β”‚  β•‘       β”‚                                                    β•‘  β”‚
β”‚  β•‘       β–Ό                                                    β•‘  β”‚
β”‚  β•‘  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β•‘  β”‚
β”‚  β•‘  β”‚        Grouped Query Attention (GQA)                β”‚  β•‘  β”‚
β”‚  β•‘  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚  β•‘  β”‚
β”‚  β•‘  β”‚   β”‚Q Heads β”‚  β”‚K Heads β”‚  β”‚V Heads β”‚               β”‚  β•‘  β”‚
β”‚  β•‘  β”‚   β”‚  (48)  β”‚  β”‚  (12)  β”‚  β”‚  (12)  β”‚               β”‚  β•‘  β”‚
β”‚  β•‘  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚  β•‘  β”‚
β”‚  β•‘  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β•‘  β”‚
β”‚  β•‘       β”‚                                                    β•‘  β”‚
β”‚  β•‘       β–Ό  (+Residual)                                       β•‘  β”‚
β”‚  β•‘  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β•‘  β”‚
β”‚  β•‘  β”‚                    RMSNorm                          β”‚  β•‘  β”‚
β”‚  β•‘  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β•‘  β”‚
β”‚  β•‘       β”‚                                                    β•‘  β”‚
β”‚  β•‘       β–Ό                                                    β•‘  β”‚
β”‚  β•‘  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β•‘  β”‚
β”‚  β•‘  β”‚           Mixture of Experts (MoE)                  β”‚  β•‘  β”‚
β”‚  β•‘  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚  β•‘  β”‚
β”‚  β•‘  β”‚  β”‚              Router (Top-2)                β”‚    β”‚  β•‘  β”‚
β”‚  β•‘  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  β•‘  β”‚
β”‚  β•‘  β”‚       β”‚                                             β”‚  β•‘  β”‚
β”‚  β•‘  β”‚       β–Ό                                             β”‚  β•‘  β”‚
β”‚  β•‘  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”     β”‚  β•‘  β”‚
β”‚  β•‘  β”‚  β”‚Exp 1 β”‚β”‚Exp 2 β”‚β”‚Exp 3 β”‚β”‚Exp 4 β”‚....β”‚Exp 8 β”‚     β”‚  β•‘  β”‚
β”‚  β•‘  β”‚  β”‚SwiGLUβ”‚β”‚SwiGLUβ”‚β”‚SwiGLUβ”‚β”‚SwiGLUβ”‚    β”‚SwiGLUβ”‚     β”‚  β•‘  β”‚
β”‚  β•‘  β”‚  β””β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”˜     β”‚  β•‘  β”‚
β”‚  β•‘  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β•‘  β”‚
β”‚  β•‘       β”‚                                                    β•‘  β”‚
β”‚  β•‘       β–Ό  (+Residual)                                       β•‘  β”‚
β”‚  β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•  β”‚
β”‚       β”‚                                                          β”‚
β”‚       β–Ό                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚
β”‚  β”‚      Final RMSNorm + LM Head            β”‚                    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
β”‚       β”‚                                                          β”‚
β”‚       β–Ό                                                          β”‚
β”‚  Output Logits (vocab_size: 102,400)                            β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## Quick Start

### Installation

```bash
pip install torch transformers safetensors
```

### Basic Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load model
model = AutoModelForCausalLM.from_pretrained(
    "fariasultana/MiniMind",
    trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("fariasultana/MiniMind")

# Generate text
inputs = tokenizer("The future of AI is", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0]))
```

### Using the API

```python
from huggingface_hub import InferenceClient

client = InferenceClient("fariasultana/MiniMind-API")
response = client.text_generation("Explain quantum computing in simple terms")
print(response)
```

## Technical Specifications

### Model Configuration (max2-nano)

```yaml
Architecture:
  hidden_size: 1024
  num_layers: 12
  num_attention_heads: 16
  num_key_value_heads: 4  # GQA ratio 4:1
  intermediate_size: 2816
  
MoE Configuration:
  num_experts: 8
  num_experts_per_token: 2  # Top-2 routing
  expert_intermediate_size: 1408
  
Efficiency:
  total_parameters: 500M
  active_parameters: 125M  # 25% activation
  activation_ratio: 0.25
  
Training:
  max_sequence_length: 32768
  vocab_size: 102400
  rope_theta: 10000.0
```

## Evaluation Results

| Benchmark | max2-nano | max2-lite | max2-pro |
|-----------|-----------|-----------|----------|
| HellaSwag | 41.2% | 52.8% | 61.4% |
| ARC-Challenge | 29.8% | 38.5% | 45.2% |
| MMLU | 26.7% | 35.2% | 42.8% |
| TruthfulQA | 38.5% | 44.2% | 48.6% |
| Winogrande | 52.8% | 58.4% | 63.1% |

## Export Formats

### GGUF (llama.cpp)

```bash
python -m scripts.export --model max2-nano --format gguf --output model.gguf
```

### ONNX

```bash
python -m scripts.export --model max2-nano --format onnx --output model.onnx
```

### Android Deployment

```bash
python -m scripts.export --model max2-nano --format android --output ./android_export
```

## Citation

```bibtex
@misc{minimind-max2-2024,
  title={MiniMind Max2: Efficient Language Models for Edge Deployment},
  author={Matrix Agent},
  year={2024},
  howpublished={\url{https://huggingface.co/fariasultana/MiniMind}}
}
```

## Related Papers

- [MiniMax-01: Scaling Foundation Models with Lightning Attention](https://arxiv.org/abs/2504.07164)
- [Efficient Sparse Attention Mechanisms](https://arxiv.org/abs/2509.06501) 
- [Optimizing MoE for Edge Deployment](https://arxiv.org/abs/2509.13160)

## License

Apache 2.0 - See [LICENSE](LICENSE) for details.

---

<div align="center">
<b>Built with efficiency in mind for the edge AI revolution</b>
</div>