# Mixture of experts (MoE)

> Canonical: https://skillalmanac.com/glossary/mixture-of-experts | Last verified: 2026-11-25 | Index status: index-eligible

In sparse transformer mixtures of experts (MoE), a learned router sends each token to a few expert sub-networks. Only selected experts compute for that token, so active parameters are fewer than total parameters.

Also called: MoE, MoE model, MoE models, mixture of experts model, mixture-of-experts.

## In plain language

A sparse transformer mixture-of-experts model is built like a large office with many specialists and a receptionist. The specialists are small sub-networks called experts, and the receptionist, called a router, decides which few of them handle each small piece of text. Because only some experts work on each piece, the model can hold a lot of learned knowledge while doing less computing per word than a dense model, one that uses all of its parts every time. The catch is the total weight size. In the resident-weight setup described by Hugging Face, all experts occupy memory even though only some compute per token. That does not mean they must all occupy GPU memory: llama.cpp documents CPU expert placement and a GPU cache. Budget storage for all weights, then check the runtime's RAM, GPU and cache placement.

## Technical definition

In the sparse mixture-of-experts transformers discussed here, some dense feed-forward layers are replaced by sparse MoE layers. Each contains several expert networks and a learned router, or gate network, that scores the experts for each token and sends the token to a small subset. Only the selected experts compute for that token, so the parameters used per token are fewer than the total. The Switch Transformer paper (Fedus, Zoph and Shazeer, arXiv 2101.03961, January 2021) describes such sparsely activated models and simplified routing to reduce communication and computation cost. The Hugging Face overview discusses resident-weight memory costs and historical fine-tuning difficulties. Load-balancing losses discourage routing collapse onto a few experts; its separate router z-loss discussion concerns numerical training stability.

## How it shows up when you use agents

Most of the time you meet MoE as a line in a model card or a vendor's description, not as a setting. Hosted services may expose it only through a model card; pricing depends on the provider and plan. It becomes your problem when you run an open-weight model yourself, for example behind a local coding agent. Only selected experts compute per token, but active parameter counts alone do not size the full weight storage or the runtime's memory placement.

What breaks when this is misunderstood: you read that only part of the model runs per token, assume a small memory need, download the model and find it does not fit or swaps to disk. The Hugging Face blog describes a resident-weight setup with all experts in memory. Runtimes with CPU placement or caching divide that cost differently. Check full weight storage and the intended memory placement before downloading, using [local-model-sizing](/skills/skill-almanac/local-model-sizing) or the guide on [self-hosting](/learn/self-hosted-ai-agent-considerations). The same blog notes that MoE models have historically struggled with overfitting during fine-tuning, so plan extra testing if you intend to adapt one.

Next action: when comparing models, record both the total size and the vendor's active-per-token figure, and check the total weight footprint plus the runtime's host/device placement. See [Self-hosted LLM](/glossary/self-hosted-llm) and [Transformer](/glossary/transformer).

## Common confusions

- **Total versus active parameters.** Total counts every expert; active counts only those used for a given token.
- **Experts versus topics.** You do not pick an expert. The router is a learned component trained together with the rest of the model (Hugging Face blog), and a token can go to more than one expert.
- **One model versus many models.** An MoE is a single model whose layers contain several experts, not several separate models you call in turn.
- **Myth.** "Fewer active parameters means a smaller download." The full model includes all expert weights, so active parameters do not determine download size. GPU residency depends on placement and caching.

## Worked examples in this catalogue

### [local-model-sizing](https://skillalmanac.com/skills/skill-almanac/local-model-sizing)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A calculation of whether an open-weight language model will run on a given GPU, Mac or PC, using a script that computes the memory the weights need.

Why it exercises the concept: The skill distinguishes total weights from active parameters and estimates memory, including partial offload. These are planning estimates; check actual expert placement and load logs in your runtime.

### [Self-Hosting an AI Agent: What You Take On](https://skillalmanac.com/learn/self-hosted-ai-agent-considerations)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A guide to what you take on when an agent runs on your machine, including matching the model to your hardware and checking that it fits.

Why it exercises the concept: Running an open-weight MoE model makes hardware planning concrete: total weights determine storage, while runtime placement determines RAM and GPU residency.

### [llm-cost-estimator](https://skillalmanac.com/skills/skill-almanac/llm-cost-estimator)

```
Give the skill a usage profile (requests per day, input and output tokens) and your own price table.
```

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A monthly cost range per model, with the effect of prompt caching and batch pricing shown as separate lines.

Why it exercises the concept: For token-priced hosted usage, the estimate uses token counts and the supplied price list. Entering a price table lets you compare models on that basis rather than on architecture claims.

## Related terms

- [Transformer](https://skillalmanac.com/glossary/transformer.md)
- [Large language model (LLM)](https://skillalmanac.com/glossary/large-language-model.md)
- [Inference](https://skillalmanac.com/glossary/inference.md)
- [Self-hosted LLM](https://skillalmanac.com/glossary/self-hosted-llm.md)
- [Neural network](https://skillalmanac.com/glossary/neural-network.md)
- [Fine-tuning](https://skillalmanac.com/glossary/fine-tuning.md)

## Sources

- [Mixture of Experts Explained](https://huggingface.co/blog/moe), Hugging Face (accessed 2026-11-23)
- [Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity](https://arxiv.org/abs/2101.03961), arXiv (Fedus, Zoph and Shazeer) (accessed 2026-11-23)
- [llama.cpp server: common parameters for MoE CPU placement and GPU caching](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/server/README.md), ggml-org/llama.cpp (accessed 2026-11-25)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
