File size: 16,837 Bytes
f41f1fb |
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 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
---
license: apache-2.0
language:
- en
pipeline_tag: text-generation
library_name: transformers
---
# Monet: Mixture of Monosemantic Experts for Transformers
## Model Summary
Monet introduces a novel approach for improving mechanistic interpretability in large language models (LLMs) using a Sparse Mixture-of-Experts (SMoE) architecture with 262,144 experts. By integrating sparse dictionary learning directly into end-to-end pretraining, Monet tackles the core issue of polysemanticity—where single neurons encode multiple unrelated concepts—while preserving overall model performance.
### Resources and Technical Documentation
- **GitHub Repository**: https://github.com/dmis-lab/Monet
- **Paper**: https://arxiv.org/abs/2412.04139
- **Model Hub**: https://huggingface.co/MonetLLM
- **Demo**: https://huggingface.co/spaces/MonetLLM/monet-vd-1.4B-100BT-hf-viewer
### Available Checkpoints
#### Base Models
<table class="center">
<tr>
<td align="center"><b>Model</b></td>
<td align="center"><b>Dataset</b></td>
<td align="center"><b>#Params</b></td>
<td align="center"><b>#Tokens</b></td>
<td align="center"><b>Checkpoint</b></td>
<td align="center"><b>Demo</b></td>
</tr>
<tr>
<td align="center" rowspan="4"><b>Monet-VD</b></td>
<td align="center" rowspan="3"><a href="https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu">FineWeb-Edu</a></td>
<td align="center">850M</td>
<td align="center">100BT</td>
<td><a href="https://huggingface.co/MonetLLM/monet-vd-850M-100BT-hf">monet-vd-850M-100BT-hf</a></td>
<td></td>
</tr>
<tr>
<td align="center">1.4B</td>
<td align="center">100BT</td>
<td><a href="https://huggingface.co/MonetLLM/monet-vd-1.4B-100BT-hf">monet-vd-1.4B-100BT-hf</a></td>
<td><a href="https://huggingface.co/spaces/MonetLLM/monet-vd-1.4B-100BT-hf-viewer">Viewer</a></td>
</tr>
<tr>
<td align="center">4.1B</td>
<td align="center">100BT</td>
<td><a href="https://huggingface.co/MonetLLM/monet-vd-4.1B-100BT-hf">monet-vd-4.1B-100BT-hf</a></td>
<td></td>
</tr>
<tr>
<td align="center"><a href="https://huggingface.co/datasets/bigcode/starcoderdata">StarCoderData</a></td>
<td align="center">1.4B</td>
<td align="center">100BT</td>
<td><a href="https://huggingface.co/MonetLLM/codemonet-vd-1.4B-100BT-hf">codemonet-vd-1.4B-100BT-hf</a></td>
<td><a href="https://huggingface.co/spaces/MonetLLM/codemonet-vd-1.4B-100BT-hf-viewer">Viewer</a></td>
</tr>
<tr>
<td align="center" rowspan="3"><b>Monet-HD</b></td>
<td align="center" rowspan="3"><a href="https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu">FineWeb-Edu</a></td>
<td align="center">850M</td>
<td align="center">100BT</td>
<td><a href="https://huggingface.co/MonetLLM/monet-hd-850M-100BT-hf">monet-hd-850M-100BT-hf</a></td>
<td></td>
</tr>
<tr>
<td align="center">1.4B</td>
<td align="center">100BT</td>
<td><a href="https://huggingface.co/MonetLLM/monet-hd-1.4B-100BT-hf">monet-hd-1.4B-100BT-hf</a></td>
<td></td>
</tr>
<tr>
<td align="center">4.1B</td>
<td align="center">100BT</td>
<td><a href="https://huggingface.co/MonetLLM/monet-hd-4.1B-100BT-hf">monet-hd-4.1B-100BT-hf</a></td>
<td></td>
</tr>
</table>
#### Instruction-Tuned Models
<table class="center">
<tr>
<td align="center"><b>Model</b></td>
<td align="center"><b>Purpose</b></td>
<td align="center"><b>Recipe</b></td>
<td align="center"><b>#Params</b></td>
<td align="center"><b>Checkpoint</b></td>
</tr>
<tr>
<td align="center" rowspan="2"><b>Monet-VD</b></td>
<td align="center">Chat Completion</td>
<td align="center"><a href="https://github.com/huggingface/alignment-handbook/tree/main/recipes/smollm">SmolLM</a></td>
<td align="center">1.4B</td>
<td><a href="https://huggingface.co/MonetLLM/monet-vd-1.4B-100BT-chat-hf">monet-vd-1.4B-100BT-chat-hf</a></td>
</tr>
<tr>
<td align="center">Vision-Language Model</td>
<td align="center"><a href="https://github.com/haotian-liu/LLaVA">LLaVA</a></td>
<td align="center">1.6B</td>
<td><a href="https://huggingface.co/MonetLLM/visionmonet-vd-1.4B-100BT-hf">visionmonet-vd-1.4B-100BT-hf</a></td>
</tr>
</table>
## Evaluation
### Open-Ended LLM Benchmarks
<table>
<thead>
<th>Model</th><th>MMLU</th><th>ARC</th><th>WG</th><th>PIQA</th><th>SIQA</th><th>OBQA</th><th>HS</th><th>CSQA</th><th>Avg.</th>
</thead>
<tbody>
<tr><td colspan="10" align="center"><b>0-shot</b></td></tr>
<tr><td align="center"><b>Monet-HD 850M</b></td><td align="center">0.320</td><td align="center">0.460</td><td align="center">0.506</td><td align="center">0.699</td><td align="center">0.416</td><td align="center">0.364</td><td align="center">0.465</td><td align="center">0.337</td><td align="center">0.446</td></tr>
<tr><td align="center"><b>Monet-VD 850M</b></td><td align="center">0.328</td><td align="center">0.456</td><td align="center">0.530</td><td align="center">0.708</td><td align="center">0.417</td><td align="center">0.356</td><td align="center">0.488</td><td align="center">0.343</td><td align="center">0.453</td></tr>
<tr><td align="center"><b>Monet-HD 1.4B</b></td><td align="center">0.338</td><td align="center">0.471</td><td align="center">0.538</td><td align="center">0.714</td><td align="center">0.418</td><td align="center">0.382</td><td align="center">0.501</td><td align="center">0.339</td><td align="center">0.463</td></tr>
<tr><td align="center"><b>Monet-VD 1.4B</b></td><td align="center">0.352</td><td align="center">0.495</td><td align="center">0.522</td><td align="center">0.727</td><td align="center">0.423</td><td align="center">0.418</td><td align="center">0.529</td><td align="center">0.363</td><td align="center">0.478</td></tr>
<tr><td align="center"><b>Monet-HD 4.1B</b></td><td align="center">0.375</td><td align="center">0.558</td><td align="center">0.560</td><td align="center">0.741</td><td align="center">0.427</td><td align="center">0.414</td><td align="center">0.571</td><td align="center">0.379</td><td align="center">0.503</td></tr>
<tr><td align="center"><b>Monet-VD 4.1B</b></td><td align="center">0.380</td><td align="center">0.547</td><td align="center">0.557</td><td align="center">0.751</td><td align="center">0.437</td><td align="center">0.424</td><td align="center">0.604</td><td align="center">0.389</td><td align="center">0.511</td></tr>
<tr><td colspan="10" align="center"><b>5-shot</b></td></tr>
<tr><td align="center"><b>Monet-HD 850M</b></td><td align="center">0.332</td><td align="center">0.537</td><td align="center">0.510</td><td align="center">0.697</td><td align="center">0.409</td><td align="center">0.346</td><td align="center">0.479</td><td align="center">0.420</td><td align="center">0.466</td></tr>
<tr><td align="center"><b>Monet-VD 850M</b></td><td align="center">0.341</td><td align="center">0.548</td><td align="center">0.520</td><td align="center">0.709</td><td align="center">0.437</td><td align="center">0.368</td><td align="center">0.504</td><td align="center">0.454</td><td align="center">0.485</td></tr>
<tr><td align="center"><b>Monet-HD 1.4B</b></td><td align="center">0.352</td><td align="center">0.544</td><td align="center">0.530</td><td align="center">0.720</td><td align="center">0.432</td><td align="center">0.360</td><td align="center">0.518</td><td align="center">0.441</td><td align="center">0.487</td></tr>
<tr><td align="center"><b>Monet-VD 1.4B</b></td><td align="center">0.360</td><td align="center">0.547</td><td align="center">0.526</td><td align="center">0.730</td><td align="center">0.441</td><td align="center">0.422</td><td align="center">0.551</td><td align="center">0.501</td><td align="center">0.510</td></tr>
<tr><td align="center"><b>Monet-HD 4.1B</b></td><td align="center">0.385</td><td align="center">0.603</td><td align="center">0.545</td><td align="center">0.742</td><td align="center">0.463</td><td align="center">0.412</td><td align="center">0.588</td><td align="center">0.545</td><td align="center">0.535</td></tr>
<tr><td align="center"><b>Monet-VD 4.1B</b></td><td align="center">0.398</td><td align="center">0.625</td><td align="center">0.564</td><td align="center">0.761</td><td align="center">0.470</td><td align="center">0.438</td><td align="center">0.619</td><td align="center">0.525</td><td align="center">0.550</td></tr>
</tbody>
</table>
### Detoxification
Detoxification task performances are evaluated on the [Monet-VD 1.4B](MonetLLM/monet-vd-1.4B-100BT-hf) model.
#### RealToxicityPrompts
<table>
<thead>
<tr>
<th rowspan="2">Masking<br/>Threshold</th>
<th rowspan="2">Masking<br/>Ratio</th>
<th colspan="2">Exp. Max. Toxicity</th>
<th colspan="2">Toxicity Prob.</th>
<th rowspan="2">Avg. Perf.</th>
</tr>
<tr>
<th>Toxic</th>
<th>Non-Toxic</th>
<th>Toxic</th>
<th>Non-Toxic</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">–</td>
<td align="center">–</td>
<td align="center">0.795</td>
<td align="center">0.269</td>
<td align="center">0.926</td>
<td align="center">0.08</td>
<td align="center"><b>0.478</b></td>
</tr>
<tr>
<td align="center">0.2</td>
<td align="center">1.0%</td>
<td align="center">0.767</td>
<td align="center">0.268</td>
<td align="center">0.909</td>
<td align="center">0.07</td>
<td align="center"><b>0.479</b></td>
</tr>
<tr>
<td align="center">0.1</td>
<td align="center">4.1%</td>
<td align="center">0.657</td>
<td align="center">0.270</td>
<td align="center">0.768</td>
<td align="center">0.08</td>
<td align="center"><b>0.478</b></td>
</tr>
<tr>
<td align="center">0.05</td>
<td align="center">14.4%</td>
<td align="center"><b>0.552</b></td>
<td align="center"><b>0.256</b></td>
<td align="center"><b>0.564</b></td>
<td align="center"><b>0.05</b></td>
<td align="center">0.467</td>
</tr>
</tbody>
</table>
#### ToxiGen
<table>
<thead>
<tr>
<th rowspan="2">Masking<br/>Threshold</th>
<th rowspan="2">Masking<br/>Ratio</th>
<th colspan="2">RoBERTa Score</th>
<th rowspan="2">Avg. Perf.</th>
</tr>
<tr>
<th>Hate</th>
<th>Neutral</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">–</td>
<td align="center">–</td>
<td align="center">0.642</td>
<td align="center">0.035</td>
<td align="center"><b>0.478</b></td>
</tr>
<tr>
<td align="center">0.2</td>
<td align="center">1.4%</td>
<td align="center">0.643</td>
<td align="center">0.033</td>
<td align="center"><b>0.478</b></td>
</tr>
<tr>
<td align="center">0.1</td>
<td align="center">5.4%</td>
<td align="center">0.504</td>
<td align="center">0.028</td>
<td align="center">0.473</td>
</tr>
<tr>
<td align="center">0.05</td>
<td align="center">15.0%</td>
<td align="center"><b>0.430</b></td>
<td align="center"><b>0.027</b></td>
<td align="center">0.455</td>
</tr>
</tbody>
</table>
## Examples
### Text Generation
```python
from transformers import pipeline
model_name = "MonetLLM/monet-vd-1.4B-100BT-hf"
pipe = pipeline(
"text-generation",
model_name,
tokenizer=AutoTokenizer.from_pretrained(model_name),
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
print(pipe("The key to life is", max_new_tokens=20, do_sample=True)[0]["generated_text"])
```
### Code Generation
```python
from transformers import pipeline
model_name = "MonetLLM/codemonet-vd-1.4B-100BT-hf"
pipe = pipeline(
"text-generation",
model_name,
tokenizer=AutoTokenizer.from_pretrained(model_name),
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
text = '''
def print_len(x: str):
"""For a given string x, print the length of x."""
'''
print(pipe(text, max_new_tokens=10)[0]["generated_text"].split("\n\n")[0])
```
### Chat Completion
```python
from transformers import pipeline
model_name = "MonetLLM/codemonet-vd-1.4B-100BT-chat-hf"
pipe = pipeline(
"text-generation",
model_name,
tokenizer=AutoTokenizer.from_pretrained(model_name),
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
text = tokenizer.apply_chat_template(
[{"role": "user", "content": "Hi! How are you?"}],
add_generation_prompt=True,
tokenize=False,
)
print(pipe(text, max_new_tokens=30, do_sample=True)[0]["generated_text"])
```
### Using vLLM
The custom implementation of vLLM is provided in [the repository](https://github.com/dmis-lab/Monet/blob/main/modeling_monet_vllm.py).
```python
from vllm import LLM, ModelRegistry, SamplingParams
from modeling_monet_vllm import MonetForCausalLM
# Register Monet architecture with vLLM
ModelRegistry.register_model("MonetForCausalLM", MonetForCausalLM)
model = LLM(
"MonetLLM/monet-vd-1.4B-100BT-hf",
trust_remote_code=True,
dtype="bfloat16",
gpu_memory_utilization=0.8
)
sampling_params = SamplingParams(max_tokens=20, temperature=1.0)
print(model.generate("The key to life is", sampling_params)[0].outputs[0].text)
```
## Training
### Model
- Architecture: Monet
- Pretraining tokens: 100B
- Precision: bfloat16
### Hardware
- TPUs: TPU-v4-64 Pod Slice (supported by [TRC Program](https://sites.research.google/trc/about/))
### Software
- Training Framework: [Jax](https://github.com/jax-ml/jax), [Flax](https://github.com/google/flax)
## Intended Use
### Primary Intended Uses
This model is designed to advance research on language models and serve as a foundational component for generative AI-driven functionalities. Its primary applications, mostly in English, include:
- Mechanistic interpretability research for language models
- Text generation with enhanced interpretability
- Code generation (CodeMonet variant)
- Chat completion (instruction-tuned variant)
- Vision-language tasks (VisionMonet variant)
### Out-of-Scope Uses
This model has not been explicitly developed or tested for all potential downstream applications. Therefore:
1. Limitations & Mitigations: Developers should be mindful of common language model limitations, and thoroughly evaluate and mitigate risks regarding accuracy, safety, and fairness—especially in high-stakes or high-risk scenarios.
2. Legal & Regulatory Compliance: Developers must comply with any applicable laws and regulations (e.g., privacy, trade compliance), taking into account the model’s English-focused training (refer to <a href="https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu">FineWeb-Edu</a>).
3. No License Modification: Nothing in this Model Card modifies or restricts the license under which this model is released.
4. Unsupported Programming Languages: Programming in languages not covered by <a href="https://huggingface.co/datasets/bigcode/starcoderdata">StarCoderData</a>(CodeMonet variant) is not within the model’s intended scope.
## Model Architecture
Monet introduces a novel Mixture-of-Experts (MoE) architecture with several key innovations:
- Parameter-efficient expert decomposition: overall parameter count grows in proportion to the square root of the number of experts
- Fine-grained expert specialization: offers clear insight into model behavior
- Precise manipulation of knowledge: enables control over domain knowledge, programming language capabilities, and toxicity level.
## Ethical Considerations
### Transparency
- Designed specifically for enhanced interpretability
- Enables understanding of internal model behavior
- Allows tracking of knowledge attribution
### Control
- Supports toxicity mitigation
- Enables domain-specific knowledge control
- Maintains performance while adjusting behavior
## License and Usage
Monet is licensed under the Apache 2.0 license. The model is primarily intended for research and educational use. Important licensing notes:
- Instruction-tuned models have been fine-tuned using a dataset mix with outputs generated from third party models
- Research and educational use is encouraged
- Commercial use is subject to Apache 2.0 license terms
## Citation
```bibtex
@article{park2024monet,
title={{Monet: Mixture of Monosemantic Experts for Transformers}},
author={Jungwoo Park and Young Jin Ahn and Kee-Eung Kim and Jaewoo Kang},
journal={arXiv preprint arXiv:2404.05567},
year={2024}
}
``` |