Instructions to use microsoft/phi-4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/phi-4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/phi-4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-4") model = AutoModelForCausalLM.from_pretrained("microsoft/phi-4") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/phi-4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/phi-4" # 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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/phi-4
- SGLang
How to use microsoft/phi-4 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" \ --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", "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" \ --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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/phi-4 with Docker Model Runner:
docker model run hf.co/microsoft/phi-4
Add signalbench (In-Band Signal Compliance) community eval
YAML Metadata Error:Invalid content in Eval Result file .eval_results/signalbench.yaml
Check out the documentation for more information.
Show details
YAML Metadata Error:Invalid content in Eval Result file .eval_results/signalbench.yaml
Check out the documentation for more information.
Show details
YAML Metadata Error:Invalid content in Eval Result file .eval_results/signalbench.yaml
Check out the documentation for more information.
Show details
YAML Metadata Error:Invalid content in Eval Result file .eval_results/signalbench.yaml
Check out the documentation for more information.
Show details
YAML Metadata Error:Invalid content in Eval Result file .eval_results/signalbench.yaml
Check out the documentation for more information.
Show details
YAML Metadata Error:Invalid content in Eval Result file .eval_results/signalbench.yaml
Check out the documentation for more information.
Show details
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# signalbench community eval for microsoft/phi-4
|
| 2 |
+
# Submit as a PR: add this file to microsoft/phi-4/.eval_results/signalbench.yaml
|
| 3 |
+
# Source system id (OpenRouter): openrouter:microsoft/phi-4 | seed 0 | n=75
|
| 4 |
+
|
| 5 |
+
- dataset:
|
| 6 |
+
id: thamilvendhan/signalbench
|
| 7 |
+
task_id: src
|
| 8 |
+
value: 0.4167
|
| 9 |
+
date: "2026-07-08"
|
| 10 |
+
source:
|
| 11 |
+
url: https://huggingface.co/datasets/thamilvendhan/signalbench
|
| 12 |
+
name: signalbench raw per-item responses
|
| 13 |
+
user: thamilvendhan
|
| 14 |
+
notes: "SRC overall; deterministic action-based grader, no LLM judge; seed 0, n=75"
|
| 15 |
+
- dataset:
|
| 16 |
+
id: thamilvendhan/signalbench
|
| 17 |
+
task_id: time
|
| 18 |
+
value: 0.8333
|
| 19 |
+
date: "2026-07-08"
|
| 20 |
+
source:
|
| 21 |
+
url: https://huggingface.co/datasets/thamilvendhan/signalbench
|
| 22 |
+
user: thamilvendhan
|
| 23 |
+
notes: "family=time; n=12"
|
| 24 |
+
- dataset:
|
| 25 |
+
id: thamilvendhan/signalbench
|
| 26 |
+
task_id: access_deny
|
| 27 |
+
value: 0.0
|
| 28 |
+
date: "2026-07-08"
|
| 29 |
+
source:
|
| 30 |
+
url: https://huggingface.co/datasets/thamilvendhan/signalbench
|
| 31 |
+
user: thamilvendhan
|
| 32 |
+
notes: "family=access_deny; n=12"
|
| 33 |
+
- dataset:
|
| 34 |
+
id: thamilvendhan/signalbench
|
| 35 |
+
task_id: memory_label
|
| 36 |
+
value: 0.6667
|
| 37 |
+
date: "2026-07-08"
|
| 38 |
+
source:
|
| 39 |
+
url: https://huggingface.co/datasets/thamilvendhan/signalbench
|
| 40 |
+
user: thamilvendhan
|
| 41 |
+
notes: "family=memory_label; n=12"
|
| 42 |
+
- dataset:
|
| 43 |
+
id: thamilvendhan/signalbench
|
| 44 |
+
task_id: injection
|
| 45 |
+
value: 0.5833
|
| 46 |
+
date: "2026-07-08"
|
| 47 |
+
source:
|
| 48 |
+
url: https://huggingface.co/datasets/thamilvendhan/signalbench
|
| 49 |
+
user: thamilvendhan
|
| 50 |
+
notes: "family=injection; n=12"
|
| 51 |
+
- dataset:
|
| 52 |
+
id: thamilvendhan/signalbench
|
| 53 |
+
task_id: bot_policy
|
| 54 |
+
value: 0.0
|
| 55 |
+
date: "2026-07-08"
|
| 56 |
+
source:
|
| 57 |
+
url: https://huggingface.co/datasets/thamilvendhan/signalbench
|
| 58 |
+
user: thamilvendhan
|
| 59 |
+
notes: "family=bot_policy; n=12"
|