What Is Microsoft Phi-4?
Phi-4 is Microsoft’s fourth-generation small language model, released in late 2024. It is a 14-billion-parameter dense transformer model designed around a specific thesis: that carefully curated, high-quality training data produces better models than simply scaling up parameter counts on web-scraped data. Microsoft’s Phi series has consistently challenged the assumption that more parameters equal better performance, demonstrating that smaller, carefully trained models can match or exceed much larger models on certain benchmark categories — particularly reasoning and mathematics.
Phi-4 extends this approach with a training dataset that heavily weights synthetic data generated by more capable models, selected textbook content, and curated problem-solution pairs. The result is a 14B model that punches significantly above its weight class on structured reasoning tasks while fitting on a single consumer GPU — a combination that makes it uniquely appealing for deployment scenarios where model size is constrained but reasoning quality matters.
Phi-4 Benchmark Performance
Benchmark | Phi-4 14B | Llama 3.3 70B | Qwen 2.5 72B | GPT-4o mini
--------------------|-----------|---------------|--------------|------------
MMLU | 84.8 | 86.0 | 86.1 | 82.0
MATH | 80.4 | 77.0 | 83.1 | 70.2
HumanEval (coding) | 82.6 | 81.7 | 86.5 | 87.2
GPQA (science) | 56.1 | 49.1 | 49.5 | 40.9
MT-Bench | 8.8 | 8.7 | 8.7 | 8.4
The headline result: Phi-4 at 14B parameters outperforms Llama 3.3 at 70B on mathematics (MATH: 80.4 vs 77.0) and science reasoning (GPQA: 56.1 vs 49.1), while being 5x smaller. On MMLU general knowledge, it trails by a small margin. On coding, it is competitive with Llama 3.3 70B but below Qwen 2.5 72B. For reasoning-heavy tasks on constrained hardware, these numbers are remarkable.
Hardware Requirements: Where Phi-4 Shines
Precision | VRAM needed | Fits on
-------------|-------------|------------------
BF16 (full) | ~28 GB | A100 40GB (tight), RTX 4090 (no)
Q8 | ~14 GB | Single RTX 4090 (24GB) with headroom
Q4_K_M | ~8 GB | RTX 3060 (12GB), consumer laptops
Q2_K | ~5 GB | Entry-level GPUs, Apple M1 base
At Q8, Phi-4 fits on a single RTX 4090 with 10 GB to spare for KV cache — meaning you can run it at near-full quality with a meaningful context window. At Q4_K_M, it fits on budget consumer GPUs. This footprint is dramatically smaller than Llama 3.3 70B at Q4 (which requires dual 24 GB GPUs) while delivering comparable or better reasoning quality.
Running Phi-4 Locally
Phi-4 is available on Hugging Face and through Ollama:
# Via Ollama
ollama pull phi4
ollama run phi4
# At Q8 for near-full quality on RTX 4090
ollama pull phi4:14b-q8_0
ollama run phi4:14b-q8_0
# Via Hugging Face Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"microsoft/phi-4",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-4")
messages = [{"role": "user", "content": "Prove by induction that the sum of first n integers is n(n+1)/2."}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Phi-4’s reasoning on the mathematical proof example above is notably strong — it produces clear, well-structured proofs with fewer errors than much larger models. For structured reasoning tasks specifically, the quality-per-GB-of-VRAM is extraordinary.
Phi-4 vs. Phi-3.5: What Changed
The Phi-3.5 Mini (3.8B) and Phi-3.5 MoE (16×3.8B) models preceded Phi-4. Phi-3.5 Mini remains relevant for extremely constrained deployments — it fits on a Raspberry Pi 5 with 8 GB RAM for CPU inference, opening embedded and IoT use cases. Phi-4 at 14B is significantly more capable but requires a proper GPU for practical inference speeds. The jump from Phi-3.5 to Phi-4 is substantial on reasoning benchmarks: MATH improved from ~59% to 80.4%, and GPQA improved from ~37% to 56.1%. For teams that deployed Phi-3.5 and found the reasoning quality insufficient, Phi-4 represents a meaningful capability upgrade within a similar hardware footprint at Q4.
When to Choose Phi-4 Over Larger Models
Phi-4 is the right choice in specific scenarios where its unique combination of attributes — strong reasoning at small size — is what you actually need. For single-GPU deployment where reasoning quality matters more than breadth: Phi-4 at Q8 on one RTX 4090 delivers better mathematical and scientific reasoning than Llama 3.3 70B at Q4 on two RTX 4090s, at half the hardware cost. For latency-sensitive applications where small model size means faster generation: at Q4, Phi-4 generates 150–200 tok/s on a single RTX 4090 versus 40–50 tok/s for 70B models on dual GPUs. For fine-tuning on reasoning tasks: the high base reasoning capability means fine-tuned Phi-4 models can deliver strong domain-specific reasoning with less training data than larger general-purpose bases. For edge deployment: at Q4 Phi-4 runs acceptably on Apple Silicon base configurations (M2 16GB) where 70B models are completely infeasible.
When Not to Choose Phi-4
Phi-4’s training focus on reasoning and structured problem-solving comes at the cost of breadth. For general knowledge, creative writing, and open-ended conversation, Llama 3.3 70B and Qwen 2.5 72B produce more well-rounded outputs. For coding tasks specifically, Qwen 2.5 Coder 32B outperforms Phi-4 substantially. For multilingual work, Phi-4’s training data skews heavily toward English. And for community tooling, fine-tunes, and documentation, Llama 3.3 70B has a dramatically larger ecosystem. Phi-4 is a specialised instrument rather than a general-purpose one — it excels on the tasks its training explicitly optimised for and is merely adequate elsewhere.
API Access Through Azure AI
Phi-4 is available through Azure AI Studio as a managed endpoint, making it accessible within Azure’s compliance and networking infrastructure without self-hosting. For enterprises already on Azure who need strong reasoning capability at lower inference cost than frontier models, Phi-4 on Azure AI is worth evaluating. The per-token cost is significantly lower than GPT-4o or Claude Sonnet, and for tasks where Phi-4’s reasoning quality is sufficient, the cost savings are substantial. Access it through the Azure AI model catalogue, deploy to a managed online endpoint, and call it through the Azure AI Inference SDK or directly via the OpenAI-compatible REST API that Azure AI endpoints expose.
The Phi Series Thesis and What It Means for the Field
Microsoft’s Phi series is important beyond the specific models because it has proven a point about AI training that the field initially resisted: data quality can substitute for scale. The early argument against Phi-2 and Phi-3 was that their benchmark performance would not generalise to real tasks — that they had been “trained on the test.” Phi-4’s continued strong performance across diverse reasoning evaluations makes this argument increasingly difficult to sustain. If high-quality, curated training data can produce a 14B model that matches or beats 70B models on reasoning tasks, the implications for training efficiency, inference cost, and accessibility are significant. The trend toward smaller, more carefully trained models with strong targeted capabilities is likely to continue — and Phi-4 is currently the clearest demonstration of how far that approach can be pushed.
Fine-Tuning Phi-4 for Specialised Reasoning
Phi-4’s strong base reasoning capability makes it an attractive fine-tuning target for domain-specific reasoning tasks — medical diagnosis assistance, financial analysis, legal clause interpretation, scientific literature summarisation. The reasoning chain quality in the base model means fine-tuned variants learn the domain-specific patterns with less training data than would be needed for a model with weaker base reasoning. LoRA fine-tuning at rank 16 on Phi-4 fits comfortably on a single RTX 4090 (24 GB) with batch size 2–4:
from peft import LoraConfig, get_peft_model
from transformers import AutoModelForCausalLM
import torch
model = AutoModelForCausalLM.from_pretrained(
"microsoft/phi-4",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
lora_config = LoraConfig(
r=16, lora_alpha=32,
target_modules=["q_proj", "k_proj", "v_proj", "dense"],
lora_dropout=0.05, bias="none"
)
model = get_peft_model(model, lora_config)
model.print_trainable_parameters()
# trainable params: ~13M — under 0.1% of total
Phi-4 uses Microsoft’s own target module naming (dense rather than o_proj) — check the model architecture before applying LoRA configs from Llama tutorials without modification. A 500-example domain-specific fine-tuning dataset is typically sufficient to meaningfully improve Phi-4’s performance on structured reasoning tasks within your domain, given the strong base capability the model brings to the fine-tuning starting point.
Phi-4 Multimodal: Phi-4-Vision
Microsoft released Phi-4-Vision alongside Phi-4, extending the model with image understanding capability. Phi-4-Vision processes images alongside text for document analysis, chart reading, scientific diagram interpretation, and visual Q&A — at the same small model size. For teams that need vision capability without the cost of GPT-4o Vision or Claude’s vision pricing, Phi-4-Vision is the strongest small multimodal option available open-source. It is available on Hugging Face and through Azure AI, with the same hardware footprint as the base Phi-4 model.
Summary: Phi-4 in Your Model Portfolio
Phi-4 is not a general-purpose replacement for Llama or Qwen — it is a precision instrument that excels at a specific class of tasks. If your application involves structured mathematical or scientific reasoning, step-by-step problem solving, or logic puzzles and you are constrained to single-GPU deployment, Phi-4 should be at the top of your evaluation list. If your application is primarily general-purpose chat, creative writing, or coding-heavy tasks, the larger and more well-rounded open-source models are likely to serve you better. The most effective model portfolios in 2026 are ones that match model selection to task type — and for reasoning tasks under hardware constraints, Phi-4 is currently the optimal choice.
Phi-4 for Agentic and Tool-Use Workflows
Beyond single-turn reasoning tasks, Phi-4 performs well in agentic settings where the model must plan multi-step approaches, call tools, and synthesise results. Its strong structured reasoning translates into more reliable function calling and tool selection compared to other models of similar size. For applications that need an agent capable of breaking down a complex problem, deciding which tools to use, and integrating results without drifting off-task, Phi-4 is a more reliable 14B agent than the general-purpose 13B models it competes with on VRAM.
This has practical implications for small-team and individual developer agentic setups. An RTX 4090 running Phi-4 at Q8 can serve as a capable local agent that calls tools, writes code, searches documents, and synthesises answers — at speeds fast enough for interactive use (150+ tokens per second at Q4). The combination of strong reasoning, small size, fast inference, and single-GPU deployment makes Phi-4 the go-to choice for developers building local agentic workflows who cannot or do not want to pay API costs per interaction.
Microsoft ships Phi-4 with function calling support using the standard JSON schema format compatible with the OpenAI tools API. Existing tool definitions written for GPT-4o or Claude require no modification to work with Phi-4 — swap the model name and endpoint and the tool-calling pipeline works unchanged. This makes migrating agentic workloads from expensive frontier APIs to a local Phi-4 instance a low-friction experiment worth running before committing to frontier API costs for agentic use cases.
Community Resources and Model Variants
Phi-4’s Hugging Face community has grown rapidly since release. A range of GGUF quantisations for llama.cpp and Ollama deployment are maintained by community contributors, covering everything from Q2_K for extremely constrained hardware to Q8_0 for near-full-quality inference. Fine-tuned variants for specific domains — medical reasoning, legal analysis, mathematics tutoring — are also appearing as the model’s strong reasoning base attracts domain-specific fine-tuning efforts. The Microsoft Research blog and the Phi-4 model card on Hugging Face are the primary sources for official updates on new variants, capability evaluations, and recommended use configurations.