Phi-4 GGUF
Collection
llama.cpp GGUF quantizations of Phi-4. • 1 item • Updated
How to use Xylolabs/phi-4-GGUF with llama.cpp:
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Xylolabs/phi-4-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf Xylolabs/phi-4-GGUF:Q4_K_M
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Xylolabs/phi-4-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf Xylolabs/phi-4-GGUF:Q4_K_M
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf Xylolabs/phi-4-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf Xylolabs/phi-4-GGUF:Q4_K_M
docker model run hf.co/Xylolabs/phi-4-GGUF:Q4_K_M
How to use Xylolabs/phi-4-GGUF with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Xylolabs/phi-4-GGUF"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Xylolabs/phi-4-GGUF",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Xylolabs/phi-4-GGUF:Q4_K_M
How to use Xylolabs/phi-4-GGUF with Ollama:
ollama run hf.co/Xylolabs/phi-4-GGUF:Q4_K_M
How to use Xylolabs/phi-4-GGUF with Docker Model Runner:
docker model run hf.co/Xylolabs/phi-4-GGUF:Q4_K_M
How to use Xylolabs/phi-4-GGUF with Lemonade:
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Xylolabs/phi-4-GGUF:Q4_K_M
lemonade run user.phi-4-GGUF-Q4_K_M
lemonade list
GGUF quants of microsoft/phi-4 for llama.cpp, on CUDA, Metal or CPU.
| File | Size |
|---|---|
phi-4-Q5_K_M.gguf |
10.500 GB |
phi-4-Q4_K_M.gguf |
9.059 GB |
phi-4-IQ4_XS.gguf |
8.259 GB |
phi-4-IQ4_XS-imat.gguf |
8.187 GB |
Use llama.cpp cd959bae99ff4bed22bef2604f45241c09bbb8c8 or newer.
git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp
git checkout cd959bae99ff4bed22bef2604f45241c09bbb8c8
cmake -B build -DCMAKE_BUILD_TYPE=Release # add -DGGML_CUDA=ON for NVIDIA GPUs
cmake --build build -j --target llama-cli llama-server
./build/bin/llama-cli -m phi-4-Q5_K_M.gguf --jinja -c 8192 -ngl 99
llama-server takes the same flags.
Against BF16.
| Quant | Size | WikiText-2 KL | top-1 | Held-out KL | top-1 |
|---|---|---|---|---|---|
| Unsloth Q8_0 | 15.581 GB | 0.000465 | 98.706% | 0.000259 | 99.294% |
| llama.cpp Q8_0 | 15.580 GB | 0.000460 | 98.824% | 0.000265 | 99.304% |
| Unsloth Q6_K | 12.030 GB | 0.002103 | 97.583% | 0.001274 | 98.422% |
| llama.cpp Q6_K | 12.030 GB | 0.002112 | 97.520% | 0.001251 | 98.392% |
| Q5_K_M | 10.500 GB | 0.005030 | 96.270% | 0.003265 | 97.118% |
| Unsloth Q5_K_M | 10.413 GB | 0.005218 | 96.260% | 0.003347 | 97.137% |
| Q4_K_M | 9.059 GB | 0.016550 | 94.039% | 0.012006 | 94.725% |
| Unsloth Q4_K_M | 8.890 GB | 0.017342 | 93.824% | 0.012320 | 94.745% |
| IQ4_XS | 8.259 GB | 0.018695 | 93.539% | 0.013586 | 94.412% |
| IQ4_XS-imat | 8.187 GB | 0.017889 | 93.598% | 0.012414 | 94.471% |
| llama.cpp Q3_K_M | 7.373 GB | 0.051110 | 89.721% | 0.035958 | 91.500% |
| Unsloth Q3_K_M | 7.191 GB | 0.057706 | 89.059% | 0.039513 | 90.676% |
| Unsloth Q2_K_L | 5.729 GB | 0.224612 | 79.206% | 0.166215 | 81.804% |
| Unsloth Q2_K | 5.609 GB | 0.227470 | 79.216% | 0.171434 | 81.500% |
| Hardware | Memory | File | Context |
|---|---|---|---|
| RTX 4090 / RTX 3090 | 24 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| RTX 5090 | 32 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| RTX 6000 Ada, or 2 x 24 GB | 48 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| One H100 | 80 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| RTX PRO 6000 Blackwell (GDDR7) | 96 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| DGX Spark | 128 GB unified | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| Mac Studio M5 Max | 128 GB unified | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| One H200 (HBM3e) | 141 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| One B200 | 192 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| Mac Studio M5 Ultra | 256 GB unified | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| Mac Studio M5 Ultra | 512 GB unified | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
| One B300 (HBM3e) | 288 GB | phi-4-Q5_K_M.gguf (10.5 GB) |
16K |
MIT License, copied in LICENSE. We converted the weights to GGUF and quantized them.
Cite the original Microsoft Phi-4 release.
phi-4-IQ4_XS-imat.gguf, phi-4-IQ4_XS.gguf, phi-4-Q4_K_M.gguf, phi-4-Q5_K_M.gguf.4-bit
5-bit
Base model
microsoft/phi-4