aashish1904
commited on
Commit
•
7dcfbd4
1
Parent(s):
876caaf
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
|
|
1 |
---
|
|
|
2 |
license: mit
|
3 |
license_link: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/LICENSE
|
4 |
|
@@ -8,14 +10,24 @@ pipeline_tag: text-generation
|
|
8 |
tags:
|
9 |
- nlp
|
10 |
- code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
19 |
|
20 |
The Phi-3-Mini-4K-Instruct is a 3.8B parameters, lightweight, state-of-the-art open model trained with the Phi-3 datasets that includes both synthetic data and the filtered publicly available websites data with a focus on high-quality and reasoning dense properties.
|
21 |
The model belongs to the Phi-3 family with the Mini version in two variants [4K](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) and [128K](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct) which is the context length (in tokens) that it can support.
|
@@ -25,62 +37,106 @@ When assessed against benchmarks testing common sense, language understanding, m
|
|
25 |
|
26 |
Resources and Technical Documentation:
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
## Intended Uses
|
34 |
|
35 |
**Primary use cases**
|
36 |
|
37 |
-
The model is intended for commercial and research use in English. The model provides uses for applications which require
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
2) Latency bound scenarios
|
41 |
-
3) Strong reasoning (especially code, math and logic)
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
|
46 |
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
|
50 |
|
51 |
## How to Use
|
52 |
|
53 |
-
Phi-3 Mini-4K-Instruct has been integrated in the
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
|
58 |
|
59 |
-
|
60 |
|
61 |
-
Phi-3 Mini-4K-Instruct
|
62 |
|
63 |
### Chat Format
|
64 |
|
65 |
Given the nature of the training data, the Phi-3 Mini-4K-Instruct model is best suited for prompts using the chat format as follows.
|
66 |
You can provide the prompt as a question with a generic template as follow:
|
67 |
```markdown
|
68 |
-
<|
|
|
|
|
|
|
|
|
|
69 |
```
|
|
|
70 |
For example:
|
71 |
```markdown
|
72 |
<|system|>
|
73 |
-
You are a helpful
|
74 |
<|user|>
|
75 |
How to explain Internet for a medieval knight?<|end|>
|
76 |
-
<|assistant|>
|
77 |
```
|
78 |
-
|
79 |
where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
|
80 |
|
81 |
```markdown
|
82 |
<|system|>
|
83 |
-
You are a helpful
|
84 |
<|user|>
|
85 |
I am going to Paris, what should I see?<|end|>
|
86 |
<|assistant|>
|
@@ -90,6 +146,49 @@ What is so great about #1?<|end|>
|
|
90 |
<|assistant|>
|
91 |
```
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
## Responsible AI Considerations
|
95 |
|
@@ -109,7 +208,6 @@ Developers should apply responsible AI best practices and are responsible for en
|
|
109 |
+ Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
|
110 |
+ Misuse: Other forms of misuse such as fraud, spam, or malware production may be possible, and developers should ensure that their applications do not violate applicable laws and regulations.
|
111 |
|
112 |
-
|
113 |
## Training
|
114 |
|
115 |
### Model
|
@@ -118,26 +216,29 @@ Developers should apply responsible AI best practices and are responsible for en
|
|
118 |
* Inputs: Text. It is best suited for prompts using chat format.
|
119 |
* Context length: 4K tokens
|
120 |
* GPUs: 512 H100-80G
|
121 |
-
* Training time:
|
122 |
-
* Training data:
|
123 |
* Outputs: Generated text in response to the input
|
124 |
-
* Dates: Our models were trained between
|
125 |
* Status: This is a static model trained on an offline dataset with cutoff date October 2023. Future versions of the tuned models may be released as we improve models.
|
|
|
126 |
|
127 |
### Datasets
|
128 |
|
129 |
-
Our training data includes a wide variety of sources, totaling
|
130 |
1) Publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
|
131 |
2) Newly created synthetic, “textbook-like” data for the purpose of teaching math, coding, common sense reasoning, general knowledge of the world (science, daily activities, theory of mind, etc.);
|
132 |
3) High quality chat format supervised data covering various topics to reflect human preferences on different aspects such as instruct-following, truthfulness, honesty and helpfulness.
|
133 |
|
|
|
|
|
134 |
### Fine-tuning
|
135 |
|
136 |
A basic example of multi-GPUs supervised fine-tuning (SFT) with TRL and Accelerate modules is provided [here](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/sample_finetune.py).
|
137 |
|
138 |
## Benchmarks
|
139 |
|
140 |
-
We report the results for Phi-3-Mini-4K-Instruct on standard open-source benchmarks measuring the model's reasoning ability (both common sense reasoning and logical reasoning). We compare to
|
141 |
|
142 |
All the reported numbers are produced with the exact same pipeline to ensure that the numbers are comparable. These numbers might differ from other published numbers due to slightly different choices in the evaluation.
|
143 |
|
@@ -147,55 +248,78 @@ More specifically, we do not change prompts, pick different few-shot examples, c
|
|
147 |
|
148 |
The number of k–shot examples is listed per-benchmark.
|
149 |
|
150 |
-
|
|
151 |
-
|
152 |
-
|
|
153 |
-
|
|
154 |
-
|
|
155 |
-
|
|
156 |
-
|
|
157 |
-
|
|
158 |
-
|
|
159 |
-
|
|
160 |
-
|
|
161 |
-
| PIQA <br>
|
162 |
-
|
|
163 |
-
|
|
164 |
-
|
|
165 |
-
|
|
166 |
-
|
|
167 |
-
|
|
168 |
-
|
|
169 |
-
|
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
## Software
|
173 |
|
174 |
* [PyTorch](https://github.com/pytorch/pytorch)
|
175 |
-
* [DeepSpeed](https://github.com/microsoft/DeepSpeed)
|
176 |
* [Transformers](https://github.com/huggingface/transformers)
|
177 |
* [Flash-Attention](https://github.com/HazyResearch/flash-attention)
|
178 |
|
179 |
## Hardware
|
180 |
-
Note that by default, the Phi-3-
|
181 |
* NVIDIA A100
|
182 |
* NVIDIA A6000
|
183 |
* NVIDIA H100
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
Along with DirectML, ONNX Runtime provides cross platform support for Phi-3 across a range of devices CPU, GPU, and mobile.
|
191 |
-
|
192 |
-
Here are some of the optimized configurations we have added:
|
193 |
-
|
194 |
-
1. ONNX models for int4 DML: Quantized to int4 via AWQ
|
195 |
-
2. ONNX model for fp16 CUDA
|
196 |
-
3. ONNX model for int4 CUDA: Quantized to int4 via RTN
|
197 |
-
4. ONNX model for int4 CPU and Mobile: Quantized to int4 via RTN
|
198 |
-
|
199 |
## License
|
200 |
|
201 |
The model is licensed under the [MIT license](https://huggingface.co/microsoft/Phi-3-mini-4k/resolve/main/LICENSE).
|
@@ -203,3 +327,4 @@ The model is licensed under the [MIT license](https://huggingface.co/microsoft/P
|
|
203 |
## Trademarks
|
204 |
|
205 |
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
|
|
|
|
1 |
+
|
2 |
---
|
3 |
+
|
4 |
license: mit
|
5 |
license_link: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/LICENSE
|
6 |
|
|
|
10 |
tags:
|
11 |
- nlp
|
12 |
- code
|
13 |
+
inference:
|
14 |
+
parameters:
|
15 |
+
temperature: 0.0
|
16 |
+
widget:
|
17 |
+
- messages:
|
18 |
+
- role: user
|
19 |
+
content: Can you provide ways to eat combinations of bananas and dragonfruits?
|
20 |
+
|
21 |
---
|
22 |
|
23 |
+
![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)
|
24 |
|
25 |
+
# QuantFactory/Phi-3-mini-4k-instruct-GGUF
|
26 |
+
This is quantized version of [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) created using llama.cpp
|
27 |
|
28 |
+
# Original Model Card
|
29 |
+
|
30 |
+
## Model Summary
|
31 |
|
32 |
The Phi-3-Mini-4K-Instruct is a 3.8B parameters, lightweight, state-of-the-art open model trained with the Phi-3 datasets that includes both synthetic data and the filtered publicly available websites data with a focus on high-quality and reasoning dense properties.
|
33 |
The model belongs to the Phi-3 family with the Mini version in two variants [4K](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) and [128K](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct) which is the context length (in tokens) that it can support.
|
|
|
37 |
|
38 |
Resources and Technical Documentation:
|
39 |
|
40 |
+
🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br>
|
41 |
+
📰 [Phi-3 Microsoft Blog](https://aka.ms/Phi-3Build2024) <br>
|
42 |
+
📖 [Phi-3 Technical Report](https://aka.ms/phi3-tech-report) <br>
|
43 |
+
🛠️ [Phi-3 on Azure AI Studio](https://aka.ms/phi3-azure-ai) <br>
|
44 |
+
👩🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br>
|
45 |
+
🖥️ [Try It](https://aka.ms/try-phi3)
|
46 |
+
|
47 |
+
| | Short Context | Long Context |
|
48 |
+
| :------- | :------------- | :------------ |
|
49 |
+
| Mini | 4K [[HF]](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-onnx) ; [[GGUF]](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf) | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct-onnx)|
|
50 |
+
| Small | 8K [[HF]](https://huggingface.co/microsoft/Phi-3-small-8k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-small-8k-instruct-onnx-cuda) | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-small-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-small-128k-instruct-onnx-cuda)|
|
51 |
+
| Medium | 4K [[HF]](https://huggingface.co/microsoft/Phi-3-medium-4k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-medium-4k-instruct-onnx-cuda) | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-medium-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-medium-128k-instruct-onnx-cuda)|
|
52 |
+
| Vision | | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct-onnx-cuda)|
|
53 |
+
|
54 |
|
55 |
## Intended Uses
|
56 |
|
57 |
**Primary use cases**
|
58 |
|
59 |
+
The model is intended for broad commercial and research use in English. The model provides uses for general purpose AI systems and applications which require
|
60 |
+
1) memory/compute constrained environments;
|
61 |
+
2) latency bound scenarios;
|
62 |
+
3) strong reasoning (especially math and logic).
|
63 |
+
|
64 |
+
Our model is designed to accelerate research on language and multimodal models, for use as a building block for generative AI powered features.
|
65 |
+
|
66 |
+
**Out-of-scope use cases**
|
67 |
+
|
68 |
+
Our models are not specifically designed or evaluated for all downstream purposes. Developers should consider common limitations of language models as they select use cases, and evaluate and mitigate for accuracy, safety, and fairness before using within a specific downstream use case, particularly for high-risk scenarios.
|
69 |
+
|
70 |
+
Developers should be aware of and adhere to applicable laws or regulations (including privacy, trade compliance laws, etc.) that are relevant to their use case.
|
71 |
+
|
72 |
+
**Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.**
|
73 |
|
74 |
+
## Release Notes
|
|
|
|
|
75 |
|
76 |
+
This is an update over the original instruction-tuned Phi-3-mini release based on valuable customer feedback.
|
77 |
+
The model used additional post-training data leading to substantial gains on instruction following and structure output.
|
78 |
+
We also improve multi-turn conversation quality, explicitly support <|system|> tag, and significantly improve reasoning capability.
|
79 |
+
We believe most use cases will benefit from this release, but we encourage users to test in their particular AI applications.
|
80 |
+
We appreciate the enthusiastic adoption of the Phi-3 model family, and continue to welcome all feedback from the community.
|
81 |
|
82 |
+
The table below highlights improvements on instruction following, structure output, and reasoning of the new release on publich and internal benchmark datasets.
|
83 |
|
84 |
+
| Benchmarks | Original | June 2024 Update |
|
85 |
+
|:------------|:----------|:------------------|
|
86 |
+
| Instruction Extra Hard | 5.7 | 6.0 |
|
87 |
+
| Instruction Hard | 4.9 | 5.1 |
|
88 |
+
| Instructions Challenge | 24.6 | 42.3 |
|
89 |
+
| JSON Structure Output | 11.5 | 52.3 |
|
90 |
+
| XML Structure Output | 14.4 | 49.8 |
|
91 |
+
| GPQA | 23.7 | 30.6 |
|
92 |
+
| MMLU | 68.8 | 70.9 |
|
93 |
+
| **Average** | **21.9** | **36.7** |
|
94 |
|
95 |
+
Notes: if users would like to check out the previous version, use the git commit id **ff07dc01615f8113924aed013115ab2abd32115b**. For the model conversion, e.g. GGUF and other formats, we invite the community to experiment with various approaches and share your valuable feedback. Let's innovate together!
|
96 |
|
97 |
## How to Use
|
98 |
|
99 |
+
Phi-3 Mini-4K-Instruct has been integrated in the `4.41.2` version of `transformers`. The current `transformers` version can be verified with: `pip list | grep transformers`.
|
100 |
|
101 |
+
Examples of required packages:
|
102 |
+
```
|
103 |
+
flash_attn==2.5.8
|
104 |
+
torch==2.3.1
|
105 |
+
accelerate==0.31.0
|
106 |
+
transformers==4.41.2
|
107 |
+
```
|
108 |
|
109 |
+
Phi-3 Mini-4K-Instruct is also available in [Azure AI Studio](https://aka.ms/try-phi3)
|
110 |
|
111 |
+
### Tokenizer
|
112 |
|
113 |
+
Phi-3 Mini-4K-Instruct supports a vocabulary size of up to `32064` tokens. The [tokenizer files](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/blob/main/added_tokens.json) already provide placeholder tokens that can be used for downstream fine-tuning, but they can also be extended up to the model's vocabulary size.
|
114 |
|
115 |
### Chat Format
|
116 |
|
117 |
Given the nature of the training data, the Phi-3 Mini-4K-Instruct model is best suited for prompts using the chat format as follows.
|
118 |
You can provide the prompt as a question with a generic template as follow:
|
119 |
```markdown
|
120 |
+
<|system|>
|
121 |
+
You are a helpful assistant.<|end|>
|
122 |
+
<|user|>
|
123 |
+
Question?<|end|>
|
124 |
+
<|assistant|>
|
125 |
```
|
126 |
+
|
127 |
For example:
|
128 |
```markdown
|
129 |
<|system|>
|
130 |
+
You are a helpful assistant.<|end|>
|
131 |
<|user|>
|
132 |
How to explain Internet for a medieval knight?<|end|>
|
133 |
+
<|assistant|>
|
134 |
```
|
|
|
135 |
where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
|
136 |
|
137 |
```markdown
|
138 |
<|system|>
|
139 |
+
You are a helpful travel assistant.<|end|>
|
140 |
<|user|>
|
141 |
I am going to Paris, what should I see?<|end|>
|
142 |
<|assistant|>
|
|
|
146 |
<|assistant|>
|
147 |
```
|
148 |
|
149 |
+
### Sample inference code
|
150 |
+
|
151 |
+
This code snippets show how to get quickly started with running the model on a GPU:
|
152 |
+
|
153 |
+
```python
|
154 |
+
import torch
|
155 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
156 |
+
|
157 |
+
torch.random.manual_seed(0)
|
158 |
+
model = AutoModelForCausalLM.from_pretrained(
|
159 |
+
"microsoft/Phi-3-mini-4k-instruct",
|
160 |
+
device_map="cuda",
|
161 |
+
torch_dtype="auto",
|
162 |
+
trust_remote_code=True,
|
163 |
+
)
|
164 |
+
|
165 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
|
166 |
+
|
167 |
+
messages = [
|
168 |
+
{"role": "system", "content": "You are a helpful AI assistant."},
|
169 |
+
{"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
|
170 |
+
{"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
|
171 |
+
{"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
|
172 |
+
]
|
173 |
+
|
174 |
+
pipe = pipeline(
|
175 |
+
"text-generation",
|
176 |
+
model=model,
|
177 |
+
tokenizer=tokenizer,
|
178 |
+
)
|
179 |
+
|
180 |
+
generation_args = {
|
181 |
+
"max_new_tokens": 500,
|
182 |
+
"return_full_text": False,
|
183 |
+
"temperature": 0.0,
|
184 |
+
"do_sample": False,
|
185 |
+
}
|
186 |
+
|
187 |
+
output = pipe(messages, **generation_args)
|
188 |
+
print(output[0]['generated_text'])
|
189 |
+
```
|
190 |
+
|
191 |
+
Note: If you want to use flash attention, call _AutoModelForCausalLM.from_pretrained()_ with _attn_implementation="flash_attention_2"_
|
192 |
|
193 |
## Responsible AI Considerations
|
194 |
|
|
|
208 |
+ Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
|
209 |
+ Misuse: Other forms of misuse such as fraud, spam, or malware production may be possible, and developers should ensure that their applications do not violate applicable laws and regulations.
|
210 |
|
|
|
211 |
## Training
|
212 |
|
213 |
### Model
|
|
|
216 |
* Inputs: Text. It is best suited for prompts using chat format.
|
217 |
* Context length: 4K tokens
|
218 |
* GPUs: 512 H100-80G
|
219 |
+
* Training time: 10 days
|
220 |
+
* Training data: 4.9T tokens
|
221 |
* Outputs: Generated text in response to the input
|
222 |
+
* Dates: Our models were trained between May and June 2024
|
223 |
* Status: This is a static model trained on an offline dataset with cutoff date October 2023. Future versions of the tuned models may be released as we improve models.
|
224 |
+
* Release dates: June, 2024.
|
225 |
|
226 |
### Datasets
|
227 |
|
228 |
+
Our training data includes a wide variety of sources, totaling 4.9 trillion tokens, and is a combination of
|
229 |
1) Publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
|
230 |
2) Newly created synthetic, “textbook-like” data for the purpose of teaching math, coding, common sense reasoning, general knowledge of the world (science, daily activities, theory of mind, etc.);
|
231 |
3) High quality chat format supervised data covering various topics to reflect human preferences on different aspects such as instruct-following, truthfulness, honesty and helpfulness.
|
232 |
|
233 |
+
We are focusing on the quality of data that could potentially improve the reasoning ability for the model, and we filter the publicly available documents to contain the correct level of knowledge. As an example, the result of a game in premier league in a particular day might be good training data for frontier models, but we need to remove such information to leave more model capacity for reasoning for the small size models. More details about data can be found in the [Phi-3 Technical Report](https://aka.ms/phi3-tech-report).
|
234 |
+
|
235 |
### Fine-tuning
|
236 |
|
237 |
A basic example of multi-GPUs supervised fine-tuning (SFT) with TRL and Accelerate modules is provided [here](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/sample_finetune.py).
|
238 |
|
239 |
## Benchmarks
|
240 |
|
241 |
+
We report the results under completion format for Phi-3-Mini-4K-Instruct on standard open-source benchmarks measuring the model's reasoning ability (both common sense reasoning and logical reasoning). We compare to Mistral-7b-v0.1, Mixtral-8x7b, Gemma 7B, Llama-3-8B-Instruct, and GPT3.5-Turbo-1106.
|
242 |
|
243 |
All the reported numbers are produced with the exact same pipeline to ensure that the numbers are comparable. These numbers might differ from other published numbers due to slightly different choices in the evaluation.
|
244 |
|
|
|
248 |
|
249 |
The number of k–shot examples is listed per-benchmark.
|
250 |
|
251 |
+
| Category | Benchmark | Phi-3-Mini-4K-Ins | Gemma-7B | Mistral-7b | Mixtral-8x7b | Llama-3-8B-Ins | GPT3.5-Turbo-1106 |
|
252 |
+
|:----------|:-----------|:-------------------|:----------|:------------|:--------------|:----------------|:-------------------|
|
253 |
+
| Popular aggregated benchmark | AGI Eval <br>5-shot| 39.0 | 42.1 | 35.1 | 45.2 | 42 | 48.4 |
|
254 |
+
| | MMLU <br>5-shot | 70.9 | 63.6 | 61.7 | 70.5 | 66.5 | 71.4 |
|
255 |
+
| | BigBench Hard CoT<br>3-shot| 73.5 | 59.6 | 57.3 | 69.7 | 51.5 | 68.3 |
|
256 |
+
| Language Understanding | ANLI <br>7-shot | 53.6 | 48.7 | 47.1 | 55.2 | 57.3 | 58.1 |
|
257 |
+
| | HellaSwag <br>5-shot| 75.3 | 49.8 | 58.5 | 70.4 | 71.1 | 78.8 |
|
258 |
+
| Reasoning | ARC Challenge <br>10-shot | 86.3 | 78.3 | 78.6 | 87.3 | 82.8 | 87.4 |
|
259 |
+
| | BoolQ <br>0-shot | 78.1 | 66 | 72.2 | 76.6 | 80.9 | 79.1 |
|
260 |
+
| | MedQA <br>2-shot| 56.5 | 49.6 | 50 | 62.2 | 60.5 | 63.4 |
|
261 |
+
| | OpenBookQA <br>10-shot| 82.2 | 78.6 | 79.8 | 85.8 | 82.6 | 86 |
|
262 |
+
| | PIQA <br>5-shot| 83.5 | 78.1 | 77.7 | 86 | 75.7 | 86.6 |
|
263 |
+
| | GPQA <br>0-shot| 30.6 | 2.9 | 15 | 6.9 | 32.4 | 30.8 |
|
264 |
+
| | Social IQA <br>5-shot| 77.6 | 65.5 | 74.6 | 75.9 | 73.9 | 68.3 |
|
265 |
+
| | TruthfulQA (MC2) <br>10-shot| 64.7 | 52.1 | 53 | 60.1 | 63.2 | 67.7 |
|
266 |
+
| | WinoGrande <br>5-shot| 71.6 | 55.6 | 54.2 | 62 | 65 | 68.8 |
|
267 |
+
| Factual Knowledge | TriviaQA <br>5-shot| 61.4 | 72.3 | 75.2 | 82.2 | 67.7 | 85.8 |
|
268 |
+
| Math | GSM8K CoT <br>8-shot| 85.7 | 59.8 | 46.4 | 64.7 | 77.4 | 78.1 |
|
269 |
+
| Code Generation | HumanEval <br>0-shot| 57.3 | 34.1 | 28.0 | 37.8 | 60.4 | 62.2 |
|
270 |
+
| | MBPP <br>3-shot| 69.8 | 51.5 | 50.8 | 60.2 | 67.7 | 77.8 |
|
271 |
+
| **Average** | | **67.6** | **56.0** | **56.4** | **64.4** | **65.5** | **70.4** |
|
272 |
+
|
273 |
+
|
274 |
+
We take a closer look at different categories across 100 public benchmark datasets at the table below:
|
275 |
+
|
276 |
+
| Category | Phi-3-Mini-4K-Instruct | Gemma-7B | Mistral-7B | Mixtral 8x7B | Llama-3-8B-Instruct | GPT-3.5-Turbo |
|
277 |
+
|:----------|:------------------------|:----------|:------------|:--------------|:---------------------|:---------------|
|
278 |
+
| Popular aggregated benchmark | 61.1 | 59.4 | 56.5 | 66.2 | 59.9 | 67.0 |
|
279 |
+
| Reasoning | 70.8 | 60.3 | 62.8 | 68.1 | 69.6 | 71.8 |
|
280 |
+
| Language understanding | 60.5 | 57.6 | 52.5 | 66.1 | 63.2 | 67.7 |
|
281 |
+
| Code generation | 60.7 | 45.6 | 42.9 | 52.7 | 56.4 | 70.4 |
|
282 |
+
| Math | 50.6 | 35.8 | 25.4 | 40.3 | 41.1 | 52.8 |
|
283 |
+
| Factual knowledge | 38.4 | 46.7 | 49.8 | 58.6 | 43.1 | 63.4 |
|
284 |
+
| Multilingual | 56.7 | 66.5 | 57.4 | 66.7 | 66.6 | 71.0 |
|
285 |
+
| Robustness | 61.1 | 38.4 | 40.6 | 51.0 | 64.5 | 69.3 |
|
286 |
+
|
287 |
+
|
288 |
+
Overall, the model with only 3.8B-param achieves a similar level of language understanding and reasoning ability as much larger models. However, it is still fundamentally limited by its size for certain tasks. The model simply does not have the capacity to store too much world knowledge, which can be seen for example with low performance on TriviaQA. However, we believe such weakness can be resolved by augmenting Phi-3-Mini with a search engine.
|
289 |
+
|
290 |
+
|
291 |
+
## Cross Platform Support
|
292 |
+
|
293 |
+
[ONNX runtime](https://onnxruntime.ai/blogs/accelerating-phi-3) now supports Phi-3 mini models across platforms and hardware.
|
294 |
+
|
295 |
+
Optimized phi-3 models are also 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. DirectML GPU acceleration is supported for Windows desktops GPUs (AMD, Intel, and NVIDIA).
|
296 |
+
|
297 |
+
Along with DML, ONNX Runtime provides cross platform support for Phi3 mini across a range of devices CPU, GPU, and mobile.
|
298 |
+
|
299 |
+
Here are some of the optimized configurations we have added:
|
300 |
+
|
301 |
+
1. ONNX models for int4 DML: Quantized to int4 via AWQ
|
302 |
+
2. ONNX model for fp16 CUDA
|
303 |
+
3. ONNX model for int4 CUDA: Quantized to int4 via RTN
|
304 |
+
4. ONNX model for int4 CPU and Mobile: Quantized to int4 via R
|
305 |
|
306 |
## Software
|
307 |
|
308 |
* [PyTorch](https://github.com/pytorch/pytorch)
|
|
|
309 |
* [Transformers](https://github.com/huggingface/transformers)
|
310 |
* [Flash-Attention](https://github.com/HazyResearch/flash-attention)
|
311 |
|
312 |
## Hardware
|
313 |
+
Note that by default, the Phi-3 Mini-4K-Instruct model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types:
|
314 |
* NVIDIA A100
|
315 |
* NVIDIA A6000
|
316 |
* NVIDIA H100
|
317 |
|
318 |
+
If you want to run the model on:
|
319 |
+
* NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
|
320 |
+
* CPU: use the **GGUF** quantized models [4K](https://aka.ms/Phi3-mini-4k-instruct-gguf)
|
321 |
+
+ Optimized inference on GPU, CPU, and Mobile: use the **ONNX** models [4K](https://aka.ms/Phi3-mini-4k-instruct-onnx)
|
322 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
## License
|
324 |
|
325 |
The model is licensed under the [MIT license](https://huggingface.co/microsoft/Phi-3-mini-4k/resolve/main/LICENSE).
|
|
|
327 |
## Trademarks
|
328 |
|
329 |
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
|
330 |
+
|