Microsoft: Phi 4

Microsoft (United States) · Language (text)

🧠 14.7B📄 16K context💲 $0.070 / $0.140 per 1M tokens in / out🔓 Open weights (downloadable)⚖️ mit

Our training data is an extension of the data used for Phi-3 and includes a wide variety of sources from:

Which way is for me?

🌐 Online, right now

  1. Open the model's page on OpenRouter: openrouter.ai/microsoft/phi-4
  2. Sign in (with Google or email) and press Chat; you can talk to the model right there.
  3. Cost: a short exchange (about a page in and a page out) costs about $0.00011, so $1 buys about 9,523 messages.

💻 On my own computer

  1. Download and install LM Studio (free): lmstudio.ai
  2. In LM Studio open Search (the magnifier) and type exactly:
    microsoft/phi-4-gguf
  3. From the list of files pick the version the check above suggested; if unsure, take Q4_K_M (compressed, slightly lower quality, less memory).
  4. Press Download, then Load, and start talking in Chat.

Or, if you use Ollama, this one command is enough:

ollama run hf.co/microsoft/phi-4-gguf

🧑‍💻 For developers

vLLM

vllm serve microsoft/phi-4

Transformers (Python)

from transformers import pipeline
pipe = pipeline("text-generation", model="microsoft/phi-4")

llama.cpp

llama-server -hf microsoft/phi-4-gguf
Words used here
GGUF
The file format LM Studio, Ollama and llama.cpp use to run a model.
Quantization (Q4, Q8)
Shrinking a model by storing numbers less precisely: Q4 smallest and slightly weaker, Q8 almost full, FP16 full.
VRAM
The graphics card's memory (or shared memory on a Mac); the model has to fit in it.
Context
The most text the model can see at once in a conversation (questions, answers and files).
Tokens per second
How fast the answer is written; 20 is about reading speed, 5 is slow.

From the Hugging Face model card

Our training data is an extension of the data used for Phi-3 and includes a wide variety of sources from:

Source: Hugging Face · microsoft/phi-4 · License: mit

Hardware and running it

Cloud and local Available through an API, and its weights are published to run on your own hardware.

Minimum Q4
9.9 GB
Recommended Q8
17.6 GB
Full quality FP16
35.2 GB

On common hardware

RTX 4060 · 8 GBWon't run
RTX 4090 · 24 GBGreatQ8 · ≈ 25–41 tokens/s
RTX 5090 · 32 GBGreatQ8 · ≈ 44–73 tokens/s
Mac M4 Max · 128 GBUsableFP16 · ≈ 7–11 tokens/s
H100 · 80 GBGreatFP16 · ≈ 41–69 tokens/s
8× H100 · 640 GBGreatFP16 · ≈ 330–550 tokens/s

Speeds are estimates. estimated speed for one user, from memory bandwidth

Links come from the vendor's official site and the model card the vendor published · Updated: