๐Ÿ”ท

Microsoft Phi-4

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.

Quick facts
Made by: Microsoft Research
Access: Open weights (MIT license) on Hugging Face and Ollama, plus hosted access via Azure AI Foundry and GitHub Models
Context window: 16,384 tokens (Phi-4); Phi-4-mini variants support longer contexts
Strengths: Strong reasoning and math for its size, efficient enough for edge/laptop inference, low hosting cost
Primary use case: On-device or cost-constrained apps needing solid reasoning without a large model's compute footprint
Jump to: ExampleGetting startedBest for

Example

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"])

Getting started

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)
Best for: Developers who need decent reasoning and coding help but can't afford a large model's latency or GPU cost โ€” laptop-based dev tools, offline assistants, and edge devices where a 14B-parameter model is the practical ceiling.