Microsoft's Phi-4 Beats GPT-4o on Math Using a 14B Open Model
Microsoft's 14B open model beats GPT-4o on graduate-level science and math benchmarks, using synthetic data as its secret weapon
ProTakeaways
- Microsoft released Phi-4, a 14B open model under MIT license on Hugging Face
- Beats teacher model GPT-4o on GPQA (56.1) and MATH (80.4) benchmarks
- Outperforms Qwen-2.5-14B-Instruct on 9 of 12 benchmarks tested
- Trained on 9.8T tokens using 1920 H100 GPUs over 21 days
- Weak spots: SimpleQA factual recall (3.0), IFEval instruction following, English-only
- Recipe centers on synthetic textbook-style data plus SFT and iterative DPO
Microsoft Research has quietly dropped Phi-4 onto Hugging Face under an MIT license, and the numbers are hard to ignore. A 14-billion parameter dense transformer outscores its own teacher (GPT-4o) on graduate-level science questions and competition math, while fitting comfortably on a single high-end GPU. The interesting part is the recipe: Phi-4 is built almost entirely around the idea that synthetic, textbook-style training data can beat scraping more of the open web.
Small model, frontier scores
Phi-4 is a 14B parameter, decoder-only transformer with a 16K context window, released under an MIT license, so commercial use has essentially no strings attached. On Microsoft's own evaluation table, it beats every other model in its weight class and punches into 70B+ territory on reasoning tasks.
Highlights from the technical report:
- GPQA (graduate-level science): 56.1 vs 50.6 for GPT-4o and 49.0 for Qwen 2.5 72B
- MATH (competition math): 80.4 vs 74.6 for GPT-4o
- HumanEval (code): 82.6, higher than any open-weight model tested, including much larger Llamas
- MMLU: 84.8, close to GPT-4o's 88.1 despite being roughly an order of magnitude smaller
- MGSM (multilingual grade-school math): 80.6
Phi-4 outperforms the closest in-class contemporary, Qwen-2.5-14B-Instruct, on 9 of 12 benchmarks. On GPQA and MATH, it also outscores its teacher model, GPT-4o. A small model beating the frontier model it was distilled from, on the exact domains where reasoning matters most, suggests the training pipeline is doing more than distillation.
Data quality as the whole game
Phi-4 is a bet that pretraining data curation matters more than raw scale. Most language models are pretrained primarily on organic sources such as web content and code. Phi-4 strategically incorporates synthetic data throughout the training process. Earlier Phi models largely distilled the capabilities of a GPT-4 teacher, but Phi-4 substantially surpasses that teacher on STEM-focused QA, evidence that its data-generation and post-training techniques push past distillation.
The training data comes from four buckets:
- Filtered public web documents and code
- Newly generated synthetic "textbook-like" data for math, coding, common sense, and world knowledge
- Acquired academic books and Q&A datasets
- Chat-format supervised data targeting instruction-following, honesty, and helpfulness
Multilingual content makes up only about 8% of the mix, a deliberate trade for English reasoning quality. The team ran ablations on the ratio between synthetic, filtered web, and web-rewrite clusters, holding acquired and code data constant, to land on the final blend.
Inside the training run
The pretraining setup is unusually detailed for a model card. Phi-4 was pretrained for approximately 10T tokens using linear warm-up and decay schedules with a peak learning rate of 0.0003, constant weight decay of 0.1, and a global batch size of 5760. Hyperparameters were tuned via interpolations from shorter-horizon runs, then adjusted by stress-testing the learning rate warm-up stage for stability.
Total compute: 1920 H100-80G GPUs for 21 days on 9.8T tokens. That is a fraction of what a 70B+ model typically consumes, and it lands close to GPT-4o on MMLU.
Post-training uses supervised fine-tuning plus iterative Direct Preference Optimization (DPO), a preference-learning method that trains the model to prefer better responses over worse ones without needing a separate reward model. The team also traded raw benchmark scores for user experience in at least one place: the base model outscored Qwen-2.5-14B-Instruct on SimpleQA, and they intentionally modified behavior in post-training to optimize for user experience over the leaderboard number.
Where it falls down
Phi-4 is not a general-purpose GPT-4o replacement. Its weakest benchmark scores show up on SimpleQA, DROP, and IFEval. The team argues the first two are reductive measurements that undersell the model's actual behavior on those problems. IFEval, however, reveals a real weakness: the model struggles to strictly follow instructions.
Concretely, that means:
- Factual recall is weak: SimpleQA score of 3.0 vs 39.4 for GPT-4o. Do not use this as a knowledge oracle without RAG.
- Strict instruction following is spotty: if your pipeline depends on exact JSON schemas or rigid formats, test carefully.
- Code coverage is narrow: training data is Python-heavy and leans on standard-library packages like
typing,math,random,collections,datetime, anditertools. Other languages and third-party libs need human review. - English-only: quality degrades outside English, and multilingual deployment is not intended.
Running it
The model is a straight Transformers-compatible checkpoint. Minimal chat setup:
from transformers import pipeline
pipe = pipeline("text-generation", model="microsoft/phi-4",
model_kwargs={"torch_dtype": "auto"}, device_map="auto")
messages = [{"role": "user", "content": "Prove that sqrt(2) is irrational."}]
print(pipe(messages, max_new_tokens=512)[0]["generated_text"][-1])
Phi-4 uses a specific chat template with <|im_start|> and <|im_sep|> tokens, so apply the tokenizer's chat template rather than hand-rolling prompts. It runs out of the box in vLLM and SGLang for OpenAI-compatible serving, and quantized GGUF builds exist for llama.cpp, Ollama, and LM Studio, so a 4-bit version fits on a laptop with 12 to 16 GB of memory.
Where it actually fits
Microsoft is explicit about the target use cases: memory- or compute-constrained environments, latency-sensitive scenarios, and reasoning-heavy workloads. That maps to:
- Local math and coding assistants on developer laptops, without shipping code to an API
- STEM tutoring and step-by-step problem solving, where GPQA and MATH scores actually matter
- Edge and on-prem reasoning agents where a 70B model is too expensive but you still need real chain-of-thought quality
- Synthetic data generation for training smaller, task-specific models
- RAG backends where the retrieval layer handles facts and Phi-4 handles reasoning over them
The bigger shift
Phi-4 adds to a growing pile of evidence that the scaling curve is no longer the only lever left. The Phi team has since extended the recipe with dedicated reasoning variants: the Phi-4-reasoning report describes 14B models trained to reason step by step through math, science, and coding. Phi-4-reasoning and Phi-4-reasoning-plus match or exceed the accuracy of DeepSeek-R1, DeepSeek-R1-Distill-Llama-70B, and o1/o3-mini on math reasoning, at 14B parameters. Transfer to untargeted domains also shows up: over 25% improvement on coding (LiveCodeBench) and 30% to 60% gains on algorithmic and planning problems (Traveling Salesman, Satisfiability, Calendar Planning), none of which were fine-tuning targets.
The assumption worth updating: a 14B open-weight model with the right data can now sit in the same conversation as frontier closed models on hard reasoning, at a fraction of the serving cost. If you have been defaulting to a paid API for math, code, and STEM Q&A, Phi-4 is worth a serious A/B test on your workload.