Phi-4-mini-instruct

Updated
05.10.2026
Reasoning
Code
Multilingual
Tools

A 3.8B-parameter open instruct model from Microsoft’s Phi-4 family with 128K context, strong math and reasoning, and function calling.

At a glance

  • License: MIT
  • Parameters: 3.8B, dense decoder-only
  • Context length: 128K tokens
  • Modalities: Text input, text output
  • Minimum hardware: 4 GB of memory, the Q4_K_M GGUF is a 2.49 GB file

What is Phi-4-mini-instruct?

Phi-4-mini-instruct is a 3.8B dense decoder-only model from Microsoft and the small text model of the Phi-4 family. Microsoft trained it on 5 trillion tokens of synthetic and filtered public web data weighted toward reasoning-dense material, then post-trained it with supervised fine-tuning and direct preference optimization for instruction following. It shipped in February 2025 under the MIT license, and it is one of the easiest open models to run locally: the Q4_K_M build is 2.49 GB.

SpecificationPhi-4-mini-instruct
Parameters3.8B (3,836,021,760)
ArchitectureDense decoder-only Transformer
AttentionGrouped-query attention, flash attention by default
EmbeddingsInput and output embeddings shared
Vocabulary200,064 tokens, spare slots for fine-tuning
Context window128K tokens
ModalitiesText input, text output
Languages23 supported, Arabic to Ukrainian
Function callingSupported, tools declared as JSON in the system prompt
Training data5T tokens, cutoff June 2024
Training run512 A100-80G GPUs, 21 days, late 2024
Post-trainingSupervised fine-tuning, direct preference optimization
Release dateFebruary 2025
LicenseMIT

The 200K vocabulary, grouped-query attention and shared input and output embeddings are the three architecture changes Microsoft names over Phi-3.5-mini; the larger vocabulary is there for multilingual coverage across the 23 languages. The corpus was curated rather than scraped: public documents were filtered to a preferred level of knowledge, with trivia dropped to leave capacity for reasoning, then decontaminated by n-gram matching against the benchmarks. Microsoft is also direct about the limit of the size: a 3.8B model cannot store much factual knowledge, so the card itself recommends pairing it with a search engine or RAG when facts matter.

Phi-4-mini-instruct benchmarks

Microsoft published its own comparison, run on an internal benchmark platform, against instruct models of similar size, including the predecessor Phi-3.5-mini, plus Qwen2.5-7B from its 2x size class:

BenchmarkPhi-4-mini-instructPhi-3.5-miniLlama-3.2-3BQwen2.5-3BQwen2.5-7B
MMLU
General knowledge
67.365.561.865.072.6
MMLU-Pro
Academic knowledge
52.847.439.244.756.2
BigBench Hard
Hard reasoning
70.463.155.456.272.4
ARC Challenge
Science reasoning
83.784.676.182.690.1
TruthfulQA
Grounded reasoning
66.465.259.264.369.4
GSM8K
Grade-school math
88.676.975.680.688.7
MATH
Competition math
64.049.846.761.760.4
MGSM
Multilingual math
63.949.644.653.564.5

Against models its own size it takes seven of these eight rows, widest in math: 88.6 on GSM8K and 64.0 on MATH. Only ARC Challenge goes the other way, 83.7 against 84.6. Qwen2.5-7B leads at almost twice the parameters, but the mini takes MATH outright and is within a point on GSM8K and MGSM.

Across the full 17-benchmark table Microsoft reports an overall average of 63.5, against 60.5 for Phi-3.5-mini and 56.2 for Llama-3.2-3B. Its own summary is that the 3.8B model "achieves a similar level of multilingual language understanding and reasoning ability as much larger models", and it names three target uses: constrained memory and compute, latency bound scenarios, and reasoning that leans on math and logic. The rows outside the table show the cost against Phi-3.5-mini: 69.1 on HellaSwag against 72.2, 67.0 on Winogrande against 72.2, and 49.3 on Multilingual MMLU against 51.8.

Phi-4-mini-instruct hardware requirements

The system requirement to check is memory. The GGUF builds below are published as unsloth/Phi-4-mini-instruct-GGUF, and even the full-precision file is small by local-model standards:

MemoryBuild to pickFile size
2 GBQ2_K1.68 GB
3 GBQ3_K_M2.12 GB
4 GBQ4_K_M2.49 GB
5 GBQ5_K_M2.85 GB
6 GBQ6_K3.16 GB
8 GBQ8_04.08 GB
16 GB and upBF167.68 GB

The quantized builds sit less than a gigabyte apart, so when two of them fit, take the larger one. That matters most at the bottom: Q2_K saves only 0.81 GB over Q4_K_M, and Q2_K_L in the same repo is the same 1.68 GB, so take the 2-bit files only on a machine that cannot spare 4 GB.

To run the original weights, Microsoft names vLLM 0.7.3 or newer and Transformers 4.49.0, both with torch 2.5.1 and flash_attn 2.7.4.post1, and its sample scripts decode greedily at temperature 0.0. Flash attention is on by default and needs a recent NVIDIA card: A100, A6000 and H100 are the tested ones, V100 or older needs attn_implementation set to eager. If the format is new to you, start with what GGUF is, and see the best local LLMs for a 16 GB Mac for what else fits alongside it.

How to run Phi-4-mini-instruct in Atomic Chat

Atomic Chat is a free local app for macOS, Windows and Linux. It includes a Hugging Face model browser and a built-in chat, with no manual llama.cpp build required.

  1. Download Atomic Chat for your platform and open it.
  2. Search for Phi-4-mini-instruct in the model browser and open Download Options.
  3. Pick the build that fits the memory you have, then start a chat.

For the rest of the family, see every Phi model you can run locally, or the full-size Phi-4.

Phi-4-mini-instruct license

Phi-4-mini-instruct is released under the MIT license, one of the most permissive licenses an open model ships with. It permits commercial use, modification and redistribution with no royalties, so you can build products on top of it and run it on your own hardware without a usage fee. Microsoft states one carve-out separately: the grant covers the model, not its trademarks and logos, so modified versions must not imply Microsoft sponsorship.

Get the weights from Hugging Face

pip install -U transformers accelerate
huggingface-cli download microsoft/Phi-4-mini-instruct
# or run with Ollama:
ollama run phi4-mini
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "microsoft/Phi-4-mini-instruct",
    "messages": [{"role": "user", "content": "What is 17 * 24?"}]
  }'
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-mini-instruct", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-mini-instruct")
messages = [{"role": "user", "content": "Explain gradient descent in one paragraph."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
print(tokenizer.decode(model.generate(inputs, max_new_tokens=256)[0]))
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "http://localhost:8000/v1", apiKey: "not-needed" });
const res = await client.chat.completions.create({
  model: "microsoft/Phi-4-mini-instruct",
  messages: [{ role: "user", content: "Write a haiku about compilers." }],
});
console.log(res.choices[0].message.content);
Desktop
macOS
(Intel and Apple Silicon)
Download
Windows
(x64)
Download
Windows
(ARM64)
Download
Linux
(x86_64)
Download

Frequently asked questions

Phi-4-mini-instruct has 3.8 billion parameters. It is a dense decoder-only Transformer that uses grouped-query attention and a 200K-token vocabulary, which keeps it small enough to run on modest hardware while still matching the quality of several larger models on reasoning and math benchmarks.

Phi-4-mini-instruct supports a 128K-token context window. That is large enough to process long documents, multi-turn conversations, or sizeable code files in a single prompt, which is unusual for a model of its size.

Yes. Microsoft released Phi-4-mini-instruct under the MIT license, which permits commercial and research use, modification, and redistribution with minimal restrictions. The weights are downloadable for free from Hugging Face and are also available through Azure AI Foundry, Ollama, and NVIDIA NIM.

Because it has only 3.8B parameters, Phi-4-mini-instruct runs comfortably on consumer hardware. A 4-bit quantized build needs roughly 3 to 4 GB of VRAM, so an 8 GB GPU has plenty of headroom. The full-precision model fits in about 8 to 9 GB. It also runs on CPU through llama.cpp or Ollama, though more slowly. Note that the default build uses flash attention and expects an Ampere-class or newer GPU; on older cards load it with attn_implementation set to eager.

Yes. Function calling is a headline addition in the Phi-4-mini release. You declare the available tools as JSON inside the system prompt, wrapped in the model's tool tokens, and it returns structured calls. Microsoft notes that in some function-calling scenarios the model can occasionally hallucinate function names or URLs, so validating the returned calls before executing them is recommended.