Upload folder using huggingface_hub
Browse files- Phi-3-mini-128k-instruct.f16.gguf +2 -2
- Phi-3-mini-128k-instruct.q5_k.gguf +2 -2
- Phi-3-mini-128k-instruct.q6_k.gguf +2 -2
- Phi-3-mini-128k-instruct.q8_0.gguf +2 -2
- Phi-3-mini-128k-instruct/CODE_OF_CONDUCT.md +9 -0
- Phi-3-mini-128k-instruct/NOTICE.md +38 -0
- Phi-3-mini-128k-instruct/README.md +344 -0
- Phi-3-mini-128k-instruct/SECURITY.md +41 -0
- README.md +2 -0
Phi-3-mini-128k-instruct.f16.gguf
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b2000f05ea9e68b481fb9f1d7f34e053ff3481ac96fc2d5be2fd8edd62604cf7
|
3 |
+
size 7643296736
|
Phi-3-mini-128k-instruct.q5_k.gguf
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:452fa63041e558946e350743b13194a30d03476d07afaa4004124d463f8fb611
|
3 |
+
size 3060757472
|
Phi-3-mini-128k-instruct.q6_k.gguf
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9a3f38163593053afc7f3d317cf1cfd81f04ea5b23ac29b71a4a15d65b1d238e
|
3 |
+
size 3368252384
|
Phi-3-mini-128k-instruct.q8_0.gguf
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1ceece5569877e592b90209140d78c783fa2a4579caf6355d1daa0eb8403d2a6
|
3 |
+
size 4245910496
|
Phi-3-mini-128k-instruct/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Microsoft Open Source Code of Conduct
|
2 |
+
|
3 |
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
4 |
+
|
5 |
+
Resources:
|
6 |
+
|
7 |
+
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
|
8 |
+
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
|
9 |
+
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
|
Phi-3-mini-128k-instruct/NOTICE.md
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
NOTICES AND INFORMATION
|
2 |
+
Do Not Translate or Localize
|
3 |
+
|
4 |
+
This software incorporates material from third parties.
|
5 |
+
|
6 |
+
**Component.** https://github.com/Dao-AILab/flash-attention
|
7 |
+
|
8 |
+
**Open Source License/Copyright Notice.**
|
9 |
+
|
10 |
+
BSD 3-Clause License
|
11 |
+
|
12 |
+
Copyright (c) 2022, the respective contributors, as shown by the AUTHORS file.
|
13 |
+
All rights reserved.
|
14 |
+
|
15 |
+
Redistribution and use in source and binary forms, with or without
|
16 |
+
modification, are permitted provided that the following conditions are met:
|
17 |
+
|
18 |
+
* Redistributions of source code must retain the above copyright notice, this
|
19 |
+
list of conditions and the following disclaimer.
|
20 |
+
|
21 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
22 |
+
this list of conditions and the following disclaimer in the documentation
|
23 |
+
and/or other materials provided with the distribution.
|
24 |
+
|
25 |
+
* Neither the name of the copyright holder nor the names of its
|
26 |
+
contributors may be used to endorse or promote products derived from
|
27 |
+
this software without specific prior written permission.
|
28 |
+
|
29 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
30 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
31 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
32 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
33 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
34 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
35 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
36 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
37 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
38 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Phi-3-mini-128k-instruct/README.md
ADDED
@@ -0,0 +1,344 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
license_link: https://huggingface.co/microsoft/Phi-3-mini-128k-instruct/resolve/main/LICENSE
|
4 |
+
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
tags:
|
9 |
+
- nlp
|
10 |
+
- code
|
11 |
+
widget:
|
12 |
+
- messages:
|
13 |
+
- role: user
|
14 |
+
content: Can you provide ways to eat combinations of bananas and dragonfruits?
|
15 |
+
---
|
16 |
+
|
17 |
+
## Model Summary
|
18 |
+
|
19 |
+
The Phi-3-Mini-128K-Instruct is a 3.8 billion-parameter, lightweight, state-of-the-art open model trained using the Phi-3 datasets.
|
20 |
+
This dataset includes both synthetic data and filtered publicly available website data, with an emphasis 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.
|
22 |
+
|
23 |
+
After initial training, the model underwent a post-training process that involved supervised fine-tuning and direct preference optimization to enhance its ability to follow instructions and adhere to safety measures.
|
24 |
+
When evaluated against benchmarks that test common sense, language understanding, mathematics, coding, long-term context, and logical reasoning, the Phi-3 Mini-128K-Instruct demonstrated robust and state-of-the-art performance among models with fewer than 13 billion parameters.
|
25 |
+
Resources and Technical Documentation:
|
26 |
+
|
27 |
+
🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br>
|
28 |
+
📰 [Phi-3 Microsoft Blog](https://aka.ms/Phi-3Build2024) <br>
|
29 |
+
📖 [Phi-3 Technical Report](https://aka.ms/phi3-tech-report) <br>
|
30 |
+
🛠️ [Phi-3 on Azure AI Studio](https://aka.ms/phi3-azure-ai) <br>
|
31 |
+
👩🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br>
|
32 |
+
🖥️ [Try It](https://aka.ms/try-phi3)
|
33 |
+
|
34 |
+
| | Short Context | Long Context |
|
35 |
+
| :- | :- | :- |
|
36 |
+
| 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)|
|
37 |
+
| 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)|
|
38 |
+
| 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)|
|
39 |
+
| Vision | | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct-onnx-cuda)|
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
## Intended Uses
|
44 |
+
|
45 |
+
**Primary use cases**
|
46 |
+
|
47 |
+
The model is intended for commercial and research use in English. The model provides uses for applications which require:
|
48 |
+
|
49 |
+
1) Memory/compute constrained environments
|
50 |
+
2) Latency bound scenarios
|
51 |
+
3) Strong reasoning (especially code, math and logic)
|
52 |
+
|
53 |
+
Our model is designed to accelerate research on language and multimodal models, for use as a building block for generative AI powered features.
|
54 |
+
|
55 |
+
**Use case considerations**
|
56 |
+
|
57 |
+
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.
|
58 |
+
|
59 |
+
Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.
|
60 |
+
|
61 |
+
## Release Notes
|
62 |
+
|
63 |
+
This is an update over the original instruction-tuned Phi-3-mini release based on valuable customer feedback.
|
64 |
+
The model used additional post-training data leading to substantial gains on long-context understanding, instruction following, and structure output.
|
65 |
+
We also improve multi-turn conversation quality, explicitly support <|system|> tag, and significantly improve reasoning capability.
|
66 |
+
We believe most use cases will benefit from this release, but we encourage users to test in their particular AI applications.
|
67 |
+
We appreciate the enthusiastic adoption of the Phi-3 model family, and continue to welcome all feedback from the community.
|
68 |
+
|
69 |
+
These tables below highlights improvements on instruction following, structure output, reasoning, and long-context understanding of the new release on our public and internal benchmark datasets.
|
70 |
+
|
71 |
+
| Benchmarks | Original | June 2024 Update |
|
72 |
+
| :- | :- | :- |
|
73 |
+
| Instruction Extra Hard | 5.7 | 5.9 |
|
74 |
+
| Instruction Hard | 5.0 | 5.2 |
|
75 |
+
| JSON Structure Output | 1.9 | 60.1 |
|
76 |
+
| XML Structure Output | 47.8 | 52.9 |
|
77 |
+
| GPQA | 25.9 | 29.7 |
|
78 |
+
| MMLU | 68.1 | 69.7 |
|
79 |
+
| **Average** | **25.7** | **37.3** |
|
80 |
+
|
81 |
+
RULER: a retrieval-based benchmark for long context understanding
|
82 |
+
|
83 |
+
| Model | 4K | 8K | 16K | 32K | 64K | 128K | Average |
|
84 |
+
| :-------------------| :------| :------| :------| :------| :------| :------| :---------|
|
85 |
+
| Original | 86.7 | 78.1 | 75.6 | 70.3 | 58.9 | 43.3 | **68.8** |
|
86 |
+
| June 2024 Update | 92.4 | 91.1 | 90.8 | 87.9 | 79.8 | 65.6 | **84.6** |
|
87 |
+
|
88 |
+
RepoQA: a benchmark for long context code understanding
|
89 |
+
|
90 |
+
| Model | Python | C++ | Rust | Java | TypeScript | Average |
|
91 |
+
| :-------------------| :--------| :-----| :------| :------| :------------| :---------|
|
92 |
+
| Original | 27 | 29 | 40 | 33 | 33 | **32.4** |
|
93 |
+
| June 2024 Update | 85 | 63 | 72 | 93 | 72 | **77** |
|
94 |
+
|
95 |
+
|
96 |
+
Notes: if users would like to check out the previous version, use the git commit id **bb5bf1e4001277a606e11debca0ef80323e5f824**. 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!
|
97 |
+
|
98 |
+
## How to Use
|
99 |
+
|
100 |
+
Phi-3 Mini-128K-Instruct has been integrated in the development version (4.41.3) of `transformers`. Until the official version is released through `pip`, ensure that you are doing one of the following:
|
101 |
+
|
102 |
+
* When loading the model, ensure that `trust_remote_code=True` is passed as an argument of the `from_pretrained()` function.
|
103 |
+
|
104 |
+
* Update your local `transformers` to the development version: `pip uninstall -y transformers && pip install git+https://github.com/huggingface/transformers`. The previous command is an alternative to cloning and installing from the source.
|
105 |
+
|
106 |
+
The current `transformers` version can be verified with: `pip list | grep transformers`.
|
107 |
+
|
108 |
+
Examples of required packages:
|
109 |
+
```
|
110 |
+
flash_attn==2.5.8
|
111 |
+
torch==2.3.1
|
112 |
+
accelerate==0.31.0
|
113 |
+
transformers==4.41.2
|
114 |
+
```
|
115 |
+
|
116 |
+
Phi-3 Mini-128K-Instruct is also available in [Azure AI Studio](https://aka.ms/try-phi3)
|
117 |
+
|
118 |
+
### Tokenizer
|
119 |
+
|
120 |
+
Phi-3 Mini-128K-Instruct supports a vocabulary size of up to `32064` tokens. The [tokenizer files](https://huggingface.co/microsoft/Phi-3-mini-128k-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.
|
121 |
+
|
122 |
+
|
123 |
+
### Chat Format
|
124 |
+
|
125 |
+
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.
|
126 |
+
You can provide the prompt as a question with a generic template as follow:
|
127 |
+
```markdown
|
128 |
+
<|system|>
|
129 |
+
You are a helpful assistant.<|end|>
|
130 |
+
<|user|>
|
131 |
+
Question?<|end|>
|
132 |
+
<|assistant|>
|
133 |
+
```
|
134 |
+
|
135 |
+
For example:
|
136 |
+
```markdown
|
137 |
+
<|system|>
|
138 |
+
You are a helpful assistant.<|end|>
|
139 |
+
<|user|>
|
140 |
+
How to explain Internet for a medieval knight?<|end|>
|
141 |
+
<|assistant|>
|
142 |
+
```
|
143 |
+
where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
|
144 |
+
|
145 |
+
```markdown
|
146 |
+
<|system|>
|
147 |
+
You are a helpful travel assistant.<|end|>
|
148 |
+
<|user|>
|
149 |
+
I am going to Paris, what should I see?<|end|>
|
150 |
+
<|assistant|>
|
151 |
+
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|>
|
152 |
+
<|user|>
|
153 |
+
What is so great about #1?<|end|>
|
154 |
+
<|assistant|>
|
155 |
+
```
|
156 |
+
|
157 |
+
### Sample inference code
|
158 |
+
|
159 |
+
This code snippets show how to get quickly started with running the model on a GPU:
|
160 |
+
|
161 |
+
```python
|
162 |
+
import torch
|
163 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
164 |
+
|
165 |
+
torch.random.manual_seed(0)
|
166 |
+
model = AutoModelForCausalLM.from_pretrained(
|
167 |
+
"microsoft/Phi-3-mini-128k-instruct",
|
168 |
+
device_map="cuda",
|
169 |
+
torch_dtype="auto",
|
170 |
+
trust_remote_code=True,
|
171 |
+
)
|
172 |
+
|
173 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-128k-instruct")
|
174 |
+
|
175 |
+
messages = [
|
176 |
+
{"role": "system", "content": "You are a helpful AI assistant."},
|
177 |
+
{"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
|
178 |
+
{"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."},
|
179 |
+
{"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
|
180 |
+
]
|
181 |
+
|
182 |
+
pipe = pipeline(
|
183 |
+
"text-generation",
|
184 |
+
model=model,
|
185 |
+
tokenizer=tokenizer,
|
186 |
+
)
|
187 |
+
|
188 |
+
generation_args = {
|
189 |
+
"max_new_tokens": 500,
|
190 |
+
"return_full_text": False,
|
191 |
+
"temperature": 0.0,
|
192 |
+
"do_sample": False,
|
193 |
+
}
|
194 |
+
|
195 |
+
output = pipe(messages, **generation_args)
|
196 |
+
print(output[0]['generated_text'])
|
197 |
+
```
|
198 |
+
|
199 |
+
Notes: If you want to use flash attention, call _AutoModelForCausalLM.from_pretrained()_ with _attn_implementation="flash_attention_2"_
|
200 |
+
|
201 |
+
## Responsible AI Considerations
|
202 |
+
|
203 |
+
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:
|
204 |
+
|
205 |
+
+ 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.
|
206 |
+
+ 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.
|
207 |
+
+ 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.
|
208 |
+
+ Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
|
209 |
+
+ 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.
|
210 |
+
|
211 |
+
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:
|
212 |
+
|
213 |
+
+ 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.
|
214 |
+
+ 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.
|
215 |
+
+ 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).
|
216 |
+
+ Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
|
217 |
+
+ 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.
|
218 |
+
|
219 |
+
## Training
|
220 |
+
|
221 |
+
### Model
|
222 |
+
|
223 |
+
* 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.
|
224 |
+
* Inputs: Text. It is best suited for prompts using chat format.
|
225 |
+
* Context length: 128K tokens
|
226 |
+
* GPUs: 512 H100-80G
|
227 |
+
* Training time: 10 days
|
228 |
+
* Training data: 4.9T tokens
|
229 |
+
* Outputs: Generated text in response to the input
|
230 |
+
* Dates: Our models were trained between May and June 2024
|
231 |
+
* 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.
|
232 |
+
* Release dates: June, 2024.
|
233 |
+
|
234 |
+
### Datasets
|
235 |
+
|
236 |
+
Our training data includes a wide variety of sources, totaling 4.9 trillion tokens, and is a combination of
|
237 |
+
1) Publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
|
238 |
+
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.);
|
239 |
+
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.
|
240 |
+
|
241 |
+
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).
|
242 |
+
|
243 |
+
### Fine-tuning
|
244 |
+
|
245 |
+
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-128k-instruct/resolve/main/sample_finetune.py).
|
246 |
+
|
247 |
+
## Benchmarks
|
248 |
+
|
249 |
+
We report the results under completion format 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 Mistral-7b-v0.1, Mixtral-8x7b, Gemma 7B, Llama-3-8B-Instruct, and GPT-3.5.
|
250 |
+
|
251 |
+
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.
|
252 |
+
|
253 |
+
As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
|
254 |
+
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.
|
255 |
+
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.
|
256 |
+
|
257 |
+
The number of k–shot examples is listed per-benchmark.
|
258 |
+
|
259 |
+
| Category | Benchmark | Phi-3-Mini-128K-Ins | Gemma-7B | Mistral-7B | Mixtral-8x7B | Llama-3-8B-Ins | GPT3.5-Turbo-1106 |
|
260 |
+
| :----------| :-----------| :---------------------| :----------| :------------| :--------------| :----------------| :-------------------|
|
261 |
+
| Popular aggregated benchmark | AGI Eval <br>5-shot| 39.5 | 42.1 | 35.1 | 45.2 | 42 | 48.4 |
|
262 |
+
| | MMLU <br>5-shot | 69.7 | 63.6 | 61.7 | 70.5 | 66.5 | 71.4 |
|
263 |
+
| | BigBench Hard <br>3-shot | 72.1 | 59.6 | 57.3 | 69.7 | 51.5 | 68.3 |
|
264 |
+
| Language Understanding | ANLI <br>7-shot | 52.3 | 48.7 | 47.1 | 55.2 | 57.3 | 58.1 |
|
265 |
+
| | HellaSwag <br>5-shot | 70.5 | 49.8 | 58.5 | 70.4 | 71.1 | 78.8 |
|
266 |
+
| Reasoning | ARC Challenge <br>10-shot | 85.5 | 78.3 | 78.6 | 87.3 | 82.8 | 87.4 |
|
267 |
+
| | BoolQ <br>0-shot | 77.1 | 66 | 72.2 | 76.6 | 80.9 | 79.1 |
|
268 |
+
| | MedQA <br>2-shot | 56.4 | 49.6 | 50 | 62.2 | 60.5 | 63.4 |
|
269 |
+
| | OpenBookQA <br>10-shot | 78.8 | 78.6 | 79.8 | 85.8 | 82.6 | 86 |
|
270 |
+
| | PIQA <br>5-shot | 80.1 | 78.1 | 77.7 | 86 | 75.7 | 86.6 |
|
271 |
+
| | GPQA <br>0-shot | 29.7 | 2.9 | 15 | 6.9 | 32.4 | 29.9 |
|
272 |
+
| | Social IQA <br>5-shot | 74.7 | 65.5 | 74.6 | 75.9 | 73.9 | 68.3 |
|
273 |
+
| | TruthfulQA (MC2) <br>10-shot | 64.8 | 52.1 | 53 | 60.1 | 63.2 | 67.7 |
|
274 |
+
| | WinoGrande <br>5-shot | 71.0 | 55.6 | 54.2 | 62 | 65 | 68.8 |
|
275 |
+
| Factual Knowledge | TriviaQA <br>5-shot | 57.8 | 72.3 | 75.2 | 82.2 | 67.7 | 85.8 |
|
276 |
+
| Math | GSM8K CoTT <br>8-shot | 85.3 | 59.8 | 46.4 | 64.7 | 77.4 | 78.1 |
|
277 |
+
| Code Generation | HumanEval <br>0-shot | 60.4 | 34.1 | 28.0 | 37.8 | 60.4 | 62.2 |
|
278 |
+
| | MBPP <br>3-shot | 70.0 | 51.5 | 50.8 | 60.2 | 67.7 | 77.8 |
|
279 |
+
| **Average** | | **66.4** | **56.0** | **56.4** | **64.4** | **65.5** | **70.3** |
|
280 |
+
|
281 |
+
**Long Context**: Phi-3 Mini-128K-Instruct supports 128K context length, therefore the model is capable of several long context tasks including long document/meeting summarization, long document QA.
|
282 |
+
|
283 |
+
| Benchmark | Phi-3 Mini-128K-Instruct | Mistral-7B | Mixtral 8x7B | LLaMA-3-8B-Instruct |
|
284 |
+
| :---------------| :--------------------------|:------------|:--------------|:---------------------|
|
285 |
+
| GovReport | 25.3 | 4.9 | 20.3 | 10.3 |
|
286 |
+
| QMSum | 21.9 | 15.5 | 20.6 | 2.9 |
|
287 |
+
| Qasper | 41.6 | 23.5 | 26.6 | 8.1 |
|
288 |
+
| SQuALITY | 24.1 | 14.7 | 16.2 | 25 |
|
289 |
+
| SummScreenFD | 16.8 | 9.3 | 11.3 | 5.1 |
|
290 |
+
| **Average** | **25.9** | **13.6** | **19.0** | **10.3** |
|
291 |
+
|
292 |
+
We take a closer look at different categories across 100 public benchmark datasets at the table below:
|
293 |
+
|
294 |
+
| Category | Phi-3-Mini-128K-Instruct | Gemma-7B | Mistral-7B | Mixtral 8x7B | Llama-3-8B-Instruct | GPT-3.5-Turbo |
|
295 |
+
|:----------|:--------------------------|:----------|:------------|:--------------|:---------------------|:---------------|
|
296 |
+
| Popular aggregated benchmark | 60.6 | 59.4 | 56.5 | 66.2 | 59.9 | 67.0 |
|
297 |
+
| Reasoning | 69.4 | 60.3 | 62.8 | 68.1 | 69.6 | 71.7 |
|
298 |
+
| Language understanding | 57.5 | 57.6 | 52.5 | 66.1 | 63.2 | 67.7 |
|
299 |
+
| Code generation | 61.0 | 45.6 | 42.9 | 52.7 | 56.4 | 70.4 |
|
300 |
+
| Math | 51.6 | 35.8 | 25.4 | 40.3 | 41.1 | 52.8 |
|
301 |
+
| Factual knowledge | 35.8 | 46.7 | 49.8 | 58.6 | 43.1 | 63.4 |
|
302 |
+
| Multilingual | 56.4 | 66.5 | 57.4 | 66.7 | 66.6 | 71.0 |
|
303 |
+
| Robustness | 61.1 | 38.4 | 40.6 | 51.0 | 64.5 | 69.3 |
|
304 |
+
|
305 |
+
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.
|
306 |
+
|
307 |
+
## Cross Platform Support
|
308 |
+
|
309 |
+
[ONNX runtime](https://onnxruntime.ai/blogs/accelerating-phi-3) now supports Phi-3 mini models across platforms and hardware.
|
310 |
+
|
311 |
+
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).
|
312 |
+
|
313 |
+
Along with DML, ONNX Runtime provides cross platform support for Phi3 mini across a range of devices CPU, GPU, and mobile.
|
314 |
+
|
315 |
+
Here are some of the optimized configurations we have added:
|
316 |
+
|
317 |
+
1. ONNX models for int4 DML: Quantized to int4 via AWQ
|
318 |
+
2. ONNX model for fp16 CUDA
|
319 |
+
3. ONNX model for int4 CUDA: Quantized to int4 via RTN
|
320 |
+
4. ONNX model for int4 CPU and Mobile: Quantized to int4 via RTN
|
321 |
+
|
322 |
+
## Software
|
323 |
+
|
324 |
+
* [PyTorch](https://github.com/pytorch/pytorch)
|
325 |
+
* [Transformers](https://github.com/huggingface/transformers)
|
326 |
+
* [Flash-Attention](https://github.com/HazyResearch/flash-attention)
|
327 |
+
|
328 |
+
## Hardware
|
329 |
+
Note that by default, the Phi-3 Mini-128K-Instruct model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types:
|
330 |
+
* NVIDIA A100
|
331 |
+
* NVIDIA A6000
|
332 |
+
* NVIDIA H100
|
333 |
+
|
334 |
+
If you want to run the model on:
|
335 |
+
* NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
|
336 |
+
* Optimized inference on GPU, CPU, and Mobile: use the **ONNX** models [128K](https://aka.ms/phi3-mini-128k-instruct-onnx)
|
337 |
+
|
338 |
+
## License
|
339 |
+
|
340 |
+
The model is licensed under the [MIT license](https://huggingface.co/microsoft/Phi-3-mini-128k/resolve/main/LICENSE).
|
341 |
+
|
342 |
+
## Trademarks
|
343 |
+
|
344 |
+
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.
|
Phi-3-mini-128k-instruct/SECURITY.md
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
|
2 |
+
|
3 |
+
## Security
|
4 |
+
|
5 |
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin).
|
6 |
+
|
7 |
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
|
8 |
+
|
9 |
+
## Reporting Security Issues
|
10 |
+
|
11 |
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
12 |
+
|
13 |
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
|
14 |
+
|
15 |
+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
|
16 |
+
|
17 |
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
|
18 |
+
|
19 |
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
20 |
+
|
21 |
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
22 |
+
* Full paths of source file(s) related to the manifestation of the issue
|
23 |
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
24 |
+
* Any special configuration required to reproduce the issue
|
25 |
+
* Step-by-step instructions to reproduce the issue
|
26 |
+
* Proof-of-concept or exploit code (if possible)
|
27 |
+
* Impact of the issue, including how an attacker might exploit the issue
|
28 |
+
|
29 |
+
This information will help us triage your report more quickly.
|
30 |
+
|
31 |
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
|
32 |
+
|
33 |
+
## Preferred Languages
|
34 |
+
|
35 |
+
We prefer all communications to be in English.
|
36 |
+
|
37 |
+
## Policy
|
38 |
+
|
39 |
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
|
40 |
+
|
41 |
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
README.md
CHANGED
@@ -12,3 +12,5 @@ all other tensors quantized to q5_k or q6_k.
|
|
12 |
Result:
|
13 |
both f16.q6 and f16.q5 are smaller than q8_0 standard quantization
|
14 |
and they perform as well as the pure f16.
|
|
|
|
|
|
12 |
Result:
|
13 |
both f16.q6 and f16.q5 are smaller than q8_0 standard quantization
|
14 |
and they perform as well as the pure f16.
|
15 |
+
|
16 |
+
Updated on: Tue Jul 3, 09:54:00
|