Skip to content
المشاريع

حول

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

الذكاء الاصطناعي وتعلّم الآلة

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
٠
خلال 15 يومًا
+١
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

MixtureKit logo

MixtureKit

Turn the fine-tuned models you already have into one Mixture-of-Experts model.
Merge Hugging Face checkpoints, train the routers, see which expert every token uses.

PyPI Tests Docs ACL 2026 Demo arXiv License: BSD-3-Clause Open In Colab

You have a base model and a few fine-tunes of it: one for math, one for code, one for a language. MixtureKit composes them into a single Mixture-of-Experts model whose routers learn, token by token, which expert to use, and shows you what they learned.

pip install "mixturekit[vis]"

mixturekit build examples/configs/traditional_qwen3.yaml   # merge the experts -> models_merge/qwen3moe2x
mixturekit train my_training.yaml                          # train the routers -> e.g. qwen3moe2x-trained
mixturekit visualize qwen3moe2x-trained                    # see which expert every token uses
mixturekit push qwen3moe2x-trained my-org/my-moe           # share it, with a model card

my_training.yaml starts from mixture_training/config_training.yaml (model_id: models_merge/qwen3moe2x, your dataset and output_dir). Merging runs on a laptop; training the routers wants a GPU.

Token routing of a two-expert MoE of Nile 4B models: Latin-script (Arabizi) Egyptian tokens go to one expert, Arabic-script tokens to the other

Try it in 15 minutes on a free GPU: the Colab notebook merges two Qwen3-0.6B models, trains the routers and shows the routing. The tutorial walks through it step by step.

Why MixtureKit

  • Three composition methods behind one config: Branch-Train-MiX (BTX), Mixtral-style MoE and Branch-Train-Stitch (BTS).
  • Merges on a laptop: the experts are read and the merged model written tensor by tensor, so a merge needs memory for a few tensors at a time, not for the experts.
  • Plain transformers models: the result loads with AutoModelForCausalLM.from_pretrained(path, trust_remote_code=True), without MixtureKit, and is tested on transformers 4.52 to 5.19.
  • Router training included: mixturekit train trains the routers (or the BTS stitch layers) with a load balancing loss, optionally with LoRA on the experts, on one GPU or many.
  • Routing visualizer: an app, a shareable HTML page or an inline notebook view of which expert every token uses, layer by layer.
  • Benchmarks: mixturekit benchmark scores the merged model next to its experts with lm-evaluation-harness and writes the table.
  • Hub ready: mixturekit push uploads the model with a generated model card.
  • Runs everywhere: mixturekit export turns a traditional MoE of Llama, Mistral or Qwen3 experts into a native Mixtral or Qwen3-MoE model, ready for GGUF and llama.cpp, vLLM or MLX.

Tested with Llama 3, Qwen 2.5, Qwen 3, Qwen 3.5, Gemma 3 and Gemma 4 experts (multimodal checkpoints are merged through their language model).

Which method?

BTX Traditional BTS
Kept per expert the projections you choose the feed-forward block the whole model
Shared everything else, averaged everything else, averaged nothing: experts run next to a hub
Trained a router per routed projection a router per layer stitch layers
Compute per token top-k routed projections top-k feed-forward blocks all the experts

Start with traditional for fine-tunes of one base model. More in the guide.

A merge, in YAML or Python

moe_method: traditional          # btx, traditional or bts
model_type: qwen3moe2x           # the name of the merged model and of its folder
num_experts_per_tok: 2
experts:
  - {expert_name: base, model_id: Qwen/Qwen3-0.6B-Base}
  - {expert_name: chat, model_id: Qwen/Qwen3-0.6B}
alpha: 0.01                      # load balancing weight
import torch
from MixtureKit import build_moe

config = {
    "moe_method": "traditional",
    "model_type": "qwen3moe2x",
    "experts": [
        {"expert_name": "base", "model_id": "Qwen/Qwen3-0.6B-Base"},
        {"expert_name": "chat", "model_id": "Qwen/Qwen3-0.6B"},
    ],
    "alpha": 0.01,
}
path = build_moe(config, torch_dtype=torch.bfloat16)   # models_merge/qwen3moe2x

More configurations: examples/configs/. All the keys: Configuration.

Documentation

mbzuai-paris.github.io/MixtureKit: quickstart · methods · command line · training · visualizer · export and GGUF · benchmarks · upgrading older models and limitations · API

Development

git clone https://github.com/MBZUAI-Paris/MixtureKit && cd MixtureKit
pip install -e ".[test]"
pytest                                # CPU, tiny models, no download
pip install -e ".[doc]" && sphinx-build docs docs/_build/html

Requirements: Python 3.10 or later, PyTorch 2.5 or later, transformers 4.52 to 5.x. Issues and pull requests are welcome: see CONTRIBUTING.md.

Citation

MixtureKit was published at ACL 2026 (System Demonstrations). If it is useful in your work, please cite the paper:

@inproceedings{chamma-etal-2026-mixturekit,
  title = "{M}ixture{K}it: A General Framework for Composing, Training, and Visualizing Mixture-of-Experts Models",
  author = "Chamma, Ahmad and El Herraoui, Omar and Shang, Guokan",
  booktitle = "Proceedings of the 64th Annual Meeting of the {A}ssociation for {C}omputational {L}inguistics (Volume 3: System Demonstrations)",
  month = jul,
  year = "2026",
  address = "San Diego, California, United States",
  publisher = "Association for Computational Linguistics",
  url = "https://aclanthology.org/2026.acl-demo.15/",
  doi = "10.18653/v1/2026.acl-demo.15",
  pages = "148--156"
}

Acknowledgements and license

MixtureKit builds on Branch-Train-MiX and Branch-Train-Stitch. It is released under the BSD 3-Clause License.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…