Instructions to use paulilioaica/MixtureOfPhi3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use paulilioaica/MixtureOfPhi3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="paulilioaica/MixtureOfPhi3", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("paulilioaica/MixtureOfPhi3", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("paulilioaica/MixtureOfPhi3", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use paulilioaica/MixtureOfPhi3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "paulilioaica/MixtureOfPhi3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paulilioaica/MixtureOfPhi3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/paulilioaica/MixtureOfPhi3
- SGLang
How to use paulilioaica/MixtureOfPhi3 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "paulilioaica/MixtureOfPhi3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paulilioaica/MixtureOfPhi3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "paulilioaica/MixtureOfPhi3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paulilioaica/MixtureOfPhi3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use paulilioaica/MixtureOfPhi3 with Docker Model Runner:
docker model run hf.co/paulilioaica/MixtureOfPhi3
MixtureOfPhi3
MixtureOfPhi3 is a Mixure of Experts (MoE) made with the following models using mergekit:
This has been created using LazyMergekit-Phi3
This run is only for development purposes, since merging 2 identical models does not bring any performance benefits, but once specialized finetunes of Phi3 models will be available, it will be a starting point for creating MoE from them.
©️ Credits
- mlabonne's phixtral where I adapted the inference code to Phi3's architecture.
- mergekit code which I tweaked to merge Phi3s
These have been merged using cheap_embed where each model is assigned a vector representation of words - such as experts for scientific work, reasoning, math etc.
Try your own in the link above !
🧩 Configuration
base_model: microsoft/Phi-3-mini-128k-instruct
gate_mode: cheap_embed
dtype: float16
experts:
- source_model: microsoft/Phi-3-mini-128k-instruct
positive_prompts: ["research, logic, math, science"]
- source_model: microsoft/Phi-3-mini-128k-instruct
positive_prompts: ["creative, art"]
💻 Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model = "paulilioaica/MixtureOfPhi3"
tokenizer = AutoTokenizer.from_pretrained(model)
model = AutoModelForCausalLM.from_pretrained(
model,
trust_remote_code=True,
)
prompt="How many continents are there?"
input = f"<|system|>\nYou are a helpful AI assistant.<|end|>\n<|user|>{prompt}\n<|assistant|>"
tokenized_input = tokenizer.encode(input, return_tensors="pt")
outputs = model.generate(tokenized_input, max_new_tokens=128, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
print(tokenizer.decode(outputs[0]))
- Downloads last month
- 151
Model tree for paulilioaica/MixtureOfPhi3
Base model
microsoft/Phi-3-mini-128k-instruct