mixture-of-experts

Implements sparse Mixture of Experts routing for language models.

1|Updated Jun 4, 2026
One-click install
npx skills add https://github.com/hung-phan/ml-skills --skill mixture-of-experts-hung-phan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mixture-of-experts
Source: https://github.com/hung-phan/ml-skills/tree/main/skills/ml-review/references/ml-architectures/mixture-of-experts
Command: npx skills add https://github.com/hung-phan/ml-skills --skill mixture-of-experts-hung-phan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, and includes scripts (resource) components.

What problem does it solve?

Mixture of Experts (MoE) addresses the challenge of scaling dense models while maintaining constant per-token compute, reducing inference cost for larger models.

Core Features & Use Cases

  • Sparse Routing: Divides the input into N expert subnetworks and routes to K active experts for each token.
  • Capacity Scaling: Increases model capacity with fewer parameters, without proportional inference cost.
  • Load Balancing: Distributes tokens across experts to avoid overloading and improve training stability.
  • Use Case: Use MoE for tasks requiring high capacity, multi-domain expertise, and efficient compute scaling, like large language models or complex sequence modeling.

Quick Start

Execute the moe-train script with the following command: moe-train -m your_model -e experts -k experts_active

Frequently Asked Questions about mixture-of-experts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does sparse routing in mixture of experts reduce inference cost for large language models?

Sparse routing in mixture of experts reduces inference cost by dividing inputs into N expert subnetworks and routing tokens to only K active experts, increasing model capacity without proportional per-token compute overhead.

How do I train a model with mixture of experts using torch?

Train a model with mixture of experts by running the moe-train script via torch, specifying the model, expert count, and active experts using the command: moe-train -m your_model -e experts -k experts_active.

Why is auxiliary load balancing important when scaling model capacity with MoE?

Auxiliary load balancing is important when scaling model capacity with MoE because it distributes tokens across experts to avoid overloading, ensuring training stability and efficient sparse activation.

Does this mixture of experts implementation work with any sequence modeling architecture in torch?

This mixture of experts implementation targets large language models and complex sequence modeling architectures in torch, requiring an understanding of MoE architecture and routing techniques.

What's the best way to scale model capacity without increasing per-token computation?

The best way to scale model capacity without increasing per-token computation is using mixture of experts, which enables sparse activation of experts to maintain constant compute while expanding model parameters.

When should I avoid using sparse activation for model scaling?

You should avoid using sparse activation for model scaling if your task does not require multi-domain expertise or high capacity, as MoE introduces routing complexity and requires auxiliary load balancing for training stability.