nguyenbh gargamit commited on
Commit
4f818b1
1 Parent(s): ff07dc0

Update model (#77)

Browse files

- Update model (ba3e2e891adaf6b9e7471bcc80dec875d73ae4e9)
- updated headers (43660c77a28ff014ed8f63fb8137ade85ef8ece1)


Co-authored-by: Amit Garg <[email protected]>

.gitattributes CHANGED
@@ -1,35 +1,35 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
CODE_OF_CONDUCT.md CHANGED
@@ -1,9 +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 [[email protected]](mailto:[email protected]) with questions or concerns
 
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 [[email protected]](mailto:[email protected]) with questions or concerns
LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- Microsoft.
2
- Copyright (c) Microsoft Corporation.
3
-
4
- MIT License
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
  SOFTWARE.
 
1
+ Microsoft.
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
  SOFTWARE.
NOTICE.md CHANGED
@@ -1,38 +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.
 
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.
README.md CHANGED
@@ -1,263 +1,318 @@
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
-
20
- ## Model Summary
21
-
22
- 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.
23
- 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.
24
-
25
- 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.
26
- 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.
27
-
28
- Resources and Technical Documentation:
29
-
30
- + [Phi-3 Microsoft Blog](https://aka.ms/Phi-3Build2024)
31
- + [Phi-3 Technical Report](https://aka.ms/phi3-tech-report)
32
- + [Phi-3 on Azure AI Studio](https://aka.ms/phi3-azure-ai)
33
- + [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook)
34
-
35
- | | Short Context | Long Context |
36
- | ------- | ------------- | ------------ |
37
- | 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)|
38
- | 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)|
39
- | 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)|
40
- | Vision | | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct-onnx-cuda)|
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
- ## How to Use
62
-
63
- Phi-3 Mini-4K-Instruct has been integrated in the development version (4.41.0.dev0) of `transformers`. Until the official version is released through `pip`, ensure that you are doing one of the following:
64
-
65
- * When loading the model, ensure that `trust_remote_code=True` is passed as an argument of the `from_pretrained()` function.
66
-
67
- * 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.
68
-
69
- The current `transformers` version can be verified with: `pip list | grep transformers`.
70
-
71
- Phi-3 Mini-4K-Instruct is also available in [HuggingChat](https://aka.ms/try-phi3-hf-chat).
72
-
73
- ### Tokenizer
74
-
75
- 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.
76
-
77
- ### Chat Format
78
-
79
- 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.
80
- You can provide the prompt as a question with a generic template as follow:
81
- ```markdown
82
- <|user|>\nQuestion <|end|>\n<|assistant|>
83
- ```
84
- For example:
85
- ```markdown
86
- <|user|>
87
- How to explain Internet for a medieval knight?<|end|>
88
- <|assistant|>
89
- ```
90
-
91
- where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
92
-
93
- ```markdown
94
- <|user|>
95
- I am going to Paris, what should I see?<|end|>
96
- <|assistant|>
97
- 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|>
98
- <|user|>
99
- What is so great about #1?<|end|>
100
- <|assistant|>
101
- ```
102
-
103
- ### Sample inference code
104
-
105
- This code snippets show how to get quickly started with running the model on a GPU:
106
-
107
- ```python
108
- import torch
109
- from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
110
-
111
- torch.random.manual_seed(0)
112
-
113
- model = AutoModelForCausalLM.from_pretrained(
114
- "microsoft/Phi-3-mini-4k-instruct",
115
- device_map="cuda",
116
- torch_dtype="auto",
117
- trust_remote_code=True,
118
- )
119
- tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
120
-
121
- messages = [
122
- {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
123
- {"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."},
124
- {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
125
- ]
126
-
127
- pipe = pipeline(
128
- "text-generation",
129
- model=model,
130
- tokenizer=tokenizer,
131
- )
132
-
133
- generation_args = {
134
- "max_new_tokens": 500,
135
- "return_full_text": False,
136
- "temperature": 0.0,
137
- "do_sample": False,
138
- }
139
-
140
- output = pipe(messages, **generation_args)
141
- print(output[0]['generated_text'])
142
- ```
143
-
144
- *Some applications/frameworks might not include a BOS token (`<s>`) at the start of the conversation. Please ensure that it is included since it provides more reliable results.*
145
-
146
- ## Responsible AI Considerations
147
-
148
- 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:
149
-
150
- + 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.
151
- + 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.
152
- + 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.
153
- + Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
154
- + 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.
155
-
156
- 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:
157
-
158
- + 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.
159
- + 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.
160
- + 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).
161
- + Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
162
- + 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.
163
-
164
-
165
- ## Training
166
-
167
- ### Model
168
-
169
- * 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.
170
- * Inputs: Text. It is best suited for prompts using chat format.
171
- * Context length: 4K tokens
172
- * GPUs: 512 H100-80G
173
- * Training time: 7 days
174
- * Training data: 3.3T tokens
175
- * Outputs: Generated text in response to the input
176
- * Dates: Our models were trained between February and April 2024
177
- * 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.
178
-
179
- ### Datasets
180
-
181
- Our training data includes a wide variety of sources, totaling 3.3 trillion tokens, and is a combination of
182
- 1) Publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
183
- 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.);
184
- 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.
185
-
186
- ### Fine-tuning
187
-
188
- 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).
189
-
190
- ## Benchmarks
191
-
192
- 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 Phi-2, Mistral-7b-v0.1, Mixtral-8x7b, Gemma 7B, Llama-3-8B-Instruct, and GPT-3.5.
193
-
194
- 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.
195
-
196
- As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
197
- 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.
198
- 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.
199
-
200
- The number of k–shot examples is listed per-benchmark.
201
-
202
- | | 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 |
203
- |---|---|---|---|---|---|---|---|---|---|
204
- | MMLU <br>5-Shot | 68.8 | 75.3 | 78.2 | 56.3 | 61.7 | 63.6 | 66.5 | 68.4 | 71.4 |
205
- | HellaSwag <br> 5-Shot | 76.7 | 78.7 | 83.2 | 53.6 | 58.5 | 49.8 | 71.1 | 70.4 | 78.8 |
206
- | ANLI <br> 7-Shot | 52.8 | 55.0 | 58.7 | 42.5 | 47.1 | 48.7 | 57.3 | 55.2 | 58.1 |
207
- | GSM-8K <br> 0-Shot; CoT | 82.5 | 86.4 | 90.8 | 61.1 | 46.4 | 59.8 | 77.4 | 64.7 | 78.1 |
208
- | MedQA <br> 2-Shot | 53.8 | 58.2 | 69.8 | 40.9 | 49.6 | 50.0 | 60.5 | 62.2 | 63.4 |
209
- | AGIEval <br> 0-Shot | 37.5 | 45.0 | 49.7 | 29.8 | 35.1 | 42.1 | 42.0 | 45.2 | 48.4 |
210
- | TriviaQA <br> 5-Shot | 64.0 | 59.1 | 73.3 | 45.2 | 72.3 | 75.2 | 67.7 | 82.2 | 85.8 |
211
- | Arc-C <br> 10-Shot | 84.9 | 90.7 | 91.9 | 75.9 | 78.6 | 78.3 | 82.8 | 87.3 | 87.4 |
212
- | Arc-E <br> 10-Shot | 94.6 | 97.1 | 98.0 | 88.5 | 90.6 | 91.4 | 93.4 | 95.6 | 96.3 |
213
- | PIQA <br> 5-Shot | 84.2 | 87.8 | 88.2 | 60.2 | 77.7 | 78.1 | 75.7 | 86.0 | 86.6 |
214
- | SociQA <br> 5-Shot | 76.6 | 79.0 | 79.4 | 68.3 | 74.6 | 65.5 | 73.9 | 75.9 | 68.3 |
215
- | BigBench-Hard <br> 0-Shot | 71.7 | 75.0 | 82.5 | 59.4 | 57.3 | 59.6 | 51.5 | 69.7 | 68.32 |
216
- | WinoGrande <br> 5-Shot | 70.8 | 82.5 | 81.2 | 54.7 | 54.2 | 55.6 | 65 | 62.0 | 68.8 |
217
- | OpenBookQA <br> 10-Shot | 83.2 | 88.4 | 86.6 | 73.6 | 79.8 | 78.6 | 82.6 | 85.8 | 86.0 |
218
- | BoolQ <br> 0-Shot | 77.6 | 82.9 | 86.5 | -- | 72.2 | 66.0 | 80.9 | 77.6 | 79.1 |
219
- | CommonSenseQA <br> 10-Shot | 80.2 | 80.3 | 82.6 | 69.3 | 72.6 | 76.2 | 79 | 78.1 | 79.6 |
220
- | TruthfulQA <br> 10-Shot | 65.0 | 68.1 | 74.8 | -- | 52.1 | 53.0 | 63.2 | 60.1 | 85.8 |
221
- | HumanEval <br> 0-Shot | 59.1 | 59.1 | 54.7 | 47.0 | 28.0 | 34.1 | 60.4 | 37.8 | 62.2 |
222
- | MBPP <br> 3-Shot | 53.8 | 71.4 | 73.7 | 60.6 | 50.8 | 51.5 | 67.7 | 60.2 | 77.8 |
223
-
224
- ## Software
225
-
226
- * [PyTorch](https://github.com/pytorch/pytorch)
227
- * [DeepSpeed](https://github.com/microsoft/DeepSpeed)
228
- * [Transformers](https://github.com/huggingface/transformers)
229
- * [Flash-Attention](https://github.com/HazyResearch/flash-attention)
230
-
231
- ## Hardware
232
- Note that by default, the Phi-3-mini model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types:
233
- * NVIDIA A100
234
- * NVIDIA A6000
235
- * NVIDIA H100
236
-
237
- If you want to run the model on:
238
- * NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
239
- * CPU: use the **GGUF** quantized models [4K](https://aka.ms/Phi3-mini-4k-instruct-gguf)
240
- + Optimized inference on GPU, CPU, and Mobile: use the **ONNX** models [4K](https://aka.ms/Phi3-mini-4k-instruct-onnx)
241
-
242
-
243
- ## Cross Platform Support
244
-
245
- ONNX runtime ecosystem now supports Phi-3 Mini models across platforms and hardware. You can find the optimized Phi-3 Mini-4K-Instruct ONNX model [here](https://aka.ms/phi3-mini-4k-instruct-onnx).
246
-
247
- 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.
248
- Along with DirectML, ONNX Runtime provides cross platform support for Phi-3 across a range of devices CPU, GPU, and mobile.
249
-
250
- Here are some of the optimized configurations we have added:
251
-
252
- 1. ONNX models for int4 DML: Quantized to int4 via AWQ
253
- 2. ONNX model for fp16 CUDA
254
- 3. ONNX model for int4 CUDA: Quantized to int4 via RTN
255
- 4. ONNX model for int4 CPU and Mobile: Quantized to int4 via RTN
256
-
257
- ## License
258
-
259
- The model is licensed under the [MIT license](https://huggingface.co/microsoft/Phi-3-mini-4k/resolve/main/LICENSE).
260
-
261
- ## Trademarks
262
-
263
- 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
+ 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
+ ## Model Summary
20
+
21
+ 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.
22
+ 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.
23
+
24
+ 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.
25
+ 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.
26
+
27
+ Resources and Technical Documentation:
28
+
29
+ 🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br>
30
+ 📰 [Phi-3 Microsoft Blog](https://aka.ms/Phi-3Build2024) <br>
31
+ 📖 [Phi-3 Technical Report](https://aka.ms/phi3-tech-report) <br>
32
+ 🛠️ [Phi-3 on Azure AI Studio](https://aka.ms/phi3-azure-ai) <br>
33
+ 👩‍🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br>
34
+ 🖥️ [Try It](https://aka.ms/try-phi3)
35
+
36
+ | | Short Context | Long Context |
37
+ | ------- | ------------- | ------------ |
38
+ | 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)|
39
+ | 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)|
40
+ | 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)|
41
+ | Vision | | 128K [[HF]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct) ; [[ONNX]](https://huggingface.co/microsoft/Phi-3-vision-128k-instruct-onnx-cuda)|
42
+
43
+
44
+ ## Intended Uses
45
+
46
+ **Primary use cases**
47
+
48
+ 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
49
+ 1) memory/compute constrained environments;
50
+ 2) latency bound scenarios;
51
+ 3) strong reasoning (especially 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
+ **Out-of-scope use cases**
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 fairness before using within a specific downstream use case, particularly for high-risk scenarios.
58
+
59
+ 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.
60
+
61
+ **Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.**
62
+
63
+ ## Release Notes
64
+
65
+ This is an update over the original instruction-tuned Phi-3-mini release based on valuable customer feedback.
66
+ The model used additional post-training data leading to substantial gains on instruction following and structure output.
67
+ We also improve multi-turn conversation quality, explicitly support <|system|> tag, and significantly improve reasoning capability.
68
+ We believe most use cases will benefit from this release, but we encourage users to test in their particular AI applications.
69
+ We appreciate the enthusiastic adoption of the Phi-3 model family, and continue to welcome all feedback from the community.
70
+
71
+ The table below highlights improvements on instruction following, structure output, and reasoning of the new release on publich and internal benchmark datasets.
72
+
73
+ | Benchmarks | Original | June 2024 Update |
74
+ |------------|----------|------------------|
75
+ | Instruction Extra Hard | 5.7 | 6.0 |
76
+ | Instruction Hard | 4.9 | 5.1 |
77
+ | Instructions Challenge | 24.6 | 42.3 |
78
+ | JSON Structure Output | 11.5 | 52.3 |
79
+ | XML Structure Output | 14.4 | 49.8 |
80
+ | GPQA | 23.7 | 30.6 |
81
+ | MMLU | 68.8 | 70.9 |
82
+ | **Average** | **21.9** | **36.7** |
83
+
84
+ 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!
85
+
86
+ ## How to Use
87
+
88
+ 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`.
89
+
90
+ Examples of required packages:
91
+ ```
92
+ flash_attn==2.5.8
93
+ torch==2.3.1
94
+ accelerate==0.31.0
95
+ transformers==4.41.2
96
+ ```
97
+
98
+ Phi-3 Mini-4K-Instruct is also available in [Azure AI Studio](https://aka.ms/try-phi3)
99
+
100
+ ### Tokenizer
101
+
102
+ 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.
103
+
104
+ ### Chat Format
105
+
106
+ 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.
107
+ You can provide the prompt as a question with a generic template as follow:
108
+ ```markdown
109
+ <|system|>
110
+ You are a helpful assistant.<|end|>
111
+ <|user|>
112
+ Question?<|end|>
113
+ <|assistant|>
114
+ ```
115
+
116
+ For example:
117
+ ```markdown
118
+ <|system|>
119
+ You are a helpful assistant.<|end|>
120
+ <|user|>
121
+ How to explain Internet for a medieval knight?<|end|>
122
+ <|assistant|>
123
+ ```
124
+ where the model generates the text after `<|assistant|>` . In case of few-shots prompt, the prompt can be formatted as the following:
125
+
126
+ ```markdown
127
+ <|system|>
128
+ You are a helpful travel assistant.<|end|>
129
+ <|user|>
130
+ I am going to Paris, what should I see?<|end|>
131
+ <|assistant|>
132
+ 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|>
133
+ <|user|>
134
+ What is so great about #1?<|end|>
135
+ <|assistant|>
136
+ ```
137
+
138
+ ### Sample inference code
139
+
140
+ This code snippets show how to get quickly started with running the model on a GPU:
141
+
142
+ ```python
143
+ import torch
144
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
145
+
146
+ torch.random.manual_seed(0)
147
+ model = AutoModelForCausalLM.from_pretrained(
148
+ "microsoft/Phi-3-mini-4k-instruct",
149
+ device_map="cuda",
150
+ torch_dtype="auto",
151
+ trust_remote_code=True,
152
+ )
153
+
154
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
155
+
156
+ messages = [
157
+ {"role": "system", "content": "You are a helpful AI assistant."},
158
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
159
+ {"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."},
160
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
161
+ ]
162
+
163
+ pipe = pipeline(
164
+ "text-generation",
165
+ model=model,
166
+ tokenizer=tokenizer,
167
+ )
168
+
169
+ generation_args = {
170
+ "max_new_tokens": 500,
171
+ "return_full_text": False,
172
+ "temperature": 0.0,
173
+ "do_sample": False,
174
+ }
175
+
176
+ output = pipe(messages, **generation_args)
177
+ print(output[0]['generated_text'])
178
+ ```
179
+
180
+ Note: If you want to use flash attention, call _AutoModelForCausalLM.from_pretrained()_ with _attn_implementation="flash_attention_2"_
181
+
182
+ ## Responsible AI Considerations
183
+
184
+ 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:
185
+
186
+ + 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.
187
+ + 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.
188
+ + 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.
189
+ + Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
190
+ + 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.
191
+
192
+ 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:
193
+
194
+ + 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.
195
+ + 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.
196
+ + 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).
197
+ + Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
198
+ + 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.
199
+
200
+ ## Training
201
+
202
+ ### Model
203
+
204
+ * 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.
205
+ * Inputs: Text. It is best suited for prompts using chat format.
206
+ * Context length: 4K tokens
207
+ * GPUs: 512 H100-80G
208
+ * Training time: 10 days
209
+ * Training data: 4.9T tokens
210
+ * Outputs: Generated text in response to the input
211
+ * Dates: Our models were trained between May and June 2024
212
+ * 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.
213
+ * Release dates: June, 2024.
214
+
215
+ ### Datasets
216
+
217
+ Our training data includes a wide variety of sources, totaling 4.9 trillion tokens, and is a combination of
218
+ 1) Publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
219
+ 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.);
220
+ 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.
221
+
222
+ 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).
223
+
224
+ ### Fine-tuning
225
+
226
+ 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).
227
+
228
+ ## Benchmarks
229
+
230
+ 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.
231
+
232
+ 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.
233
+
234
+ As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
235
+ 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.
236
+ 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.
237
+
238
+ The number of k–shot examples is listed per-benchmark.
239
+
240
+ | Category | Benchmark | Phi-3-Mini-4K-Ins | Gemma-7B | Mistral-7b | Mixtral-8x7b | Llama-3-8B-Ins | GPT3.5-Turbo-1106 |
241
+ |----------|-----------|-------------------|----------|------------|--------------|----------------|-------------------|
242
+ | Popular aggregated benchmark | AGI Eval <br>5-shot| 39.0 | 42.1 | 35.1 | 45.2 | 42 | 48.4 |
243
+ | | MMLU <br>5-shot | 70.9 | 63.6 | 61.7 | 70.5 | 66.5 | 71.4 |
244
+ | | BigBench Hard CoT<br>3-shot| 73.5 | 59.6 | 57.3 | 69.7 | 51.5 | 68.3 |
245
+ | Language Understanding | ANLI <br>7-shot | 53.6 | 48.7 | 47.1 | 55.2 | 57.3 | 58.1 |
246
+ | | HellaSwag <br>5-shot| 75.3 | 49.8 | 58.5 | 70.4 | 71.1 | 78.8 |
247
+ | Reasoning | ARC Challenge <br>10-shot | 86.3 | 78.3 | 78.6 | 87.3 | 82.8 | 87.4 |
248
+ | | BoolQ <br>0-shot | 78.1 | 66 | 72.2 | 76.6 | 80.9 | 79.1 |
249
+ | | MedQA <br>2-shot| 56.5 | 49.6 | 50 | 62.2 | 60.5 | 63.4 |
250
+ | | OpenBookQA <br>10-shot| 82.2 | 78.6 | 79.8 | 85.8 | 82.6 | 86 |
251
+ | | PIQA <br>5-shot| 83.5 | 78.1 | 77.7 | 86 | 75.7 | 86.6 |
252
+ | | GPQA <br>0-shot| 30.6 | 2.9 | 15 | 6.9 | 32.4 | 30.8 |
253
+ | | Social IQA <br>5-shot| 77.6 | 65.5 | 74.6 | 75.9 | 73.9 | 68.3 |
254
+ | | TruthfulQA (MC2) <br>10-shot| 64.7 | 52.1 | 53 | 60.1 | 63.2 | 67.7 |
255
+ | | WinoGrande <br>5-shot| 71.6 | 55.6 | 54.2 | 62 | 65 | 68.8 |
256
+ | Factual Knowledge | TriviaQA <br>5-shot| 61.4 | 72.3 | 75.2 | 82.2 | 67.7 | 85.8 |
257
+ | Math | GSM8K CoT <br>8-shot| 85.7 | 59.8 | 46.4 | 64.7 | 77.4 | 78.1 |
258
+ | Code Generation | HumanEval <br>0-shot| 57.3 | 34.1 | 28.0 | 37.8 | 60.4 | 62.2 |
259
+ | | MBPP <br>3-shot| 69.8 | 51.5 | 50.8 | 60.2 | 67.7 | 77.8 |
260
+ | **Average** | | **67.6** | **56.0** | **56.4** | **64.4** | **65.5** | **70.4** |
261
+
262
+
263
+ We take a closer look at different categories across 100 public benchmark datasets at the table below:
264
+
265
+ | Category | Phi-3-Mini-4K-Instruct | Gemma-7B | Mistral-7B | Mixtral 8x7B | Llama-3-8B-Instruct | GPT-3.5-Turbo |
266
+ |----------|------------------------|----------|------------|--------------|---------------------|---------------|
267
+ | Popular aggregated benchmark | 61.1 | 59.4 | 56.5 | 66.2 | 59.9 | 67.0 |
268
+ | Reasoning | 70.8 | 60.3 | 62.8 | 68.1 | 69.6 | 71.8 |
269
+ | Language understanding | 60.5 | 57.6 | 52.5 | 66.1 | 63.2 | 67.7 |
270
+ | Code generation | 60.7 | 45.6 | 42.9 | 52.7 | 56.4 | 70.4 |
271
+ | Math | 50.6 | 35.8 | 25.4 | 40.3 | 41.1 | 52.8 |
272
+ | Factual knowledge | 38.4 | 46.7 | 49.8 | 58.6 | 43.1 | 63.4 |
273
+ | Multilingual | 56.7 | 66.5 | 57.4 | 66.7 | 66.6 | 71.0 |
274
+ | Robustness | 61.1 | 38.4 | 40.6 | 51.0 | 64.5 | 69.3 |
275
+
276
+
277
+ 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.
278
+
279
+
280
+ ## Cross Platform Support
281
+
282
+ [ONNX runtime](https://onnxruntime.ai/blogs/accelerating-phi-3) now supports Phi-3 mini models across platforms and hardware.
283
+
284
+ 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).
285
+
286
+ Along with DML, ONNX Runtime provides cross platform support for Phi3 mini across a range of devices CPU, GPU, and mobile.
287
+
288
+ Here are some of the optimized configurations we have added:
289
+
290
+ 1. ONNX models for int4 DML: Quantized to int4 via AWQ
291
+ 2. ONNX model for fp16 CUDA
292
+ 3. ONNX model for int4 CUDA: Quantized to int4 via RTN
293
+ 4. ONNX model for int4 CPU and Mobile: Quantized to int4 via R
294
+
295
+ ## Software
296
+
297
+ * [PyTorch](https://github.com/pytorch/pytorch)
298
+ * [Transformers](https://github.com/huggingface/transformers)
299
+ * [Flash-Attention](https://github.com/HazyResearch/flash-attention)
300
+
301
+ ## Hardware
302
+ 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:
303
+ * NVIDIA A100
304
+ * NVIDIA A6000
305
+ * NVIDIA H100
306
+
307
+ If you want to run the model on:
308
+ * NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
309
+ * CPU: use the **GGUF** quantized models [4K](https://aka.ms/Phi3-mini-4k-instruct-gguf)
310
+ + Optimized inference on GPU, CPU, and Mobile: use the **ONNX** models [4K](https://aka.ms/Phi3-mini-4k-instruct-onnx)
311
+
312
+ ## License
313
+
314
+ The model is licensed under the [MIT license](https://huggingface.co/microsoft/Phi-3-mini-4k/resolve/main/LICENSE).
315
+
316
+ ## Trademarks
317
+
318
+ 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.
SECURITY.md CHANGED
@@ -1,41 +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 [[email protected]](mailto:[email protected]). 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 -->
 
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 [[email protected]](mailto:[email protected]). 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 -->
added_tokens.json CHANGED
@@ -1,13 +1,13 @@
1
- {
2
- "<|endoftext|>": 32000,
3
- "<|assistant|>": 32001,
4
- "<|placeholder1|>": 32002,
5
- "<|placeholder2|>": 32003,
6
- "<|placeholder3|>": 32004,
7
- "<|placeholder4|>": 32005,
8
- "<|system|>": 32006,
9
- "<|end|>": 32007,
10
- "<|placeholder5|>": 32008,
11
- "<|placeholder6|>": 32009,
12
- "<|user|>": 32010
13
- }
 
1
+ {
2
+ "<|endoftext|>": 32000,
3
+ "<|assistant|>": 32001,
4
+ "<|placeholder1|>": 32002,
5
+ "<|placeholder2|>": 32003,
6
+ "<|placeholder3|>": 32004,
7
+ "<|placeholder4|>": 32005,
8
+ "<|system|>": 32006,
9
+ "<|end|>": 32007,
10
+ "<|placeholder5|>": 32008,
11
+ "<|placeholder6|>": 32009,
12
+ "<|user|>": 32010
13
+ }
config.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "_name_or_path": "Phi-3-mini-4k-instruct",
3
- "architectures": [
4
- "Phi3ForCausalLM"
5
- ],
6
- "attention_dropout": 0.0,
7
- "auto_map": {
8
- "AutoConfig": "configuration_phi3.Phi3Config",
9
- "AutoModelForCausalLM": "modeling_phi3.Phi3ForCausalLM"
10
- },
11
- "bos_token_id": 1,
12
- "embd_pdrop": 0.0,
13
- "eos_token_id": 32000,
14
- "hidden_act": "silu",
15
- "hidden_size": 3072,
16
- "initializer_range": 0.02,
17
- "intermediate_size": 8192,
18
- "max_position_embeddings": 4096,
19
- "model_type": "phi3",
20
- "num_attention_heads": 32,
21
- "num_hidden_layers": 32,
22
- "num_key_value_heads": 32,
23
- "original_max_position_embeddings": 4096,
24
- "pad_token_id": 32000,
25
- "resid_pdrop": 0.0,
26
- "rms_norm_eps": 1e-05,
27
- "rope_scaling": null,
28
- "rope_theta": 10000.0,
29
- "sliding_window": 2047,
30
- "tie_word_embeddings": false,
31
- "torch_dtype": "bfloat16",
32
- "transformers_version": "4.39.3",
33
- "use_cache": true,
34
- "attention_bias": false,
35
- "vocab_size": 32064
36
- }
 
1
+ {
2
+ "_name_or_path": "Phi-3-mini-4k-instruct",
3
+ "architectures": [
4
+ "Phi3ForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_phi3.Phi3Config",
9
+ "AutoModelForCausalLM": "modeling_phi3.Phi3ForCausalLM"
10
+ },
11
+ "bos_token_id": 1,
12
+ "embd_pdrop": 0.0,
13
+ "eos_token_id": 32000,
14
+ "hidden_act": "silu",
15
+ "hidden_size": 3072,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 8192,
18
+ "max_position_embeddings": 4096,
19
+ "model_type": "phi3",
20
+ "num_attention_heads": 32,
21
+ "num_hidden_layers": 32,
22
+ "num_key_value_heads": 32,
23
+ "original_max_position_embeddings": 4096,
24
+ "pad_token_id": 32000,
25
+ "resid_pdrop": 0.0,
26
+ "rms_norm_eps": 1e-05,
27
+ "rope_scaling": null,
28
+ "rope_theta": 10000.0,
29
+ "sliding_window": 2047,
30
+ "tie_word_embeddings": false,
31
+ "torch_dtype": "bfloat16",
32
+ "transformers_version": "4.40.2",
33
+ "use_cache": true,
34
+ "attention_bias": false,
35
+ "vocab_size": 32064
36
+ }
configuration_phi3.py CHANGED
@@ -1,213 +1,227 @@
1
- # coding=utf-8
2
- # Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- """ Phi-3 model configuration"""
17
-
18
-
19
- from transformers.configuration_utils import PretrainedConfig
20
- from transformers.utils import logging
21
-
22
-
23
- logger = logging.get_logger(__name__)
24
-
25
- PHI3_PRETRAINED_CONFIG_ARCHIVE_MAP = {
26
- "microsoft/Phi-3-mini-4k-instruct": "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/config.json",
27
- "microsoft/Phi-3-mini-128k-instruct": "https://huggingface.co/microsoft/Phi-3-mini-128k-instruct/resolve/main/config.json",
28
- }
29
-
30
-
31
- class Phi3Config(PretrainedConfig):
32
- r"""
33
- This is the configuration class to store the configuration of a [`Phi3Model`]. It is used to instantiate a Phi-3
34
- model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
35
- defaults will yield a similar configuration to that of the
36
- [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct).
37
-
38
- Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
39
- documentation from [`PretrainedConfig`] for more information.
40
-
41
- Args:
42
- vocab_size (`int`, *optional*, defaults to 32064):
43
- Vocabulary size of the Phi-3 model. Defines the number of different tokens that can be represented by the
44
- `inputs_ids` passed when calling [`Phi3Model`].
45
- hidden_size (`int`, *optional*, defaults to 3072):
46
- Dimension of the hidden representations.
47
- intermediate_size (`int`, *optional*, defaults to 8192):
48
- Dimension of the MLP representations.
49
- num_hidden_layers (`int`, *optional*, defaults to 32):
50
- Number of hidden layers in the Transformer decoder.
51
- num_attention_heads (`int`, *optional*, defaults to 32):
52
- Number of attention heads for each attention layer in the Transformer decoder.
53
- num_key_value_heads (`int`, *optional*):
54
- This is the number of key_value heads that should be used to implement Grouped Query Attention. If
55
- `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
56
- `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
57
- converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
58
- by meanpooling all the original heads within that group. For more details checkout [this
59
- paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
60
- `num_attention_heads`.
61
- resid_pdrop (`float`, *optional*, defaults to 0.0):
62
- Dropout probability for mlp outputs.
63
- embd_pdrop (`int`, *optional*, defaults to 0.0):
64
- The dropout ratio for the embeddings.
65
- attention_dropout (`float`, *optional*, defaults to 0.0):
66
- The dropout ratio after computing the attention scores.
67
- hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
68
- The non-linear activation function (function or string) in the decoder.
69
- max_position_embeddings (`int`, *optional*, defaults to 4096):
70
- The maximum sequence length that this model might ever be used with.
71
- original_max_position_embeddings (`int`, *optional*, defaults to 4096):
72
- The maximum sequence length that this model was trained with. This is used to determine the size of the
73
- original RoPE embeddings when using long scaling.
74
- initializer_range (`float`, *optional*, defaults to 0.02):
75
- The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
76
- rms_norm_eps (`float`, *optional*, defaults to 1e-05):
77
- The epsilon value used for the RMSNorm.
78
- use_cache (`bool`, *optional*, defaults to `True`):
79
- Whether or not the model should return the last key/values attentions (not used by all models). Only
80
- relevant if `config.is_decoder=True`. Whether to tie weight embeddings or not.
81
- tie_word_embeddings (`bool`, *optional*, defaults to `False`):
82
- Whether to tie weight embeddings
83
- rope_theta (`float`, *optional*, defaults to 10000.0):
84
- The base period of the RoPE embeddings.
85
- rope_scaling (`dict`, *optional*):
86
- The scaling strategy for the RoPE embeddings. If `None`, no scaling is applied. If a dictionary, it must
87
- contain the following keys: `type`, `short_factor` and `long_factor`. The `type` must be either `su` or `yarn` and
88
- the `short_factor` and `long_factor` must be lists of numbers with the same length as the hidden size
89
- divided by the number of attention heads divided by 2.
90
- bos_token_id (`int`, *optional*, defaults to 1):
91
- The id of the "beginning-of-sequence" token.
92
- eos_token_id (`int`, *optional*, defaults to 32000):
93
- The id of the "end-of-sequence" token.
94
- pad_token_id (`int`, *optional*, defaults to 32000):
95
- The id of the padding token.
96
- sliding_window (`int`, *optional*):
97
- Sliding window attention window size. If `None`, no sliding window is applied.
98
-
99
- Example:
100
-
101
- ```python
102
- >>> from transformers import Phi3Model, Phi3Config
103
-
104
- >>> # Initializing a Phi-3 style configuration
105
- >>> configuration = Phi3Config.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
106
-
107
- >>> # Initializing a model from the configuration
108
- >>> model = Phi3Model(configuration)
109
-
110
- >>> # Accessing the model configuration
111
- >>> configuration = model.config
112
- ```"""
113
-
114
- model_type = "phi3"
115
- keys_to_ignore_at_inference = ["past_key_values"]
116
-
117
- def __init__(
118
- self,
119
- vocab_size=32064,
120
- hidden_size=3072,
121
- intermediate_size=8192,
122
- num_hidden_layers=32,
123
- num_attention_heads=32,
124
- num_key_value_heads=None,
125
- resid_pdrop=0.0,
126
- embd_pdrop=0.0,
127
- attention_dropout=0.0,
128
- hidden_act="silu",
129
- max_position_embeddings=4096,
130
- original_max_position_embeddings=4096,
131
- initializer_range=0.02,
132
- rms_norm_eps=1e-5,
133
- use_cache=True,
134
- tie_word_embeddings=False,
135
- rope_theta=10000.0,
136
- rope_scaling=None,
137
- bos_token_id=1,
138
- eos_token_id=32000,
139
- pad_token_id=32000,
140
- sliding_window=None,
141
- **kwargs,
142
- ):
143
- self.vocab_size = vocab_size
144
- self.hidden_size = hidden_size
145
- self.intermediate_size = intermediate_size
146
- self.num_hidden_layers = num_hidden_layers
147
- self.num_attention_heads = num_attention_heads
148
-
149
- if num_key_value_heads is None:
150
- num_key_value_heads = num_attention_heads
151
-
152
- self.num_key_value_heads = num_key_value_heads
153
- self.resid_pdrop = resid_pdrop
154
- self.embd_pdrop = embd_pdrop
155
- self.attention_dropout = attention_dropout
156
- self.hidden_act = hidden_act
157
- self.max_position_embeddings = max_position_embeddings
158
- self.original_max_position_embeddings = original_max_position_embeddings
159
- self.initializer_range = initializer_range
160
- self.rms_norm_eps = rms_norm_eps
161
- self.use_cache = use_cache
162
- self.rope_theta = rope_theta
163
- self.rope_scaling = rope_scaling
164
- self._rope_scaling_validation()
165
- self.sliding_window = sliding_window
166
-
167
- super().__init__(
168
- bos_token_id=bos_token_id,
169
- eos_token_id=eos_token_id,
170
- pad_token_id=pad_token_id,
171
- tie_word_embeddings=tie_word_embeddings,
172
- **kwargs,
173
- )
174
-
175
- def _rope_scaling_validation(self):
176
- """
177
- Validate the `rope_scaling` configuration.
178
- """
179
- if self.rope_scaling is None:
180
- return
181
-
182
- if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 3:
183
- raise ValueError(
184
- "`rope_scaling` must be a dictionary with three fields, `type`, `short_factor` and `long_factor`, "
185
- f"got {self.rope_scaling}"
186
- )
187
- rope_scaling_type = self.rope_scaling.get("type", None)
188
- rope_scaling_short_factor = self.rope_scaling.get("short_factor", None)
189
- rope_scaling_long_factor = self.rope_scaling.get("long_factor", None)
190
- if rope_scaling_type is None or rope_scaling_type not in ["su", "yarn"]:
191
- raise ValueError(f"`rope_scaling`'s type field must be one of ['su', 'yarn'], got {rope_scaling_type}")
192
- if not (
193
- isinstance(rope_scaling_short_factor, list)
194
- and all(isinstance(x, (int, float)) for x in rope_scaling_short_factor)
195
- ):
196
- raise ValueError(
197
- f"`rope_scaling`'s short_factor field must be a list of numbers, got {rope_scaling_short_factor}"
198
- )
199
- if not len(rope_scaling_short_factor) == self.hidden_size // self.num_attention_heads // 2:
200
- raise ValueError(
201
- f"`rope_scaling`'s short_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_short_factor)}"
202
- )
203
- if not (
204
- isinstance(rope_scaling_long_factor, list)
205
- and all(isinstance(x, (int, float)) for x in rope_scaling_long_factor)
206
- ):
207
- raise ValueError(
208
- f"`rope_scaling`'s long_factor field must be a list of numbers, got {rope_scaling_long_factor}"
209
- )
210
- if not len(rope_scaling_long_factor) == self.hidden_size // self.num_attention_heads // 2:
211
- raise ValueError(
212
- f"`rope_scaling`'s long_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_long_factor)}"
213
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """ Phi-3 model configuration"""
17
+
18
+
19
+ from transformers.configuration_utils import PretrainedConfig
20
+ from transformers.utils import logging
21
+
22
+
23
+ logger = logging.get_logger(__name__)
24
+
25
+ PHI3_PRETRAINED_CONFIG_ARCHIVE_MAP = {
26
+ "microsoft/Phi-3-mini-4k-instruct": "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/config.json",
27
+ "microsoft/Phi-3-mini-128k-instruct": "https://huggingface.co/microsoft/Phi-3-mini-128k-instruct/resolve/main/config.json",
28
+ }
29
+
30
+
31
+ class Phi3Config(PretrainedConfig):
32
+ r"""
33
+ This is the configuration class to store the configuration of a [`Phi3Model`]. It is used to instantiate a Phi-3
34
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
35
+ defaults will yield a similar configuration to that of the
36
+ [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct).
37
+
38
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
39
+ documentation from [`PretrainedConfig`] for more information.
40
+
41
+ Args:
42
+ vocab_size (`int`, *optional*, defaults to 32064):
43
+ Vocabulary size of the Phi-3 model. Defines the number of different tokens that can be represented by the
44
+ `inputs_ids` passed when calling [`Phi3Model`].
45
+ hidden_size (`int`, *optional*, defaults to 3072):
46
+ Dimension of the hidden representations.
47
+ intermediate_size (`int`, *optional*, defaults to 8192):
48
+ Dimension of the MLP representations.
49
+ num_hidden_layers (`int`, *optional*, defaults to 32):
50
+ Number of hidden layers in the Transformer decoder.
51
+ num_attention_heads (`int`, *optional*, defaults to 32):
52
+ Number of attention heads for each attention layer in the Transformer decoder.
53
+ num_key_value_heads (`int`, *optional*):
54
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
55
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
56
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
57
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
58
+ by meanpooling all the original heads within that group. For more details checkout [this
59
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
60
+ `num_attention_heads`.
61
+ resid_pdrop (`float`, *optional*, defaults to 0.0):
62
+ Dropout probability for mlp outputs.
63
+ embd_pdrop (`int`, *optional*, defaults to 0.0):
64
+ The dropout ratio for the embeddings.
65
+ attention_dropout (`float`, *optional*, defaults to 0.0):
66
+ The dropout ratio after computing the attention scores.
67
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
68
+ The non-linear activation function (function or string) in the decoder.
69
+ max_position_embeddings (`int`, *optional*, defaults to 4096):
70
+ The maximum sequence length that this model might ever be used with.
71
+ original_max_position_embeddings (`int`, *optional*, defaults to 4096):
72
+ The maximum sequence length that this model was trained with. This is used to determine the size of the
73
+ original RoPE embeddings when using long scaling.
74
+ initializer_range (`float`, *optional*, defaults to 0.02):
75
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
76
+ rms_norm_eps (`float`, *optional*, defaults to 1e-05):
77
+ The epsilon value used for the RMSNorm.
78
+ use_cache (`bool`, *optional*, defaults to `True`):
79
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
80
+ relevant if `config.is_decoder=True`. Whether to tie weight embeddings or not.
81
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
82
+ Whether to tie weight embeddings
83
+ rope_theta (`float`, *optional*, defaults to 10000.0):
84
+ The base period of the RoPE embeddings.
85
+ rope_scaling (`dict`, *optional*):
86
+ The scaling strategy for the RoPE embeddings. If `None`, no scaling is applied. If a dictionary, it must
87
+ contain the following keys: `type`, `short_factor` and `long_factor`. The `type` must be `longrope` and
88
+ the `short_factor` and `long_factor` must be lists of numbers with the same length as the hidden size
89
+ divided by the number of attention heads divided by 2.
90
+ bos_token_id (`int`, *optional*, defaults to 1):
91
+ The id of the "beginning-of-sequence" token.
92
+ eos_token_id (`int`, *optional*, defaults to 32000):
93
+ The id of the "end-of-sequence" token.
94
+ pad_token_id (`int`, *optional*, defaults to 32000):
95
+ The id of the padding token.
96
+ sliding_window (`int`, *optional*):
97
+ Sliding window attention window size. If `None`, no sliding window is applied.
98
+
99
+ Example:
100
+
101
+ ```python
102
+ >>> from transformers import Phi3Model, Phi3Config
103
+
104
+ >>> # Initializing a Phi-3 style configuration
105
+ >>> configuration = Phi3Config.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
106
+
107
+ >>> # Initializing a model from the configuration
108
+ >>> model = Phi3Model(configuration)
109
+
110
+ >>> # Accessing the model configuration
111
+ >>> configuration = model.config
112
+ ```"""
113
+
114
+ model_type = "phi3"
115
+ keys_to_ignore_at_inference = ["past_key_values"]
116
+
117
+ def __init__(
118
+ self,
119
+ vocab_size=32064,
120
+ hidden_size=3072,
121
+ intermediate_size=8192,
122
+ num_hidden_layers=32,
123
+ num_attention_heads=32,
124
+ num_key_value_heads=None,
125
+ resid_pdrop=0.0,
126
+ embd_pdrop=0.0,
127
+ attention_dropout=0.0,
128
+ hidden_act="silu",
129
+ max_position_embeddings=4096,
130
+ original_max_position_embeddings=4096,
131
+ initializer_range=0.02,
132
+ rms_norm_eps=1e-5,
133
+ use_cache=True,
134
+ tie_word_embeddings=False,
135
+ rope_theta=10000.0,
136
+ rope_scaling=None,
137
+ bos_token_id=1,
138
+ eos_token_id=32000,
139
+ pad_token_id=32000,
140
+ sliding_window=None,
141
+ **kwargs,
142
+ ):
143
+ self.vocab_size = vocab_size
144
+ self.hidden_size = hidden_size
145
+ self.intermediate_size = intermediate_size
146
+ self.num_hidden_layers = num_hidden_layers
147
+ self.num_attention_heads = num_attention_heads
148
+
149
+ if num_key_value_heads is None:
150
+ num_key_value_heads = num_attention_heads
151
+
152
+ self.num_key_value_heads = num_key_value_heads
153
+ self.resid_pdrop = resid_pdrop
154
+ self.embd_pdrop = embd_pdrop
155
+ self.attention_dropout = attention_dropout
156
+ self.hidden_act = hidden_act
157
+ self.max_position_embeddings = max_position_embeddings
158
+ self.original_max_position_embeddings = original_max_position_embeddings
159
+ self.initializer_range = initializer_range
160
+ self.rms_norm_eps = rms_norm_eps
161
+ self.use_cache = use_cache
162
+ self.rope_theta = rope_theta
163
+ self.rope_scaling = rope_scaling
164
+ self._rope_scaling_adjustment()
165
+ self._rope_scaling_validation()
166
+ self.sliding_window = sliding_window
167
+
168
+ super().__init__(
169
+ bos_token_id=bos_token_id,
170
+ eos_token_id=eos_token_id,
171
+ pad_token_id=pad_token_id,
172
+ tie_word_embeddings=tie_word_embeddings,
173
+ **kwargs,
174
+ )
175
+
176
+ def _rope_scaling_adjustment(self):
177
+ """
178
+ Adjust the `type` of the `rope_scaling` configuration for backward compatibility.
179
+ """
180
+ if self.rope_scaling is None:
181
+ return
182
+
183
+ rope_scaling_type = self.rope_scaling.get("type", None)
184
+
185
+ # For backward compatibility if previous version used "su" or "yarn"
186
+ if rope_scaling_type is not None and rope_scaling_type in ["su", "yarn"]:
187
+ self.rope_scaling["type"] = "longrope"
188
+
189
+ def _rope_scaling_validation(self):
190
+ """
191
+ Validate the `rope_scaling` configuration.
192
+ """
193
+ if self.rope_scaling is None:
194
+ return
195
+
196
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 3:
197
+ raise ValueError(
198
+ "`rope_scaling` must be a dictionary with three fields, `type`, `short_factor` and `long_factor`, "
199
+ f"got {self.rope_scaling}"
200
+ )
201
+ rope_scaling_type = self.rope_scaling.get("type", None)
202
+ rope_scaling_short_factor = self.rope_scaling.get("short_factor", None)
203
+ rope_scaling_long_factor = self.rope_scaling.get("long_factor", None)
204
+ if rope_scaling_type is None or rope_scaling_type not in ["longrope"]:
205
+ raise ValueError(f"`rope_scaling`'s type field must be one of ['longrope'], got {rope_scaling_type}")
206
+ if not (
207
+ isinstance(rope_scaling_short_factor, list)
208
+ and all(isinstance(x, (int, float)) for x in rope_scaling_short_factor)
209
+ ):
210
+ raise ValueError(
211
+ f"`rope_scaling`'s short_factor field must be a list of numbers, got {rope_scaling_short_factor}"
212
+ )
213
+ if not len(rope_scaling_short_factor) == self.hidden_size // self.num_attention_heads // 2:
214
+ raise ValueError(
215
+ f"`rope_scaling`'s short_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_short_factor)}"
216
+ )
217
+ if not (
218
+ isinstance(rope_scaling_long_factor, list)
219
+ and all(isinstance(x, (int, float)) for x in rope_scaling_long_factor)
220
+ ):
221
+ raise ValueError(
222
+ f"`rope_scaling`'s long_factor field must be a list of numbers, got {rope_scaling_long_factor}"
223
+ )
224
+ if not len(rope_scaling_long_factor) == self.hidden_size // self.num_attention_heads // 2:
225
+ raise ValueError(
226
+ f"`rope_scaling`'s long_factor field must have length {self.hidden_size // self.num_attention_heads // 2}, got {len(rope_scaling_long_factor)}"
227
+ )
generation_config.json CHANGED
@@ -1,11 +1,11 @@
1
- {
2
- "_from_model_config": true,
3
- "bos_token_id": 1,
4
- "eos_token_id": [
5
- 32000,
6
- 32001,
7
- 32007
8
- ],
9
- "pad_token_id": 32000,
10
- "transformers_version": "4.39.3"
11
- }
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": [
5
+ 32000,
6
+ 32001,
7
+ 32007
8
+ ],
9
+ "pad_token_id": 32000,
10
+ "transformers_version": "4.39.3"
11
+ }
model-00001-of-00002.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f95c89449ba404df51c3f633df65c52cabea9dbfae7e21977d32b5daa397cc91
3
  size 4972489328
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7492726c01287bf6e13c3d74c65ade3d436d50da1cf5bb6925bc962419d6610
3
  size 4972489328
model-00002-of-00002.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5de695669421c1e12d2d1588a4795de6a5900bd1513c06be357b65a041b3590e
3
  size 2669692552
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f311787aa136e858556caa8543015161edcad85ba81b6a36072443d7fa73c87
3
  size 2669692552
model.safetensors.index.json CHANGED
@@ -1,202 +1,202 @@
1
- {
2
- "metadata": {
3
- "total_size": 7642159104
4
- },
5
- "weight_map": {
6
- "lm_head.weight": "model-00002-of-00002.safetensors",
7
- "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
8
- "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
9
- "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
10
- "model.layers.0.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
11
- "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
12
- "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
13
- "model.layers.0.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
14
- "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
15
- "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
16
- "model.layers.1.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
17
- "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
18
- "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
19
- "model.layers.1.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
20
- "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
21
- "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
22
- "model.layers.10.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
23
- "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
24
- "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
25
- "model.layers.10.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
26
- "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
27
- "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
28
- "model.layers.11.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
29
- "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
30
- "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
31
- "model.layers.11.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
32
- "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
33
- "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
34
- "model.layers.12.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
35
- "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
36
- "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
37
- "model.layers.12.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
38
- "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
39
- "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
40
- "model.layers.13.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
41
- "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
42
- "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
43
- "model.layers.13.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
44
- "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
45
- "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
46
- "model.layers.14.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
47
- "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
48
- "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
49
- "model.layers.14.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
50
- "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
51
- "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
52
- "model.layers.15.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
53
- "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
54
- "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
55
- "model.layers.15.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
56
- "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
57
- "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
58
- "model.layers.16.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
59
- "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
60
- "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
61
- "model.layers.16.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
62
- "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
63
- "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
64
- "model.layers.17.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
65
- "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
66
- "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
67
- "model.layers.17.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
68
- "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
69
- "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
70
- "model.layers.18.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
71
- "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
72
- "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
73
- "model.layers.18.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
74
- "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
75
- "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
76
- "model.layers.19.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
77
- "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
78
- "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
79
- "model.layers.19.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
80
- "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
81
- "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
82
- "model.layers.2.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
83
- "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
84
- "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
85
- "model.layers.2.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
86
- "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
87
- "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
88
- "model.layers.20.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
89
- "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
90
- "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
91
- "model.layers.20.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
92
- "model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
93
- "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
94
- "model.layers.21.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
95
- "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
96
- "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
97
- "model.layers.21.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
98
- "model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
99
- "model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
100
- "model.layers.22.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
101
- "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
102
- "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
103
- "model.layers.22.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
104
- "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
105
- "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
106
- "model.layers.23.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
107
- "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
108
- "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
109
- "model.layers.23.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
110
- "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
111
- "model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
112
- "model.layers.24.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
113
- "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
114
- "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
115
- "model.layers.24.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
116
- "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
117
- "model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
118
- "model.layers.25.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
119
- "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
120
- "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
121
- "model.layers.25.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
122
- "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
123
- "model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
124
- "model.layers.26.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
125
- "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
126
- "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
127
- "model.layers.26.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
128
- "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
129
- "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
130
- "model.layers.27.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
131
- "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
132
- "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
133
- "model.layers.27.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
134
- "model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
135
- "model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
136
- "model.layers.28.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
137
- "model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
138
- "model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
139
- "model.layers.28.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
140
- "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
141
- "model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
142
- "model.layers.29.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
143
- "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
144
- "model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
145
- "model.layers.29.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
146
- "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
147
- "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
148
- "model.layers.3.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
149
- "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
150
- "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
151
- "model.layers.3.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
152
- "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
153
- "model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
154
- "model.layers.30.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
155
- "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
156
- "model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
157
- "model.layers.30.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
158
- "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
159
- "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
160
- "model.layers.31.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
161
- "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
162
- "model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
163
- "model.layers.31.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
164
- "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
165
- "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
166
- "model.layers.4.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
167
- "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
168
- "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
169
- "model.layers.4.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
170
- "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
171
- "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
172
- "model.layers.5.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
173
- "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
174
- "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
175
- "model.layers.5.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
176
- "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
177
- "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
178
- "model.layers.6.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
179
- "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
180
- "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
181
- "model.layers.6.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
182
- "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
183
- "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
184
- "model.layers.7.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
185
- "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
186
- "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
187
- "model.layers.7.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
188
- "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
189
- "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
190
- "model.layers.8.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
191
- "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
192
- "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
193
- "model.layers.8.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
194
- "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
195
- "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
196
- "model.layers.9.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
197
- "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
198
- "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
199
- "model.layers.9.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
200
- "model.norm.weight": "model-00002-of-00002.safetensors"
201
- }
202
- }
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 7642159104
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00002-of-00002.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.1.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.10.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.10.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.11.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.11.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.12.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.12.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.13.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
42
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.13.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.14.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.14.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.15.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.15.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.16.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
61
+ "model.layers.16.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
63
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.17.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
66
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.17.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.18.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
73
+ "model.layers.18.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
75
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.19.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
78
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.19.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
80
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.2.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.2.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
87
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.20.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
90
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
91
+ "model.layers.20.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
93
+ "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
94
+ "model.layers.21.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
95
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
96
+ "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
97
+ "model.layers.21.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
98
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
99
+ "model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
100
+ "model.layers.22.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
101
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
102
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
103
+ "model.layers.22.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
104
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
105
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
106
+ "model.layers.23.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
107
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
108
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
109
+ "model.layers.23.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
110
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
111
+ "model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
112
+ "model.layers.24.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
113
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
114
+ "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
115
+ "model.layers.24.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
116
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
117
+ "model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
118
+ "model.layers.25.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
119
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
120
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
121
+ "model.layers.25.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
122
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
123
+ "model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
124
+ "model.layers.26.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
125
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
126
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
127
+ "model.layers.26.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
128
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
129
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
130
+ "model.layers.27.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
131
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
132
+ "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
133
+ "model.layers.27.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
134
+ "model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
135
+ "model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
136
+ "model.layers.28.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
137
+ "model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
138
+ "model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
139
+ "model.layers.28.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
140
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
141
+ "model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
142
+ "model.layers.29.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
143
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
144
+ "model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
145
+ "model.layers.29.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
146
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
147
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.3.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
150
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.3.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
152
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
153
+ "model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
154
+ "model.layers.30.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
155
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
156
+ "model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
157
+ "model.layers.30.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
158
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
159
+ "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
160
+ "model.layers.31.mlp.gate_up_proj.weight": "model-00002-of-00002.safetensors",
161
+ "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
162
+ "model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
163
+ "model.layers.31.self_attn.qkv_proj.weight": "model-00002-of-00002.safetensors",
164
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
165
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.4.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
167
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
168
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
169
+ "model.layers.4.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
171
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
172
+ "model.layers.5.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
173
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
174
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
175
+ "model.layers.5.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
176
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
177
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.6.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
179
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
180
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
181
+ "model.layers.6.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
182
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
183
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
184
+ "model.layers.7.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
185
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
186
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
187
+ "model.layers.7.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
188
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
189
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
190
+ "model.layers.8.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
191
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
192
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
193
+ "model.layers.8.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
194
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
195
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
196
+ "model.layers.9.mlp.gate_up_proj.weight": "model-00001-of-00002.safetensors",
197
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
198
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
199
+ "model.layers.9.self_attn.qkv_proj.weight": "model-00001-of-00002.safetensors",
200
+ "model.norm.weight": "model-00002-of-00002.safetensors"
201
+ }
202
+ }
modeling_phi3.py CHANGED
The diff for this file is too large to render. See raw diff
 
sample_finetune.py CHANGED
@@ -1,214 +1,214 @@
1
- import sys
2
- import logging
3
-
4
- import datasets
5
- from datasets import load_dataset
6
- from peft import LoraConfig
7
- import torch
8
- import transformers
9
- from trl import SFTTrainer
10
- from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, BitsAndBytesConfig
11
-
12
- """
13
- A simple example on using SFTTrainer and Accelerate to finetune Phi-3 models. For
14
- a more advanced example, please follow HF alignment-handbook/scripts/run_sft.py.
15
- This example has utilized DeepSpeed ZeRO3 offload to reduce the memory usage. The
16
- script can be run on V100 or later generation GPUs. Here are some suggestions on
17
- futher reducing memory consumption:
18
- - reduce batch size
19
- - decrease lora dimension
20
- - restrict lora target modules
21
- Please follow these steps to run the script:
22
- 1. Install dependencies:
23
- conda install -c conda-forge accelerate
24
- pip3 install -i https://pypi.org/simple/ bitsandbytes
25
- pip3 install peft transformers trl datasets
26
- pip3 install deepspeed
27
- 2. Setup accelerate and deepspeed config based on the machine used:
28
- accelerate config
29
- Here is a sample config for deepspeed zero3:
30
- compute_environment: LOCAL_MACHINE
31
- debug: false
32
- deepspeed_config:
33
- gradient_accumulation_steps: 1
34
- offload_optimizer_device: none
35
- offload_param_device: none
36
- zero3_init_flag: true
37
- zero3_save_16bit_model: true
38
- zero_stage: 3
39
- distributed_type: DEEPSPEED
40
- downcast_bf16: 'no'
41
- enable_cpu_affinity: false
42
- machine_rank: 0
43
- main_training_function: main
44
- mixed_precision: bf16
45
- num_machines: 1
46
- num_processes: 4
47
- rdzv_backend: static
48
- same_network: true
49
- tpu_env: []
50
- tpu_use_cluster: false
51
- tpu_use_sudo: false
52
- use_cpu: false
53
- 3. check accelerate config:
54
- accelerate env
55
- 4. Run the code:
56
- accelerate launch sample_finetune.py
57
- """
58
-
59
- logger = logging.getLogger(__name__)
60
-
61
-
62
- ###################
63
- # Hyper-parameters
64
- ###################
65
- training_config = {
66
- "bf16": True,
67
- "do_eval": False,
68
- "learning_rate": 5.0e-06,
69
- "log_level": "info",
70
- "logging_steps": 20,
71
- "logging_strategy": "steps",
72
- "lr_scheduler_type": "cosine",
73
- "num_train_epochs": 1,
74
- "max_steps": -1,
75
- "output_dir": "./checkpoint_dir",
76
- "overwrite_output_dir": True,
77
- "per_device_eval_batch_size": 4,
78
- "per_device_train_batch_size": 4,
79
- "remove_unused_columns": True,
80
- "save_steps": 100,
81
- "save_total_limit": 1,
82
- "seed": 0,
83
- "gradient_checkpointing": True,
84
- "gradient_checkpointing_kwargs":{"use_reentrant": False},
85
- "gradient_accumulation_steps": 1,
86
- "warmup_ratio": 0.2,
87
- }
88
-
89
- peft_config = {
90
- "r": 16,
91
- "lora_alpha": 32,
92
- "lora_dropout": 0.05,
93
- "bias": "none",
94
- "task_type": "CAUSAL_LM",
95
- "target_modules": "all-linear",
96
- "modules_to_save": None,
97
- }
98
- train_conf = TrainingArguments(**training_config)
99
- peft_conf = LoraConfig(**peft_config)
100
-
101
-
102
- ###############
103
- # Setup logging
104
- ###############
105
- logging.basicConfig(
106
- format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
107
- datefmt="%Y-%m-%d %H:%M:%S",
108
- handlers=[logging.StreamHandler(sys.stdout)],
109
- )
110
- log_level = train_conf.get_process_log_level()
111
- logger.setLevel(log_level)
112
- datasets.utils.logging.set_verbosity(log_level)
113
- transformers.utils.logging.set_verbosity(log_level)
114
- transformers.utils.logging.enable_default_handler()
115
- transformers.utils.logging.enable_explicit_format()
116
-
117
- # Log on each process a small summary
118
- logger.warning(
119
- f"Process rank: {train_conf.local_rank}, device: {train_conf.device}, n_gpu: {train_conf.n_gpu}"
120
- + f" distributed training: {bool(train_conf.local_rank != -1)}, 16-bits training: {train_conf.fp16}"
121
- )
122
- logger.info(f"Training/evaluation parameters {train_conf}")
123
- logger.info(f"PEFT parameters {peft_conf}")
124
-
125
-
126
- ################
127
- # Modle Loading
128
- ################
129
- checkpoint_path = "microsoft/Phi-3-mini-4k-instruct"
130
- # checkpoint_path = "microsoft/Phi-3-mini-128k-instruct"
131
- model_kwargs = dict(
132
- use_cache=False,
133
- trust_remote_code=True,
134
- attn_implementation="flash_attention_2", # loading the model with flash-attenstion support
135
- torch_dtype=torch.bfloat16,
136
- device_map=None
137
- )
138
- model = AutoModelForCausalLM.from_pretrained(checkpoint_path, **model_kwargs)
139
- tokenizer = AutoTokenizer.from_pretrained(checkpoint_path)
140
- tokenizer.model_max_length = 2048
141
- tokenizer.pad_token = tokenizer.unk_token # use unk rather than eos token to prevent endless generation
142
- tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids(tokenizer.pad_token)
143
- tokenizer.padding_side = 'right'
144
-
145
-
146
- ##################
147
- # Data Processing
148
- ##################
149
- def apply_chat_template(
150
- example,
151
- tokenizer,
152
- ):
153
- messages = example["messages"]
154
- example["text"] = tokenizer.apply_chat_template(
155
- messages, tokenize=False, add_generation_prompt=False)
156
- return example
157
-
158
- raw_dataset = load_dataset("HuggingFaceH4/ultrachat_200k")
159
- train_dataset = raw_dataset["train_sft"]
160
- test_dataset = raw_dataset["test_sft"]
161
- column_names = list(train_dataset.features)
162
-
163
- processed_train_dataset = train_dataset.map(
164
- apply_chat_template,
165
- fn_kwargs={"tokenizer": tokenizer},
166
- num_proc=10,
167
- remove_columns=column_names,
168
- desc="Applying chat template to train_sft",
169
- )
170
-
171
- processed_test_dataset = test_dataset.map(
172
- apply_chat_template,
173
- fn_kwargs={"tokenizer": tokenizer},
174
- num_proc=10,
175
- remove_columns=column_names,
176
- desc="Applying chat template to test_sft",
177
- )
178
-
179
-
180
- ###########
181
- # Training
182
- ###########
183
- trainer = SFTTrainer(
184
- model=model,
185
- args=train_conf,
186
- peft_config=peft_conf,
187
- train_dataset=processed_train_dataset,
188
- eval_dataset=processed_test_dataset,
189
- max_seq_length=2048,
190
- dataset_text_field="text",
191
- tokenizer=tokenizer,
192
- packing=True
193
- )
194
- train_result = trainer.train()
195
- metrics = train_result.metrics
196
- trainer.log_metrics("train", metrics)
197
- trainer.save_metrics("train", metrics)
198
- trainer.save_state()
199
-
200
-
201
- #############
202
- # Evaluation
203
- #############
204
- tokenizer.padding_side = 'left'
205
- metrics = trainer.evaluate()
206
- metrics["eval_samples"] = len(processed_test_dataset)
207
- trainer.log_metrics("eval", metrics)
208
- trainer.save_metrics("eval", metrics)
209
-
210
-
211
- # ############
212
- # # Save model
213
- # ############
214
  trainer.save_model(train_conf.output_dir)
 
1
+ import sys
2
+ import logging
3
+
4
+ import datasets
5
+ from datasets import load_dataset
6
+ from peft import LoraConfig
7
+ import torch
8
+ import transformers
9
+ from trl import SFTTrainer
10
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, BitsAndBytesConfig
11
+
12
+ """
13
+ A simple example on using SFTTrainer and Accelerate to finetune Phi-3 models. For
14
+ a more advanced example, please follow HF alignment-handbook/scripts/run_sft.py.
15
+ This example has utilized DeepSpeed ZeRO3 offload to reduce the memory usage. The
16
+ script can be run on V100 or later generation GPUs. Here are some suggestions on
17
+ futher reducing memory consumption:
18
+ - reduce batch size
19
+ - decrease lora dimension
20
+ - restrict lora target modules
21
+ Please follow these steps to run the script:
22
+ 1. Install dependencies:
23
+ conda install -c conda-forge accelerate
24
+ pip3 install -i https://pypi.org/simple/ bitsandbytes
25
+ pip3 install peft transformers trl datasets
26
+ pip3 install deepspeed
27
+ 2. Setup accelerate and deepspeed config based on the machine used:
28
+ accelerate config
29
+ Here is a sample config for deepspeed zero3:
30
+ compute_environment: LOCAL_MACHINE
31
+ debug: false
32
+ deepspeed_config:
33
+ gradient_accumulation_steps: 1
34
+ offload_optimizer_device: none
35
+ offload_param_device: none
36
+ zero3_init_flag: true
37
+ zero3_save_16bit_model: true
38
+ zero_stage: 3
39
+ distributed_type: DEEPSPEED
40
+ downcast_bf16: 'no'
41
+ enable_cpu_affinity: false
42
+ machine_rank: 0
43
+ main_training_function: main
44
+ mixed_precision: bf16
45
+ num_machines: 1
46
+ num_processes: 4
47
+ rdzv_backend: static
48
+ same_network: true
49
+ tpu_env: []
50
+ tpu_use_cluster: false
51
+ tpu_use_sudo: false
52
+ use_cpu: false
53
+ 3. check accelerate config:
54
+ accelerate env
55
+ 4. Run the code:
56
+ accelerate launch sample_finetune.py
57
+ """
58
+
59
+ logger = logging.getLogger(__name__)
60
+
61
+
62
+ ###################
63
+ # Hyper-parameters
64
+ ###################
65
+ training_config = {
66
+ "bf16": True,
67
+ "do_eval": False,
68
+ "learning_rate": 5.0e-06,
69
+ "log_level": "info",
70
+ "logging_steps": 20,
71
+ "logging_strategy": "steps",
72
+ "lr_scheduler_type": "cosine",
73
+ "num_train_epochs": 1,
74
+ "max_steps": -1,
75
+ "output_dir": "./checkpoint_dir",
76
+ "overwrite_output_dir": True,
77
+ "per_device_eval_batch_size": 4,
78
+ "per_device_train_batch_size": 4,
79
+ "remove_unused_columns": True,
80
+ "save_steps": 100,
81
+ "save_total_limit": 1,
82
+ "seed": 0,
83
+ "gradient_checkpointing": True,
84
+ "gradient_checkpointing_kwargs":{"use_reentrant": False},
85
+ "gradient_accumulation_steps": 1,
86
+ "warmup_ratio": 0.2,
87
+ }
88
+
89
+ peft_config = {
90
+ "r": 16,
91
+ "lora_alpha": 32,
92
+ "lora_dropout": 0.05,
93
+ "bias": "none",
94
+ "task_type": "CAUSAL_LM",
95
+ "target_modules": "all-linear",
96
+ "modules_to_save": None,
97
+ }
98
+ train_conf = TrainingArguments(**training_config)
99
+ peft_conf = LoraConfig(**peft_config)
100
+
101
+
102
+ ###############
103
+ # Setup logging
104
+ ###############
105
+ logging.basicConfig(
106
+ format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
107
+ datefmt="%Y-%m-%d %H:%M:%S",
108
+ handlers=[logging.StreamHandler(sys.stdout)],
109
+ )
110
+ log_level = train_conf.get_process_log_level()
111
+ logger.setLevel(log_level)
112
+ datasets.utils.logging.set_verbosity(log_level)
113
+ transformers.utils.logging.set_verbosity(log_level)
114
+ transformers.utils.logging.enable_default_handler()
115
+ transformers.utils.logging.enable_explicit_format()
116
+
117
+ # Log on each process a small summary
118
+ logger.warning(
119
+ f"Process rank: {train_conf.local_rank}, device: {train_conf.device}, n_gpu: {train_conf.n_gpu}"
120
+ + f" distributed training: {bool(train_conf.local_rank != -1)}, 16-bits training: {train_conf.fp16}"
121
+ )
122
+ logger.info(f"Training/evaluation parameters {train_conf}")
123
+ logger.info(f"PEFT parameters {peft_conf}")
124
+
125
+
126
+ ################
127
+ # Model Loading
128
+ ################
129
+ checkpoint_path = "microsoft/Phi-3-mini-4k-instruct"
130
+ # checkpoint_path = "microsoft/Phi-3-mini-128k-instruct"
131
+ model_kwargs = dict(
132
+ use_cache=False,
133
+ trust_remote_code=True,
134
+ attn_implementation="flash_attention_2", # loading the model with flash-attenstion support
135
+ torch_dtype=torch.bfloat16,
136
+ device_map=None
137
+ )
138
+ model = AutoModelForCausalLM.from_pretrained(checkpoint_path, **model_kwargs)
139
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint_path)
140
+ tokenizer.model_max_length = 2048
141
+ tokenizer.pad_token = tokenizer.unk_token # use unk rather than eos token to prevent endless generation
142
+ tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids(tokenizer.pad_token)
143
+ tokenizer.padding_side = 'right'
144
+
145
+
146
+ ##################
147
+ # Data Processing
148
+ ##################
149
+ def apply_chat_template(
150
+ example,
151
+ tokenizer,
152
+ ):
153
+ messages = example["messages"]
154
+ example["text"] = tokenizer.apply_chat_template(
155
+ messages, tokenize=False, add_generation_prompt=False)
156
+ return example
157
+
158
+ raw_dataset = load_dataset("HuggingFaceH4/ultrachat_200k")
159
+ train_dataset = raw_dataset["train_sft"]
160
+ test_dataset = raw_dataset["test_sft"]
161
+ column_names = list(train_dataset.features)
162
+
163
+ processed_train_dataset = train_dataset.map(
164
+ apply_chat_template,
165
+ fn_kwargs={"tokenizer": tokenizer},
166
+ num_proc=10,
167
+ remove_columns=column_names,
168
+ desc="Applying chat template to train_sft",
169
+ )
170
+
171
+ processed_test_dataset = test_dataset.map(
172
+ apply_chat_template,
173
+ fn_kwargs={"tokenizer": tokenizer},
174
+ num_proc=10,
175
+ remove_columns=column_names,
176
+ desc="Applying chat template to test_sft",
177
+ )
178
+
179
+
180
+ ###########
181
+ # Training
182
+ ###########
183
+ trainer = SFTTrainer(
184
+ model=model,
185
+ args=train_conf,
186
+ peft_config=peft_conf,
187
+ train_dataset=processed_train_dataset,
188
+ eval_dataset=processed_test_dataset,
189
+ max_seq_length=2048,
190
+ dataset_text_field="text",
191
+ tokenizer=tokenizer,
192
+ packing=True
193
+ )
194
+ train_result = trainer.train()
195
+ metrics = train_result.metrics
196
+ trainer.log_metrics("train", metrics)
197
+ trainer.save_metrics("train", metrics)
198
+ trainer.save_state()
199
+
200
+
201
+ #############
202
+ # Evaluation
203
+ #############
204
+ tokenizer.padding_side = 'left'
205
+ metrics = trainer.evaluate()
206
+ metrics["eval_samples"] = len(processed_test_dataset)
207
+ trainer.log_metrics("eval", metrics)
208
+ trainer.save_metrics("eval", metrics)
209
+
210
+
211
+ # ############
212
+ # # Save model
213
+ # ############
214
  trainer.save_model(train_conf.output_dir)
special_tokens_map.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "bos_token": {
3
- "content": "<s>",
4
- "lstrip": false,
5
- "normalized": false,
6
- "rstrip": false,
7
- "single_word": false
8
- },
9
- "eos_token": {
10
- "content": "<|endoftext|>",
11
- "lstrip": false,
12
- "normalized": false,
13
- "rstrip": false,
14
- "single_word": false
15
- },
16
- "pad_token": {
17
- "content": "<|endoftext|>",
18
- "lstrip": false,
19
- "normalized": false,
20
- "rstrip": false,
21
- "single_word": false
22
- },
23
- "unk_token": {
24
- "content": "<unk>",
25
- "lstrip": false,
26
- "normalized": false,
27
- "rstrip": false,
28
- "single_word": false
29
- }
30
- }
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json CHANGED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json CHANGED
@@ -1,130 +1,130 @@
1
- {
2
- "add_bos_token": true,
3
- "add_eos_token": false,
4
- "added_tokens_decoder": {
5
- "0": {
6
- "content": "<unk>",
7
- "lstrip": false,
8
- "normalized": false,
9
- "rstrip": false,
10
- "single_word": false,
11
- "special": true
12
- },
13
- "1": {
14
- "content": "<s>",
15
- "lstrip": false,
16
- "normalized": false,
17
- "rstrip": false,
18
- "single_word": false,
19
- "special": true
20
- },
21
- "2": {
22
- "content": "</s>",
23
- "lstrip": false,
24
- "normalized": false,
25
- "rstrip": true,
26
- "single_word": false,
27
- "special": false
28
- },
29
- "32000": {
30
- "content": "<|endoftext|>",
31
- "lstrip": false,
32
- "normalized": false,
33
- "rstrip": false,
34
- "single_word": false,
35
- "special": true
36
- },
37
- "32001": {
38
- "content": "<|assistant|>",
39
- "lstrip": false,
40
- "normalized": false,
41
- "rstrip": true,
42
- "single_word": false,
43
- "special": true
44
- },
45
- "32002": {
46
- "content": "<|placeholder1|>",
47
- "lstrip": false,
48
- "normalized": false,
49
- "rstrip": true,
50
- "single_word": false,
51
- "special": true
52
- },
53
- "32003": {
54
- "content": "<|placeholder2|>",
55
- "lstrip": false,
56
- "normalized": false,
57
- "rstrip": true,
58
- "single_word": false,
59
- "special": true
60
- },
61
- "32004": {
62
- "content": "<|placeholder3|>",
63
- "lstrip": false,
64
- "normalized": false,
65
- "rstrip": true,
66
- "single_word": false,
67
- "special": true
68
- },
69
- "32005": {
70
- "content": "<|placeholder4|>",
71
- "lstrip": false,
72
- "normalized": false,
73
- "rstrip": true,
74
- "single_word": false,
75
- "special": true
76
- },
77
- "32006": {
78
- "content": "<|system|>",
79
- "lstrip": false,
80
- "normalized": false,
81
- "rstrip": true,
82
- "single_word": false,
83
- "special": true
84
- },
85
- "32007": {
86
- "content": "<|end|>",
87
- "lstrip": false,
88
- "normalized": false,
89
- "rstrip": true,
90
- "single_word": false,
91
- "special": true
92
- },
93
- "32008": {
94
- "content": "<|placeholder5|>",
95
- "lstrip": false,
96
- "normalized": false,
97
- "rstrip": true,
98
- "single_word": false,
99
- "special": true
100
- },
101
- "32009": {
102
- "content": "<|placeholder6|>",
103
- "lstrip": false,
104
- "normalized": false,
105
- "rstrip": true,
106
- "single_word": false,
107
- "special": true
108
- },
109
- "32010": {
110
- "content": "<|user|>",
111
- "lstrip": false,
112
- "normalized": false,
113
- "rstrip": true,
114
- "single_word": false,
115
- "special": true
116
- }
117
- },
118
- "bos_token": "<s>",
119
- "chat_template": "{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') %}{{'<|user|>' + '\n' + message['content'] + '<|end|>' + '\n' + '<|assistant|>' + '\n'}}{% elif (message['role'] == 'assistant') %}{{message['content'] + '<|end|>' + '\n'}}{% endif %}{% endfor %}",
120
- "clean_up_tokenization_spaces": false,
121
- "eos_token": "<|endoftext|>",
122
- "legacy": false,
123
- "model_max_length": 4096,
124
- "pad_token": "<|endoftext|>",
125
- "padding_side": "left",
126
- "sp_model_kwargs": {},
127
- "tokenizer_class": "LlamaTokenizer",
128
- "unk_token": "<unk>",
129
- "use_default_system_prompt": false
130
- }
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": true,
26
+ "single_word": false,
27
+ "special": false
28
+ },
29
+ "32000": {
30
+ "content": "<|endoftext|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "32001": {
38
+ "content": "<|assistant|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": true,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "32002": {
46
+ "content": "<|placeholder1|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": true,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "32003": {
54
+ "content": "<|placeholder2|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": true,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "32004": {
62
+ "content": "<|placeholder3|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": true,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "32005": {
70
+ "content": "<|placeholder4|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": true,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "32006": {
78
+ "content": "<|system|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": true,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "32007": {
86
+ "content": "<|end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": true,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "32008": {
94
+ "content": "<|placeholder5|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": true,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "32009": {
102
+ "content": "<|placeholder6|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": true,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "32010": {
110
+ "content": "<|user|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": true,
114
+ "single_word": false,
115
+ "special": true
116
+ }
117
+ },
118
+ "bos_token": "<s>",
119
+ "chat_template": "{% for message in messages %}{% if message['role'] == 'system' %}{{'<|system|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'user' %}{{'<|user|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'assistant' %}{{'<|assistant|>\n' + message['content'] + '<|end|>\n'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\n' }}{% else %}{{ eos_token }}{% endif %}",
120
+ "clean_up_tokenization_spaces": false,
121
+ "eos_token": "<|endoftext|>",
122
+ "legacy": false,
123
+ "model_max_length": 4096,
124
+ "pad_token": "<|endoftext|>",
125
+ "padding_side": "left",
126
+ "sp_model_kwargs": {},
127
+ "tokenizer_class": "LlamaTokenizer",
128
+ "unk_token": "<unk>",
129
+ "use_default_system_prompt": false
130
+ }