MixtureKit: A General Framework for Composing, Training, and Visualizing Mixture-of-Experts Models

Ahmad Chamma, Omar El Herraoui, Guokan Shang · DOI

Introduction

Training Large Language Models (LLMs) from scratch is an increasingly resource-intensive endeavor. While Mixture-of-Experts (MoE) architectures offer a pathway to scale model capacity without a linear increase in inference costs, the standard practice remains training them from the ground up. This approach often ignores the wealth of high-quality, pre-trained dense models that are frequently surpassed and left unused. MixtureKit addresses this inefficiency by providing an open-source framework that allows researchers to "recycle" existing models into powerful MoE architectures.

Methodology and Architecture

MixtureKit introduces a modular, model-agnostic pipeline designed to lower the barrier to creating specialized models. It supports three primary MoE construction strategies:

  1. Traditional MoE: This approach uses a single router per transformer block to select the most relevant experts for a given token.
  2. Branch-Train-Mix (BTX): A more granular strategy that introduces separate routers for individual sub-layers, such as the gate, up, and down projections within a Feed-Forward Network (FFN). This enables fine-grained token routing, which is particularly effective for complex tasks like code-switching.
  3. Branch-Train-Stitch (BTS): A "plug-in" style method where experts remain fully intact and frozen. Instead of merging weights, it introduces small, trainable "stitch layers" to facilitate information exchange between a central "hub" model and specialized experts.
Architectural strategies supported by MixtureKit: Traditional MoE, BTX, and BTS.

The framework's flexibility stems from its use of regex pattern matching to identify submodules, allowing it to patch almost any transformer-based architecture without requiring hand-crafted configuration files for every new model family. To ensure stability during training, the framework also implements load-balancing losses to prevent the common MoE pitfall of expert collapse.

Case Study: Specializing for Egyptian Arabic

To demonstrate the framework's utility, the authors tackled the challenge of Egyptian Arabic (Masri), a dialect often written in both traditional Arabic script and the Latin-based Arabizi. Using Gemma3-4B-pt as a base, separate experts were continually pre-trained on Arabic-script and Latin-script datasets.

The resulting model, Nile-Chat-3x4B-A6B (a 3-expert MoE with 6B active parameters), was fine-tuned using WildChat-1M alongside specialized data to ensure it retained general instruction-following capabilities while mastering its new domains.

Key Results and Interpretability

The BTX-based MoE significantly outperformed the 4B dense baseline across all benchmarks. Notably, in Arabic script tasks, the 6B active-parameter MoE achieved a score of 55.74, approaching the performance of a much larger 12B dense model (60.0) while remaining significantly more efficient to run. The model also achieved top-tier results in translation and transliteration tasks, proving that specialized experts can be harmonized without degrading general performance.

Beyond raw metrics, MixtureKit emphasizes interpretability through a Streamlit-based visualizer. This tool allows researchers to observe how the model routes specific tokens, turning the "black box" of MoE into a transparent system. For example, the visualizer confirmed that the model correctly routes Arabizi tokens to Latin experts and traditional script to Arabic experts, providing a crucial diagnostic tool for model development.

Limitations and Future Work

While MixtureKit is model-agnostic, its reliance on regex for architecture patching can be brittle if model configurations change drastically. Future work aims to integrate optimized kernels from engines like vLLM for faster deployment and to explore cross-architecture merging, enabling the composition of MoEs using experts from entirely different model families (e.g., mixing Llama and Mistral experts).

Summary updated

BibTeX
@misc{chamma2025mixturekit,
  author = {Ahmad Chamma and Omar El Herraoui and Guokan Shang},
  title = {{MixtureKit: A General Framework for Composing, Training, and Visualizing Mixture-of-Experts Models}},
  year = {2025},
  eprint = {2512.12121},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.12121},
}
Figure