Microsoft’s Phi-4 Reasoning Fashions Defined Merely

Microsoft isn’t like OpenAI, Google, and Meta; particularly not in relation to giant language fashions. Whereas different tech giants favor to launch a number of fashions virtually overwhelming the customers with selections; Microsoft launches a number of, however these fashions at all times make it huge amongst builders around the globe. Of their newest launch, they’ve launched 2 reasoning fashions: Phi-4-Reasoning and Phi-4-Reasoning-plus, each skilled on the bottom Phi-4 mannequin. The 2 Phi-4-Reasoning fashions compete with the mighty fashions like o1, o3-mini, and DeepSeek R1. On this weblog, we’ll dive into the technical particulars, structure, coaching strategies, and efficiency of Phi-4-Reasoning fashions intimately. 

Let’s discover the Phi-4-Reasoning fashions. 

What’s Phi-4 Reasoning?

Phi-4 will not be new within the LLM world. This small and mighty language fashions broke the web when it was launched final yr. Now to cater to the growing demand for reasoning fashions, Microsoft has launched Phi-4-Reasoning fashions. These are 14 B parameters that excel at performing advanced reasoning duties involving arithmetic, coding, and STEM questions. Unline its common function Phi-4 sequence, Phi-4-Reasoning is particularly optimized for long-chain reasoning – that’s the capability to interrupt down advanced multi-step issues systematically into logical steps.

Additionally Learn: Phi-4: Redefining Language Fashions with Artificial Information

Phi 4 Reasoning Fashions

The 2 reasoning fashions launched by Microsoft are:

  • Phi-4-Reasoning:  A reasoning mannequin skilled utilizing supervised fine-tuning or SFT on high-quality datasets. The mannequin is most well-liked for all duties that require quicker responses with guided efficiency constraints. 
  • Phi-4-Reasoning-Plus: An enhanced reasoning mannequin that has been enhanced utilizing reinforcement studying or RL to enhance its efficiency however generates virtually 50% extra tokens in comparison with its counterpart. The mannequin reveals an elevated latency and therefore is advisable for high-accuracy duties.  

The 2 14B fashions at present help solely textual content enter, and Microsoft has launched them as open-weight so builders can freely take a look at and fine-tune them primarily based on their wants. Listed here are some key highlights of the fashions:

Particulars Phi-4-Reasoning Fashions
Developer Microsoft Analysis
Mannequin Variants Phi-4-Reasoning, Phi-4-Reasoning-Plus
Base Structure Phi-4 (14B parameters), dense decoder-only Transformer
Coaching Methodology Supervised fine-tuning on chain-of-thought knowledge; Plus variant consists of extra Reinforcement Studying (RLHF)
Coaching Length 2.5 days on 32× H100-80G GPUs
Coaching Information 16B tokens complete (~8.3B distinctive), from artificial prompts and filtered public area knowledge
Coaching Interval January – April 2025
Information Cutoff March 2025
Enter Format Textual content enter, optimized for chat-style prompts
Context Size 32,000 tokens
Output Format Two sections: reasoning chain-of-thought block adopted by a summarization block
Launch Date April 30, 2025

Key Options of Phi-4-Reasoning Fashions

For Phi-4 the staff took a number of revolutionary steps involving knowledge choice, its coaching methodology in addition to its efficiency. A number of the key issues they did have been:

Information Centric Coaching 

The Information Curation for coaching the Phi-4 reasoning fashions relied not simply on sheer amount however emphasised equally on the standard of knowledge too. They particularly selected the information that was on the “edge” of the mannequin’s capabilities. This ensured that the coaching knowledge was solvable however not simply.  

The principle steps concerned in constructing the information set for Phi-4 fashions have been:

  • Seed Database: The Microsft staff began with publicly out there datasets like AIME and GPQA. These knowledge units concerned issues in algebra and geometry involving multi-step reasoning. 
  • Artificial Reasoning Chains: To get complete and detailed step-by-step reasoned-out responses for the issues, the Microsoft staff relied on OpenAI’s o3-mini mannequin. 

For instance, for the query “What’s the spinoff of sin(x2 )2?”; o3-mini gave the next output:

Step 1: Apply the chain rule: d/dx sin(u)=cos(u)*du/dx.  

Step 2: Let u=x² ⇒ du/dx=2x. 

Ultimate Reply: cos(x²) * 2x.

These artificially or synthetically generated chains of well-reasoned responses gave a transparent blueprint on how a mannequin ought to construction its personal reasoning responses. 

  • Deciding on “Teachable Moments”: The developer staff, knowingly went for prompts that challenged the bottom Phi-4 mannequin whereas being solvable. These included issues on which Phi-4 initially confirmed round 50-% accuracy. This strategy ensured that the coaching course of averted “straightforward” knowledge that simply bolstered present patterns, and targeted extra on “structured reasoning”.

The staff basically needed the Phi-4-reasoning fashions to study as they do, an strategy that we people often depend on. 

Supervised Superb-Tuning (SFT)

Supervised Superb-Tuning (SFT) is the method of bettering a pre-trained language mannequin by coaching it on rigorously chosen enter–output pairs with high-quality responses. For the Phi-4-Reasoning fashions, this meant beginning with the bottom Phi-4 mannequin after which refining it utilizing reasoning-focused duties. Basically, Phi-4-Reasoning was skilled to study and comply with the step-by-step reasoning patterns seen in responses from o3-mini.

Coaching Particulars

  • Batch Measurement: It was stored at 32. This small batch dimension allowed the mannequin to deal with particular person examples with out being overwhelmed by the extra noise. 
  • Studying price: This was 7e-5, a average price that avoids overshooting the optimum weights throughout updates.
  • Optimizer: A normal “Adam W” optimizer was used. This deep studying optimizer balances pace and stability. 
  • Context Size:  It was taken to 32,768 tokens which was double the 16K token restrict of the bottom Phi-4 mannequin. This allowed the mannequin to deal with an extended context. 

Utilizing SFT throughout early coaching allowed the mannequin to make use of <considering> and </considering> tokens to separate uncooked enter from its inside reasoning. This construction made its decision-making course of clear. Additionally, the mannequin confirmed regular enhancements on the AIME benchmarks proving that the mannequin was not simply copying codecs however was constructing reasoning logic. 

Reinforcement Studying

Reinforcement studying is educating a mannequin find out how to do higher with suggestions on all its generated outputs. The mannequin will get a reward each time it solutions accurately and is punished every time it responds incorrectly. RL was used to additional prepare the Phi-4-Reasoning -Plus mannequin. This coaching methodology refined the mannequin’s math-solving expertise which evaluated the responses for accuracy and the structured strategy. 

How does RL work?

  • Reward Design: The mannequin bought +1 for every right response and -0.5 for incorrect response. The mannequin bought punished for repetitive phrases “Let’s see.. Let’s see..” and many others. 
  • Algorithm: The GRPO algorithm or generalized reward coverage optimization algorithm, which is a variant of RL that balances exploration and exploitation was used. 
  • Outcomes: Phi-4-Reasoning-Plus achieved 82.5% accuracy on AIME 2025 whereas Phi-4 Reasoning scored simply 71.4%. It confirmed improved efficiency on Omni-MATH and TSP (touring Salesman Drawback) too. 

RL coaching allowed the mannequin to refine its steps iteratively and helped scale back the “hallucinations” within the generated outputs. 

Structure of Phi-4-Reasoning Fashions

The principle structure of the Phi-4-Reasoning fashions is much like the bottom Phi-4 mannequin however to help the “reasoning” duties some key modifications have been made. 

  1. The 2 placeholder tokens from Phi-4 have been repurposed. These tokens helped the mannequin to distinguish between uncooked enter and inside reasoning.
    • <considering>: Used to mark the beginning of a reasoning block.
    • </considering>: Used to mark the top of a reasoning block. 
  2. The Phi-4 Reasoning fashions bought an prolonged context window of 32 Okay tokens to deal with the additional reasoning chains. 
  3. The fashions used rotary place embeddings to higher monitor the place of tokens in lengthy sequences to assist the fashions preserve coherency.
  4. The fashions are skilled to work effectively on shopper {hardware} together with units like mobiles, tablets and desktops.

Phi-4-Reasoning Fashions: Benchmark Efficiency 

Phi-4-Reasoning fashions have been evaluated on numerous benchmarks to check their efficiency towards totally different fashions on various duties.  

  • AIME 2025: A benchmark that assessments superior math, reasoning, and up to date examination problem. Phi-4-Reasoning Plus outperforms a lot of the top-performing fashions like o1, and Claude 3.7 Sonnet however remains to be behind o3-mini-high. 
  • Omni-MATH: A benchmark that evaluates various math reasoning throughout subjects and ranges. Each Phi-4-Reasoning and Phi-4-Reasoning plus outperform virtually all fashions solely behind DeepSeek R1.
  • GPQA: A benchmark that assessments mannequin efficiency on graduate-level skilled QA reasoning. The 2 Phi reasoning fashions lag behind the giants like o1, o3-mini excessive and DeepSeek R1.
  • SAT: A benchmark that evaluates U.S. excessive school-level tutorial reasoning (math + verbal mix). The Phi-4-Reasoning-Plus mannequin stands among the many high 3 contenders with Phi-4-Reasoning following shut behind.
  • Maze: This benchmark assessments navigation + resolution pathfinding reasoning. On this benchmark, the Phi-4-reasoning fashions lag behind the top-tier fashions like o1 and Claude 3.7 sonnet.

On different benchmarks like Spatial map, TSP, and BA calendar, each the Phi-4-Reasoning fashions carry out decently. 

Additionally Learn: Learn how to Superb-Tune Phi-4 Domestically?

Learn how to Entry Phi-4-Reasoning Fashions?

The 2 Phi-4-Reasoning fashions can be found on Hugging Face:

Click on on the hyperlinks to move to the cuddling face web page the place you possibly can entry these fashions. On the correct aspect nook of the display, click on on “Use This Mannequin”, click on on “Transformers” and replica the next code:

# Use a pipeline as a high-level helper
from transformers import pipeline

messages = [
    {"role": "user", "content": "Who are you?"},
]

pipe = pipeline("text-generation", mannequin="microsoft/Phi-4-reasoning")
pipe(messages)

Since it’s a 14B parameter mannequin and therefore requires round 40 + GB of VRAM (GPU), You possibly can both run these fashions on “Colab Professional” or “Runpod”. For this weblog, we ran the mannequin on “Runpod” and used “A100 GPU”. 

Set up Required Libraries

First, guarantee you’ve gotten the transformer’s library put in. You possibly can set up it utilizing pip:

pip set up transformers

Load the Mannequin

As soon as all of the libraries have been put in, now you can load the Phi-4-Reasoning mannequin in your pocket book:

# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", mannequin="microsoft/Phi-4-reasoning", max_new_tokens=4096)

Ensure that to set the max_new_tokens = 4096, the mannequin generates its total reasoning and sometimes lesser token rely can cease its output halfway.

Phi-4-Reasoning: HandsOn Functions

We are going to now take a look at the Phi-4-reasoning fashions for 2 duties involving Logical Pondering and Reasoning. Let’s begin.

Job 1: Logical Pondering

Enter:

messages = [

    {"role": "user", "content": """A team is to be selected from among ten persons — A, B, C, D, E, F, G, H, I and J — subject to the following conditions.

Exactly two among E, J, l and C must be selected.

If F is selected, then J cannot be selected.

Exactly one among A and C must be selected.

Unless A is selected, E cannot be selected,

If and only if G is selected, D must not be selected.

If D is not selected, then H must be selected.

The size of a team is defined as the number of members in the team. In how many ways can the team of size 6 be selected, if it includes E? and What is the largest possible size of the team?"""

    },

]

Output:

Markdown(pipe(messages)[0]["generated_text"][1]["content"])

The mannequin thinks totally. It does an awesome job of breaking down all the downside into small steps. The issue consists of two duties, with the given token window, it gave the reply for the primary job however it couldn’t generate the reply for the second job. What was fascinating was the strategy that the mannequin took in direction of fixing the given downside. First, it began by understanding the query, mapping out all the probabilities, after which it went forward into fixing every job, generally, repeating the logic that it had pre-established. 

Job 2: Clarify Working of LLMs to an 8 12 months Outdated Child

Enter:

messages = [

    {"role": "user", "content": """Explain How LLMs works by comparing their working to the photosynthesis process in a plant so that an 8 year old kid can actually understand"""

    },

]

Output:

Markdown(pipe(messages)[0]["generated_text"][1]["content"])

The mannequin hallucinates a bit whereas producing the response for this downside. Then lastly it generates the response that gives a superb analogy between how LLMs work and the photosynthesis course of. It retains the language easy and eventually provides a disclaimer too. 

Phi-4 Reasoning vs o3-mini: Comparability

Within the final part, we noticed how the Phi-4-Reasoning mannequin performs whereas coping with advanced issues. Now let’s evaluate its efficiency towards OpenAI’s o3-mini. To do that, let’s take a look at the output generated by the 2 fashions for a similar job.

Phi-4-Reasoning

Enter:

from IPython.show import Markdown

messages = [

    {"role": "user", "content": """Suppose players A and B are playing a game with fair coins. To begin the game A and B 

    both flip their coins simultaneously. If A and B both get heads, the game ends. If A and B both get tails, they both 

    flip again simultaneously. If one player gets heads and the other gets tails, the player who got heads flips again until he 

    gets tails, at which point the players flip again simultaneously. What is the expected number of flips until the game ends?"""

    },

]

Output = pipe(messages)

Output:

Markdown(Output[0]["generated_text"][1]["content"])

o3-mini

Enter:

response = shopper.responses.create(

    mannequin="o3-mini",

    enter="""Suppose gamers A and B are taking part in a recreation with truthful cash. To start the sport A and B 

    each flip their cash concurrently. If A and B each get heads, the sport ends. If A and B each get tails, they each 

    flip once more concurrently. If one participant will get heads and the opposite will get tails, the participant who bought heads flips once more till he 

    will get tails, at which level the gamers flip once more concurrently. What's the anticipated variety of flips till the sport ends?"""

)

Output:

print(response.output_text)

To examine the detailed output you possibly can confer with the next Github hyperlink.  

End result Analysis

Each fashions give correct solutions. Phi-4-Reasoning breaks the issue into many detailed steps and thinks by means of each earlier than reaching the ultimate reply. o3-mini, alternatively, combines its considering and remaining response extra easily, making the output clear and able to use. Its solutions are additionally extra concise and direct.

Functions of Phi-4-Reasoning Fashions

The Phi-4-Reasoning fashions open a world of prospects. Builders can use these fashions to develop clever techniques to cater to totally different industries. Listed here are a number of areas the place the Phi-4-Reasoning fashions can actually excel:

  • Their sturdy efficiency in coding benchmarks (like LiveCodeBench) suggests purposes in code era, debugging, algorithm design, and automatic software program growth.
  • Their capability to generate detailed reasoning chains makes them well-suited for answering advanced questions that require multi-step inference and logical deduction.
  • The fashions’ talents in planning duties could possibly be leveraged in logistics, useful resource administration, game-playing, and autonomous techniques requiring sequential decision-making.
  • The fashions may contribute to designing techniques in robotics, autonomous navigation, and duties involving the interpretation and manipulation of spatial relationships.

Conclusion

The Phi-4-Reasoning fashions are open-weight and constructed to compete with high paid reasoning fashions like DeepSeek and OpenAI’s o3-mini. Since they aren’t instruction-tuned, their solutions could not at all times comply with a transparent, structured format like some widespread fashions, however this could enhance over time or with customized fine-tuning. Microsoft’s new fashions are highly effective reasoning instruments with sturdy efficiency, and so they’re solely going to get higher from right here.

Anu Madan is an skilled in tutorial design, content material writing, and B2B advertising and marketing, with a expertise for remodeling advanced concepts into impactful narratives. Along with her deal with Generative AI, she crafts insightful, revolutionary content material that educates, evokes, and drives significant engagement.

Login to proceed studying and revel in expert-curated content material.