What is Mixture of Experts?

Stephen M. Walker II · Co-Founder / CEO

What is Mixture of Experts?

Mixture of Experts (MoE) is a machine learning technique that embeds smaller “expert” networks inside a larger network. These experts are dynamically chosen for each input based on the specific task. MoE allows models to scale up accuracy and parameter counts while keeping FLOPS constant. It is a form of ensemble learning where the outputs of multiple models are combined, often leading to improved performance.

  • With the same FLOPS, MoE can achieve much better accuracy than dense models. Google's Switch Transformer paper reported a 7x speedup to reach the same accuracy.
  • MoE also outperforms larger dense models. The same paper reported a 2x speedup over a model with 3.5x more FLOPS.
  • 128 experts significantly outperforms fewer experts or no experts given the same FLOPS budget.
  • Each training example provides more benefit, so MoE helps when data is limited.

Despite being around since the 1990s, MoE became a mainstream technique for scaling large language models as scaling through wider and deeper dense networks hit diminishing returns. Companies like Google and Microsoft have worked to address MoE's challenges around complexity, training, and memory footprint. Challenges include:

  • Larger expert counts increase overall parameters, which increases memory footprint.
  • Dynamic routing leads to irregular communication patterns, which can reduce utilization.
  • Fine-tuning and transfer learning can be problematic, but workarounds exist.
  • Memory bandwidth bottlenecks limit the number of experts during inference.

How does Mixture of Experts work?

Mixture of Experts works by training multiple models on different portions of the input space. Each model becomes an "expert" on its specific portion. The outputs of these models are then combined, often using a gating network, to produce the final output.

  • Training — Multiple models are trained on different portions of the input space.
  • Combining — The outputs of the models are combined, often using a gating network, to produce the final output.

What are the applications of Mixture of Experts?

Mixture of Experts can be used in a wide range of machine learning tasks. These include regression, classification, and more complex tasks like image recognition and natural language processing.

  • Regression — Mixture of Experts can be used for regression tasks, where the goal is to predict a continuous output variable.
  • Classification — Mixture of Experts can be used for classification tasks, where the goal is to predict a categorical output variable.
  • Image recognition — Mixture of Experts can be used for image recognition tasks, where the goal is to identify objects or features in images.
  • Natural language processing — Mixture of Experts can be used for natural language processing tasks, where the goal is to understand and generate human language.

How is Mixture of Experts impacting AI?

Mixture of Experts is significantly impacting AI by enabling the development of more robust and accurate models. By combining the outputs of multiple models, Mixture of Experts often achieves better performance than any single model could. However, as with any machine learning technique, it is important to use Mixture of Experts responsibly to avoid issues around bias and transparency.

  • Improved performance — Mixture of Experts often achieves better performance than any single model could.
  • Robust models — By combining the outputs of multiple models, Mixture of Experts can create more robust models that are less likely to overfit to the training data.
  • Responsible use — As with any machine learning technique, it is important to use Mixture of Experts responsibly to avoid issues around bias and transparency.

Mixture of Experts in Large Language Models

Google's 1.2 trillion parameter MoE model GLaM matched GPT-3 accuracy with 1/3 the energy and half the FLOPS, demonstrating MoE's efficiency benefits at scale. OpenAI has not disclosed GPT-4's architecture, but unverified reports from 2023 claimed it uses a Mixture of Experts design with 16 experts, of which 2 are selected per token. OpenAI has never confirmed these details, so they should be treated as speculation rather than fact.

MoE architectures like this generally introduce routing-related challenges during inference:

  • Variable batch size — Because different experts are chosen per token, the batch size varies unpredictably for each expert. This leads to inconsistent latency and lower utilization.

  • Communication overhead — Routing inputs to different experts requires additional communication between GPUs/nodes, increasing overhead.

  • Memory bandwidth — More experts means memory bandwidth is a constraint, limiting the total number of experts.

Common optimizations include:

  • Pruning underutilized experts to maximize throughput.

  • Careful expert placement to minimize communication between nodes.

  • Low-bandwidth routing algorithms like Top-2 gating to reduce memory traffic.

MoE lets large language models scale up size and specialization, at the cost of routing challenges that must be addressed by inference optimization techniques.

More terms

Continue exploring the glossary.

Learn how teams define, measure, and improve LLM systems.

Glossary term

What is fluent AI?

Fluent AI describes systems that understand and generate natural language smoothly and coherently, without the stilted or error-prone output of earlier rule-based systems.
Read term

Glossary term

MATH Benchmark

The MATH Benchmark is an LLM evaluation dataset of 12,500 competition mathematics problems, split into 7,500 training and 5,000 test problems, that measures text models' mathematical problem-solving accuracy in zero-shot and few-shot settings to evaluate their mathematical reasoning, problem-solving skills, and limitations.
Read term

It's time to build

Collaborate with your team on reliable Generative AI features.
Want expert guidance? Book a 1:1 onboarding session from your dashboard.

Talk to sales