This repository hosts the optimized versions of the Phi-4 mini reasoning models to accelerate inference with ONNX Runtime.
Optimized models are published here in ONNX format to run with ONNX Runtime on CPU and GPU across devices, including server platforms, Windows, Linux and Mac desktops, and mobile CPUs, with the precision best suited to each of these targets.
You can see how to run examples with ORT GenAI
here
1# Download the model directly using the Hugging Face CLI
2huggingface-cli download microsoft/Phi-4-mini-reasoning-onnx --include cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4/* --local-dir .
3
4# Install the CPU package of ONNX Runtime GenAI
5pip install --pre onnxruntime-genai
6
7# Please adjust the model directory (-m) accordingly
8curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
9curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
10python model-qa.py -m cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4 -e cpu
1# Download the model directly using the Hugging Face CLI
2huggingface-cli download microsoft/Phi-4-mini-reasoning-onnx --include gpu/* --local-dir .
3
4# Install the CUDA package of ONNX Runtime GenAI
5pip install --pre onnxruntime-genai-cuda
6
7# Please adjust the model directory (-m) accordingly
8curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
9curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
10python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e cuda
1# Download the model directly using the Hugging Face CLI
2huggingface-cli download microsoft/Phi-4-mini-reasoning-onnx --include gpu/* --local-dir .
3
4# Install the DML package of ONNX Runtime GenAI
5pip install --pre onnxruntime-genai-directml
6
7# Please adjust the model directory (-m) accordingly
8curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
9curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
10python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e dml
Phi-4 mini reasoning is a lightweight open model built upon synthetic data and filtered publicly available websites - with a focus on high-quality, reasoning dense data. The model belongs to the Phi-4 model family and supports 128K token context length. The model underwent an enhancement process, incorporating both supervised fine-tuning and direct preference optimization to support precise instruction adherence and robust safety measures.
See details at
https://huggingface.co/microsoft/Phi-4-mini-reasoning/blob/main/README.md