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")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("microsoft/phi-4-gguf", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use microsoft/phi-4-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -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 serve -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 Desktop
- 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
- Atomic Chat
Download phi-4-Q3_K_L.gguf from microsoft/phi-4-gguf: direct link, hf CLI and curl.
- Browser
- Download file 7.93 GB
-
https://huggingface.co/microsoft/phi-4-gguf/resolve/main/phi-4-Q3_K_L.gguf
- Command line
-
hf download hf://microsoft/phi-4-gguf/phi-4-Q3_K_L.gguf
-
curl -L -o phi-4-Q3_K_L.gguf https://huggingface.co/microsoft/phi-4-gguf/resolve/main/phi-4-Q3_K_L.gguf
7.93 GB
- Xet hash:
- 9eccfe4281a9ebd9a9925f8ee82c4209b58d93fa7bcc08efeef11859c94ad765
- Size of remote file:
- 7.93 GB
- SHA256:
- 8fe8deaa431f877d7c9c3caf49f0e149c396b526c50558991ad87040cd43111e
·
Xet efficiently stores Large Files inside Git, intelligently splitting files into unique chunks and accelerating uploads and downloads. More info.