Text Generation
Transformers
Safetensors
English
phi-msft
Mixture of Experts
nlp
code
cognitivecomputations/dolphin-2_6-phi-2
lxuechen/phi-2-dpo
conversational
custom_code
Instructions to use mlabonne/phixtral-2x2_8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlabonne/phixtral-2x2_8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlabonne/phixtral-2x2_8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("mlabonne/phixtral-2x2_8", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use mlabonne/phixtral-2x2_8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlabonne/phixtral-2x2_8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlabonne/phixtral-2x2_8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlabonne/phixtral-2x2_8
- SGLang
How to use mlabonne/phixtral-2x2_8 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 "mlabonne/phixtral-2x2_8" \ --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": "mlabonne/phixtral-2x2_8", "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 "mlabonne/phixtral-2x2_8" \ --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": "mlabonne/phixtral-2x2_8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mlabonne/phixtral-2x2_8 with Docker Model Runner:
docker model run hf.co/mlabonne/phixtral-2x2_8
Update configuration_phi.py
Browse files- configuration_phi.py +4 -0
configuration_phi.py
CHANGED
|
@@ -27,6 +27,8 @@ class PhiConfig(PretrainedConfig):
|
|
| 27 |
n_inner: Optional[int] = None,
|
| 28 |
n_head: int = 16,
|
| 29 |
n_head_kv: Optional[int] = None,
|
|
|
|
|
|
|
| 30 |
rotary_dim: Optional[int] = 32,
|
| 31 |
activation_function: Optional[str] = "gelu_new",
|
| 32 |
flash_attn: bool = False,
|
|
@@ -48,6 +50,8 @@ class PhiConfig(PretrainedConfig):
|
|
| 48 |
self.n_inner = n_inner
|
| 49 |
self.n_head = n_head
|
| 50 |
self.n_head_kv = n_head_kv
|
|
|
|
|
|
|
| 51 |
self.rotary_dim = min(rotary_dim, n_embd // n_head)
|
| 52 |
self.activation_function = activation_function
|
| 53 |
self.flash_attn = flash_attn
|
|
|
|
| 27 |
n_inner: Optional[int] = None,
|
| 28 |
n_head: int = 16,
|
| 29 |
n_head_kv: Optional[int] = None,
|
| 30 |
+
num_experts_per_tok: int = 2,
|
| 31 |
+
num_local_experts: int = 4,
|
| 32 |
rotary_dim: Optional[int] = 32,
|
| 33 |
activation_function: Optional[str] = "gelu_new",
|
| 34 |
flash_attn: bool = False,
|
|
|
|
| 50 |
self.n_inner = n_inner
|
| 51 |
self.n_head = n_head
|
| 52 |
self.n_head_kv = n_head_kv
|
| 53 |
+
self.num_experts_per_tok = num_experts_per_tok
|
| 54 |
+
self.num_local_experts = num_local_experts
|
| 55 |
self.rotary_dim = min(rotary_dim, n_embd // n_head)
|
| 56 |
self.activation_function = activation_function
|
| 57 |
self.flash_attn = flash_attn
|