Files changed (1) hide show
  1. README.md +3 -117
README.md CHANGED
@@ -1,117 +1,3 @@
1
- ---
2
- tags:
3
- - ONNX
4
- - ONNX Runtime
5
- - code
6
- - nlp
7
- - phi4
8
- - phi4 mini
9
- license: mit
10
- language:
11
- - multilingual
12
- - ar
13
- - zh
14
- - cs
15
- - da
16
- - nl
17
- - en
18
- - fi
19
- - fr
20
- - de
21
- - he
22
- - hu
23
- - it
24
- - ja
25
- - ko
26
- - no
27
- - pl
28
- - pt
29
- - ru
30
- - es
31
- - sv
32
- - th
33
- - tr
34
- - uk
35
- ---
36
- # Phi-4-Mini-Reasoning ONNX models
37
-
38
- ## Introduction
39
- This repository hosts the optimized versions of the Phi-4 mini reasoning models to accelerate inference with ONNX Runtime.
40
-
41
- 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.
42
-
43
- Here are some of the optimized configurations we have added:
44
-
45
- 1. ONNX model for int4 CPU: ONNX model for CPU and mobile using int4 quantization via RTN.
46
- 2. ONNX model for int4 GPU: ONNX model for GPU using int4 quantization via RTN.
47
-
48
- ## Model Run
49
- You can see how to run examples with ORT GenAI [here](https://github.com/microsoft/onnxruntime-genai/blob/main/examples/python/phi-3-tutorial.md)
50
-
51
- For CPU:
52
-
53
- ```bash
54
- # Download the model directly using the Hugging Face CLI
55
- huggingface-cli download microsoft/Phi-4-mini-reasoning-onnx --include cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4/* --local-dir .
56
-
57
- # Install the CPU package of ONNX Runtime GenAI
58
- pip install --pre onnxruntime-genai
59
-
60
- # Please adjust the model directory (-m) accordingly
61
- curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
62
- curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
63
- python model-qa.py -m cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4 -e cpu
64
- ```
65
-
66
- For CUDA:
67
-
68
- ```bash
69
- # Download the model directly using the Hugging Face CLI
70
- huggingface-cli download microsoft/Phi-4-mini-reasoning-onnx --include gpu/* --local-dir .
71
-
72
- # Install the CUDA package of ONNX Runtime GenAI
73
- pip install --pre onnxruntime-genai-cuda
74
-
75
- # Please adjust the model directory (-m) accordingly
76
- curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
77
- curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
78
- python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e cuda
79
- ```
80
-
81
- For DirectML:
82
-
83
- ```bash
84
- # Download the model directly using the Hugging Face CLI
85
- huggingface-cli download microsoft/Phi-4-mini-reasoning-onnx --include gpu/* --local-dir .
86
-
87
- # Install the DML package of ONNX Runtime GenAI
88
- pip install --pre onnxruntime-genai-directml
89
-
90
- # Please adjust the model directory (-m) accordingly
91
- curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
92
- curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-qa.py -o model-qa.py
93
- python model-qa.py -m gpu/gpu-int4-rtn-block-32 -e dml
94
- ```
95
-
96
-
97
- ## Model Description
98
- - Developed by: Microsoft
99
- - Model type: ONNX
100
- - License: MIT
101
- - Model Description: This is a conversion of the Phi-4 mini reasoning model for ONNX Runtime inference.
102
-
103
- **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.
104
-
105
- ## Base Model
106
- 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.
107
- See details at [https://huggingface.co/microsoft/Phi-4-mini-reasoning/blob/main/README.md](https://huggingface.co/microsoft/Phi-4-mini-reasoning/blob/main/README.md)
108
-
109
- ## Performance Comparison
110
- | Hardware | ONNX | PyTorch | speedup |
111
- | -------|----------|------|---------|
112
- | RTX 4090 GPU | int4: 260.045 tokens/sec fp16: 97.463 tokens/se fp32: 19.320 tokens/sec | fp16: 43.957 tokens/sec | 5x(fp16) |
113
- | Intel Xeon Platinum 8272CL CPU | int4: 16.89 tokens/sec | fp32: 1.636 tokens/sec | 10x |
114
- | Intel Xeon Platinum 8573B CPU | int4: 23.978 tokens/sec | fp32: 4.479 tokens/sec | 5.35X |
115
- | AMD EPYC 7763v CPU | int4: 19.884 tokens/sec | fp32: 1.599 tokens/sec | 12.4x |
116
- | Intel Core Ultra 7 165H Laptop CPU | int4: 4.863 tokens/sec | fp32: 1.699 tokens/sec | 2.8x |
117
- | Intel i7 processor | int4: 3.474 tokens/sec fp32: 1.800 tokens/sec | fp32: 0.702 tokens/sec | 4.85x|
 
1
+ ---
2
+ license: mit
3
+ ---