Many small feed-forward blocks instead of one big one
In a normal, dense transformer, every token goes through every weight of every feed-forward block. A mixture of experts replaces each feed-forward block with many smaller ones, called experts, plus a small router that picks a few experts for each token. The attention part stays the same.
- The token’s vectorComing out of attention, as in any transformer block
- RouterA small matrix gives one score per expert: 256 scores in DeepSeek-V3
- Pick the top kKeep only the best few: 8 of 256 in DeepSeek-V3, 4 of 128 in gpt-oss-120b
- Run only those expertsEach is an ordinary SwiGLU feed-forward block, just smaller
- Weighted sumMix their outputs by the router’s scores, then add to the residual stream
s = score(W_router · x)One score per expert. Softmax in most models; DeepSeek-V3 uses a sigmoid for each.
keep the k highest scores, set the rest to 0This is what makes it sparse: most experts get nothing.
y = Σ s_i · Expert_i(x)Only the k chosen experts are ever computed.
Different tokens pick different experts, and the shared expert sees them all.
This interactive part needs JavaScript.
Total parameters and active parameters
An MoE model has two sizes. Model names often show both: Qwen3-235B-A22B means 235 billion in total, 22 billion active for each token.
| Model | Total | Active per token | Routed experts (used per token) | Share used |
|---|---|---|---|---|
| Mixtral 8x7B (2023) | 47B | 13B | 8 (2) | 28 % |
| DeepSeek-V3 (2024) | 671B | 37B | 256 (8), plus 1 shared | 5.5 % |
| gpt-oss-20b (2025) | 20.9B | 3.6B | 32 (4) | 17 % |
| gpt-oss-120b (2025) | 116.8B | 5.1B | 128 (4) | 4.4 % |
| DeepSeek-V4-Flash (2026) | 284B | 13B | 256 (6), plus 1 shared | 4.6 % |
| DeepSeek-V4-Pro (2026) | 1.6T | 49B | 384 (6), plus 1 shared | 3.1 % |
| Kimi K3 (2026) | 2.8T | 104B | 896 (16) | 3.7 % |
From each model’s paper or model card. Attention, embeddings and shared experts are always active, which is why the active share is higher than the share of experts used.
Total parameters decide
- How much memory you need: every expert must be loaded
- The file size on disk
- How much knowledge the model can hold
Active parameters decide
- The computation per token: about 2 operations per active weight
- How many bytes are read per token, and so the speed
- The electricity and price per token
Quick check
Which size decides it: total or active parameters?
-
How much memory the model needs
Answer: Total parameters
-
How much computation each token costs
Answer: Active parameters
-
The size of the download
Answer: Total parameters
-
Tokens per second on a memory-bound device
Answer: Active parameters
-
How much the model can remember from training
Answer: Total parameters
-
The price per million tokens on an API
Answer: Active parameters
Keeping the experts balanced
A router left alone tends to collapse: a few experts get slightly better early on, get picked more, learn more, and get picked even more. Soon most experts sit idle, which wastes their memory, and the busy experts become a traffic jam. This is called routing collapse.
- The classic fix: an extra loss. Add a penalty to training whenever the load is uneven, as in Switch Transformer. It works, but the penalty pulls against the real goal of predicting text, and too much of it makes the model worse.
- DeepSeek’s fix: a bias, not a loss. Give each expert a bias number that is added to its score only when choosing experts. After each training step, lower the bias of experts that were overloaded and raise it for those that were underused. The load evens out, and the training goal is left untouched. DeepSeek-V3 and V4 use this “auxiliary-loss-free” balancing.
The DeepSeek recipe: fine-grained and shared experts
Early MoE models used a few large experts, such as Mixtral’s 8, with 2 picked per token. DeepSeek’s 2024 paper DeepSeekMoE changed two things, and almost everyone copied them.
- Fine-grained experts. Cut each expert into smaller ones and pick more of them. The computation stays the same, but there are far more ways to combine experts. With 16 experts and 2 picked, there are 120 possible pairs. Split each into 4 (64 experts, 8 picked) and there are 4,426,165,368 combinations.
- Shared experts. Some knowledge is needed by every token: grammar, common words. Instead of every routed expert learning it again, one or more shared experts always run. The routed experts are then free to specialise.
Experts on your own computer
MoE models are kind to home hardware in one way and hard in another. They are fast, because each token reads only the active weights. But they are large, because all the experts must be somewhere in memory.
Qwen3.8-27B, dense, Q4_K_M: the whole 19 GB file is read for every token614 ÷ 19 ≈ 32 tokens per second at most.
gpt-oss-120b, MoE, MXFP4: 5.1B active × about 4.3 bits ÷ 8 ≈ 2.8 GB per token614 ÷ 2.8 ≈ 220 tokens per second at most, for a model four times bigger.
Real speeds are lower than these limits, but the gap is real: the bigger MoE model can write faster. The catch is that its 63 GB file has to fit somewhere. On a PC with a GPU, llama.cpp can split it: attention and shared parts on the GPU, the experts in ordinary RAM, where each token reads only a few.
# by default, llama.cpp decides how much fits on the GPU
$ llama serve -hf ggml-org/gpt-oss-120b-GGUF:MXFP4
# keep every expert in system RAM, everything else on the GPU
$ llama serve -hf ggml-org/gpt-oss-120b-GGUF:MXFP4 --cpu-moe
# keep only the experts of the first 24 layers in RAM
$ llama serve -hf ggml-org/gpt-oss-120b-GGUF:MXFP4 --n-cpu-moe 24
:MXFP4picks the 63.4 GB file, in the 4-bit format gpt-oss was released in.--cpu-moeputs all expert weights in system RAM. The GPU keeps attention, the KV cache and the other weights that every token needs.--n-cpu-moe 24moves only the first 24 layers’ experts. Lower the number until the GPU is nearly full: more on the GPU means more speed.
A short history
- 1991: Jacobs, Jordan, Nowlan and Hinton publish “Adaptive Mixtures of Local Experts”: several small networks plus a gate that decides which one to trust.
- 2017: Google’s Shazeer and colleagues build sparse MoE layers with thousands of experts and up to 137 billion parameters, between LSTM layers.
- 2020–2021: Google’s GShard (600 billion parameters, translation) and Switch Transformer (one expert per token, a trillion parameters).
- 2023: Mistral releases Mixtral 8x7B, an open MoE model that matched or beat Llama 2 70B.
- 2024: DeepSeekMoE, DeepSeek-V2 and V3 make fine-grained, shared experts the standard design.
- 2026: trillion-parameter open models using only 3 to 4 % of their weights per token: DeepSeek-V4-Pro and Kimi K3.
Remember
- An MoE layer has many small feed-forward experts and a router that picks the top k for each token.
- Total parameters decide memory and knowledge; active parameters decide computation, speed and price.
- Routers tend to collapse onto a few experts. DeepSeek balances them with a per-expert bias instead of an extra loss.
- Fine-grained experts give far more combinations; shared experts hold what every token needs.
- Experts do not specialise by subject; their choices follow syntax and patterns.
- At home, MoE models are fast but large: llama.cpp’s
--cpu-moekeeps experts in RAM and the rest on the GPU.
Words to know
- Mixture of experts (MoE)
- A model whose feed-forward blocks are split into many experts, only a few of which run for each token.
- Expert
- One of the small feed-forward blocks inside an MoE layer.
- Router (gate)
- The small network that scores the experts and picks the top few for each token.
- Top-k routing
- Sending each token to the k experts with the highest scores.
- Dense model
- A model that uses all its weights for every token.
- Active parameters
- The weights actually used for one token. Written as “A22B” in names like 235B-A22B.
- Shared expert
- An expert that every token uses, holding common knowledge.
- Load balancing
- Keeping all experts roughly equally busy, so none is wasted or overloaded.
- Routing collapse
- When a router sends almost everything to a few experts and the rest stop learning.
- Expert parallelism
- Spreading the experts over many GPUs, with tokens sent to wherever their experts live.
Go to the source
This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.
-
Mixture of Experts Explained (Hugging Face)
The friendliest long introduction, with history, diagrams and the practical problems.
-
Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer
Where modern MoE began. The gating network in Section 2 is the router of this lesson.
-
Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity
Routing to a single expert, and the load-balancing loss everyone used afterwards.
-
Mixtral of Experts
Short. Section 5 shows that experts do not specialise by subject.
-
DeepSeekMoE: Towards Ultimate Expert Specialization in Mixture-of-Experts Language Models
Fine-grained and shared experts. Figure 2 shows the old design and both changes side by side.
-
Auxiliary-Loss-Free Load Balancing Strategy for Mixture-of-Experts
The bias trick, explained and tested in a few pages.
-
DeepSeek-V3 Technical Report
Section 2.1.2 is the complete modern MoE layer; Section 3.2 shows how the experts are spread across a cluster.
Check yourself
6 questions. Tap the answer you think is right.
0 of 6 answered
Lesson complete
Answer every question above to complete this lesson.
Your progress is saved on this device only.
Next lessonPretraining: reading a good part of the internet