NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Flexible and Effective Mixing of Large Language Models into a Mixture of Domain Experts

Rhui Dih Lee, Laura Wynter, Raghu Kiran GantiarXiv 2024 · DOI

Abstract

Mixture-of-Experts (MoE) architectures provide high model capacity with efficient inference, but training them from scratch is computationally expensive. We present a toolkit and methodology for "moetifying" existing specialized Large Language Models (LLMs) by hot-swapping feed-forward network (FFN) layers. We explore "Gate-less" and "Noisy" routing strategies that require little to no training. Our results show that these modular compositions can match or exceed the performance of traditionally trained models across various benchmarks, including general reasoning and domain-specific tasks like mathematics.

Introduction

Mixture-of-Experts (MoE) architectures, such as Mixtral, have gained prominence for their ability to offer high parameter counts while maintaining lower inference costs by activating only a subset of parameters per token. However, the standard approach of training MoEs from scratch is prohibitively expensive for most organizations. Furthermore, the "experts" in these models are often emergent and lack clear domain-specific interpretability.

This work addresses the challenge of modular model composition: combining high-quality, pre-existing specialized models into a single MoE framework without the need for massive compute budgets.

Methodology: The MoDE Approach

The proposed methodology, implemented in the moetify toolkit, focuses on creating a "Mixture-of-Domain-Experts" (MoDE). The core idea is to preserve the "skeleton" of a base model—specifically its attention layers and embeddings—while replacing the Feed-Forward Network (FFN) layers with those from specialized expert models sharing the same architecture.

The transformation of a standard FFN layer into a Mixture-of-Experts structure using a router.

The researchers explored three primary routing strategies:

  1. Gate-less MoE: A "committee" approach where every expert is assigned equal weight for every token. This requires zero training and avoids the risk of catastrophic forgetting.
  2. Noisy MoE: A sparse routing strategy designed for inference efficiency. It utilizes a fixed linear layer initialized with white noise and a Top-$K$ selection mechanism to activate only a subset of experts.
  3. Router Training: For scenarios where task-specific data is available, the toolkit supports training a small gating layer via instruction tuning to optimize expert selection.

Experimental Setup

The effectiveness of these strategies was evaluated across a diverse set of benchmarks:

  • General Reasoning: MMLU, MMLU-pro, ARC-Challenge, and the GPT4ALL suite.
  • Mathematics: GSM8K (5-shot and Chain-of-Thought) and MathQA.
  • Specialized Domains: Finance (ConvFinQA) and Medical (PubMedQA).

The experiments primarily utilized IBM’s Merlinite as a base model, mixing it with experts like MetaMath.

Results and Discussion

The results demonstrate that modular composition is a highly effective and low-cost alternative to traditional training.

Performance comparison of various MoE configurations (Gate-less, Noisy, and Tuned) against base models across multiple benchmarks.

Performance Gains

As shown in the performance benchmarks, the MoE variants consistently outperformed the base models. Notably, a 2x MoE combining Merlinite with a MetaMath expert significantly improved math scores (GSM8K) while preserving general reasoning capabilities. The "Gate-less" approach proved surprisingly robust for small numbers of experts, often outperforming the base model without any additional training.

Inference Efficiency

The "Noisy MoE" strategy successfully introduced sparsity without significant performance degradation. In a 6-expert configuration, the Noisy MoE (Top-2) achieved an inference time of 1.203s, whereas the Gate-less version (activating all 6 experts) required 2.694s.

Conclusion

The moetify toolkit provides a flexible recipe for building domain-specific LLMs at a fraction of the usual cost. While VRAM remains a primary bottleneck for scaling the number of experts, the ability to "hot-swap" FFNs and use simple routing strategies like Noisy MoE opens new avenues for modular AI development.

Summary updated

BibTeX
@misc{lee2024flexible,
  author = {Rhui Dih Lee and Laura Wynter and Raghu Kiran Ganti},
  title = {{Flexible and Effective Mixing of Large Language Models into a Mixture of Domain Experts}},
  year = {2024},
  eprint = {2408.17280},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.17280},
}
Figure