shubhamrathore081 commited on
Commit
108068f
1 Parent(s): 4b7b714

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +297 -47
README.md CHANGED
@@ -1,70 +1,320 @@
1
  ---
2
- base_model: microsoft/Phi-3-mini-4k-instruct
3
- library_name: peft
4
- license: apache-2.0
 
 
 
5
  tags:
6
- - text-generation-inference
7
- - transformers
8
- - unsloth
9
- - mistral
10
- - trl
11
  inference:
12
  parameters:
13
  temperature: 0.0
 
 
 
 
14
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
17
- should probably proofread and complete it, then remove this comment. -->
 
 
 
 
 
 
 
 
18
 
19
- # logs
20
 
21
- This model is a fine-tuned version of [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) on the None dataset.
22
- It achieves the following results on the evaluation set:
23
- - Loss: 1.0939
24
 
25
- ## Model description
26
 
27
- More information needed
28
 
29
- ## Intended uses & limitations
30
 
31
- More information needed
32
 
33
- ## Training and evaluation data
34
 
35
- More information needed
36
 
37
- ## Training procedure
 
 
 
38
 
39
- ### Training hyperparameters
40
 
41
- The following hyperparameters were used during training:
42
- - learning_rate: 0.0002
43
- - train_batch_size: 1
44
- - eval_batch_size: 8
45
- - seed: 42
46
- - gradient_accumulation_steps: 8
47
- - total_train_batch_size: 8
48
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
49
- - lr_scheduler_type: cosine
50
- - lr_scheduler_warmup_ratio: 0.03
51
- - num_epochs: 4
52
- - mixed_precision_training: Native AMP
53
 
54
- ### Training results
 
 
 
 
55
 
56
- | Training Loss | Epoch | Step | Validation Loss |
57
- |:-------------:|:------:|:----:|:---------------:|
58
- | 1.0751 | 0.9956 | 112 | 1.0510 |
59
- | 0.8778 | 2.0 | 225 | 1.0214 |
60
- | 0.7249 | 2.9956 | 337 | 1.0544 |
61
- | 0.6308 | 3.9822 | 448 | 1.0939 |
62
 
 
63
 
64
- ### Framework versions
65
 
66
- - PEFT 0.12.0
67
- - Transformers 4.40.0
68
- - Pytorch 2.4.0+cu121
69
- - Datasets 2.21.0
70
- - Tokenizers 0.19.1
 
1
  ---
2
+ license: mit
3
+ license_link: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/LICENSE
4
+
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
  tags:
9
+ - nlp
10
+ - code
 
 
 
11
  inference:
12
  parameters:
13
  temperature: 0.0
14
+ widget:
15
+ - messages:
16
+ - role: user
17
+ content: Can you provide ways to eat combinations of bananas and dragonfruits?
18
  ---
19
+ 🎉 **Phi-3.5**: [[mini-instruct]](https://huggingface.co/microsoft/Phi-3.5-mini-instruct); [[MoE-instruct]](https://huggingface.co/microsoft/Phi-3.5-MoE-instruct) ; [[vision-instruct]](https://huggingface.co/microsoft/Phi-3.5-vision-instruct)
20
+
21
+ ## Model Summary
22
+
23
+ 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.
24
+ 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
+
26
+ The model has underwent a post-training process that incorporates both supervised fine-tuning and direct preference optimization for the instruction following and safety measures.
27
+ When assessed against benchmarks testing common sense, language understanding, math, code, long context and logical reasoning, Phi-3 Mini-4K-Instruct showcased a robust and state-of-the-art performance among models with less than 13 billion parameters.
28
+
29
+ Resources and Technical Documentation:
30
+
31
+ 🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br>
32
+ 📰 [Phi-3 Microsoft Blog](https://aka.ms/Phi-3Build2024) <br>
33
+ 📖 [Phi-3 Technical Report](https://aka.ms/phi3-tech-report) <br>
34
+ 🛠️ [Phi-3 on Azure AI Studio](https://aka.ms/phi3-azure-ai) <br>
35
+ 👩‍🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br>
36
+ 🖥️ [Try It](https://aka.ms/try-phi3)
37
+
38
+ | | Short Context | Long Context |
39
+ | :------- | :------------- | :------------ |
40
+ | 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)|
41
+ | 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)|
42
+ | 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)|
43
+ | Vision | | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct-onnx-cuda)|
44
+
45
+
46
+ ## Intended Uses
47
+
48
+ **Primary use cases**
49
+
50
+ 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
51
+ 1) memory/compute constrained environments;
52
+ 2) latency bound scenarios;
53
+ 3) strong reasoning (especially math and logic).
54
+
55
+ Our model is designed to accelerate research on language and multimodal models, for use as a building block for generative AI powered features.
56
+
57
+ **Out-of-scope use cases**
58
+
59
+ 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.
60
+
61
+ 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.
62
+
63
+ **Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.**
64
+
65
+ ## Release Notes
66
+
67
+ This is an update over the original instruction-tuned Phi-3-mini release based on valuable customer feedback.
68
+ The model used additional post-training data leading to substantial gains on instruction following and structure output.
69
+ We also improve multi-turn conversation quality, explicitly support <|system|> tag, and significantly improve reasoning capability.
70
+ We believe most use cases will benefit from this release, but we encourage users to test in their particular AI applications.
71
+ We appreciate the enthusiastic adoption of the Phi-3 model family, and continue to welcome all feedback from the community.
72
+
73
+ The table below highlights improvements on instruction following, structure output, and reasoning of the new release on publich and internal benchmark datasets.
74
+
75
+ | Benchmarks | Original | June 2024 Update |
76
+ |:------------|:----------|:------------------|
77
+ | Instruction Extra Hard | 5.7 | 6.0 |
78
+ | Instruction Hard | 4.9 | 5.1 |
79
+ | Instructions Challenge | 24.6 | 42.3 |
80
+ | JSON Structure Output | 11.5 | 52.3 |
81
+ | XML Structure Output | 14.4 | 49.8 |
82
+ | GPQA | 23.7 | 30.6 |
83
+ | MMLU | 68.8 | 70.9 |
84
+ | **Average** | **21.9** | **36.7** |
85
+
86
+ 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!
87
+
88
+ ## How to Use
89
+
90
+ 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`.
91
+
92
+ Examples of required packages:
93
+ ```
94
+ flash_attn==2.5.8
95
+ torch==2.3.1
96
+ accelerate==0.31.0
97
+ transformers==4.41.2
98
+ ```
99
+
100
+ Phi-3 Mini-4K-Instruct is also available in [Azure AI Studio](https://aka.ms/try-phi3)
101
+
102
+ ### Tokenizer
103
+
104
+ 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.
105
+
106
+ ### Chat Format
107
+
108
+ 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.
109
+ You can provide the prompt as a question with a generic template as follow:
110
+ ```markdown
111
+ <|system|>
112
+ You are a helpful assistant.<|end|>
113
+ <|user|>
114
+ Question?<|end|>
115
+ <|assistant|>
116
+ ```
117
+
118
+ For example:
119
+ ```markdown
120
+ <|system|>
121
+ You are a helpful assistant.<|end|>
122
+ <|user|>
123
+ How to explain Internet for a medieval knight?<|end|>
124
+ <|assistant|>
125
+ ```
126
+ where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
127
+
128
+ ```markdown
129
+ <|system|>
130
+ You are a helpful travel assistant.<|end|>
131
+ <|user|>
132
+ I am going to Paris, what should I see?<|end|>
133
+ <|assistant|>
134
+ Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:\n\n1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.\n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.\n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.\n\nThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world."<|end|>
135
+ <|user|>
136
+ What is so great about #1?<|end|>
137
+ <|assistant|>
138
+ ```
139
+
140
+ ### Sample inference code
141
+
142
+ This code snippets show how to get quickly started with running the model on a GPU:
143
+
144
+ ```python
145
+ import torch
146
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
147
+
148
+ torch.random.manual_seed(0)
149
+ model = AutoModelForCausalLM.from_pretrained(
150
+ "microsoft/Phi-3-mini-4k-instruct",
151
+ device_map="cuda",
152
+ torch_dtype="auto",
153
+ trust_remote_code=True,
154
+ )
155
+
156
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
157
+
158
+ messages = [
159
+ {"role": "system", "content": "You are a helpful AI assistant."},
160
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
161
+ {"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."},
162
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
163
+ ]
164
+
165
+ pipe = pipeline(
166
+ "text-generation",
167
+ model=model,
168
+ tokenizer=tokenizer,
169
+ )
170
+
171
+ generation_args = {
172
+ "max_new_tokens": 500,
173
+ "return_full_text": False,
174
+ "temperature": 0.0,
175
+ "do_sample": False,
176
+ }
177
+
178
+ output = pipe(messages, **generation_args)
179
+ print(output[0]['generated_text'])
180
+ ```
181
+
182
+ Note: If you want to use flash attention, call _AutoModelForCausalLM.from_pretrained()_ with _attn_implementation="flash_attention_2"_
183
+
184
+ ## Responsible AI Considerations
185
+
186
+ Like other language models, the Phi series models can potentially behave in ways that are unfair, unreliable, or offensive. Some of the limiting behaviors to be aware of include:
187
+
188
+ + Quality of Service: the Phi models are trained primarily on English text. Languages other than English will experience worse performance. English language varieties with less representation in the training data might experience worse performance than standard American English.
189
+ + Representation of Harms & Perpetuation of Stereotypes: These models can over- or under-represent groups of people, erase representation of some groups, or reinforce demeaning or negative stereotypes. Despite safety post-training, these limitations may still be present due to differing levels of representation of different groups or prevalence of examples of negative stereotypes in training data that reflect real-world patterns and societal biases.
190
+ + Inappropriate or Offensive Content: these models may produce other types of inappropriate or offensive content, which may make it inappropriate to deploy for sensitive contexts without additional mitigations that are specific to the use case.
191
+ + Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
192
+ + Limited Scope for Code: Majority of Phi-3 training data is based in Python and use common packages such as "typing, math, random, collections, datetime, itertools". If the model generates Python scripts that utilize other packages or scripts in other languages, we strongly recommend users manually verify all API uses.
193
+
194
+ Developers should apply responsible AI best practices and are responsible for ensuring that a specific use case complies with relevant laws and regulations (e.g. privacy, trade, etc.). Important areas for consideration include:
195
+
196
+ + Allocation: Models may not be suitable for scenarios that could have consequential impact on legal status or the allocation of resources or life opportunities (ex: housing, employment, credit, etc.) without further assessments and additional debiasing techniques.
197
+ + High-Risk Scenarios: Developers should assess suitability of using models in high-risk scenarios where unfair, unreliable or offensive outputs might be extremely costly or lead to harm. This includes providing advice in sensitive or expert domains where accuracy and reliability are critical (ex: legal or health advice). Additional safeguards should be implemented at the application level according to the deployment context.
198
+ + Misinformation: Models may produce inaccurate information. Developers should follow transparency best practices and inform end-users they are interacting with an AI system. At the application level, developers can build feedback mechanisms and pipelines to ground responses in use-case specific, contextual information, a technique known as Retrieval Augmented Generation (RAG).
199
+ + Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
200
+ + 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.
201
+
202
+ ## Training
203
+
204
+ ### Model
205
+
206
+ * Architecture: Phi-3 Mini-4K-Instruct has 3.8B parameters and is a dense decoder-only Transformer model. The model is fine-tuned with Supervised fine-tuning (SFT) and Direct Preference Optimization (DPO) to ensure alignment with human preferences and safety guidlines.
207
+ * Inputs: Text. It is best suited for prompts using chat format.
208
+ * Context length: 4K tokens
209
+ * GPUs: 512 H100-80G
210
+ * Training time: 10 days
211
+ * Training data: 4.9T tokens
212
+ * Outputs: Generated text in response to the input
213
+ * Dates: Our models were trained between May and June 2024
214
+ * 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.
215
+ * Release dates: June, 2024.
216
+
217
+ ### Datasets
218
+
219
+ Our training data includes a wide variety of sources, totaling 4.9 trillion tokens, and is a combination of
220
+ 1) Publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
221
+ 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.);
222
+ 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.
223
+
224
+ 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).
225
+
226
+ ### Fine-tuning
227
+
228
+ 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).
229
+
230
+ ## Benchmarks
231
+
232
+ 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.
233
+
234
+ 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.
235
+
236
+ As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
237
+ The prompts and number of shots are part of a Microsoft internal tool to evaluate language models, and in particular we did no optimization to the pipeline for Phi-3.
238
+ More specifically, we do not change prompts, pick different few-shot examples, change prompt format, or do any other form of optimization for the model.
239
+
240
+ The number of k–shot examples is listed per-benchmark.
241
+
242
+ | Category | Benchmark | Phi-3-Mini-4K-Ins | Gemma-7B | Mistral-7b | Mixtral-8x7b | Llama-3-8B-Ins | GPT3.5-Turbo-1106 |
243
+ |:----------|:-----------|:-------------------|:----------|:------------|:--------------|:----------------|:-------------------|
244
+ | Popular aggregated benchmark | AGI Eval <br>5-shot| 39.0 | 42.1 | 35.1 | 45.2 | 42 | 48.4 |
245
+ | | MMLU <br>5-shot | 70.9 | 63.6 | 61.7 | 70.5 | 66.5 | 71.4 |
246
+ | | BigBench Hard CoT<br>3-shot| 73.5 | 59.6 | 57.3 | 69.7 | 51.5 | 68.3 |
247
+ | Language Understanding | ANLI <br>7-shot | 53.6 | 48.7 | 47.1 | 55.2 | 57.3 | 58.1 |
248
+ | | HellaSwag <br>5-shot| 75.3 | 49.8 | 58.5 | 70.4 | 71.1 | 78.8 |
249
+ | Reasoning | ARC Challenge <br>10-shot | 86.3 | 78.3 | 78.6 | 87.3 | 82.8 | 87.4 |
250
+ | | BoolQ <br>0-shot | 78.1 | 66 | 72.2 | 76.6 | 80.9 | 79.1 |
251
+ | | MedQA <br>2-shot| 56.5 | 49.6 | 50 | 62.2 | 60.5 | 63.4 |
252
+ | | OpenBookQA <br>10-shot| 82.2 | 78.6 | 79.8 | 85.8 | 82.6 | 86 |
253
+ | | PIQA <br>5-shot| 83.5 | 78.1 | 77.7 | 86 | 75.7 | 86.6 |
254
+ | | GPQA <br>0-shot| 30.6 | 2.9 | 15 | 6.9 | 32.4 | 30.8 |
255
+ | | Social IQA <br>5-shot| 77.6 | 65.5 | 74.6 | 75.9 | 73.9 | 68.3 |
256
+ | | TruthfulQA (MC2) <br>10-shot| 64.7 | 52.1 | 53 | 60.1 | 63.2 | 67.7 |
257
+ | | WinoGrande <br>5-shot| 71.6 | 55.6 | 54.2 | 62 | 65 | 68.8 |
258
+ | Factual Knowledge | TriviaQA <br>5-shot| 61.4 | 72.3 | 75.2 | 82.2 | 67.7 | 85.8 |
259
+ | Math | GSM8K CoT <br>8-shot| 85.7 | 59.8 | 46.4 | 64.7 | 77.4 | 78.1 |
260
+ | Code Generation | HumanEval <br>0-shot| 57.3 | 34.1 | 28.0 | 37.8 | 60.4 | 62.2 |
261
+ | | MBPP <br>3-shot| 69.8 | 51.5 | 50.8 | 60.2 | 67.7 | 77.8 |
262
+ | **Average** | | **67.6** | **56.0** | **56.4** | **64.4** | **65.5** | **70.4** |
263
+
264
+
265
+ We take a closer look at different categories across 100 public benchmark datasets at the table below:
266
 
267
+ | Category | Phi-3-Mini-4K-Instruct | Gemma-7B | Mistral-7B | Mixtral 8x7B | Llama-3-8B-Instruct | GPT-3.5-Turbo |
268
+ |:----------|:------------------------|:----------|:------------|:--------------|:---------------------|:---------------|
269
+ | Popular aggregated benchmark | 61.1 | 59.4 | 56.5 | 66.2 | 59.9 | 67.0 |
270
+ | Reasoning | 70.8 | 60.3 | 62.8 | 68.1 | 69.6 | 71.8 |
271
+ | Language understanding | 60.5 | 57.6 | 52.5 | 66.1 | 63.2 | 67.7 |
272
+ | Code generation | 60.7 | 45.6 | 42.9 | 52.7 | 56.4 | 70.4 |
273
+ | Math | 50.6 | 35.8 | 25.4 | 40.3 | 41.1 | 52.8 |
274
+ | Factual knowledge | 38.4 | 46.7 | 49.8 | 58.6 | 43.1 | 63.4 |
275
+ | Multilingual | 56.7 | 66.5 | 57.4 | 66.7 | 66.6 | 71.0 |
276
+ | Robustness | 61.1 | 38.4 | 40.6 | 51.0 | 64.5 | 69.3 |
277
 
 
278
 
279
+ 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.
 
 
280
 
 
281
 
282
+ ## Cross Platform Support
283
 
284
+ [ONNX runtime](https://onnxruntime.ai/blogs/accelerating-phi-3) now supports Phi-3 mini models across platforms and hardware.
285
 
286
+ 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).
287
 
288
+ Along with DML, ONNX Runtime provides cross platform support for Phi3 mini across a range of devices CPU, GPU, and mobile.
289
 
290
+ Here are some of the optimized configurations we have added:
291
 
292
+ 1. ONNX models for int4 DML: Quantized to int4 via AWQ
293
+ 2. ONNX model for fp16 CUDA
294
+ 3. ONNX model for int4 CUDA: Quantized to int4 via RTN
295
+ 4. ONNX model for int4 CPU and Mobile: Quantized to int4 via R
296
 
297
+ ## Software
298
 
299
+ * [PyTorch](https://github.com/pytorch/pytorch)
300
+ * [Transformers](https://github.com/huggingface/transformers)
301
+ * [Flash-Attention](https://github.com/HazyResearch/flash-attention)
 
 
 
 
 
 
 
 
 
302
 
303
+ ## Hardware
304
+ 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:
305
+ * NVIDIA A100
306
+ * NVIDIA A6000
307
+ * NVIDIA H100
308
 
309
+ If you want to run the model on:
310
+ * NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
311
+ * CPU: use the **GGUF** quantized models [4K](https://aka.ms/Phi3-mini-4k-instruct-gguf)
312
+ + Optimized inference on GPU, CPU, and Mobile: use the **ONNX** models [4K](https://aka.ms/Phi3-mini-4k-instruct-onnx)
313
+
314
+ ## License
315
 
316
+ The model is licensed under the [MIT license](https://huggingface.co/microsoft/Phi-3-mini-4k/resolve/main/LICENSE).
317
 
318
+ ## Trademarks
319
 
320
+ 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.