Phi-4 is Microsoft Research's family of small language models (SLMs) โ models built from around 3.8 billion to 14 billion parameters that aim to punch above their weight on reasoning, math, and coding benchmarks rather than compete on raw scale. It ranks around #14 in real-world usage share (roughly 5%), reflecting its niche as a research-grade small model rather than a mass consumer chatbot. Phi-4 is known for being trained on carefully curated, high-quality synthetic and filtered data, letting it run efficiently on a single GPU or even a laptop.
Phi-4 is small enough to load directly with transformers on a single GPU, or run through Ollama for a quick local chat.
from transformers import pipeline
pipe = pipeline(
"text-generation",
model="microsoft/phi-4",
device_map="auto"
)
messages = [{"role": "user", "content": "Explain what a REST API is in two sentences."}]
result = pipe(messages, max_new_tokens=200)
print(result[0]["generated_text"])
Because Phi-4 is a small model, the quickest way to try it is running it locally with Ollama โ no cloud account required.
# 1. install Ollama from ollama.com
ollama run phi4
# 2. or install transformers to load the weights from Hugging Face
pip install transformers torch accelerate
# 3. or use it hosted for free via GitHub Models (github.com/marketplace/models)