microsoft/Phi-4-mini-instruct-onnx

Model

48

stars

21

commits

2

repos using this model

2

linked in READMEs

Feb 11, 2026

updated

code
multilingual
nlp
onnx
ONNX
ONNX Runtime
phi4
phi4 mini
Browse cluster: Multilingual Large Language Models

README

Phi-4-Mini-Instruct ONNX models

Introduction

This repository hosts the optimized versions of the Phi-4 mini 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.

Here are some of the optimized configurations we have added:

  1. ONNX model for int4 CPU: ONNX model for CPU and mobile using int4 quantization via RTN.
  2. ONNX model for int4 GPU: ONNX model for GPU using int4 quantization via RTN.

Model Run

You can see how to run examples with ORT GenAI here

For CPU:

# Download the model directly using the Hugging Face CLI
huggingface-cli download microsoft/Phi-4-mini-instruct-onnx --include cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4/* --local-dir .

# Install the CPU package of ONNX Runtime GenAI
pip install --pre onnxruntime-genai

# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
python model-qa.py -m cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4 -e cpu

For CUDA:

# Download the model directly using the Hugging Face CLI
huggingface-cli download microsoft/Phi-4-mini-instruct-onnx --include gpu/* --local-dir .

# Install the CUDA package of ONNX Runtime GenAI
pip install --pre onnxruntime-genai-cuda

# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e cuda

For DirectML:

# Download the model directly using the Hugging Face CLI
huggingface-cli download microsoft/Phi-4-mini-instruct-onnx --include gpu/* --local-dir .

# Install the DML package of ONNX Runtime GenAI
pip install --pre onnxruntime-genai-directml

# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e dml

Model Description

  • Developed by: Microsoft
  • Model type: ONNX
  • License: MIT
  • Model Description: This is a conversion of the Phi-4 mini model for ONNX Runtime inference.

Disclaimer: Model is only an optimization of the base model, any risk associated with the model is the responsibility of the user of the model. Please verify and test for your scenarios. There may be a slight difference in output from the base model with the optimizations applied.

Base Model

Phi-4-Mini 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-instruct/blob/main/README.md

Performance Comparison

HardwareONNXPyTorchspeedup
RTX 4090 GPUint4: 260.045 tokens/sec fp16: 97.463 tokens/se fp32: 19.320 tokens/secfp16: 43.957 tokens/sec5x(fp16)
Intel Xeon Platinum 8272CL CPUint4: 16.89 tokens/secfp32: 1.636 tokens/sec10x
Intel Xeon Platinum 8573B CPUint4: 23.978 tokens/secfp32: 4.479 tokens/sec5.35X
AMD EPYC 7763v CPUint4: 19.884 tokens/secfp32: 1.599 tokens/sec12.4x
Intel Core Ultra 7 165H Laptop CPUint4: 4.863 tokens/secfp32: 1.699 tokens/sec2.8x
Intel i7 processorint4: 3.474 tokens/sec fp32: 1.800 tokens/secfp32: 0.702 tokens/sec4.85x

Contributors

parinitarahi

11 commits

kvaishnavi

8 commits

lbourdois

1 commits

nguyenbh

1 commits

microsoft/Phi-4-mini-instruct-onnx

Model

48

stars

21

commits

2

repos using this model

2

linked in READMEs

Feb 11, 2026

updated

code
multilingual
nlp
onnx
ONNX
ONNX Runtime
phi4
phi4 mini
Browse cluster: Multilingual Large Language Models

README

Phi-4-Mini-Instruct ONNX models

Introduction

This repository hosts the optimized versions of the Phi-4 mini 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.

Here are some of the optimized configurations we have added:

  1. ONNX model for int4 CPU: ONNX model for CPU and mobile using int4 quantization via RTN.
  2. ONNX model for int4 GPU: ONNX model for GPU using int4 quantization via RTN.

Model Run

You can see how to run examples with ORT GenAI here

For CPU:

# Download the model directly using the Hugging Face CLI
huggingface-cli download microsoft/Phi-4-mini-instruct-onnx --include cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4/* --local-dir .

# Install the CPU package of ONNX Runtime GenAI
pip install --pre onnxruntime-genai

# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
python model-qa.py -m cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4 -e cpu

For CUDA:

# Download the model directly using the Hugging Face CLI
huggingface-cli download microsoft/Phi-4-mini-instruct-onnx --include gpu/* --local-dir .

# Install the CUDA package of ONNX Runtime GenAI
pip install --pre onnxruntime-genai-cuda

# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e cuda

For DirectML:

# Download the model directly using the Hugging Face CLI
huggingface-cli download microsoft/Phi-4-mini-instruct-onnx --include gpu/* --local-dir .

# Install the DML package of ONNX Runtime GenAI
pip install --pre onnxruntime-genai-directml

# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e dml

Model Description

  • Developed by: Microsoft
  • Model type: ONNX
  • License: MIT
  • Model Description: This is a conversion of the Phi-4 mini model for ONNX Runtime inference.

Disclaimer: Model is only an optimization of the base model, any risk associated with the model is the responsibility of the user of the model. Please verify and test for your scenarios. There may be a slight difference in output from the base model with the optimizations applied.

Base Model

Phi-4-Mini 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-instruct/blob/main/README.md

Performance Comparison

HardwareONNXPyTorchspeedup
RTX 4090 GPUint4: 260.045 tokens/sec fp16: 97.463 tokens/se fp32: 19.320 tokens/secfp16: 43.957 tokens/sec5x(fp16)
Intel Xeon Platinum 8272CL CPUint4: 16.89 tokens/secfp32: 1.636 tokens/sec10x
Intel Xeon Platinum 8573B CPUint4: 23.978 tokens/secfp32: 4.479 tokens/sec5.35X
AMD EPYC 7763v CPUint4: 19.884 tokens/secfp32: 1.599 tokens/sec12.4x
Intel Core Ultra 7 165H Laptop CPUint4: 4.863 tokens/secfp32: 1.699 tokens/sec2.8x
Intel i7 processorint4: 3.474 tokens/sec fp32: 1.800 tokens/secfp32: 0.702 tokens/sec4.85x

Contributors

parinitarahi

11 commits

kvaishnavi

8 commits

lbourdois

1 commits

nguyenbh

1 commits