★ Reading this for free? Get 25 structured AI courses + per-chapter AI tutor — the first chapter of every course free, no card.Start free in 30 secondsOr own every course: $149 once
3.8B parametersMIT licence128K context2.5 GB on Ollama

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.

📅 Published: March 19, 2026🔄 Last Updated: October 15, 2026✓ Manually Reviewed

Overview

Parameters
3.8B
Dense decoder-only Transformer
Ollama download
2.5 GB
phi4-mini:latest (q4_K_M)
Context
128K
131,072 positions in config.json
MMLU (5-shot)
67.3
Microsoft's model-card table
Licence
MIT
Commercial use allowed
Released
Feb 2025
Microsoft; data cutoff June 2024

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.

BenchmarkPhi-4 MiniPhi-3.5 MiniLlama 3.2 3BQwen2.5 3BQwen2.5 7BLlama 3.1 8BGemma 2 9B
MMLU (5-shot)67.365.561.865.072.668.171.3
MMLU-Pro (0-shot, CoT)52.847.439.244.756.244.050.1
GSM8K (8-shot, CoT)88.676.975.680.688.782.484.9
MATH (0-shot, CoT)64.049.846.761.760.447.651.3
GPQA (0-shot, CoT)25.226.624.323.430.626.339.1
ARC-Challenge (10-shot)83.784.676.182.690.183.189.8
BigBench Hard (0-shot, CoT)70.463.155.456.272.463.465.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-mini

The 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 tagFileListed contextMemory at 8K ctxMemory at 32K ctxFits on
3.8b-q4_K_M (= latest, 3.8b)2.5 GB128K~4 GB~6.5 GB6 GB card; 8 GB RAM on CPU/Mac
3.8b-q8_04.1 GB4K~5.6 GB~8.6 GB8 GB card (short context); 12 GB for 32K
3.8b-fp167.7 GB4K~9.2 GB~12.2 GB12 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)ParamsQuantFileMeasured tok/sRun spreadCeilingShareDate
llama3.2:3b3.2BQ4_K_M2.02 GB55.054.9–55.17474%2026-10-14
qwen2.5-coder:3b-base3.1BQ4_K_M1.93 GB54.053.6–54.37869%2026-10-14
phi4-mini3.8BQ4_K_M2.49 GB46.344.0–46.46077%2026-10-14
qwen3:4b4.0BQ4_K_M2.50 GB43.242.4–43.26072%2026-10-14
mistral:7b7.2BQ4_K_M4.37 GB28.528.4–28.63483%2026-10-15
qwen2.5-coder:7b7.6BQ4_K_M4.68 GB28.027.8–28.23287%2026-10-15
llama3.1:8b8.0BQ4_K_M4.92 GB26.826.2–26.93088%2026-10-14
qwen3:8b8.2BQ4_K_M5.23 GB24.924.7–24.92987%2026-10-15
deepseek-r1:8b8.2BQ4_K_M5.23 GB24.824.6–25.02986%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

ModelParamsOllama q4 fileMMLUMATHGSM8KLicence
Phi-4 Mini3.8B2.5 GB67.364.088.6MIT
Phi-3.5 Mini3.8B—65.549.876.9MIT
Llama 3.2 3B3B—61.846.775.6Llama 3.2 Community
Qwen2.5 3B3B—65.061.780.6Qwen Research
Qwen2.5 7B7.6B4.7 GB72.660.488.7Apache 2.0
Llama 3.1 8B8B—68.147.682.4Llama 3.1 Community
Gemma 2 9B9B—71.351.384.9Gemma 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-maths

More 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-instruct directly; 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.

ModelReleaseParamsMMLU (Microsoft table)Notes
Phi-1 / Phi-1.520231.3B—"Textbooks are all you need": synthetic textbook data
Phi-2Dec 20232.7B—Same recipe scaled up; see our Phi-2 page
Phi-3 MiniApr 20243.8B—4K and 128K context variants
Phi-3.5 MiniAug 20243.8B65.5Multilingual and 128K context
Phi-4 (14B)Dec 202414B—Larger reasoning-focused sibling
Phi-4 MiniFeb 20253.8B67.3200K 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.

See Plans →

Ready to Go Beyond Tutorials?

25 structured courses with hands-on chapters - build RAG chatbots, AI agents, and ML pipelines on your own hardware.

🎯
AI Learning Path

Go from reading about AI to building with AI

25 structured courses. Hands-on projects. Runs on your machine. Start free.

Or own it for life — Lifetime $149 $599, pay once
Barsha Mohapatra

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.

More on Local AI Hardware
See the full AI Hardware Guide 2026 guide.
📚
Free · no account required

Grab the AI Starter Kit — career roadmap, cheat sheet, setup guide

No spam. Unsubscribe with one click.

🎯
AI Learning Path

Found your model? Now build something with it.

25 hands-on courses — RAG, agents, fine-tuning — all running locally. First chapter free, no card.

Or own it for life — Lifetime $149 $599, pay once
Free Tools & Calculators