georgesZam commited on
Commit
96c6e84
Β·
verified Β·
1 Parent(s): 24f5a6f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +27 -30
README.md CHANGED
@@ -14,21 +14,23 @@ base_model: allenai/Emo_1b14b_1T
14
  base_model_relation: quantized
15
  ---
16
 
17
- # Emo-1B-14B-1T β€” MLX
18
 
19
- MLX-quantized port of [`allenai/Emo_1b14b_1T`](https://huggingface.co/allenai/Emo_1b14b_1T) β€” Ai2's EMO (Emergent Modularity) MoE LM (1B active / 14B total, top-8 of 128 experts, 1 shared expert, midtrained on 1T tokens of OLMoE-mix-0924).
 
 
 
 
20
 
21
  ## Credits
22
 
23
- **All credit for the model, the training, the data, and the EMO architecture itself goes to the original authors at Allen Institute for AI (Ai2):**
24
 
25
  - **Paper:** [EMO: Pretraining Mixture of Experts for Emergent Modularity](https://arxiv.org/abs/2605.06663) β€” Wang, Bhagia, Min et al., Ai2, 2026.
26
  - **Base model:** [`allenai/Emo_1b14b_1T`](https://huggingface.co/allenai/Emo_1b14b_1T)
27
  - **Training data:** [`allenai/OLMoE-mix-0924`](https://huggingface.co/datasets/allenai/OLMoE-mix-0924)
28
  - **Visualization:** [emovisualization.netlify.app](https://emovisualization.netlify.app)
29
 
30
- If you use this model in your work, please cite the original EMO paper:
31
-
32
  ```bibtex
33
  @article{wang2026emo,
34
  title = {EMO: Pretraining Mixture of Experts for Emergent Modularity},
@@ -38,57 +40,52 @@ If you use this model in your work, please cite the original EMO paper:
38
  }
39
  ```
40
 
41
- This repository only contributes the MLX port and the 4-bit quantization β€” no training, no data, no architectural research.
42
-
43
- ## Variants
44
 
45
- | Folder | Bits | Group size | Approx size |
46
- |---|---|---|---|
47
- | `4bit-g64/` | 4 | 64 | ~7.5 GB |
48
- | `4bit-g32/` | 4 | 32 | ~8.0 GB |
49
 
50
- `g32` keeps router quality slightly higher than `g64`; pick `g64` if you're memory-tight, `g32` if you want a touch more headroom on tasks that lean on routing precision.
51
 
52
- ## ⚠️ Requires a forked `mlx-lm`
 
 
53
 
54
- The `emo` model type is not yet upstream in [`ml-explore/mlx-lm`](https://github.com/ml-explore/mlx-lm). Until the PR is merged, install the fork that ships `mlx_lm/models/emo.py`:
55
 
56
  ```bash
57
- git clone https://github.com/<your-fork>/mlx-lm
58
  cd mlx-lm
 
59
  pip install -e .
60
  ```
61
 
62
- (Replace with the upstream URL once the PR is merged β€” at that point a plain `pip install mlx-lm` will work.)
63
 
64
  ## Usage
65
 
66
  ```python
67
  from mlx_lm import load, generate
68
 
69
- model, tokenizer = load("georgesZam/emo-1b14b-1t-4bit/4bit-g64")
70
- # If you cloned a specific subfolder, point load() at the local path of that subfolder instead.
71
-
72
- prompt = "The capital of France is"
73
- out = generate(model, tokenizer, prompt=prompt, max_tokens=80, verbose=True)
74
  ```
75
 
76
- To pull only one variant:
77
 
78
  ```bash
79
- hf download georgesZam/emo-1b14b-1t-4bit --include "4bit-g64/*" --local-dir ./emo-mlx
80
  ```
81
 
82
  ## Architecture notes (port)
83
 
84
- EMO at inference time is OLMoE-shaped with two tweaks:
85
 
86
- 1. **Shared experts.** The last `num_shared_experts` columns of the gate are routed through a *separate* softmax + top-k (here top-1 over 1 shared expert) and concatenated to the standard top-k; their indices are offset by `num_experts - num_shared_experts`. This matches the original `EmoSparseMoeBlock` legacy path.
87
- 2. **Layernorm naming.** EMO uses `pre_attention_layernorm` / `pre_feedforward_layernorm` (vs. OLMoE's `input_layernorm` / `post_attention_layernorm`). The MLX module mirrors EMO's names so weights map 1-to-1.
88
- 3. **No q/k norm** (OLMoE has them; EMO doesn't).
89
 
90
- The "emergent modularity" itself is a *pretraining* contribution β€” at inference it's a vanilla MoE forward pass. Expert subsetting (the headline benefit of EMO) is not exposed in this checkpoint; doing it cleanly would require an offline analysis of expert activations on your target domain, then dropping unused expert columns/rows from each layer.
91
 
92
  ## License
93
 
94
- Inherits from the base model. See `allenai/Emo_1b14b_1T` for terms.
 
14
  base_model_relation: quantized
15
  ---
16
 
17
+ # Emo-1B-14B-1T β€” MLX (4-bit, group_size=32)
18
 
19
+ MLX 4-bit quantization of [`allenai/Emo_1b14b_1T`](https://huggingface.co/allenai/Emo_1b14b_1T) β€” Ai2's EMO (Emergent Modularity) MoE LM (1B active / 14B total, top-8 of 128 experts, 1 shared expert, midtrained on 1T tokens of OLMoE-mix-0924).
20
+
21
+ Quantization: **4-bit, group_size=32** (chosen over `g64` to keep the MoE router precision tighter β€” group_size=32 limits the quantization error on the gate projection, which matters more for MoE than for dense models).
22
+
23
+ Size on disk: ~9.5 GB. Runs comfortably on Apple Silicon with β‰₯16 GB unified memory.
24
 
25
  ## Credits
26
 
27
+ **All credit for the model, training, data, and the EMO architecture goes to the original authors at Allen Institute for AI (Ai2):**
28
 
29
  - **Paper:** [EMO: Pretraining Mixture of Experts for Emergent Modularity](https://arxiv.org/abs/2605.06663) β€” Wang, Bhagia, Min et al., Ai2, 2026.
30
  - **Base model:** [`allenai/Emo_1b14b_1T`](https://huggingface.co/allenai/Emo_1b14b_1T)
31
  - **Training data:** [`allenai/OLMoE-mix-0924`](https://huggingface.co/datasets/allenai/OLMoE-mix-0924)
32
  - **Visualization:** [emovisualization.netlify.app](https://emovisualization.netlify.app)
33
 
 
 
34
  ```bibtex
35
  @article{wang2026emo,
36
  title = {EMO: Pretraining Mixture of Experts for Emergent Modularity},
 
40
  }
41
  ```
42
 
43
+ This repository only contributes the MLX port and 4-bit quantization β€” no training, no data, no architectural research.
 
 
44
 
45
+ ## ⚠️ Requires a fork of `mlx-lm`
 
 
 
46
 
47
+ The `emo` model type is **not yet upstream** in [`ml-explore/mlx-lm`](https://github.com/ml-explore/mlx-lm). Loading this model with stock `pip install mlx-lm` will fail with:
48
 
49
+ ```
50
+ ValueError: Model type emo not supported.
51
+ ```
52
 
53
+ Until the PR lands upstream, install the fork that ships `mlx_lm/models/emo.py`:
54
 
55
  ```bash
56
+ git clone https://github.com/ml-explore/mlx-lm.git
57
  cd mlx-lm
58
+ # Add the emo.py model file (see "Architecture notes" below for the exact code)
59
  pip install -e .
60
  ```
61
 
62
+ Or, if a public fork already exists, replace the URL above with it. The `emo.py` file used to produce this repo is shipped alongside this README for reference.
63
 
64
  ## Usage
65
 
66
  ```python
67
  from mlx_lm import load, generate
68
 
69
+ model, tokenizer = load("georgesZam/emo-1b14b-1t-4bit")
70
+ out = generate(model, tokenizer, prompt="The capital of France is", max_tokens=80, verbose=True)
 
 
 
71
  ```
72
 
73
+ CLI:
74
 
75
  ```bash
76
+ python -m mlx_lm generate --model georgesZam/emo-1b14b-1t-4bit --prompt "Hello"
77
  ```
78
 
79
  ## Architecture notes (port)
80
 
81
+ EMO at inference time is OLMoE-shaped with three tweaks the MLX port handles:
82
 
83
+ 1. **Shared experts.** The last `num_shared_experts` columns of the gate route through a *separate* softmax + top-k (here top-1 over 1 shared expert) and are concatenated to the standard top-k. Shared indices are offset by `num_experts - num_shared_experts`. This matches the original `EmoSparseMoeBlock` legacy path in `modeling_emo.py`.
84
+ 2. **Layernorm naming.** EMO uses `pre_attention_layernorm` / `pre_feedforward_layernorm`. The MLX module mirrors these names so weights map 1-to-1 without a remap.
85
+ 3. **No q/k norm.** Unlike OLMoE, EMO's attention has no q_norm / k_norm.
86
 
87
+ "Emergent Modularity" itself is a *pretraining* contribution β€” at inference it's a vanilla MoE forward pass. Expert subsetting (the paper's headline benefit) is not exposed in this checkpoint; doing it cleanly requires an offline analysis of expert activations on your target domain and dropping unused expert rows from each layer's stacked `switch_mlp` tensors.
88
 
89
  ## License
90
 
91
+ Inherits from the base model. See [`allenai/Emo_1b14b_1T`](https://huggingface.co/allenai/Emo_1b14b_1T) for terms.