Instructions to use microsoft/phi-4-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/phi-4-gguf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/phi-4-gguf") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("microsoft/phi-4-gguf", dtype="auto") - llama-cpp-python
How to use microsoft/phi-4-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="microsoft/phi-4-gguf", filename="phi-4-IQ3_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use microsoft/phi-4-gguf with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf microsoft/phi-4-gguf:Q4_K_S # Run inference directly in the terminal: llama-cli -hf microsoft/phi-4-gguf:Q4_K_S
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf microsoft/phi-4-gguf:Q4_K_S # Run inference directly in the terminal: llama-cli -hf microsoft/phi-4-gguf:Q4_K_S
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf microsoft/phi-4-gguf:Q4_K_S # Run inference directly in the terminal: ./llama-cli -hf microsoft/phi-4-gguf:Q4_K_S
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf microsoft/phi-4-gguf:Q4_K_S # Run inference directly in the terminal: ./build/bin/llama-cli -hf microsoft/phi-4-gguf:Q4_K_S
Use Docker
docker model run hf.co/microsoft/phi-4-gguf:Q4_K_S
- LM Studio
- Jan
- vLLM
How to use microsoft/phi-4-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/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": "microsoft/phi-4-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/phi-4-gguf:Q4_K_S
- SGLang
How to use microsoft/phi-4-gguf 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 "microsoft/phi-4-gguf" \ --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": "microsoft/phi-4-gguf", "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 "microsoft/phi-4-gguf" \ --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": "microsoft/phi-4-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use microsoft/phi-4-gguf with Ollama:
ollama run hf.co/microsoft/phi-4-gguf:Q4_K_S
- Unsloth Studio new
How to use microsoft/phi-4-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for microsoft/phi-4-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for microsoft/phi-4-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for microsoft/phi-4-gguf to start chatting
- Docker Model Runner
How to use microsoft/phi-4-gguf with Docker Model Runner:
docker model run hf.co/microsoft/phi-4-gguf:Q4_K_S
- Lemonade
How to use microsoft/phi-4-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull microsoft/phi-4-gguf:Q4_K_S
Run and chat with the model
lemonade run user.phi-4-gguf-Q4_K_S
List all available models
lemonade list
Gustavo de Rosa commited on
Commit ·
18ece48
1
Parent(s): b1e764c
chore(root): Re-convert and re-quantize files.
Browse files- phi-4-q4.gguf → phi-4-IQ2_M.gguf +2 -2
- phi-4-fp16.gguf → phi-4-IQ3_M.gguf +2 -2
- phi-4-IQ3_S.gguf +3 -0
- phi-4-IQ3_XS.gguf +3 -0
- phi-4-IQ3_XXS.gguf +3 -0
- phi-4-IQ4_NL.gguf +3 -0
- phi-4-IQ4_XS.gguf +3 -0
- phi-4-Q2_K.gguf +3 -0
- phi-4-Q3_K.gguf +3 -0
- phi-4-Q3_K_L.gguf +3 -0
- phi-4-Q3_K_S.gguf +3 -0
- phi-4-Q4_0.gguf +3 -0
- phi-4-Q4_1.gguf +3 -0
- phi-4-Q4_K.gguf +3 -0
- phi-4-Q4_K_S.gguf +3 -0
- phi-4-Q5_0.gguf +3 -0
- phi-4-Q5_1.gguf +3 -0
- phi-4-Q5_K.gguf +3 -0
- phi-4-Q5_K_S.gguf +3 -0
- phi-4-Q6_K.gguf +3 -0
- phi-4-Q8_0.gguf +3 -0
- phi-4-TQ1_0.gguf +3 -0
- phi-4-TQ2_0.gguf +3 -0
- phi-4-bf16.gguf +3 -0
phi-4-q4.gguf → phi-4-IQ2_M.gguf
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a3173c8a4f826e443866bd750bf1acebd4bee915dd74c6aa635a1c74e4c1d850
|
| 3 |
+
size 588873920
|
phi-4-fp16.gguf → phi-4-IQ3_M.gguf
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9298fa6c9e927b257845a8057c74f2f4bd6bb7fbce35a0db933debdd777ae9a
|
| 3 |
+
size 6913835200
|
phi-4-IQ3_S.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3f165ed951be668c9297e0721dc8a8fdab4916a8da7a6b83a3b47a2a174a9c0e
|
| 3 |
+
size 6504747200
|
phi-4-IQ3_XS.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2bd63e342a7d5801f45cab2fb15522812e9c1f4731f92b5a349474743876121c
|
| 3 |
+
size 6246699200
|
phi-4-IQ3_XXS.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b65f01aab058dc26f8f1d0a4fe84b68df58d29ea2f21c87972620a9869e57bc5
|
| 3 |
+
size 6079643840
|
phi-4-IQ4_NL.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:53aa11369a090f667dabf6b5877baa9f9947071bf7e7244a737b2d7b1d5c0379
|
| 3 |
+
size 8440762560
|
phi-4-IQ4_XS.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f5c151b6e5ea5e5bfd699b40e4c6797d08a4c6c0136cad201fb03e1d3e6e5511
|
| 3 |
+
size 8013058240
|
phi-4-Q2_K.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7ff048b61e9d6fc49bdd11affdb5e0d3365c08e55eb17ffd0f159f6e0de6f53e
|
| 3 |
+
size 5547348160
|
phi-4-Q3_K.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:570a44b43fd7bd87637586ac8d7fc47f5a2fde0376d4f58c22854960c43eb365
|
| 3 |
+
size 7363268800
|
phi-4-Q3_K_L.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8fe8deaa431f877d7c9c3caf49f0e149c396b526c50558991ad87040cd43111e
|
| 3 |
+
size 7930155200
|
phi-4-Q3_K_S.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df1d679cf9c8f73471b661168310f736886a3dad01eb4be04a127b899f65a745
|
| 3 |
+
size 6504747200
|
phi-4-Q4_0.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:367a3576b66530fac1cee6c3f47b52e7bbfb003de6cc18e2e2c9a2cc2ad89fe6
|
| 3 |
+
size 8383418560
|
phi-4-Q4_1.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:312aeab892aa958c06188775125a011164990e9c07acef75c6bd5208bd9bbaaf
|
| 3 |
+
size 9267499200
|
phi-4-Q4_K.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5652b9be0ea4ae2842130d04fe31bc869fcb99a2b7106c53b4e754a343fd688f
|
| 3 |
+
size 9053114560
|
phi-4-Q4_K_S.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a8189132ef70cd737e136d38b706e8cb832f9cdf3c744547694769e9313550e
|
| 3 |
+
size 8440762560
|
phi-4-Q5_0.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b935eaeceeb165ac8c4786a6da44bcb713a8a253abccf01658bfb64acd4b8815
|
| 3 |
+
size 10151579840
|
phi-4-Q5_1.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1bc2d63bd2fa376f510850365e6826247d211270fbbbde08629a4c52c0c7aad4
|
| 3 |
+
size 11035660480
|
phi-4-Q5_K.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1cf76820e5b9b7ae11dafe82e0769e5564754616384c08fc3d1372eb06683aec
|
| 3 |
+
size 10604187840
|
phi-4-Q5_K_S.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:83bb97146ecfd800ad948da1578e01c40d5704011d6deebb15db6069327d24a5
|
| 3 |
+
size 10151579840
|
phi-4-Q6_K.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a70147a8a8adb24d62a28e5038aca78c4c145a1c3043a38e8634738a9e6bbd93
|
| 3 |
+
size 12030251200
|
phi-4-Q8_0.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f68df5d3a22a01ea9ec547741f42ee7fedbf949bf42ef526fb1944fa0cfaa110
|
| 3 |
+
size 15580500160
|
phi-4-TQ1_0.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae08aeb1cb5da565300176b90c047d27d89dfe7d5f87a359ff95565c04a14102
|
| 3 |
+
size 3591098560
|
phi-4-TQ2_0.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c3ed993354f92e1bd4bd1c64e879bb14c085811c817ca1aa9ffac4cc7f6fa665
|
| 3 |
+
size 4230074560
|
phi-4-bf16.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0cdb8adae6864ae0b29cbd38dad2ea5952fee36321924d694a29e7f2eea0650
|
| 3 |
+
size 29323399360
|