fix(root): Another readme typo.
Browse files
README.md
CHANGED
@@ -12,8 +12,8 @@ tags:
|
|
12 |
|
13 |
## Model Summary
|
14 |
|
15 |
-
Phi-3 Mini-128K-Instruct is a 3.8B parameters, lightweight, state-of-the-art open model built upon datasets used for Phi-2 - synthetic data and filtered websites - with a focus on very high-quality, reasoning dense data.
|
16 |
-
|
17 |
The model underwent a rigorous enhancement process, incorporating both supervised fine-tuning and direct preference optimization to ensure precise instruction adherence and robust safety measures.
|
18 |
When assessed against benchmarks testing common sense, language understanding, math, code, long context and logical reasoning, Phi-3 Mini-128K-Instruct showcased a robust and state-of-the-art performance among models with less than 13 billion parameters.
|
19 |
|
@@ -22,13 +22,14 @@ Resources and Technical Documentation:
|
|
22 |
+ [Phi-3 Microsoft Blog](https://aka.ms/phi3blog-april)
|
23 |
+ [Phi-3 Technical Report](https://aka.ms/phi3-tech-report)
|
24 |
+ [Phi-3 on Azure AI Studio](https://aka.ms/phi3-azure-ai)
|
25 |
-
+ Phi-3 ONNX: [128K](https://aka.ms/
|
26 |
|
27 |
## Intended Uses
|
28 |
|
29 |
**Primary use cases**
|
30 |
|
31 |
-
The model is intended for commercial and research use in English. The model provides uses for applications which require
|
|
|
32 |
1) Memory/compute constrained environments
|
33 |
2) Latency bound scenarios
|
34 |
3) Strong reasoning (especially math and logic)
|
@@ -37,8 +38,8 @@ Our model is designed to accelerate research on language and multimodal models,
|
|
37 |
|
38 |
**Use case considerations**
|
39 |
|
40 |
-
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 fariness before using within a specific downstream use case, particularly for high risk scenarios.
|
41 |
-
|
42 |
Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.
|
43 |
|
44 |
## How to Use
|
@@ -53,7 +54,7 @@ The current `transformers` version can be verified with: `pip list | grep transf
|
|
53 |
|
54 |
### Chat Format:
|
55 |
|
56 |
-
Given the nature of the training data, the Phi-3-
|
57 |
|
58 |
```markdown
|
59 |
<|system|>
|
@@ -65,7 +66,7 @@ How to explain Internet for a medieval knight?
|
|
65 |
<|assistant|>
|
66 |
```
|
67 |
|
68 |
-
where the model generates the text after
|
69 |
|
70 |
```markdown
|
71 |
<|system|>
|
@@ -91,19 +92,14 @@ import torch
|
|
91 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
92 |
|
93 |
torch.random.manual_seed(0)
|
94 |
-
token = "your huggingface token here"
|
95 |
-
|
96 |
-
model_id = "microsoft/Phi-3-mini-128k-instruct"
|
97 |
|
98 |
model = AutoModelForCausalLM.from_pretrained(
|
99 |
-
|
100 |
device_map="cuda",
|
101 |
torch_dtype="auto",
|
102 |
trust_remote_code=True,
|
103 |
-
token=token
|
104 |
)
|
105 |
-
|
106 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id, token=token)
|
107 |
|
108 |
messages = [
|
109 |
{"role": "system", "content": "You are a helpful digital assistant. Please provide safe, ethical and accurate information to the user."},
|
@@ -131,33 +127,35 @@ output = pipe(messages, **generation_args)
|
|
131 |
print(output[0]['generated_text'])
|
132 |
```
|
133 |
|
134 |
-
Note that by default the model use flash attention which requires certain types of GPU to run. If you want to run the model on
|
|
|
135 |
+ V100 or earlier generation GPUs: call `AutoModelForCausalLM.from_pretrained()` with `attn_implementation="eager"`
|
136 |
-
+ CPU: use the **GGUF** quantized models [4K](https://aka.ms/
|
137 |
-
+ Optimized inference: use the **ONNX** models [4K](https://aka.ms/
|
138 |
|
139 |
## Responsible AI Considerations
|
140 |
|
141 |
-
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:
|
|
|
142 |
+ 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.
|
143 |
+ 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.
|
144 |
+ 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.
|
145 |
+ Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
|
146 |
+ 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.
|
147 |
|
148 |
-
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:
|
|
|
149 |
+ 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.
|
150 |
+ 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.
|
151 |
+ 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).
|
152 |
+ Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
|
153 |
+ 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.
|
154 |
|
155 |
-
|
156 |
## Training
|
157 |
|
158 |
### Model
|
159 |
|
160 |
-
* Architecture: Phi-3 Mini 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.
|
161 |
* Inputs: Text. It is best suited for prompts using chat format.
|
162 |
* Context length: 4K tokens
|
163 |
* GPUs: 512 H100-80G
|
@@ -181,11 +179,13 @@ A basic example of multi-GPUs supervised fine-tuning (SFT) with TRL and Accelera
|
|
181 |
## Benchmarks
|
182 |
|
183 |
We report the results for Phi-3-Mini-128K-Instruct on standard open-source benchmarks measuring the model's reasoning ability (both common sense reasoning and logical reasoning). We compare to Phi-2, Mistral-7b-v0.1, Mixtral-8x7b, Gemma 7B, Llama-3-8B-Instruct, and GPT-3.5.
|
184 |
-
|
185 |
-
These numbers might differ from other published numbers due to slightly different choices in the evaluation.
|
|
|
186 |
As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
|
187 |
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.
|
188 |
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.
|
|
|
189 |
The number of k–shot examples is listed per-benchmark.
|
190 |
|
191 |
| | Phi-3-Mini-4K-In<br>3.8b | Phi-3-Small<br>7b (preview) | Phi-3-Medium<br>14b (preview) | Phi-2<br>2.7b | Mistral<br>7b | Gemma<br>7b | Llama-3-In<br>8b | Mixtral<br>8x7b | GPT-3.5<br>version 1106 |
|
@@ -219,10 +219,13 @@ The number of k–shot examples is listed per-benchmark.
|
|
219 |
|
220 |
## Cross Platform Support
|
221 |
|
222 |
-
ONNX runtime ecosystem now supports
|
223 |
-
|
224 |
-
|
|
|
|
|
225 |
Here are some of the optimized configurations we have added:
|
|
|
226 |
1. ONNX models for int4 DML: Quantized to int4 via AWQ
|
227 |
2. ONNX model for fp16 CUDA
|
228 |
3. ONNX model for int4 CUDA: Quantized to int4 via RTN
|
@@ -230,7 +233,7 @@ Here are some of the optimized configurations we have added:
|
|
230 |
|
231 |
## License
|
232 |
|
233 |
-
The model is licensed under the [MIT license](https://huggingface.co/microsoft/
|
234 |
|
235 |
## Trademarks
|
236 |
|
|
|
12 |
|
13 |
## Model Summary
|
14 |
|
15 |
+
Phi-3 Mini-128K-Instruct is a 3.8B parameters, lightweight, state-of-the-art open model built upon datasets used for Phi-2 - synthetic data and filtered websites - with a focus on very high-quality, reasoning dense data. The model belongs to the Phi-3 model family, and the Mini version comes 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) it can support.
|
16 |
+
|
17 |
The model underwent a rigorous enhancement process, incorporating both supervised fine-tuning and direct preference optimization to ensure precise instruction adherence and robust safety measures.
|
18 |
When assessed against benchmarks testing common sense, language understanding, math, code, long context and logical reasoning, Phi-3 Mini-128K-Instruct showcased a robust and state-of-the-art performance among models with less than 13 billion parameters.
|
19 |
|
|
|
22 |
+ [Phi-3 Microsoft Blog](https://aka.ms/phi3blog-april)
|
23 |
+ [Phi-3 Technical Report](https://aka.ms/phi3-tech-report)
|
24 |
+ [Phi-3 on Azure AI Studio](https://aka.ms/phi3-azure-ai)
|
25 |
+
+ Phi-3 ONNX: [128K](https://aka.ms/Phi3-mini-128k-instruct-onnx)
|
26 |
|
27 |
## Intended Uses
|
28 |
|
29 |
**Primary use cases**
|
30 |
|
31 |
+
The model is intended for commercial and research use in English. The model provides uses for applications which require:
|
32 |
+
|
33 |
1) Memory/compute constrained environments
|
34 |
2) Latency bound scenarios
|
35 |
3) Strong reasoning (especially math and logic)
|
|
|
38 |
|
39 |
**Use case considerations**
|
40 |
|
41 |
+
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 fariness before using within a specific downstream use case, particularly for high risk scenarios. 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.
|
42 |
+
|
43 |
Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.
|
44 |
|
45 |
## How to Use
|
|
|
54 |
|
55 |
### Chat Format:
|
56 |
|
57 |
+
Given the nature of the training data, the Phi-3 Mini-128K-Instruct model is best suited for prompts using the chat format as follows. You can provide the prompt as a question:
|
58 |
|
59 |
```markdown
|
60 |
<|system|>
|
|
|
66 |
<|assistant|>
|
67 |
```
|
68 |
|
69 |
+
where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
|
70 |
|
71 |
```markdown
|
72 |
<|system|>
|
|
|
92 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
93 |
|
94 |
torch.random.manual_seed(0)
|
|
|
|
|
|
|
95 |
|
96 |
model = AutoModelForCausalLM.from_pretrained(
|
97 |
+
"microsoft/Phi-3-mini-128k-instruct",
|
98 |
device_map="cuda",
|
99 |
torch_dtype="auto",
|
100 |
trust_remote_code=True,
|
|
|
101 |
)
|
102 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-128k-instruct")
|
|
|
103 |
|
104 |
messages = [
|
105 |
{"role": "system", "content": "You are a helpful digital assistant. Please provide safe, ethical and accurate information to the user."},
|
|
|
127 |
print(output[0]['generated_text'])
|
128 |
```
|
129 |
|
130 |
+
Note that by default the model use flash attention which requires certain types of GPU to run. If you want to run the model on:
|
131 |
+
|
132 |
+ V100 or earlier generation GPUs: call `AutoModelForCausalLM.from_pretrained()` with `attn_implementation="eager"`
|
133 |
+
+ CPU: use the **GGUF** quantized models [4K](https://aka.ms/Phi3-mini-4k-instruct-gguf)
|
134 |
+
+ Optimized inference: use the **ONNX** models [4K](https://aka.ms/Phi3-mini-128k-instruct-onnx)
|
135 |
|
136 |
## Responsible AI Considerations
|
137 |
|
138 |
+
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:
|
139 |
+
|
140 |
+ 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.
|
141 |
+ 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.
|
142 |
+ 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.
|
143 |
+ Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
|
144 |
+ 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.
|
145 |
|
146 |
+
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:
|
147 |
+
|
148 |
+ 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.
|
149 |
+ 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.
|
150 |
+ 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).
|
151 |
+ Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
|
152 |
+ 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.
|
153 |
|
|
|
154 |
## Training
|
155 |
|
156 |
### Model
|
157 |
|
158 |
+
* Architecture: Phi-3 Mini-128K-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.
|
159 |
* Inputs: Text. It is best suited for prompts using chat format.
|
160 |
* Context length: 4K tokens
|
161 |
* GPUs: 512 H100-80G
|
|
|
179 |
## Benchmarks
|
180 |
|
181 |
We report the results for Phi-3-Mini-128K-Instruct on standard open-source benchmarks measuring the model's reasoning ability (both common sense reasoning and logical reasoning). We compare to Phi-2, Mistral-7b-v0.1, Mixtral-8x7b, Gemma 7B, Llama-3-8B-Instruct, and GPT-3.5.
|
182 |
+
|
183 |
+
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.
|
184 |
+
|
185 |
As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
|
186 |
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.
|
187 |
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.
|
188 |
+
|
189 |
The number of k–shot examples is listed per-benchmark.
|
190 |
|
191 |
| | Phi-3-Mini-4K-In<br>3.8b | Phi-3-Small<br>7b (preview) | Phi-3-Medium<br>14b (preview) | Phi-2<br>2.7b | Mistral<br>7b | Gemma<br>7b | Llama-3-In<br>8b | Mixtral<br>8x7b | GPT-3.5<br>version 1106 |
|
|
|
219 |
|
220 |
## Cross Platform Support
|
221 |
|
222 |
+
ONNX runtime ecosystem now supports Phi-3 Mini models across platforms and hardware. You can find the optimized ONNX models [here](https://aka.ms/Phi3-ONNX-HF).
|
223 |
+
|
224 |
+
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 support lets developers bring hardware acceleration to Windows devices at scale across AMD, Intel, and NVIDIA GPUs.
|
225 |
+
Along with DirectML, ONNX Runtime provides cross platform support for Phi-3 across a range of devices CPU, GPU, and mobile.
|
226 |
+
|
227 |
Here are some of the optimized configurations we have added:
|
228 |
+
|
229 |
1. ONNX models for int4 DML: Quantized to int4 via AWQ
|
230 |
2. ONNX model for fp16 CUDA
|
231 |
3. ONNX model for int4 CUDA: Quantized to int4 via RTN
|
|
|
233 |
|
234 |
## License
|
235 |
|
236 |
+
The model is licensed under the [MIT license](https://huggingface.co/microsoft/Phi-3-mini-128k/resolve/main/LICENSE).
|
237 |
|
238 |
## Trademarks
|
239 |
|