Magician-MoE-2x7B is a Mixure of Experts (MoE) made with the following models using
LazyMergekit:
1base_model: ise-uiuc/Magicoder-S-CL-7B
2gate_mode: cheap_embed
3experts:
4 - source_model: ise-uiuc/Magicoder-S-CL-7B
5 positive_prompts: ["You are an AI programmer","programming","C++ expert"]
6 - source_model: WizardLM/WizardCoder-Python-7B-V1.0
7 positive_prompts: ["Great at Deep learning","Algorithm and Data Structure","Python expert"]
1!pip install -qU transformers bitsandbytes accelerate
2
3from transformers import AutoTokenizer
4import transformers
5import torch
6
7model = "FelixChao/Magician-MoE-2x7B"
8
9tokenizer = AutoTokenizer.from_pretrained(model)
10pipeline = transformers.pipeline(
11 "text-generation",
12 model=model,
13 model_kwargs={"torch_dtype": torch.float16, "load_in_4bit": True},
14)
15
16messages = [{"role": "user", "content": "Explain what a Mixture of Experts is in less than 100 words."}]
17prompt = pipeline.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
18outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
19print(outputs[0]["generated_text"])