Skip to main content
Back

Microsoft's Phi-4-mini Beats 8B Rivals at Reasoning With Half the Parameters

Microsoft's 3.8B parameter Phi-4-mini-instruct packs 128K context, function calling, and surprisingly strong math into an edge-friendly open model.

Pro

  • Microsoft's Phi-4-mini-instruct is a 3.8B parameter dense decoder-only Transformer, MIT licensed.
  • Supports 128K context, 24 languages, and native function calling via tagged JSON tool schemas.
  • Scores 88.6 on GSM8K and 64.0 on MATH, matching or beating 7-8B competitors.
  • Trained on 5T tokens over 21 days on 512 A100-80G GPUs, cutoff June 2024.
  • Weak on factual recall (GPQA 25.2); best paired with RAG for knowledge tasks.
  • Works with transformers 4.49+, vLLM, SGLang, ONNX; see the technical report.

Microsoft's Phi-4-mini-instruct is a 3.8B parameter open model built for latency-sensitive and memory-constrained deployments where running a 70B model is off the table. It ships under an MIT license with a 128K token context window, continuing the Phi series philosophy of squeezing strong reasoning performance out of a small parameter count.

What's inside

Phi-4-mini-instruct is a dense decoder-only Transformer trained on 5 trillion tokens of synthetic and filtered public data, with an emphasis on reasoning-dense content. Compared to Phi-3.5-mini, the major architectural changes are a 200,064-token vocabulary, grouped-query attention, and shared input/output embeddings. Grouped-query attention, where multiple query heads share a single key/value head, cuts KV-cache memory during inference, which is what makes a 128K context tractable on modest hardware. The larger vocabulary is what unlocks reasonable multilingual behavior across 24 supported languages. Training ran on 512 A100-80G GPUs over 21 days, with a data cutoff of June 2024. The model was then refined through supervised fine-tuning and direct preference optimization for instruction adherence and safety.

Where it punches above its weight

On math and reasoning benchmarks, Phi-4-mini-instruct competes with models nearly twice its size:

  • GSM8K (8-shot CoT): 88.6, matching Qwen2.5-7B-Instruct (88.7) and ahead of Llama-3.1-8B (82.4)
  • MATH (0-shot CoT): 64.0, ahead of Qwen2.5-7B (60.4) and well above Llama-3.1-8B (47.6)
  • BigBench Hard: 70.4, versus 63.4 for Llama-3.1-8B
  • MMLU-Pro: 52.8, versus 44.0 for Llama-3.1-8B
  • MGSM (multilingual math): 63.9, up from 49.6 for Phi-3.5-mini

The overall average across Microsoft's internal benchmark suite is 63.5, edging out Llama-3.1-8B-Instruct at 62.3 with roughly half the parameters. Function calling is also native: a <|tool|> tagged system prompt accepts JSON tool schemas, so agent workflows are baked in rather than bolted on through fine-tuning.

Known failure modes

Microsoft is candid about the tradeoffs. At 3.8B parameters, the model has limited capacity to store factual knowledge, which shows up in GPQA at 25.2 (near random for a 4-choice test) and HellaSwag at 69.1, trailing smaller Qwen and Llama variants. Augmenting with retrieval via RAG is the recommended workaround for factual workloads.

Red-teaming surfaced two additional failure modes worth planning around: language-specific attack prompts that exploit cultural context can bypass safety training, and in function calling scenarios the model can hallucinate function names or URLs. Long multi-turn conversations are also flagged as a source of behavioral drift.

Why the data mix looks this way

The training recipe follows the Phi pattern of quality-obsessed curation over raw scale. Trivia content like sports results was explicitly filtered out to free capacity for reasoning signal. The remaining mix combines filtered public documents, code, and large volumes of synthetic "textbook-like" data targeting math, coding, and common sense reasoning. That tradeoff explains the model's strong reasoning scores alongside its weaker world-knowledge results. Full methodology is in the Phi-4-Mini Technical Report.

Getting it running

Phi-4-mini-instruct integrates with transformers 4.49.0, vLLM 0.7.3+, and SGLang. A minimal vLLM server:

pip install vllm
vllm serve "microsoft/Phi-4-mini-instruct"

Or directly with transformers:

from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("microsoft/Phi-4-mini-instruct")
model = AutoModelForCausalLM.from_pretrained(
    "microsoft/Phi-4-mini-instruct",
    device_map="auto", torch_dtype="auto", trust_remote_code=True,
)
msgs = [{"role": "user", "content": "Solve 2x + 3 = 7"}]
inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
print(tok.decode(model.generate(inputs, max_new_tokens=200)[0]))

Flash Attention is enabled by default and requires A100, A6000, or H100 class GPUs. On V100 or older hardware, pass attn_implementation="eager". An ONNX build is available for CPU and edge deployment, and Intel has published throughput benchmarks running it on Arc GPUs and Core Ultra AI PCs via OpenVINO.

Good fits and bad fits

Microsoft targets three deployment scenarios: memory or compute-constrained environments, latency-bound applications, and structured reasoning tasks. In practice:

  • On-device and edge agents where a 7B or 8B model is too heavy but tool calling is still required
  • RAG pipelines where the model reasons over retrieved context rather than serving as a knowledge store
  • Math and structured extraction workloads that benefit from strong chain-of-thought at small scale
  • Fine-tuning bases, with 118 fine-tunes and 173 quantizations already published by the community

The gap between 3-4B and 7-9B models on reasoning-heavy tasks keeps shrinking as synthetic data pipelines get better at packing useful signal per token. For evaluation suites dominated by trivia, a larger model still wins. For structured reasoning and instruction following, a 3.8B model that fits on a single consumer GPU is now a legitimate production option.