Text Generation
Transformers
Safetensors
phi-msft
Mixture of Experts
frankenmoe
Merge
mergekit
lazymergekit
cognitivecomputations/dolphin-2_6-phi-2
rhysjones/phi-2-orange
custom_code
Instructions to use paulilioaica/PhiMiX-2x2B-raw with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use paulilioaica/PhiMiX-2x2B-raw with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="paulilioaica/PhiMiX-2x2B-raw", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("paulilioaica/PhiMiX-2x2B-raw", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use paulilioaica/PhiMiX-2x2B-raw with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "paulilioaica/PhiMiX-2x2B-raw" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paulilioaica/PhiMiX-2x2B-raw", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/paulilioaica/PhiMiX-2x2B-raw
- SGLang
How to use paulilioaica/PhiMiX-2x2B-raw 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/PhiMiX-2x2B-raw" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paulilioaica/PhiMiX-2x2B-raw", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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/PhiMiX-2x2B-raw" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paulilioaica/PhiMiX-2x2B-raw", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use paulilioaica/PhiMiX-2x2B-raw with Docker Model Runner:
docker model run hf.co/paulilioaica/PhiMiX-2x2B-raw
PhiMiX-2x2B-raw
Code is work in progress
This is a RAW MoE meant to be finetuned
PhiMiX-2x2B is a Mixure of Experts (MoE) made with the following models using mergekit:
©️ Credits
- mlabonne's phixtral for the PhiConfig and inference code.
- mergekit code which I tweaked (you can find the PhiConfig here)
by mainly adding the config in the
moe_mixtral.pyscript frommixtralbranch.
🧩 Configuration
base_model: rhysjones/phi-2-orange
gate_mode: random
dtype: float16
experts:
- source_model: cognitivecomputations/dolphin-2_6-phi-2
positive_prompts: [""]
- source_model: rhysjones/phi-2-orange
positive_prompts: [""]
💻 Usage
!pip install -qU transformers bitsandbytes accelerate
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "paulilioaica/PhiMiX-2x2B-raw"
torch.set_default_device("cuda")
config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_config(config, trust_remote_code=True)
instruction = '''
def print_prime(n):
"""
Print all primes between 1 and n
"""
'''
tokenizer = AutoTokenizer.from_pretrained(
f"{model_name}",
trust_remote_code=True
)
# Tokenize the input string
inputs = tokenizer(
instruction,
return_tensors="pt",
return_attention_mask=False
)
# Generate text using the model
outputs = model.generate(**inputs, max_length=200)
# Decode and print the output
text = tokenizer.batch_decode(outputs)[0]
print(text)
- Downloads last month
- 8