Phi-4 Mini: Microsoft's 3.8B Small Language Model
Phi-4 Mini (Phi-4-mini-instruct) is a 3.8-billion-parameter dense model from Microsoft, released in February 2025 under the MIT licence with a 128K context. On Microsoft's own benchmark table it scores 67.3 on MMLU and 64.0 on MATH, which is well ahead of Llama 3.2 3B and ahead of the 8B models in that table on maths but not on knowledge. The default Ollama build is a 2.5 GB file; with an 8K context it needs about 4 GB of memory, so it runs on a 6 GB GPU or an 8 GB laptop.
Overview
Phi-4 Mini is the text-only member of Microsoft's Phi-4 family of small language models. The model card describes it as a dense, decoder-only Transformer with 3.8B parameters, a 200,064-token vocabulary, grouped-query attention and shared input/output embeddings, trained on 5 trillion tokens between November and December 2024. The training mix is filtered public documents, synthetic "textbook-like" data for maths, coding and reasoning, and chat-format supervised data. The technical report (March 2025) covers Phi-4 Mini and the speech-and-vision Phi-4 Multimodal in one paper.
Microsoft states the intended uses plainly: memory- and compute-constrained environments, latency-bound scenarios, and tasks that need "strong reasoning (especially math and logic)". That matches the benchmark table, where the model's best rows are GSM8K and MATH and its weakest is GPQA.
The MIT licence is the least restrictive of the small models it is usually compared with. Llama 3.2 3B ships under Meta's community licence and Gemma 2 2B under Google's Gemma terms; Qwen2.5 3B uses the Qwen Research licence rather than Apache 2.0.
The model card lists 22 supported languages: Arabic, Chinese, Czech, Danish, Dutch, English, Finnish, French, German, Hebrew, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish, Thai, Turkish and Ukrainian.
What changed from Phi-3.5 Mini
Phi-4 Mini keeps Phi-3.5 Mini's 3.8B size and 128K context. The model card names the changes directly: "the major changes with Phi-4-mini-instruct are 200K vocabulary, grouped-query attention, and shared input and output embedding", plus new post-training for instruction following and function calling.
200K vocabulary
The tokenizer grows to 200,064 entries, which the technical report ties to better multilingual coverage. The embedding table is shared between input and output (tie_word_embeddings is true in config.json), which keeps the parameter count at 3.8B despite the larger vocabulary.
Grouped-query attention
24 query heads share 8 key/value heads (config.json). That is what makes the KV cache 128 KB per token instead of 384 KB, and it is the reason long contexts are affordable on small cards (see the hardware section).
Maths and reasoning data
The largest benchmark moves are on the reasoning rows: MATH 49.8 to 64.0, GSM8K 76.9 to 88.6, BigBench Hard 63.1 to 70.4, MGSM 49.6 to 63.9. MMLU moves less (65.5 to 67.3) and Multilingual MMLU slips (51.8 to 49.3).
Benchmarks
The table below is Microsoft's, reproduced from the Phi-4-mini-instruct model card. All columns were run by Microsoft with the shot counts shown in the first column; we have not re-run them. Comparison columns are the instruct variants of each model as Microsoft labelled them.
| Benchmark | Phi-4 Mini | Phi-3.5 Mini | Llama 3.2 3B | Qwen2.5 3B | Qwen2.5 7B | Llama 3.1 8B | Gemma 2 9B |
|---|---|---|---|---|---|---|---|
| MMLU (5-shot) | 67.3 | 65.5 | 61.8 | 65.0 | 72.6 | 68.1 | 71.3 |
| MMLU-Pro (0-shot, CoT) | 52.8 | 47.4 | 39.2 | 44.7 | 56.2 | 44.0 | 50.1 |
| GSM8K (8-shot, CoT) | 88.6 | 76.9 | 75.6 | 80.6 | 88.7 | 82.4 | 84.9 |
| MATH (0-shot, CoT) | 64.0 | 49.8 | 46.7 | 61.7 | 60.4 | 47.6 | 51.3 |
| GPQA (0-shot, CoT) | 25.2 | 26.6 | 24.3 | 23.4 | 30.6 | 26.3 | 39.1 |
| ARC-Challenge (10-shot) | 83.7 | 84.6 | 76.1 | 82.6 | 90.1 | 83.1 | 89.8 |
| BigBench Hard (0-shot, CoT) | 70.4 | 63.1 | 55.4 | 56.2 | 72.4 | 63.4 | 65.7 |
Source: Microsoft, Phi-4-mini-instruct model card (Hugging Face). Multilingual rows on the same card: Multilingual MMLU (5-shot) 49.3 vs 51.8 for Phi-3.5 Mini and 48.1 for Llama 3.2 3B; MGSM (0-shot, CoT) 63.9 vs 49.6 and 44.6.
How to read the table
- Maths is the headline. 64.0 on MATH is the highest number in the 3B-to-9B range of this table; 88.6 on GSM8K is within 0.1 of Qwen2.5 7B.
- Knowledge is mid-pack. 67.3 MMLU is above every 3B model listed but below Llama 3.1 8B (68.1), Gemma 2 9B (71.3) and Qwen2.5 7B (72.6).
- GPQA is the weak row. 25.2 is below Phi-3.5 Mini (26.6) and every larger model in the table.
- Coding is not in this table. The model card lists HumanEval, MBPP and BigCodeBench among the evaluations run, but does not publish the per-model coding rows in the same comparison table, so this page does not quote a HumanEval figure.
Quick Start (Ollama)
The Ollama library name is phi4-mini. Five tags are published and three of them are the same 2.5 GB q4_K_M file (tag list). There is no :instruct tag because every build is the instruct model.
# Default build: q4_K_M, 2.5 GB, listed with a 128K context
ollama run phi4-mini
# Same file under its explicit tags
ollama pull phi4-mini:3.8b
ollama pull phi4-mini:3.8b-q4_K_M
# Larger builds (listed with a 4K default context on the tag page; raise num_ctx yourself)
ollama pull phi4-mini:3.8b-q8_0 # 4.1 GB
ollama pull phi4-mini:3.8b-fp16 # 7.7 GB
# Inspect the installed model (parameters, quantization, context)
ollama show phi4-miniThe Ollama library page notes that the model "now includes function calling", which matches the model card's post-training notes. For the tool-calling request format see our Ollama tool-calling guide; for installation on Windows see Ollama on Windows.
Hardware Requirements
Short answer: the default 2.5 GB build plus an 8K context needs about 4 GB, so any 6 GB GPU, any 8 GB Apple Silicon Mac, or a CPU box with 8 GB of RAM runs it. The fp16 build with a 32K context needs about 12 GB, so that wants a 16 GB card.
How the numbers are worked out
These are arithmetic, not measurements. Weights are the Ollama file sizes. The KV cache is computed from the published config: 32 layers x 8 KV heads x 128 head dimension (3072 hidden / 24 heads) x 2 for keys and values x 2 bytes at fp16 = 131,072 bytes, or 128 KB per token. That gives 1 GB at 8K context, 2 GB at 16K, 4 GB at 32K and 16 GB at the full 128K. Add roughly 0.5 GB for the runtime and compute buffers. Ollama's KV-cache quantization option (OLLAMA_KV_CACHE_TYPE=q8_0) halves the cache figures.
| Ollama tag | File | Listed context | Memory at 8K ctx | Memory at 32K ctx | Fits on |
|---|---|---|---|---|---|
| 3.8b-q4_K_M (= latest, 3.8b) | 2.5 GB | 128K | ~4 GB | ~6.5 GB | 6 GB card; 8 GB RAM on CPU/Mac |
| 3.8b-q8_0 | 4.1 GB | 4K | ~5.6 GB | ~8.6 GB | 8 GB card (short context); 12 GB for 32K |
| 3.8b-fp16 | 7.7 GB | 4K | ~9.2 GB | ~12.2 GB | 12 GB card (short context); 16 GB for 32K |
File sizes and listed context from ollama.com/library/phi4-mini/tags; memory columns are file size + KV cache (128 KB/token) + ~0.5 GB overhead, rounded. The full 128K context on the q4_K_M build is about 19 GB by the same arithmetic, so it needs a 24 GB card or a 32 GB Mac.
Measured on an Apple M3 Pro (18 GB): 14–15 October 2026
phi4-mini generated 46.3 tokens per second on the one machine we own, an Apple M3 Pro (18 GB). The rest of the table is the same run, so you can see where it sits against the other small models.
| Model (Ollama tag) | Params | Quant | File | Measured tok/s | Run spread | Ceiling | Share | Date |
|---|---|---|---|---|---|---|---|---|
llama3.2:3b | 3.2B | Q4_K_M | 2.02 GB | 55.0 | 54.9–55.1 | 74 | 74% | 2026-10-14 |
qwen2.5-coder:3b-base | 3.1B | Q4_K_M | 1.93 GB | 54.0 | 53.6–54.3 | 78 | 69% | 2026-10-14 |
phi4-mini | 3.8B | Q4_K_M | 2.49 GB | 46.3 | 44.0–46.4 | 60 | 77% | 2026-10-14 |
qwen3:4b | 4.0B | Q4_K_M | 2.50 GB | 43.2 | 42.4–43.2 | 60 | 72% | 2026-10-14 |
mistral:7b | 7.2B | Q4_K_M | 4.37 GB | 28.5 | 28.4–28.6 | 34 | 83% | 2026-10-15 |
qwen2.5-coder:7b | 7.6B | Q4_K_M | 4.68 GB | 28.0 | 27.8–28.2 | 32 | 87% | 2026-10-15 |
llama3.1:8b | 8.0B | Q4_K_M | 4.92 GB | 26.8 | 26.2–26.9 | 30 | 88% | 2026-10-14 |
qwen3:8b | 8.2B | Q4_K_M | 5.23 GB | 24.9 | 24.7–24.9 | 29 | 87% | 2026-10-15 |
deepseek-r1:8b | 8.2B | Q4_K_M | 5.23 GB | 24.8 | 24.6–25.0 | 29 | 86% | 2026-10-15 |
Apple M3 Pro, 18 GB unified memory, Ollama 0.12.3, macOS (Darwin 27.0.0, arm64), Metal. Median generation rate of 6 runs after a discarded warm-up, computed from Ollama's raw eval_count and eval_duration over its HTTP API (not scraped from the terminal); any run that produced fewer than 30 tokens is thrown out rather than averaged. The same prompt, 7 runs, for every model. Ceiling = 150 GB/s (Apple's figure for the M3 Pro) ÷ the file size Ollama downloaded. One machine is a data point, not a survey; the script is scripts/benchmark-ollama.py in our repo if you want the same table for yours. Thinking models (qwen3, deepseek-r1) are timed over every token they emit, reasoning included.
By card
- 6 GB (RTX 2060, 3050 6GB, GTX 1660): q4_K_M up to about 16K context.
- 8 GB (RTX 3050 8GB, 4060, 3070): q4_K_M to 32K; q8_0 to about 16K.
- 12 GB (RTX 3060 12GB, 4070): q8_0 to 32K; fp16 to about 16K.
- 16 GB (4060 Ti 16GB, 4080, 5080): fp16 to 32K.
- 24 GB (3090, 4090): q4_K_M at the full 128K.
CPU and Apple Silicon
- 8 GB RAM / 8 GB Mac: q4_K_M with an 8K context, leaving about 4 GB for the OS.
- 16 GB RAM / 16 GB Mac: q8_0 at 32K, or q4_K_M at 64K.
- 32 GB: any build at any context.
Use the VRAM calculator to change the context length, and quantization explained for what q4_K_M and q8_0 mean.
Model Comparisons
| Model | Params | Ollama q4 file | MMLU | MATH | GSM8K | Licence |
|---|---|---|---|---|---|---|
| Phi-4 Mini | 3.8B | 2.5 GB | 67.3 | 64.0 | 88.6 | MIT |
| Phi-3.5 Mini | 3.8B | — | 65.5 | 49.8 | 76.9 | MIT |
| Llama 3.2 3B | 3B | — | 61.8 | 46.7 | 75.6 | Llama 3.2 Community |
| Qwen2.5 3B | 3B | — | 65.0 | 61.7 | 80.6 | Qwen Research |
| Qwen2.5 7B | 7.6B | 4.7 GB | 72.6 | 60.4 | 88.7 | Apache 2.0 |
| Llama 3.1 8B | 8B | — | 68.1 | 47.6 | 82.4 | Llama 3.1 Community |
| Gemma 2 9B | 9B | — | 71.3 | 51.3 | 84.9 | Gemma Terms |
Benchmark columns are Microsoft's numbers for every row (same model-card table as above), so they are comparable with each other but not with figures other vendors publish for their own models. File sizes are from the Ollama tag pages for phi4-mini and qwen2.5; the other rows are left blank rather than guessed.
If you have 8 GB of VRAM or more, Qwen2.5 7B is the stronger generalist in this table and costs 4.7 GB on disk. Phi-4 Mini wins on MATH and on the memory budget. The model recommender narrows it down by hardware.
Best Use Cases
Maths and step-by-step reasoning
The strongest rows in Microsoft's table are GSM8K (88.6) and MATH (64.0), and the card lists "strong reasoning (especially math and logic)" as a primary use. Word problems, unit conversions and worked solutions are the natural fit. For harder competition-style maths Microsoft later shipped Phi-4-mini-reasoning (see below).
Small-memory machines
A 2.5 GB file and a 128 KB-per-token KV cache mean the model fits a 6 GB GPU or an 8 GB laptop with context to spare. This is the use Microsoft names first on the model card: memory- and compute-constrained environments.
Function calling and lightweight agents
The model card and the Ollama library both note function-calling support from post-training. Paired with Ollama's tools API it can drive simple local automations where a 7B model would not fit.
Editor assistance with a small footprint
Phi-4 Mini runs alongside an IDE on an 8 GB machine. We do not quote a HumanEval score because Microsoft does not publish one in the comparison table; for coding-first work on the same budget, Qwen2.5 Coder 7B (4.7 GB) is the usual pick if you have the memory.
Frequently Asked Questions
What is Phi-4 Mini and how is it different from Phi-3.5 Mini?
Phi-4 Mini (Phi-4-mini-instruct) is Microsoft's 3.8-billion-parameter dense decoder model, released in February 2025 under the MIT licence with a 128K context. Microsoft's model card names three architectural changes versus Phi-3.5 Mini: a 200K-token vocabulary (200,064 entries), grouped-query attention, and shared input/output embeddings. It was trained on 5 trillion tokens of filtered public documents, synthetic "textbook-like" maths, coding and reasoning data, and chat-format supervised data, with a June 2024 data cutoff. On Microsoft's own table the gains over Phi-3.5 Mini are largest on maths and reasoning: GSM8K 88.6 vs 76.9, MATH 64.0 vs 49.8, BigBench Hard 70.4 vs 63.1, MMLU-Pro 52.8 vs 47.4. MMLU moves from 65.5 to 67.3.
Can Phi-4 Mini replace a 7B or 8B model?
On maths, yes, if you trust Microsoft's table: 64.0 on MATH beats the Llama-3.1-8B (47.6) and Qwen2.5-7B (60.4) columns of that table, and 88.6 on GSM8K is level with Qwen2.5-7B (88.7). On general knowledge, no: MMLU 67.3 sits below Llama-3.1-8B (68.1), Qwen2.5-7B (72.6) and Gemma2-9B (71.3), and GPQA 25.2 is the lowest in the table apart from Qwen2.5-3B. Treat it as a maths-and-reasoning-first small model, not a drop-in for an 8B generalist.
How much VRAM does Phi-4 Mini need?
The Ollama q4_K_M build is a 2.5 GB file; q8_0 is 4.1 GB; fp16 is 7.7 GB. The KV cache adds 128 KB per token of context (32 layers x 8 KV heads x 128 head dimension x 2 (K and V) x 2 bytes), so an 8K context costs about 1 GB and 32K about 4 GB. That arithmetic puts q4_K_M with an 8K context at roughly 4 GB, which fits a 6 GB card; q8_0 with 32K context at about 8.6 GB, which fits a 12 GB card; fp16 with 32K at about 12 GB, which fits 16 GB. On CPU or Apple Silicon, 8 GB of RAM covers the q4_K_M build with a short context.
Is Phi-4 Mini good for edge devices and mobile?
Microsoft lists "memory/compute constrained environments" and "latency bound scenarios" as the model's primary intended uses, and the 2.5 GB q4_K_M file and 128 KB-per-token KV cache are small by current standards. Microsoft also publishes ONNX Runtime builds for the Phi-4 family. We have not measured phone or Raspberry Pi throughput for this model, so this page gives no speed figures for those devices.
Phi-4 Mini vs Llama 3.2 3B vs Qwen2.5 3B: which small model is better?
On Microsoft's table Phi-4 Mini leads Llama-3.2-3B on every listed row (MMLU 67.3 vs 61.8, MATH 64.0 vs 46.7, GSM8K 88.6 vs 75.6, BBH 70.4 vs 55.4) and leads Qwen2.5-3B on all but ARC-C and GPQA, where the three models are within a point or two. On the multilingual rows the picture flips: Phi-3.5 Mini scores higher than Phi-4 Mini on Multilingual MMLU (51.8 vs 49.3), though Phi-4 Mini is far ahead on MGSM (63.9 vs 49.6). Licensing differs too: Phi-4 Mini is MIT, Llama 3.2 uses Meta's community licence, Qwen2.5-3B uses the Qwen Research licence.
How do I run Phi-4 Mini with Ollama?
Run "ollama run phi4-mini". That pulls the default tag (phi4-mini:latest, identical to phi4-mini:3.8b and phi4-mini:3.8b-q4_K_M, 2.5 GB) and opens a chat. The other published tags are phi4-mini:3.8b-q8_0 (4.1 GB) and phi4-mini:3.8b-fp16 (7.7 GB). There is no separate "instruct" tag on Ollama; every tag is the instruct model. The Ollama library lists the q8_0 and fp16 builds with a 4K default context, so set num_ctx yourself if you want more.
Advanced Deployment
Custom Modelfile for Phi-4 Mini
A Modelfile pins a system prompt and sampling parameters so you do not retype them. The parameters below are standard Ollama Modelfile keys; the context value is a choice, not a requirement.
# Save as Modelfile.phi4-maths
FROM phi4-mini
SYSTEM """You are a careful maths tutor. Show each step,
check the arithmetic, and state the final answer on its own line."""
PARAMETER temperature 0.2
PARAMETER num_ctx 8192
PARAMETER top_p 0.9
# Create and run:
# ollama create phi4-maths -f Modelfile.phi4-maths
# ollama run phi4-mathsMore Modelfile examples in the complete Ollama guide.
IDE integration (Continue.dev)
Point Continue.dev at the Ollama model for chat and tab completion on a machine that cannot hold a 7B model alongside the editor:
// .continue/config.json
{
"models": [{
"model": "phi4-mini",
"provider": "ollama",
"title": "Phi-4 Mini"
}],
"tabAutocompleteModel": {
"model": "phi4-mini",
"provider": "ollama"
}
}Other runtimes
- Transformers: load
microsoft/Phi-4-mini-instructdirectly; the model card's sample uses the chat template with bfloat16 weights (7.7 GB, the same as the Ollama fp16 build). - ONNX Runtime: Microsoft publishes ONNX builds of the Phi-4 family on Hugging Face for CPU, GPU and mobile targets; the model card's intended-use text names on-device scenarios.
- llama.cpp / GGUF: the Ollama files are GGUF, so any llama.cpp front end loads the same quantizations.
- Phones and single-board computers: the file sizes make it feasible, but we have not measured throughput on those devices and do not quote any here.
The Phi Model Family
Phi-4 Mini is the fifth generation of Microsoft's small-model line. The table keeps to release timing, size and the one claim each release is known for; MMLU is shown only where this page has a Microsoft-published figure from the same table.
| Model | Release | Params | MMLU (Microsoft table) | Notes |
|---|---|---|---|---|
| Phi-1 / Phi-1.5 | 2023 | 1.3B | — | "Textbooks are all you need": synthetic textbook data |
| Phi-2 | Dec 2023 | 2.7B | — | Same recipe scaled up; see our Phi-2 page |
| Phi-3 Mini | Apr 2024 | 3.8B | — | 4K and 128K context variants |
| Phi-3.5 Mini | Aug 2024 | 3.8B | 65.5 | Multilingual and 128K context |
| Phi-4 (14B) | Dec 2024 | 14B | — | Larger reasoning-focused sibling |
| Phi-4 Mini | Feb 2025 | 3.8B | 67.3 | 200K vocab, GQA, function calling |
Site pages for the earlier generations: Phi-2, Phi-3 Mini, Phi-3 Mini 128K, Phi-3.5 Mini, and the 14B Phi-4 local setup guide. The hardware requirements tutorial explains why the 3.8B size keeps recurring.
What came after Phi-4 Mini
Phi-4-mini-reasoning (April 2025)
Same 3.8B size, MIT licence and 128K context, fine-tuned on synthetic maths data generated by DeepSeek-R1. Microsoft's model card reports AIME 2024 57.5, MATH-500 94.6 and GPQA Diamond 52.0. If your use is maths, this is the model Microsoft now points to; it is on Ollama as phi4-mini-reasoning.
Phi-4-mini-flash-reasoning (June 2025)
A 3.8B hybrid "SambaY" architecture (state-space layers plus attention) with a 64K context. Microsoft's card claims up to 10x the throughput of Phi-4-mini-reasoning at 2K prompt / 32K generation; that is Microsoft's figure, not ours.
For general chat and knowledge at a similar memory budget, the newer small models on this site are covered in best Ollama models and best models for 8 GB RAM.
Bonus kit
Ollama Prompt Pack
170+ prompts for Phi-4 Mini and other Ollama models, with 15 Modelfiles included. Included with paid plans, or free after subscribing to both Local AI Master and Little AI Master on YouTube.
Ready to Go Beyond Tutorials?
25 structured courses with hands-on chapters - build RAG chatbots, AI agents, and ML pipelines on your own hardware.
Go from reading about AI to building with AI
25 structured courses. Hands-on projects. Runs on your machine. Start free.

Written by
Barsha Mohapatra
Founder and Editor, Local AI Master · Founder, Little AI Master
Founder of Little AI Master and the editor behind every course and guide on Local AI Master. Years of tutoring students taught her where AI education actually fails.
Related Guides
Continue your local AI journey with these comprehensive guides
- PILLARLocal AI Hardware Requirements (2026): Complete Guide
- AI Hardware Requirements: CPU, GPU and RAM for Beginners
- AI RAM Requirements 2026: How Much for 7B, 13B, 70B Models?
- AI Server Build Under $1,500: Parts List and What Fits
- AMD GPU Not Supported by ROCm? HSA_OVERRIDE Values
- AMD MI50 32GB for Local LLMs: The Used VRAM King, Honestly
- AMD Ryzen AI Max+ 395 (Strix Halo) for Local AI 2026
- Apple M4 for Local AI: Mac Studio + MacBook Guide (2026)
- Benchmark Your Local AI Setup: tok/s, TTFT, VRAM
- Best GPU for AI Video Generation: By VRAM Tier (2026)
Grab the AI Starter Kit — career roadmap, cheat sheet, setup guide
No spam. Unsubscribe with one click.
Found your model? Now build something with it.
25 hands-on courses — RAG, agents, fine-tuning — all running locally. First chapter free, no card.