What is mixture of experts (MoE)?
Mixture of experts (MoE) swaps a transformer's feed-forward layer for many experts and a router that picks a few per token, so active parameters are fewer than total.
Mixture of experts (MoE) is a transformer design in which the dense feed-forward layer is replaced by several parallel networks called experts, plus a router that sends each token to a few of them. Hugging Face describes sparse MoE layers as used “instead of dense feed-forward network (FFN) layers.” The result is a model with a large total parameter count that uses only a fraction of it for each token.
The idea
Noam Shazeer and colleagues introduced the sparsely-gated MoE layer in 2017. It had up to thousands of feed-forward sub-networks and a trainable gating network that picks a sparse combination of them for each input. They reported more than a 1000x gain in model capacity with only minor losses in computational efficiency.
In a modern LLM the pieces are:
- Experts. Usually ordinary feed-forward networks. Hugging Face notes that only the feed-forward layers are experts; attention and other layers are shared.
- Router. A small learned network that scores the experts for each token and picks the top few. Its parameters are trained together with the rest of the model.
- Combination. NVIDIA’s glossary adds that the chosen experts’ outputs are fused, often weighted by the router’s confidence.
The routing repeats at every MoE layer. The Mixtral paper says its router selects 2 of 8 experts per token at each layer, and the chosen pair can differ from one token to the next.
Total versus active parameters
This is the number to read on a model card. Total parameters set the memory you need. Active parameters set the compute per token.
| Model | Experts and routing | Total parameters | Active per token | Source |
|---|---|---|---|---|
| Mixtral 8x7B | 8 experts per layer, top 2 | about 47B | about 13B | Mixtral paper |
| DeepSeek-V3 | DeepSeekMoE | 671B | 37B | DeepSeek-V3 report |
| ST-MoE-32B | sparse encoder-decoder | 269B | compute comparable to a 32B dense model | ST-MoE paper |
The “8x7B” name misleads. Hugging Face explains that Mixtral’s memory needs are comparable to a dense 47B model, not 56B, because the non-expert layers are shared. With two experts per token its inference compute is about that of a 12B dense model.
What you gain
Hugging Face reports that MoEs pretrain much faster than dense models of comparable quality and, at inference, run faster than a dense model with the same total parameters. The Switch Transformers authors reported up to 7x faster pre-training than T5 baselines at the same compute, and a trillion-parameter model 4x faster than T5-XXL. The Mixtral authors report that it matches or beats Llama 2 70B and GPT-3.5 on the benchmarks they ran while using about 13B parameters per token.
For someone calling a hosted model, the effect shows up as speed and price per token, which depend on the provider’s choices and not only on the architecture. See LLM inference and LLM cost optimization.
What it costs
- Memory. Hugging Face states that all experts must be loaded, so VRAM needs are high. NVIDIA’s glossary says a dense model generally beats an MoE of the same total size, at more compute per token. The KV cache is a separate memory cost on top of the weights.
- Uneven expert use. Without intervention the router favors a few experts. Hugging Face describes an auxiliary loss that pushes toward equal training examples per expert, and a capacity limit per expert: tokens over it overflow to the residual connection or are dropped. DeepSeek-V3’s authors describe an auxiliary-loss-free balancing strategy instead.
- Training stability. The ST-MoE authors say progress was hindered by training instabilities and uncertain quality during fine-tuning.
- Fine-tuning. Hugging Face says MoEs have historically overfit during fine-tuning, though instruction tuning appears to help them more than dense models.
- Communication. NVIDIA notes that when experts span several GPUs, sending tokens to them and gathering the results strains memory bandwidth. Hugging Face adds that sparse models suit high-throughput setups with many machines, and dense models suit low throughput with limited VRAM.
MoE, model routing and ensembles
MoE routing is internal: a learned layer picks experts per token, inside one set of weights, and you cannot choose the experts. Model routing is something you build or buy: it sends a whole request to one of several models. An MoE is also not an ensemble of separate models whose answers are averaged; the experts sit inside each layer and share the attention layers.
Choosing and testing an MoE model
Read the model card for both counts. Total parameters tell you the hardware to self-host an open-weight model such as Kimi K3.1 Pro or Tencent Hy4; active parameters hint at speed. Alibaba’s Qwen4-Max, with 2.4T total and 71B active parameters, shows how wide the gap can be. They do not tell you quality on your task, so run your own evaluation on your data before switching from a dense model, and compare latency and cost per call as well as accuracy.
With tracing you can log the model name, token counts and latency on each call. HoneyHive’s tracing concepts describe events that store model inputs, outputs and metadata such as token counts and cost, which lets you compare a dense and an MoE model on the same traffic.
FAQ
What is mixture of experts in an LLM?
A transformer design where the feed-forward layer is replaced by several expert networks and a router. Hugging Face explains that the router decides which tokens go to which experts, so only some of the model's parameters run for each token.
What is the difference between total and active parameters?
Total parameters are all the weights that must be stored. Active parameters are the ones used for one token. The Mixtral paper reports about 47B total and about 13B active, and the DeepSeek-V3 report gives 671B total and 37B activated.
Is an MoE model cheaper to run than a dense model?
Per token of compute, yes. For memory, no. Hugging Face notes that all experts must be loaded, so VRAM needs match the total size, not the active size.
Do experts specialize in topics like math or law?
Not as a rule you can rely on. NVIDIA's glossary says experts become more specialized in areas where they perform best, but the router learns its assignments during training, not from labels you set.
Is mixture of experts the same as model routing?
No. MoE routing happens inside one model, per token and per layer. Model routing chooses between whole models for each request.