fakezeta commited on
Commit
fbed355
1 Parent(s): 6ed0f8c

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ license_link: https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/LICENSE
4
+ language:
5
+ - multilingual
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - nlp
9
+ - code
10
+ widget:
11
+ - messages:
12
+ - role: user
13
+ content: Can you provide ways to eat combinations of bananas and dragonfruits?
14
+ library_name: transformers
15
+ ---
16
+ # OpenVINO IR model with int4 quantization
17
+
18
+ Model definition for LocalAI:
19
+
20
+ ```yaml
21
+ name: phi3.5-mini
22
+ backend: transformers
23
+ parameters:
24
+ model: fakezeta/Phi-3.5-mini-instruct-ov-int4
25
+ context_size: 8192
26
+ type: OVModelForCausalLM
27
+ trust_remote_code: true
28
+ template:
29
+ use_tokenizer_template: true
30
+ ```
31
+
32
+ To run the model directly with LocalAI:
33
+
34
+ ```
35
+ local-ai run huggingface://fakezeta/Phi-3.5-mini-instruct-ov-int4/model.yaml
36
+ ```
37
+
38
+ ## Model Summary
39
+
40
+ Phi-3.5-mini is a lightweight, state-of-the-art open model built upon datasets used for Phi-3 - synthetic data and filtered publicly available websites - with a focus on very high-quality, reasoning dense data. The model belongs to the Phi-3 model family and supports 128K token context length. The model underwent a rigorous enhancement process, incorporating both supervised fine-tuning, proximal policy optimization, and direct preference optimization to ensure precise instruction adherence and robust safety measures.
41
+
42
+ 🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br>
43
+ 📰 [Phi-3 Microsoft Blog](https://aka.ms/phi3.5-techblog) <br>
44
+ 📖 [Phi-3 Technical Report](https://arxiv.org/abs/2404.14219) <br>
45
+ 👩‍🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br>
46
+ 🖥️ [Try It](https://aka.ms/try-phi3.5mini) <br>
47
+
48
+ **Phi-3.5**: [[mini-instruct]](https://huggingface.co/microsoft/Phi-3.5-mini-instruct); [[MoE-instruct]](https://huggingface.co/microsoft/Phi-3.5-MoE-instruct) ; [[vision-instruct]](https://huggingface.co/microsoft/Phi-3.5-vision-instruct)
49
+
50
+ ## Intended Uses
51
+
52
+ ### Primary Use Cases
53
+
54
+ The model is intended for commercial and research use in multiple languages. The model provides uses for general purpose AI systems and applications which require:
55
+
56
+ 1) Memory/compute constrained environments
57
+ 2) Latency bound scenarios
58
+ 3) Strong reasoning (especially code, math and logic)
59
+
60
+ Our model is designed to accelerate research on language and multimodal models, for use as a building block for generative AI powered features.
61
+
62
+ ### Use Case Considerations
63
+
64
+ 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.
65
+
66
+ ***Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.***
67
+
68
+ ## Release Notes
69
+
70
+ This is an update over the June 2024 instruction-tuned Phi-3 Mini release based on valuable user feedback. The model used additional post-training data leading to substantial gains on multilingual, multi-turn conversation quality, and reasoning capability. We believe most use cases will benefit from this release, but we encourage users to test in their particular AI applications. We appreciate the enthusiastic adoption of the Phi-3 model family, and continue to welcome all feedback from the community.
71
+
72
+ ### Multilingual
73
+
74
+ The table below highlights multilingual capability of the Phi-3.5 Mini on multilingual MMLU, MEGA, and multilingual MMLU-pro datasets. Overall, we observed that even with just 3.8B active parameters, the model is competitive on multilingual tasks in comparison to other models with a much bigger active parameters.
75
+
76
+ | Benchmark | Phi-3.5 Mini-Ins | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
77
+ |----------------------------|------------------|-----------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
78
+ | Multilingual MMLU | 55.4 | 51.08 | 47.4 | 58.9 | 56.2 | 63.8 | 77.2 | 72.9 |
79
+ | Multilingual MMLU-Pro | 30.9 | 30.21 | 15.0 | 34.0 | 21.4 | 43.0 | 57.9 | 53.2 |
80
+ | MGSM | 47.9 | 41.56 | 31.8 | 63.3 | 56.7 | 75.1 | 75.8 | 81.7 |
81
+ | MEGA MLQA | 61.7 | 55.5 | 43.9 | 61.2 | 45.2 | 54.4 | 61.6 | 70.0 |
82
+ | MEGA TyDi QA | 62.2 | 55.9 | 54.0 | 63.7 | 54.5 | 65.6 | 63.6 | 81.8 |
83
+ | MEGA UDPOS | 46.5 | 48.1 | 57.2 | 58.2 | 54.1 | 56.6 | 62.4 | 66.0 |
84
+ | MEGA XCOPA | 63.1 | 62.4 | 58.8 | 10.8 | 21.1 | 31.2 | 95.0 | 90.3 |
85
+ | MEGA XStoryCloze | 73.5 | 73.6 | 75.5 | 92.3 | 71.0 | 87.0 | 20.7 | 96.6 |
86
+ | **Average** | **55.2** | **52.3** | **47.9** | **55.3** | **47.5** | **59.6** | **64.3** | **76.6** |
87
+
88
+ The table below shows Multilingual MMLU scores in some of the supported languages. For more multi-lingual benchmarks and details, see [Appendix A](#appendix-a).
89
+
90
+ | Benchmark | Phi-3.5 Mini-Ins | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
91
+ |-----------|------------------|-----------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
92
+ | Arabic | 44.2 | 35.4 | 33.7 | 45.3 | 49.1 | 56.3 | 73.6 | 67.1 |
93
+ | Chinese | 52.6 | 46.9 | 45.9 | 58.2 | 54.4 | 62.7 | 66.7 | 70.8 |
94
+ | Dutch | 57.7 | 48.0 | 51.3 | 60.1 | 55.9 | 66.7 | 80.6 | 74.2 |
95
+ | French | 61.1 | 61.7 | 53.0 | 63.8 | 62.8 | 67.0 | 82.9 | 75.6 |
96
+ | German | 62.4 | 61.3 | 50.1 | 64.5 | 59.9 | 65.7 | 79.5 | 74.3 |
97
+ | Italian | 62.8 | 63.1 | 52.5 | 64.1 | 55.9 | 65.7 | 82.6 | 75.9 |
98
+ | Russian | 50.4 | 45.3 | 48.9 | 59.0 | 57.4 | 63.2 | 78.7 | 72.6 |
99
+ | Spanish | 62.6 | 61.3 | 53.9 | 64.3 | 62.6 | 66.0 | 80.0 | 75.5 |
100
+ | Ukrainian | 45.2 | 36.7 | 46.9 | 56.6 | 52.9 | 62.0 | 77.4 | 72.6 |
101
+
102
+ ### Long Context
103
+
104
+ Phi-3.5-mini supports 128K context length, therefore the model is capable of several long context tasks including long document/meeting summarization, long document QA, long document information retrieval. We see that Phi-3.5-mini is clearly better than Gemma-2 family which only supports 8K context length. Phi-3.5-mini is competitive with other much larger open-weight models such as Llama-3.1-8B-instruct, Mistral-7B-instruct-v0.3, and Mistral-Nemo-12B-instruct-2407.
105
+
106
+ | Benchmark | Phi-3.5-mini-instruct | Llama-3.1-8B-instruct | Mistral-7B-instruct-v0.3 | Mistral-Nemo-12B-instruct-2407 | Gemini-1.5-Flash | GPT-4o-mini-2024-07-18 (Chat) |
107
+ |--|--|--|--|--|--|--|
108
+ | GovReport | 25.9 | 25.1 | 26.0 | 25.6 | 27.8 | 24.8 |
109
+ | QMSum | 21.3 | 21.6 | 21.3 | 22.1 | 24.0 | 21.7 |
110
+ | Qasper | 41.9 | 37.2 | 31.4 | 30.7 | 43.5 | 39.8 |
111
+ | SQuALITY | 25.3 | 26.2 | 25.9 | 25.8 | 23.5 | 23.8 |
112
+ | SummScreenFD | 16.0 | 17.6 | 17.5 | 18.2 | 16.3 | 17.0 |
113
+ | **Average** | **26.1** | **25.5** | **24.4** | **24.5** | **27.0** | **25.4** |
114
+
115
+ RULER: a retrieval-based benchmark for long context understanding
116
+ | Model | 4K | 8K | 16K | 32K | 64K | 128K | Average |
117
+ |--|--|--|--|--|--|--|--|
118
+ | **Phi-3.5-mini-instruct** | 94.3 | 91.1 | 90.7 | 87.1 | 78.0 | 63.6 | **84.1** |
119
+ | **Llama-3.1-8B-instruct** | 95.5 | 93.8 | 91.6 | 87.4 | 84.7 | 77.0 | **88.3** |
120
+ | **Mistral-Nemo-12B-instruct-2407** | 87.8 | 87.2 | 87.7 | 69.0 | 46.8 | 19.0 | **66.2** |
121
+
122
+ RepoQA: a benchmark for long context code understanding
123
+ | Model | Python | C++ | Rust | Java | TypeScript | Average |
124
+ |--|--|--|--|--|--|--|
125
+ | **Phi-3.5-mini-instruct** | 86 | 67 | 73 | 77 | 82 | **77** |
126
+ | **Llama-3.1-8B-instruct** | 80 | 65 | 73 | 76 | 63 | **71** |
127
+ | **Mistral-7B-instruct-v0.3** | 61 | 57 | 51 | 61 | 80 | **62** |
128
+
129
+ ## Usage
130
+
131
+ ### Requirements
132
+ Phi-3 family has been integrated in the `4.43.0` version of `transformers`. The current `transformers` version can be verified with: `pip list | grep transformers`.
133
+
134
+ Examples of required packages:
135
+ ```
136
+ flash_attn==2.5.8
137
+ torch==2.3.1
138
+ accelerate==0.31.0
139
+ transformers==4.43.0
140
+ ```
141
+
142
+ Phi-3.5-mini-instruct is also available in [Azure AI Studio](https://aka.ms/try-phi3.5mini)
143
+
144
+ ### Tokenizer
145
+
146
+ Phi-3.5-mini-Instruct supports a vocabulary size of up to `32064` tokens. The [tokenizer files](https://huggingface.co/microsoft/Phi-3.5-mini-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.
147
+
148
+ ### Input Formats
149
+ Given the nature of the training data, the Phi-3.5-mini-instruct model is best suited for prompts using the chat format as follows:
150
+
151
+ ```
152
+ <|system|>
153
+ You are a helpful assistant.<|end|>
154
+ <|user|>
155
+ How to explain Internet for a medieval knight?<|end|>
156
+ <|assistant|>
157
+ ```
158
+
159
+ ### Loading the model locally
160
+ After obtaining the Phi-3.5-mini-instruct model checkpoint, users can use this sample code for inference.
161
+
162
+ ```python
163
+ import torch
164
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
165
+
166
+ torch.random.manual_seed(0)
167
+
168
+ model = AutoModelForCausalLM.from_pretrained(
169
+ "microsoft/Phi-3.5-mini-instruct",
170
+ device_map="cuda",
171
+ torch_dtype="auto",
172
+ trust_remote_code=True,
173
+ )
174
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
175
+
176
+ messages = [
177
+ {"role": "system", "content": "You are a helpful AI assistant."},
178
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
179
+ {"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."},
180
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
181
+ ]
182
+
183
+ pipe = pipeline(
184
+ "text-generation",
185
+ model=model,
186
+ tokenizer=tokenizer,
187
+ )
188
+
189
+ generation_args = {
190
+ "max_new_tokens": 500,
191
+ "return_full_text": False,
192
+ "temperature": 0.0,
193
+ "do_sample": False,
194
+ }
195
+
196
+ output = pipe(messages, **generation_args)
197
+ print(output[0]['generated_text'])
198
+ ```
199
+
200
+ Notes: If you want to use flash attention, call _AutoModelForCausalLM.from_pretrained()_ with _attn_implementation="flash_attention_2"_
201
+
202
+ ## Responsible AI Considerations
203
+
204
+ Like other language models, the Phi family of models can potentially behave in ways that are unfair, unreliable, or offensive. Some of the limiting behaviors to be aware of include:
205
+ + Quality of Service: The Phi models are trained primarily on English text and some additional multilingual text. Languages other than English will experience worse performance as well as performance disparities across non-English. English language varieties with less representation in the training data might experience worse performance than standard American English.
206
+ + Multilingual performance and safety gaps: We believe it is important to make language models more widely available across different languages, but the Phi 3 models still exhibit challenges common across multilingual releases. As with any deployment of LLMs, developers will be better positioned to test for performance or safety gaps for their linguistic and cultural context and customize the model with additional fine-tuning and appropriate safeguards.
207
+ + 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, cultural contexts, or prevalence of examples of negative stereotypes in training data that reflect real-world patterns and societal biases.
208
+ + 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 case.
209
+ + Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
210
+ + 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.
211
+ + Long Conversation: Phi-3 models, like other models, can in some cases generate responses that are repetitive, unhelpful, or inconsistent in very long chat sessions in both English and non-English languages. Developers are encouraged to place appropriate mitigations, like limiting conversation turns to account for the possible conversational drift
212
+
213
+ Developers should apply responsible AI best practices, including mapping, measuring, and mitigating risks associated with their specific use case and cultural, linguistic context. Phi-3 family of models are general purpose models. As developers plan to deploy these models for specific use cases, they are encouraged to fine-tune the models for their use case and leverage the models as part of broader AI systems with language-specific safeguards in place. Important areas for consideration include:
214
+
215
+ + 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.
216
+ + High-Risk Scenarios: Developers should assess the 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.
217
+ + 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).
218
+ + Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
219
+ + 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.
220
+
221
+ ## Training
222
+
223
+ ### Model
224
+
225
+ **Architecture:** Phi-3.5-mini has 3.8B parameters and is a dense decoder-only Transformer model using the same tokenizer as Phi-3 Mini.<br>
226
+ **Inputs:** Text. It is best suited for prompts using chat format.<br>
227
+ **Context length:** 128K tokens<br>
228
+ **GPUs:** 512 H100-80G<br>
229
+ **Training time:** 10 days<br>
230
+ **Training data:** 3.4T tokens<br>
231
+ **Outputs:** Generated text in response to the input<br>
232
+ **Dates:** Trained between June and August 2024<br>
233
+ **Status:** This is a static model trained on an offline dataset with cutoff date October 2023 for publicly available data. Future versions of the tuned models may be released as we improve models.<br>
234
+ **Supported languages:** Arabic, Chinese, Czech, Danish, Dutch, English, Finnish, French, German, Hebrew, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish, Thai, Turkish, Ukrainian<br>
235
+ **Release date:** August 2024<br>
236
+
237
+ ### Training Datasets
238
+ Our training data includes a wide variety of sources, totaling 3.4 trillion tokens, and is a combination of
239
+ 1) publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
240
+ 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.);
241
+ 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.
242
+
243
+ 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://arxiv.org/pdf/2404.14219).
244
+
245
+ ### Fine-tuning
246
+
247
+ A basic example of multi-GPUs supervised fine-tuning (SFT) with TRL and Accelerate modules is provided [here](https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/sample_finetune.py).
248
+
249
+ ## Benchmarks
250
+
251
+ We report the results under completion format for Phi-3.5-mini on standard open-source benchmarks measuring the model's reasoning ability (both common sense reasoning and logical reasoning). We compare to Mistral-7B-Instruct-v0.3, Mistral-Nemo-12B-Ins-2407, Llama-3.1-8B-Ins, Gemma-2-9B-Ins, Gemini 1.5 Flash, and GPT-4o-mini-2024-07-18 (Chat).
252
+
253
+ 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.
254
+
255
+ As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
256
+ 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.
257
+ 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.
258
+
259
+ The number of k–shot examples is listed per-benchmark. At the high-level overview of the model quality on representative benchmarks:
260
+
261
+ | Category | Benchmark | Phi-3.5 Mini-Ins | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
262
+ |----------------|--------------------------|------------------|--------------------------|---------------------------|------------------|----------------|------------------|------------------------------|
263
+ | Popular aggregated benchmark | Arena Hard | 37 | 18.1 | 39.4 | 25.7 | 42 | 55.2 | 75 |
264
+ | | BigBench Hard CoT (0-shot) | 69 | 33.4 | 60.2 | 63.4 | 63.5 | 66.7 | 80.4 |
265
+ | | MMLU (5-shot) | 69 | 60.3 | 67.2 | 68.1 | 71.3 | 78.7 | 77.2 |
266
+ | | MMLU-Pro (0-shot, CoT) | 47.4 | 18 | 40.7 | 44 | 50.1 | 57.2 | 62.8 |
267
+ | Reasoning | ARC Challenge (10-shot) | 84.6 | 77.9 | 84.8 | 83.1 | 89.8 | 92.8 | 93.5 |
268
+ | | BoolQ (2-shot) | 78 | 80.5 | 82.5 | 82.8 | 85.7 | 85.8 | 88.7 |
269
+ | | GPQA (0-shot, CoT) | 30.4 | 15.6 | 28.6 | 26.3 | 29.2 | 37.5 | 41.1 |
270
+ | | HellaSwag (5-shot) | 69.4 | 71.6 | 76.7 | 73.5 | 80.9 | 67.5 | 87.1 |
271
+ | | OpenBookQA (10-shot) | 79.2 | 78 | 84.4 | 84.8 | 89.6 | 89 | 90 |
272
+ | | PIQA (5-shot) | 81 | 73.4 | 83.5 | 81.2 | 83.7 | 87.5 | 88.7 |
273
+ | | Social IQA (5-shot) | 74.7 | 73 | 75.3 | 71.8 | 74.7 | 77.8 | 82.9 |
274
+ | | TruthfulQA (MC2) (10-shot) | 64 | 64.7 | 68.1 | 69.2 | 76.6 | 76.6 | 78.2 |
275
+ | | WinoGrande (5-shot) | 68.5 | 58.1 | 70.4 | 64.7 | 74 | 74.7 | 76.9 |
276
+ | Multilingual | Multilingual MMLU (5-shot) | 55.4 | 47.4 | 58.9 | 56.2 | 63.8 | 77.2 | 72.9 |
277
+ | | MGSM (0-shot CoT) | 47.9 | 31.8 | 63.3 | 56.7 | 76.4 | 75.8 | 81.7 |
278
+ | Math | GSM8K (8-shot, CoT) | 86.2 | 54.4 | 84.2 | 82.4 | 84.9 | 82.4 | 91.3 |
279
+ | | MATH (0-shot, CoT) | 48.5 | 19 | 31.2 | 47.6 | 50.9 | 38 | 70.2 |
280
+ | Long context | Qasper | 41.9 | 31.4 | 30.7 | 37.2 | 13.9 | 43.5 | 39.8 |
281
+ | | SQuALITY | 24.3 | 25.9 | 25.8 | 26.2 | 0 | 23.5 | 23.8 |
282
+ | Code Generation| HumanEval (0-shot) | 62.8 | 35.4 | 63.4 | 66.5 | 61 | 74.4 | 86.6 |
283
+ | | MBPP (3-shot) | 69.6 | 50.4 | 68.1 | 69.4 | 69.3 | 77.5 | 84.1 |
284
+ | **Average** | | **61.4** | **48.5** | **61.3** | **61.0** | **63.3** | **68.5** | **74.9** |
285
+
286
+ We take a closer look at different categories across public benchmark datasets at the table below:
287
+
288
+ | Category | Phi-3.5 Mini-Ins | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
289
+ |----------------------------|------------------|--------------------------|---------------------------|------------------|----------------|------------------|------------------------------|
290
+ | Popular aggregated benchmark | 55.6 | 32.5 | 51.9 | 50.3 | 56.7 | 64.5 | 73.9 |
291
+ | Reasoning | 70.1 | 65.2 | 72.2 | 70.5 | 75.4 | 77.7 | 80 |
292
+ | Language understanding | 62.6 | 62.8 | 67 | 62.9 | 72.8 | 66.6 | 76.8 |
293
+ | Robustness | 59.7 | 53.4 | 65.2 | 59.8 | 64.7 | 68.9 | 77.5 |
294
+ | Long context | 26.1 | 25.5 | 24.4 | 24.5 | 0 | 27 | 25.4 |
295
+ | Math | 67.4 | 36.7 | 57.7 | 65 | 67.9 | 60.2 | 80.8 |
296
+ | Code generation | 62 | 43.1 | 56.9 | 65.8 | 58.3 | 66.8 | 69.9 |
297
+ | Multilingual | 55.2 | 47.9 | 55.3 | 47.5 | 59.6 | 64.3 | 76.6 |
298
+
299
+ Overall, the model with only 3.8B-param achieves a similar level of multilingual language understanding and reasoning ability as much larger models.
300
+ However, it is still fundamentally limited by its size for certain tasks.
301
+ The model simply does not have the capacity to store too much factual knowledge, therefore, users may experience factual incorrectness.
302
+ However, we believe such weakness can be resolved by augmenting Phi-3.5 with a search engine, particularly when using the model under RAG settings.
303
+
304
+ ## Safety Evaluation and Red-Teaming
305
+
306
+ We leveraged various evaluation techniques including red teaming, adversarial conversation simulations, and multilingual safety evaluation benchmark datasets to
307
+ evaluate Phi-3.5 models' propensity to produce undesirable outputs across multiple languages and risk categories.
308
+ Several approaches were used to compensate for the limitations of one approach alone. Findings across the various evaluation methods indicate that safety
309
+ post-training that was done as detailed in the [Phi-3 Safety Post-Training paper](https://arxiv.org/pdf/2407.13833) had a positive impact across multiple languages and risk categories as observed by
310
+ refusal rates (refusal to output undesirable outputs) and robustness to jailbreak techniques. Note, however, while comprehensive red team evaluations were conducted
311
+ across all models in the prior release of Phi models, red teaming was largely focused on Phi-3.5 MOE across multiple languages and risk categories for this release as
312
+ it is the largest and more capable model of the three models. Details on prior red team evaluations across Phi models can be found in the [Phi-3 Safety Post-Training paper](https://arxiv.org/pdf/2407.13833).
313
+ For this release, insights from red teaming indicate that the models may refuse to generate undesirable outputs in English, even when the request for undesirable output
314
+ is in another language. Models may also be more susceptible to longer multi-turn jailbreak techniques across both English and non-English languages. These findings
315
+ highlight the need for industry-wide investment in the development of high-quality safety evaluation datasets across multiple languages, including low resource languages,
316
+ and risk areas that account for cultural nuances where those languages are spoken.
317
+
318
+
319
+ ## Software
320
+ * [PyTorch](https://github.com/pytorch/pytorch)
321
+ * [Transformers](https://github.com/huggingface/transformers)
322
+ * [Flash-Attention](https://github.com/HazyResearch/flash-attention)
323
+
324
+ ## Hardware
325
+ Note that by default, the Phi-3.5-mini-instruct model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types:
326
+ * NVIDIA A100
327
+ * NVIDIA A6000
328
+ * NVIDIA H100
329
+
330
+ If you want to run the model on:
331
+ * NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
332
+
333
+ ## License
334
+ The model is licensed under the [MIT license](./LICENSE).
335
+
336
+ ## Trademarks
337
+ 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.
338
+
339
+
340
+ ## Appendix A
341
+
342
+ #### MGSM
343
+
344
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
345
+ |-----------|------------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
346
+ | German | 69.6 | 65.2 | 42.4 | 74.4 | 68.4 | 76.8 | 81.6 | 82.8 |
347
+ | English | 85.2 | 83.2 | 60.0 | 86.0 | 81.2 | 88.8 | 90.8 | 90.8 |
348
+ | Spanish | 79.2 | 77.6 | 46.4 | 75.6 | 66.4 | 82.4 | 84.8 | 86.8 |
349
+ | French | 71.6 | 72.8 | 47.2 | 70.4 | 66.8 | 74.4 | 77.2 | 81.6 |
350
+ | Japanese | 50.0 | 35.2 | 22.8 | 62.4 | 49.2 | 67.6 | 77.6 | 80.4 |
351
+ | Russian | 67.2 | 51.6 | 43.2 | 73.6 | 67.2 | 78.4 | 84.8 | 86.4 |
352
+ | Thai | 29.6 | 6.4 | 18.4 | 53.2 | 56.0 | 76.8 | 87.6 | 81.6 |
353
+ | Chinese | 60.0 | 52.8 | 42.4 | 66.4 | 68.0 | 72.8 | 82.0 | 82.0 |
354
+
355
+ #### Multilingual MMLU-pro
356
+
357
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
358
+ |------------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
359
+ | Czech | 24.9 | 26.3 | 14.6 | 30.6 | 23.0 | 40.5 | 59.0 | 40.9 |
360
+ | English | 47.7 | 46.2 | 17.7 | 39.8 | 43.1 | 49.0 | 66.1 | 62.7 |
361
+ | Finnish | 22.3 | 20.5 | 11.5 | 30.4 | 9.7 | 37.5 | 54.5 | 50.1 |
362
+ | Norwegian | 29.9 | 27.8 | 14.4 | 33.2 | 22.2 | 44.4 | 60.7 | 59.1 |
363
+ | Polish | 25.7 | 26.4 | 16.3 | 33.6 | 9.2 | 41.7 | 53.9 | 42.8 |
364
+ | Portuguese | 38.7 | 37.6 | 15.3 | 36.0 | 29.3 | 43.5 | 54.0 | 56.9 |
365
+ | Swedish | 30.7 | 28.1 | 15.5 | 34.3 | 16.9 | 42.6 | 57.7 | 55.5 |
366
+
367
+ #### MEGA
368
+
369
+ ##### MLQA
370
+
371
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
372
+ |-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
373
+ | Arabic | 54.3 | 32.7 | 23.5 | 31.4 | 31.5 | 57.4 | 63.8 | 64.0 |
374
+ | Chinese | 36.1 | 31.8 | 22.4 | 27.4 | 18.6 | 45.4 | 38.1 | 38.9 |
375
+ | English | 80.3 | 78.9 | 68.2 | 75.5 | 67.2 | 82.9 | 69.5 | 82.2 |
376
+ | German | 61.8 | 59.1 | 49.0 | 57.8 | 38.9 | 63.8 | 55.9 | 64.1 |
377
+ | Spanish | 68.8 | 67.0 | 50.3 | 63.6 | 52.7 | 72.8 | 59.6 | 70.1 |
378
+
379
+ ##### TyDi QA
380
+
381
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
382
+ |-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
383
+ | Arabic | 69.7 | 54.4 | 52.5 | 49.8 | 33.7 | 81.1 | 78.8 | 84.9 |
384
+ | English | 82.0 | 82.0 | 60.5 | 77.3 | 65.1 | 82.4 | 60.9 | 81.8 |
385
+ | Finnish | 70.3 | 64.3 | 68.6 | 57.1 | 74.4 | 85.7 | 73.5 | 84.8 |
386
+ | Japanese | 65.4 | 56.7 | 45.3 | 54.8 | 34.1 | 74.6 | 59.7 | 73.3 |
387
+ | Korean | 74.0 | 60.4 | 54.5 | 54.2 | 54.9 | 83.8 | 60.7 | 82.3 |
388
+ | Russian | 63.5 | 62.7 | 52.3 | 55.7 | 27.4 | 69.8 | 60.1 | 72.5 |
389
+ | Thai | 64.4 | 49.0 | 51.8 | 43.5 | 48.5 | 81.4 | 71.6 | 78.2 |
390
+
391
+ ##### XCOPA
392
+
393
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
394
+ |-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
395
+ | English | 94.6 | 94.6 | 85.6 | 94.4 | 37.6 | 63.8 | 92.0 | 98.2 |
396
+ | Italian | 86.8 | 84.8 | 76.8 | 83.2 | 16.2 | 37.2 | 85.6 | 97.6 |
397
+ | Turkish | 58.6 | 57.2 | 61.6 | 56.6 | 38.4 | 60.2 | 91.4 | 94.6 |
.ipynb_checkpoints/model-checkpoint.yaml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ name: phi3.5-medium
2
+ backend: transformers
3
+ parameters:
4
+ model: fakezeta/Phi-3.5-mini-instruct-ov-int4
5
+ context_size: 8192
6
+ type: OVModelForCausalLM
7
+ trust_remote_code: true
8
+ template:
9
+ use_tokenizer_template: true
README.md ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ license_link: https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/LICENSE
4
+ language:
5
+ - multilingual
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - nlp
9
+ - code
10
+ widget:
11
+ - messages:
12
+ - role: user
13
+ content: Can you provide ways to eat combinations of bananas and dragonfruits?
14
+ library_name: transformers
15
+ ---
16
+ # OpenVINO IR model with int4 quantization
17
+
18
+ Model definition for LocalAI:
19
+
20
+ ```yaml
21
+ name: phi3.5-mini
22
+ backend: transformers
23
+ parameters:
24
+ model: fakezeta/Phi-3.5-mini-instruct-ov-int4
25
+ context_size: 8192
26
+ type: OVModelForCausalLM
27
+ trust_remote_code: true
28
+ template:
29
+ use_tokenizer_template: true
30
+ ```
31
+
32
+ To run the model directly with LocalAI:
33
+
34
+ ```
35
+ local-ai run huggingface://fakezeta/Phi-3.5-mini-instruct-ov-int4/model.yaml
36
+ ```
37
+
38
+ ## Model Summary
39
+
40
+ Phi-3.5-mini is a lightweight, state-of-the-art open model built upon datasets used for Phi-3 - synthetic data and filtered publicly available websites - with a focus on very high-quality, reasoning dense data. The model belongs to the Phi-3 model family and supports 128K token context length. The model underwent a rigorous enhancement process, incorporating both supervised fine-tuning, proximal policy optimization, and direct preference optimization to ensure precise instruction adherence and robust safety measures.
41
+
42
+ 🏡 [Phi-3 Portal](https://azure.microsoft.com/en-us/products/phi-3) <br>
43
+ 📰 [Phi-3 Microsoft Blog](https://aka.ms/phi3.5-techblog) <br>
44
+ 📖 [Phi-3 Technical Report](https://arxiv.org/abs/2404.14219) <br>
45
+ 👩‍🍳 [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook) <br>
46
+ 🖥️ [Try It](https://aka.ms/try-phi3.5mini) <br>
47
+
48
+ **Phi-3.5**: [[mini-instruct]](https://huggingface.co/microsoft/Phi-3.5-mini-instruct); [[MoE-instruct]](https://huggingface.co/microsoft/Phi-3.5-MoE-instruct) ; [[vision-instruct]](https://huggingface.co/microsoft/Phi-3.5-vision-instruct)
49
+
50
+ ## Intended Uses
51
+
52
+ ### Primary Use Cases
53
+
54
+ The model is intended for commercial and research use in multiple languages. The model provides uses for general purpose AI systems and applications which require:
55
+
56
+ 1) Memory/compute constrained environments
57
+ 2) Latency bound scenarios
58
+ 3) Strong reasoning (especially code, math and logic)
59
+
60
+ Our model is designed to accelerate research on language and multimodal models, for use as a building block for generative AI powered features.
61
+
62
+ ### Use Case Considerations
63
+
64
+ 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.
65
+
66
+ ***Nothing contained in this Model Card should be interpreted as or deemed a restriction or modification to the license the model is released under.***
67
+
68
+ ## Release Notes
69
+
70
+ This is an update over the June 2024 instruction-tuned Phi-3 Mini release based on valuable user feedback. The model used additional post-training data leading to substantial gains on multilingual, multi-turn conversation quality, and reasoning capability. We believe most use cases will benefit from this release, but we encourage users to test in their particular AI applications. We appreciate the enthusiastic adoption of the Phi-3 model family, and continue to welcome all feedback from the community.
71
+
72
+ ### Multilingual
73
+
74
+ The table below highlights multilingual capability of the Phi-3.5 Mini on multilingual MMLU, MEGA, and multilingual MMLU-pro datasets. Overall, we observed that even with just 3.8B active parameters, the model is competitive on multilingual tasks in comparison to other models with a much bigger active parameters.
75
+
76
+ | Benchmark | Phi-3.5 Mini-Ins | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
77
+ |----------------------------|------------------|-----------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
78
+ | Multilingual MMLU | 55.4 | 51.08 | 47.4 | 58.9 | 56.2 | 63.8 | 77.2 | 72.9 |
79
+ | Multilingual MMLU-Pro | 30.9 | 30.21 | 15.0 | 34.0 | 21.4 | 43.0 | 57.9 | 53.2 |
80
+ | MGSM | 47.9 | 41.56 | 31.8 | 63.3 | 56.7 | 75.1 | 75.8 | 81.7 |
81
+ | MEGA MLQA | 61.7 | 55.5 | 43.9 | 61.2 | 45.2 | 54.4 | 61.6 | 70.0 |
82
+ | MEGA TyDi QA | 62.2 | 55.9 | 54.0 | 63.7 | 54.5 | 65.6 | 63.6 | 81.8 |
83
+ | MEGA UDPOS | 46.5 | 48.1 | 57.2 | 58.2 | 54.1 | 56.6 | 62.4 | 66.0 |
84
+ | MEGA XCOPA | 63.1 | 62.4 | 58.8 | 10.8 | 21.1 | 31.2 | 95.0 | 90.3 |
85
+ | MEGA XStoryCloze | 73.5 | 73.6 | 75.5 | 92.3 | 71.0 | 87.0 | 20.7 | 96.6 |
86
+ | **Average** | **55.2** | **52.3** | **47.9** | **55.3** | **47.5** | **59.6** | **64.3** | **76.6** |
87
+
88
+ The table below shows Multilingual MMLU scores in some of the supported languages. For more multi-lingual benchmarks and details, see [Appendix A](#appendix-a).
89
+
90
+ | Benchmark | Phi-3.5 Mini-Ins | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
91
+ |-----------|------------------|-----------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
92
+ | Arabic | 44.2 | 35.4 | 33.7 | 45.3 | 49.1 | 56.3 | 73.6 | 67.1 |
93
+ | Chinese | 52.6 | 46.9 | 45.9 | 58.2 | 54.4 | 62.7 | 66.7 | 70.8 |
94
+ | Dutch | 57.7 | 48.0 | 51.3 | 60.1 | 55.9 | 66.7 | 80.6 | 74.2 |
95
+ | French | 61.1 | 61.7 | 53.0 | 63.8 | 62.8 | 67.0 | 82.9 | 75.6 |
96
+ | German | 62.4 | 61.3 | 50.1 | 64.5 | 59.9 | 65.7 | 79.5 | 74.3 |
97
+ | Italian | 62.8 | 63.1 | 52.5 | 64.1 | 55.9 | 65.7 | 82.6 | 75.9 |
98
+ | Russian | 50.4 | 45.3 | 48.9 | 59.0 | 57.4 | 63.2 | 78.7 | 72.6 |
99
+ | Spanish | 62.6 | 61.3 | 53.9 | 64.3 | 62.6 | 66.0 | 80.0 | 75.5 |
100
+ | Ukrainian | 45.2 | 36.7 | 46.9 | 56.6 | 52.9 | 62.0 | 77.4 | 72.6 |
101
+
102
+ ### Long Context
103
+
104
+ Phi-3.5-mini supports 128K context length, therefore the model is capable of several long context tasks including long document/meeting summarization, long document QA, long document information retrieval. We see that Phi-3.5-mini is clearly better than Gemma-2 family which only supports 8K context length. Phi-3.5-mini is competitive with other much larger open-weight models such as Llama-3.1-8B-instruct, Mistral-7B-instruct-v0.3, and Mistral-Nemo-12B-instruct-2407.
105
+
106
+ | Benchmark | Phi-3.5-mini-instruct | Llama-3.1-8B-instruct | Mistral-7B-instruct-v0.3 | Mistral-Nemo-12B-instruct-2407 | Gemini-1.5-Flash | GPT-4o-mini-2024-07-18 (Chat) |
107
+ |--|--|--|--|--|--|--|
108
+ | GovReport | 25.9 | 25.1 | 26.0 | 25.6 | 27.8 | 24.8 |
109
+ | QMSum | 21.3 | 21.6 | 21.3 | 22.1 | 24.0 | 21.7 |
110
+ | Qasper | 41.9 | 37.2 | 31.4 | 30.7 | 43.5 | 39.8 |
111
+ | SQuALITY | 25.3 | 26.2 | 25.9 | 25.8 | 23.5 | 23.8 |
112
+ | SummScreenFD | 16.0 | 17.6 | 17.5 | 18.2 | 16.3 | 17.0 |
113
+ | **Average** | **26.1** | **25.5** | **24.4** | **24.5** | **27.0** | **25.4** |
114
+
115
+ RULER: a retrieval-based benchmark for long context understanding
116
+ | Model | 4K | 8K | 16K | 32K | 64K | 128K | Average |
117
+ |--|--|--|--|--|--|--|--|
118
+ | **Phi-3.5-mini-instruct** | 94.3 | 91.1 | 90.7 | 87.1 | 78.0 | 63.6 | **84.1** |
119
+ | **Llama-3.1-8B-instruct** | 95.5 | 93.8 | 91.6 | 87.4 | 84.7 | 77.0 | **88.3** |
120
+ | **Mistral-Nemo-12B-instruct-2407** | 87.8 | 87.2 | 87.7 | 69.0 | 46.8 | 19.0 | **66.2** |
121
+
122
+ RepoQA: a benchmark for long context code understanding
123
+ | Model | Python | C++ | Rust | Java | TypeScript | Average |
124
+ |--|--|--|--|--|--|--|
125
+ | **Phi-3.5-mini-instruct** | 86 | 67 | 73 | 77 | 82 | **77** |
126
+ | **Llama-3.1-8B-instruct** | 80 | 65 | 73 | 76 | 63 | **71** |
127
+ | **Mistral-7B-instruct-v0.3** | 61 | 57 | 51 | 61 | 80 | **62** |
128
+
129
+ ## Usage
130
+
131
+ ### Requirements
132
+ Phi-3 family has been integrated in the `4.43.0` version of `transformers`. The current `transformers` version can be verified with: `pip list | grep transformers`.
133
+
134
+ Examples of required packages:
135
+ ```
136
+ flash_attn==2.5.8
137
+ torch==2.3.1
138
+ accelerate==0.31.0
139
+ transformers==4.43.0
140
+ ```
141
+
142
+ Phi-3.5-mini-instruct is also available in [Azure AI Studio](https://aka.ms/try-phi3.5mini)
143
+
144
+ ### Tokenizer
145
+
146
+ Phi-3.5-mini-Instruct supports a vocabulary size of up to `32064` tokens. The [tokenizer files](https://huggingface.co/microsoft/Phi-3.5-mini-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.
147
+
148
+ ### Input Formats
149
+ Given the nature of the training data, the Phi-3.5-mini-instruct model is best suited for prompts using the chat format as follows:
150
+
151
+ ```
152
+ <|system|>
153
+ You are a helpful assistant.<|end|>
154
+ <|user|>
155
+ How to explain Internet for a medieval knight?<|end|>
156
+ <|assistant|>
157
+ ```
158
+
159
+ ### Loading the model locally
160
+ After obtaining the Phi-3.5-mini-instruct model checkpoint, users can use this sample code for inference.
161
+
162
+ ```python
163
+ import torch
164
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
165
+
166
+ torch.random.manual_seed(0)
167
+
168
+ model = AutoModelForCausalLM.from_pretrained(
169
+ "microsoft/Phi-3.5-mini-instruct",
170
+ device_map="cuda",
171
+ torch_dtype="auto",
172
+ trust_remote_code=True,
173
+ )
174
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
175
+
176
+ messages = [
177
+ {"role": "system", "content": "You are a helpful AI assistant."},
178
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
179
+ {"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."},
180
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
181
+ ]
182
+
183
+ pipe = pipeline(
184
+ "text-generation",
185
+ model=model,
186
+ tokenizer=tokenizer,
187
+ )
188
+
189
+ generation_args = {
190
+ "max_new_tokens": 500,
191
+ "return_full_text": False,
192
+ "temperature": 0.0,
193
+ "do_sample": False,
194
+ }
195
+
196
+ output = pipe(messages, **generation_args)
197
+ print(output[0]['generated_text'])
198
+ ```
199
+
200
+ Notes: If you want to use flash attention, call _AutoModelForCausalLM.from_pretrained()_ with _attn_implementation="flash_attention_2"_
201
+
202
+ ## Responsible AI Considerations
203
+
204
+ Like other language models, the Phi family of models can potentially behave in ways that are unfair, unreliable, or offensive. Some of the limiting behaviors to be aware of include:
205
+ + Quality of Service: The Phi models are trained primarily on English text and some additional multilingual text. Languages other than English will experience worse performance as well as performance disparities across non-English. English language varieties with less representation in the training data might experience worse performance than standard American English.
206
+ + Multilingual performance and safety gaps: We believe it is important to make language models more widely available across different languages, but the Phi 3 models still exhibit challenges common across multilingual releases. As with any deployment of LLMs, developers will be better positioned to test for performance or safety gaps for their linguistic and cultural context and customize the model with additional fine-tuning and appropriate safeguards.
207
+ + 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, cultural contexts, or prevalence of examples of negative stereotypes in training data that reflect real-world patterns and societal biases.
208
+ + 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 case.
209
+ + Information Reliability: Language models can generate nonsensical content or fabricate content that might sound reasonable but is inaccurate or outdated.
210
+ + 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.
211
+ + Long Conversation: Phi-3 models, like other models, can in some cases generate responses that are repetitive, unhelpful, or inconsistent in very long chat sessions in both English and non-English languages. Developers are encouraged to place appropriate mitigations, like limiting conversation turns to account for the possible conversational drift
212
+
213
+ Developers should apply responsible AI best practices, including mapping, measuring, and mitigating risks associated with their specific use case and cultural, linguistic context. Phi-3 family of models are general purpose models. As developers plan to deploy these models for specific use cases, they are encouraged to fine-tune the models for their use case and leverage the models as part of broader AI systems with language-specific safeguards in place. Important areas for consideration include:
214
+
215
+ + 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.
216
+ + High-Risk Scenarios: Developers should assess the 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.
217
+ + 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).
218
+ + Generation of Harmful Content: Developers should assess outputs for their context and use available safety classifiers or custom solutions appropriate for their use case.
219
+ + 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.
220
+
221
+ ## Training
222
+
223
+ ### Model
224
+
225
+ **Architecture:** Phi-3.5-mini has 3.8B parameters and is a dense decoder-only Transformer model using the same tokenizer as Phi-3 Mini.<br>
226
+ **Inputs:** Text. It is best suited for prompts using chat format.<br>
227
+ **Context length:** 128K tokens<br>
228
+ **GPUs:** 512 H100-80G<br>
229
+ **Training time:** 10 days<br>
230
+ **Training data:** 3.4T tokens<br>
231
+ **Outputs:** Generated text in response to the input<br>
232
+ **Dates:** Trained between June and August 2024<br>
233
+ **Status:** This is a static model trained on an offline dataset with cutoff date October 2023 for publicly available data. Future versions of the tuned models may be released as we improve models.<br>
234
+ **Supported languages:** Arabic, Chinese, Czech, Danish, Dutch, English, Finnish, French, German, Hebrew, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish, Thai, Turkish, Ukrainian<br>
235
+ **Release date:** August 2024<br>
236
+
237
+ ### Training Datasets
238
+ Our training data includes a wide variety of sources, totaling 3.4 trillion tokens, and is a combination of
239
+ 1) publicly available documents filtered rigorously for quality, selected high-quality educational data, and code;
240
+ 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.);
241
+ 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.
242
+
243
+ 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://arxiv.org/pdf/2404.14219).
244
+
245
+ ### Fine-tuning
246
+
247
+ A basic example of multi-GPUs supervised fine-tuning (SFT) with TRL and Accelerate modules is provided [here](https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/sample_finetune.py).
248
+
249
+ ## Benchmarks
250
+
251
+ We report the results under completion format for Phi-3.5-mini on standard open-source benchmarks measuring the model's reasoning ability (both common sense reasoning and logical reasoning). We compare to Mistral-7B-Instruct-v0.3, Mistral-Nemo-12B-Ins-2407, Llama-3.1-8B-Ins, Gemma-2-9B-Ins, Gemini 1.5 Flash, and GPT-4o-mini-2024-07-18 (Chat).
252
+
253
+ 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.
254
+
255
+ As is now standard, we use few-shot prompts to evaluate the models, at temperature 0.
256
+ 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.
257
+ 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.
258
+
259
+ The number of k–shot examples is listed per-benchmark. At the high-level overview of the model quality on representative benchmarks:
260
+
261
+ | Category | Benchmark | Phi-3.5 Mini-Ins | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
262
+ |----------------|--------------------------|------------------|--------------------------|---------------------------|------------------|----------------|------------------|------------------------------|
263
+ | Popular aggregated benchmark | Arena Hard | 37 | 18.1 | 39.4 | 25.7 | 42 | 55.2 | 75 |
264
+ | | BigBench Hard CoT (0-shot) | 69 | 33.4 | 60.2 | 63.4 | 63.5 | 66.7 | 80.4 |
265
+ | | MMLU (5-shot) | 69 | 60.3 | 67.2 | 68.1 | 71.3 | 78.7 | 77.2 |
266
+ | | MMLU-Pro (0-shot, CoT) | 47.4 | 18 | 40.7 | 44 | 50.1 | 57.2 | 62.8 |
267
+ | Reasoning | ARC Challenge (10-shot) | 84.6 | 77.9 | 84.8 | 83.1 | 89.8 | 92.8 | 93.5 |
268
+ | | BoolQ (2-shot) | 78 | 80.5 | 82.5 | 82.8 | 85.7 | 85.8 | 88.7 |
269
+ | | GPQA (0-shot, CoT) | 30.4 | 15.6 | 28.6 | 26.3 | 29.2 | 37.5 | 41.1 |
270
+ | | HellaSwag (5-shot) | 69.4 | 71.6 | 76.7 | 73.5 | 80.9 | 67.5 | 87.1 |
271
+ | | OpenBookQA (10-shot) | 79.2 | 78 | 84.4 | 84.8 | 89.6 | 89 | 90 |
272
+ | | PIQA (5-shot) | 81 | 73.4 | 83.5 | 81.2 | 83.7 | 87.5 | 88.7 |
273
+ | | Social IQA (5-shot) | 74.7 | 73 | 75.3 | 71.8 | 74.7 | 77.8 | 82.9 |
274
+ | | TruthfulQA (MC2) (10-shot) | 64 | 64.7 | 68.1 | 69.2 | 76.6 | 76.6 | 78.2 |
275
+ | | WinoGrande (5-shot) | 68.5 | 58.1 | 70.4 | 64.7 | 74 | 74.7 | 76.9 |
276
+ | Multilingual | Multilingual MMLU (5-shot) | 55.4 | 47.4 | 58.9 | 56.2 | 63.8 | 77.2 | 72.9 |
277
+ | | MGSM (0-shot CoT) | 47.9 | 31.8 | 63.3 | 56.7 | 76.4 | 75.8 | 81.7 |
278
+ | Math | GSM8K (8-shot, CoT) | 86.2 | 54.4 | 84.2 | 82.4 | 84.9 | 82.4 | 91.3 |
279
+ | | MATH (0-shot, CoT) | 48.5 | 19 | 31.2 | 47.6 | 50.9 | 38 | 70.2 |
280
+ | Long context | Qasper | 41.9 | 31.4 | 30.7 | 37.2 | 13.9 | 43.5 | 39.8 |
281
+ | | SQuALITY | 24.3 | 25.9 | 25.8 | 26.2 | 0 | 23.5 | 23.8 |
282
+ | Code Generation| HumanEval (0-shot) | 62.8 | 35.4 | 63.4 | 66.5 | 61 | 74.4 | 86.6 |
283
+ | | MBPP (3-shot) | 69.6 | 50.4 | 68.1 | 69.4 | 69.3 | 77.5 | 84.1 |
284
+ | **Average** | | **61.4** | **48.5** | **61.3** | **61.0** | **63.3** | **68.5** | **74.9** |
285
+
286
+ We take a closer look at different categories across public benchmark datasets at the table below:
287
+
288
+ | Category | Phi-3.5 Mini-Ins | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
289
+ |----------------------------|------------------|--------------------------|---------------------------|------------------|----------------|------------------|------------------------------|
290
+ | Popular aggregated benchmark | 55.6 | 32.5 | 51.9 | 50.3 | 56.7 | 64.5 | 73.9 |
291
+ | Reasoning | 70.1 | 65.2 | 72.2 | 70.5 | 75.4 | 77.7 | 80 |
292
+ | Language understanding | 62.6 | 62.8 | 67 | 62.9 | 72.8 | 66.6 | 76.8 |
293
+ | Robustness | 59.7 | 53.4 | 65.2 | 59.8 | 64.7 | 68.9 | 77.5 |
294
+ | Long context | 26.1 | 25.5 | 24.4 | 24.5 | 0 | 27 | 25.4 |
295
+ | Math | 67.4 | 36.7 | 57.7 | 65 | 67.9 | 60.2 | 80.8 |
296
+ | Code generation | 62 | 43.1 | 56.9 | 65.8 | 58.3 | 66.8 | 69.9 |
297
+ | Multilingual | 55.2 | 47.9 | 55.3 | 47.5 | 59.6 | 64.3 | 76.6 |
298
+
299
+ Overall, the model with only 3.8B-param achieves a similar level of multilingual language understanding and reasoning ability as much larger models.
300
+ However, it is still fundamentally limited by its size for certain tasks.
301
+ The model simply does not have the capacity to store too much factual knowledge, therefore, users may experience factual incorrectness.
302
+ However, we believe such weakness can be resolved by augmenting Phi-3.5 with a search engine, particularly when using the model under RAG settings.
303
+
304
+ ## Safety Evaluation and Red-Teaming
305
+
306
+ We leveraged various evaluation techniques including red teaming, adversarial conversation simulations, and multilingual safety evaluation benchmark datasets to
307
+ evaluate Phi-3.5 models' propensity to produce undesirable outputs across multiple languages and risk categories.
308
+ Several approaches were used to compensate for the limitations of one approach alone. Findings across the various evaluation methods indicate that safety
309
+ post-training that was done as detailed in the [Phi-3 Safety Post-Training paper](https://arxiv.org/pdf/2407.13833) had a positive impact across multiple languages and risk categories as observed by
310
+ refusal rates (refusal to output undesirable outputs) and robustness to jailbreak techniques. Note, however, while comprehensive red team evaluations were conducted
311
+ across all models in the prior release of Phi models, red teaming was largely focused on Phi-3.5 MOE across multiple languages and risk categories for this release as
312
+ it is the largest and more capable model of the three models. Details on prior red team evaluations across Phi models can be found in the [Phi-3 Safety Post-Training paper](https://arxiv.org/pdf/2407.13833).
313
+ For this release, insights from red teaming indicate that the models may refuse to generate undesirable outputs in English, even when the request for undesirable output
314
+ is in another language. Models may also be more susceptible to longer multi-turn jailbreak techniques across both English and non-English languages. These findings
315
+ highlight the need for industry-wide investment in the development of high-quality safety evaluation datasets across multiple languages, including low resource languages,
316
+ and risk areas that account for cultural nuances where those languages are spoken.
317
+
318
+
319
+ ## Software
320
+ * [PyTorch](https://github.com/pytorch/pytorch)
321
+ * [Transformers](https://github.com/huggingface/transformers)
322
+ * [Flash-Attention](https://github.com/HazyResearch/flash-attention)
323
+
324
+ ## Hardware
325
+ Note that by default, the Phi-3.5-mini-instruct model uses flash attention, which requires certain types of GPU hardware to run. We have tested on the following GPU types:
326
+ * NVIDIA A100
327
+ * NVIDIA A6000
328
+ * NVIDIA H100
329
+
330
+ If you want to run the model on:
331
+ * NVIDIA V100 or earlier generation GPUs: call AutoModelForCausalLM.from_pretrained() with attn_implementation="eager"
332
+
333
+ ## License
334
+ The model is licensed under the [MIT license](./LICENSE).
335
+
336
+ ## Trademarks
337
+ 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.
338
+
339
+
340
+ ## Appendix A
341
+
342
+ #### MGSM
343
+
344
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
345
+ |-----------|------------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
346
+ | German | 69.6 | 65.2 | 42.4 | 74.4 | 68.4 | 76.8 | 81.6 | 82.8 |
347
+ | English | 85.2 | 83.2 | 60.0 | 86.0 | 81.2 | 88.8 | 90.8 | 90.8 |
348
+ | Spanish | 79.2 | 77.6 | 46.4 | 75.6 | 66.4 | 82.4 | 84.8 | 86.8 |
349
+ | French | 71.6 | 72.8 | 47.2 | 70.4 | 66.8 | 74.4 | 77.2 | 81.6 |
350
+ | Japanese | 50.0 | 35.2 | 22.8 | 62.4 | 49.2 | 67.6 | 77.6 | 80.4 |
351
+ | Russian | 67.2 | 51.6 | 43.2 | 73.6 | 67.2 | 78.4 | 84.8 | 86.4 |
352
+ | Thai | 29.6 | 6.4 | 18.4 | 53.2 | 56.0 | 76.8 | 87.6 | 81.6 |
353
+ | Chinese | 60.0 | 52.8 | 42.4 | 66.4 | 68.0 | 72.8 | 82.0 | 82.0 |
354
+
355
+ #### Multilingual MMLU-pro
356
+
357
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
358
+ |------------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
359
+ | Czech | 24.9 | 26.3 | 14.6 | 30.6 | 23.0 | 40.5 | 59.0 | 40.9 |
360
+ | English | 47.7 | 46.2 | 17.7 | 39.8 | 43.1 | 49.0 | 66.1 | 62.7 |
361
+ | Finnish | 22.3 | 20.5 | 11.5 | 30.4 | 9.7 | 37.5 | 54.5 | 50.1 |
362
+ | Norwegian | 29.9 | 27.8 | 14.4 | 33.2 | 22.2 | 44.4 | 60.7 | 59.1 |
363
+ | Polish | 25.7 | 26.4 | 16.3 | 33.6 | 9.2 | 41.7 | 53.9 | 42.8 |
364
+ | Portuguese | 38.7 | 37.6 | 15.3 | 36.0 | 29.3 | 43.5 | 54.0 | 56.9 |
365
+ | Swedish | 30.7 | 28.1 | 15.5 | 34.3 | 16.9 | 42.6 | 57.7 | 55.5 |
366
+
367
+ #### MEGA
368
+
369
+ ##### MLQA
370
+
371
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
372
+ |-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
373
+ | Arabic | 54.3 | 32.7 | 23.5 | 31.4 | 31.5 | 57.4 | 63.8 | 64.0 |
374
+ | Chinese | 36.1 | 31.8 | 22.4 | 27.4 | 18.6 | 45.4 | 38.1 | 38.9 |
375
+ | English | 80.3 | 78.9 | 68.2 | 75.5 | 67.2 | 82.9 | 69.5 | 82.2 |
376
+ | German | 61.8 | 59.1 | 49.0 | 57.8 | 38.9 | 63.8 | 55.9 | 64.1 |
377
+ | Spanish | 68.8 | 67.0 | 50.3 | 63.6 | 52.7 | 72.8 | 59.6 | 70.1 |
378
+
379
+ ##### TyDi QA
380
+
381
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
382
+ |-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
383
+ | Arabic | 69.7 | 54.4 | 52.5 | 49.8 | 33.7 | 81.1 | 78.8 | 84.9 |
384
+ | English | 82.0 | 82.0 | 60.5 | 77.3 | 65.1 | 82.4 | 60.9 | 81.8 |
385
+ | Finnish | 70.3 | 64.3 | 68.6 | 57.1 | 74.4 | 85.7 | 73.5 | 84.8 |
386
+ | Japanese | 65.4 | 56.7 | 45.3 | 54.8 | 34.1 | 74.6 | 59.7 | 73.3 |
387
+ | Korean | 74.0 | 60.4 | 54.5 | 54.2 | 54.9 | 83.8 | 60.7 | 82.3 |
388
+ | Russian | 63.5 | 62.7 | 52.3 | 55.7 | 27.4 | 69.8 | 60.1 | 72.5 |
389
+ | Thai | 64.4 | 49.0 | 51.8 | 43.5 | 48.5 | 81.4 | 71.6 | 78.2 |
390
+
391
+ ##### XCOPA
392
+
393
+ | Languages | Phi-3.5-Mini-Instruct | Phi-3.0-Mini-128k-Instruct (June2024) | Mistral-7B-Instruct-v0.3 | Mistral-Nemo-12B-Ins-2407 | Llama-3.1-8B-Ins | Gemma-2-9B-Ins | Gemini 1.5 Flash | GPT-4o-mini-2024-07-18 (Chat) |
394
+ |-----------|-----------------------|---------------------------------------|--------------------------|---------------------------|------------------|----------------|------------------|-------------------------------|
395
+ | English | 94.6 | 94.6 | 85.6 | 94.4 | 37.6 | 63.8 | 92.0 | 98.2 |
396
+ | Italian | 86.8 | 84.8 | 76.8 | 83.2 | 16.2 | 37.2 | 85.6 | 97.6 |
397
+ | Turkish | 58.6 | 57.2 | 61.6 | 56.6 | 38.4 | 60.2 | 91.4 | 94.6 |
added_tokens.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|assistant|>": 32001,
3
+ "<|endoftext|>": 32000,
4
+ "<|end|>": 32007,
5
+ "<|placeholder1|>": 32002,
6
+ "<|placeholder2|>": 32003,
7
+ "<|placeholder3|>": 32004,
8
+ "<|placeholder4|>": 32005,
9
+ "<|placeholder5|>": 32008,
10
+ "<|placeholder6|>": 32009,
11
+ "<|system|>": 32006,
12
+ "<|user|>": 32010
13
+ }
config.json ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "microsoft/Phi-3.5-mini-instruct",
3
+ "architectures": [
4
+ "Phi3ForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "auto_map": {
9
+ "AutoConfig": "microsoft/Phi-3.5-mini-instruct--configuration_phi3.Phi3Config",
10
+ "AutoModelForCausalLM": "microsoft/Phi-3.5-mini-instruct--modeling_phi3.Phi3ForCausalLM"
11
+ },
12
+ "bos_token_id": 1,
13
+ "embd_pdrop": 0.0,
14
+ "eos_token_id": 32000,
15
+ "hidden_act": "silu",
16
+ "hidden_size": 3072,
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 8192,
19
+ "max_position_embeddings": 131072,
20
+ "model_type": "phi3",
21
+ "num_attention_heads": 32,
22
+ "num_hidden_layers": 32,
23
+ "num_key_value_heads": 32,
24
+ "original_max_position_embeddings": 4096,
25
+ "pad_token_id": 32000,
26
+ "resid_pdrop": 0.0,
27
+ "rms_norm_eps": 1e-05,
28
+ "rope_scaling": {
29
+ "long_factor": [
30
+ 1.0800000429153442,
31
+ 1.1100000143051147,
32
+ 1.1399999856948853,
33
+ 1.340000033378601,
34
+ 1.5899999141693115,
35
+ 1.600000023841858,
36
+ 1.6200000047683716,
37
+ 2.620000123977661,
38
+ 3.2300000190734863,
39
+ 3.2300000190734863,
40
+ 4.789999961853027,
41
+ 7.400000095367432,
42
+ 7.700000286102295,
43
+ 9.09000015258789,
44
+ 12.199999809265137,
45
+ 17.670000076293945,
46
+ 24.46000099182129,
47
+ 28.57000160217285,
48
+ 30.420001983642578,
49
+ 30.840002059936523,
50
+ 32.590003967285156,
51
+ 32.93000411987305,
52
+ 42.320003509521484,
53
+ 44.96000289916992,
54
+ 50.340003967285156,
55
+ 50.45000457763672,
56
+ 57.55000305175781,
57
+ 57.93000411987305,
58
+ 58.21000289916992,
59
+ 60.1400032043457,
60
+ 62.61000442504883,
61
+ 62.62000274658203,
62
+ 62.71000289916992,
63
+ 63.1400032043457,
64
+ 63.1400032043457,
65
+ 63.77000427246094,
66
+ 63.93000411987305,
67
+ 63.96000289916992,
68
+ 63.970001220703125,
69
+ 64.02999877929688,
70
+ 64.06999969482422,
71
+ 64.08000183105469,
72
+ 64.12000274658203,
73
+ 64.41000366210938,
74
+ 64.4800033569336,
75
+ 64.51000213623047,
76
+ 64.52999877929688,
77
+ 64.83999633789062
78
+ ],
79
+ "short_factor": [
80
+ 1.0,
81
+ 1.0199999809265137,
82
+ 1.0299999713897705,
83
+ 1.0299999713897705,
84
+ 1.0499999523162842,
85
+ 1.0499999523162842,
86
+ 1.0499999523162842,
87
+ 1.0499999523162842,
88
+ 1.0499999523162842,
89
+ 1.0699999332427979,
90
+ 1.0999999046325684,
91
+ 1.1099998950958252,
92
+ 1.1599998474121094,
93
+ 1.1599998474121094,
94
+ 1.1699998378753662,
95
+ 1.2899998426437378,
96
+ 1.339999794960022,
97
+ 1.679999828338623,
98
+ 1.7899998426437378,
99
+ 1.8199998140335083,
100
+ 1.8499997854232788,
101
+ 1.8799997568130493,
102
+ 1.9099997282028198,
103
+ 1.9399996995925903,
104
+ 1.9899996519088745,
105
+ 2.0199997425079346,
106
+ 2.0199997425079346,
107
+ 2.0199997425079346,
108
+ 2.0199997425079346,
109
+ 2.0199997425079346,
110
+ 2.0199997425079346,
111
+ 2.0299997329711914,
112
+ 2.0299997329711914,
113
+ 2.0299997329711914,
114
+ 2.0299997329711914,
115
+ 2.0299997329711914,
116
+ 2.0299997329711914,
117
+ 2.0299997329711914,
118
+ 2.0299997329711914,
119
+ 2.0299997329711914,
120
+ 2.0799996852874756,
121
+ 2.0899996757507324,
122
+ 2.189999580383301,
123
+ 2.2199995517730713,
124
+ 2.5899994373321533,
125
+ 2.729999542236328,
126
+ 2.749999523162842,
127
+ 2.8399994373321533
128
+ ],
129
+ "type": "longrope"
130
+ },
131
+ "rope_theta": 10000.0,
132
+ "sliding_window": 262144,
133
+ "tie_word_embeddings": false,
134
+ "transformers_version": "4.43.4",
135
+ "use_cache": true,
136
+ "vocab_size": 32064
137
+ }
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": [
5
+ 32007,
6
+ 32001,
7
+ 32000
8
+ ],
9
+ "pad_token_id": 32000,
10
+ "transformers_version": "4.43.4"
11
+ }
model.yaml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ name: phi3.5-medium
2
+ backend: transformers
3
+ parameters:
4
+ model: fakezeta/Phi-3.5-mini-instruct-ov-int4
5
+ context_size: 8192
6
+ type: OVModelForCausalLM
7
+ trust_remote_code: true
8
+ template:
9
+ use_tokenizer_template: true
openvino_detokenizer.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34f54bcfdecf199ed7333d7748c8e357c9d98b26c0c5800c7e0809e48edd74d3
3
+ size 499991
openvino_detokenizer.xml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <net name="detokenizer" version="11">
3
+ <layers>
4
+ <layer id="0" name="Parameter_237586" type="Parameter" version="opset1">
5
+ <data shape="?,?" element_type="i64" />
6
+ <output>
7
+ <port id="0" precision="I64" names="Parameter_237586">
8
+ <dim>-1</dim>
9
+ <dim>-1</dim>
10
+ </port>
11
+ </output>
12
+ </layer>
13
+ <layer id="1" name="Constant_237562" type="Const" version="opset1">
14
+ <data element_type="u8" shape="499991" offset="0" size="499991" />
15
+ <output>
16
+ <port id="0" precision="U8">
17
+ <dim>499991</dim>
18
+ </port>
19
+ </output>
20
+ </layer>
21
+ <layer id="2" name="Convert_237596" type="Convert" version="opset1">
22
+ <data destination_type="i32" />
23
+ <input>
24
+ <port id="0" precision="I64">
25
+ <dim>-1</dim>
26
+ <dim>-1</dim>
27
+ </port>
28
+ </input>
29
+ <output>
30
+ <port id="1" precision="I32">
31
+ <dim>-1</dim>
32
+ <dim>-1</dim>
33
+ </port>
34
+ </output>
35
+ </layer>
36
+ <layer id="3" name="SentencepieceDetokenizer_237587" type="SentencepieceDetokenizer" version="extension">
37
+ <input>
38
+ <port id="0" precision="U8">
39
+ <dim>499991</dim>
40
+ </port>
41
+ <port id="1" precision="I32">
42
+ <dim>-1</dim>
43
+ <dim>-1</dim>
44
+ </port>
45
+ </input>
46
+ <output>
47
+ <port id="2" precision="I32">
48
+ <dim>-1</dim>
49
+ </port>
50
+ <port id="3" precision="I32">
51
+ <dim>-1</dim>
52
+ </port>
53
+ <port id="4" precision="U8">
54
+ <dim>-1</dim>
55
+ </port>
56
+ </output>
57
+ </layer>
58
+ <layer id="4" name="StringTensorPack_237588" type="StringTensorPack" version="extension">
59
+ <data mode="begins_ends" />
60
+ <input>
61
+ <port id="0" precision="I32">
62
+ <dim>-1</dim>
63
+ </port>
64
+ <port id="1" precision="I32">
65
+ <dim>-1</dim>
66
+ </port>
67
+ <port id="2" precision="U8">
68
+ <dim>-1</dim>
69
+ </port>
70
+ </input>
71
+ <output>
72
+ <port id="3" precision="STRING" names="string_output">
73
+ <dim>-1</dim>
74
+ </port>
75
+ </output>
76
+ </layer>
77
+ <layer id="5" name="Result_237589" type="Result" version="opset1">
78
+ <input>
79
+ <port id="0" precision="STRING">
80
+ <dim>-1</dim>
81
+ </port>
82
+ </input>
83
+ </layer>
84
+ </layers>
85
+ <edges>
86
+ <edge from-layer="0" from-port="0" to-layer="2" to-port="0" />
87
+ <edge from-layer="1" from-port="0" to-layer="3" to-port="0" />
88
+ <edge from-layer="2" from-port="1" to-layer="3" to-port="1" />
89
+ <edge from-layer="3" from-port="2" to-layer="4" to-port="0" />
90
+ <edge from-layer="3" from-port="3" to-layer="4" to-port="1" />
91
+ <edge from-layer="3" from-port="4" to-layer="4" to-port="2" />
92
+ <edge from-layer="4" from-port="3" to-layer="5" to-port="0" />
93
+ </edges>
94
+ <rt_info>
95
+ <bos_token_id value="1" />
96
+ <chat_template value="{% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'&lt;|system|>&#10;' + message['content'] + '&lt;|end|>&#10;'}}{% elif message['role'] == 'user' %}{{'&lt;|user|>&#10;' + message['content'] + '&lt;|end|>&#10;'}}{% elif message['role'] == 'assistant' %}{{'&lt;|assistant|>&#10;' + message['content'] + '&lt;|end|>&#10;'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '&lt;|assistant|>&#10;' }}{% else %}{{ eos_token }}{% endif %}" />
97
+ <eos_token_id value="32000" />
98
+ <original_tokenizer_class value="&lt;class 'transformers.models.llama.tokenization_llama_fast.LlamaTokenizerFast'>" />
99
+ <pad_token_id value="32000" />
100
+ </rt_info>
101
+ </net>
openvino_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37e4a3aab18fb00d80290e94ac903cbc8ffda6a64a3779e4110c092c310c96c0
3
+ size 2080711012
openvino_model.xml ADDED
The diff for this file is too large to render. See raw diff
 
openvino_tokenizer.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27a382f4cd1318883609d060c54fd98f5d98c02b94062e129e901a37595eedad
3
+ size 499989
openvino_tokenizer.xml ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <net name="tokenizer" version="11">
3
+ <layers>
4
+ <layer id="0" name="string_input" type="Parameter" version="opset1">
5
+ <data shape="?" element_type="string" />
6
+ <output>
7
+ <port id="0" precision="STRING" names="string_input">
8
+ <dim>-1</dim>
9
+ </port>
10
+ </output>
11
+ </layer>
12
+ <layer id="1" name="Constant_237565" type="Const" version="opset1">
13
+ <data element_type="i32" shape="" offset="0" size="4" />
14
+ <output>
15
+ <port id="0" precision="I32" />
16
+ </output>
17
+ </layer>
18
+ <layer id="2" name="Constant_237561" type="Const" version="opset1">
19
+ <data element_type="u8" shape="499969" offset="4" size="499969" />
20
+ <output>
21
+ <port id="0" precision="U8">
22
+ <dim>499969</dim>
23
+ </port>
24
+ </output>
25
+ </layer>
26
+ <layer id="3" name="SentencepieceTokenizer_237564" type="SentencepieceTokenizer" version="extension">
27
+ <data nbest_size="0" alpha="0" add_bos="false" add_eos="false" reverse="true" />
28
+ <input>
29
+ <port id="0" precision="U8">
30
+ <dim>499969</dim>
31
+ </port>
32
+ <port id="1" precision="STRING">
33
+ <dim>-1</dim>
34
+ </port>
35
+ </input>
36
+ <output>
37
+ <port id="2" precision="I64">
38
+ <dim>-1</dim>
39
+ <dim>2</dim>
40
+ </port>
41
+ <port id="3" precision="I32">
42
+ <dim>-1</dim>
43
+ </port>
44
+ <port id="4" precision="I64">
45
+ <dim>2</dim>
46
+ </port>
47
+ </output>
48
+ </layer>
49
+ <layer id="4" name="Broadcast_237566" type="Broadcast" version="opset3">
50
+ <data mode="numpy" />
51
+ <input>
52
+ <port id="0" precision="I32" />
53
+ <port id="1" precision="I64">
54
+ <dim>2</dim>
55
+ </port>
56
+ </input>
57
+ <output>
58
+ <port id="2" precision="I32">
59
+ <dim>-1</dim>
60
+ <dim>-1</dim>
61
+ </port>
62
+ </output>
63
+ </layer>
64
+ <layer id="5" name="Constant_237567" type="Const" version="opset1">
65
+ <data element_type="i32" shape="" offset="499973" size="4" />
66
+ <output>
67
+ <port id="0" precision="I32" />
68
+ </output>
69
+ </layer>
70
+ <layer id="6" name="ShapeOf_237568" type="ShapeOf" version="opset3">
71
+ <data output_type="i64" />
72
+ <input>
73
+ <port id="0" precision="I32">
74
+ <dim>-1</dim>
75
+ </port>
76
+ </input>
77
+ <output>
78
+ <port id="1" precision="I64">
79
+ <dim>1</dim>
80
+ </port>
81
+ </output>
82
+ </layer>
83
+ <layer id="7" name="Broadcast_237569" type="Broadcast" version="opset3">
84
+ <data mode="numpy" />
85
+ <input>
86
+ <port id="0" precision="I32" />
87
+ <port id="1" precision="I64">
88
+ <dim>1</dim>
89
+ </port>
90
+ </input>
91
+ <output>
92
+ <port id="2" precision="I32">
93
+ <dim>-1</dim>
94
+ </port>
95
+ </output>
96
+ </layer>
97
+ <layer id="8" name="ScatterNDUpdate_237573" type="ScatterNDUpdate" version="opset4">
98
+ <input>
99
+ <port id="0" precision="I32">
100
+ <dim>-1</dim>
101
+ <dim>-1</dim>
102
+ </port>
103
+ <port id="1" precision="I64">
104
+ <dim>-1</dim>
105
+ <dim>2</dim>
106
+ </port>
107
+ <port id="2" precision="I32">
108
+ <dim>-1</dim>
109
+ </port>
110
+ </input>
111
+ <output>
112
+ <port id="3" precision="I32">
113
+ <dim>-1</dim>
114
+ <dim>-1</dim>
115
+ </port>
116
+ </output>
117
+ </layer>
118
+ <layer id="9" name="Constant_237577" type="Const" version="opset1">
119
+ <data element_type="i64" shape="1" offset="499977" size="8" />
120
+ <output>
121
+ <port id="0" precision="I64">
122
+ <dim>1</dim>
123
+ </port>
124
+ </output>
125
+ </layer>
126
+ <layer id="10" name="Reverse_237578" type="Reverse" version="opset1">
127
+ <data mode="index" />
128
+ <input>
129
+ <port id="0" precision="I32">
130
+ <dim>-1</dim>
131
+ <dim>-1</dim>
132
+ </port>
133
+ <port id="1" precision="I64">
134
+ <dim>1</dim>
135
+ </port>
136
+ </input>
137
+ <output>
138
+ <port id="2" precision="I32">
139
+ <dim>-1</dim>
140
+ <dim>-1</dim>
141
+ </port>
142
+ </output>
143
+ </layer>
144
+ <layer id="11" name="Reverse_237578" type="Convert" version="opset1">
145
+ <data destination_type="i64" />
146
+ <input>
147
+ <port id="0" precision="I32">
148
+ <dim>-1</dim>
149
+ <dim>-1</dim>
150
+ </port>
151
+ </input>
152
+ <output>
153
+ <port id="1" precision="I64" names="attention_mask">
154
+ <dim>-1</dim>
155
+ <dim>-1</dim>
156
+ </port>
157
+ </output>
158
+ </layer>
159
+ <layer id="13" name="Constant_237574" type="Const" version="opset1">
160
+ <data element_type="i32" shape="" offset="499985" size="4" />
161
+ <output>
162
+ <port id="0" precision="I32" />
163
+ </output>
164
+ </layer>
165
+ <layer id="14" name="Broadcast_237575" type="Broadcast" version="opset3">
166
+ <data mode="bidirectional" />
167
+ <input>
168
+ <port id="0" precision="I32" />
169
+ <port id="1" precision="I64">
170
+ <dim>2</dim>
171
+ </port>
172
+ </input>
173
+ <output>
174
+ <port id="2" precision="I32">
175
+ <dim>-1</dim>
176
+ <dim>-1</dim>
177
+ </port>
178
+ </output>
179
+ </layer>
180
+ <layer id="15" name="ScatterNDUpdate_237576" type="ScatterNDUpdate" version="opset4">
181
+ <input>
182
+ <port id="0" precision="I32">
183
+ <dim>-1</dim>
184
+ <dim>-1</dim>
185
+ </port>
186
+ <port id="1" precision="I64">
187
+ <dim>-1</dim>
188
+ <dim>2</dim>
189
+ </port>
190
+ <port id="2" precision="I32">
191
+ <dim>-1</dim>
192
+ </port>
193
+ </input>
194
+ <output>
195
+ <port id="3" precision="I32">
196
+ <dim>-1</dim>
197
+ <dim>-1</dim>
198
+ </port>
199
+ </output>
200
+ </layer>
201
+ <layer id="16" name="Constant_237579" type="Const" version="opset1">
202
+ <data element_type="i64" shape="1" offset="499977" size="8" />
203
+ <output>
204
+ <port id="0" precision="I64">
205
+ <dim>1</dim>
206
+ </port>
207
+ </output>
208
+ </layer>
209
+ <layer id="17" name="Reverse_237580" type="Reverse" version="opset1">
210
+ <data mode="index" />
211
+ <input>
212
+ <port id="0" precision="I32">
213
+ <dim>-1</dim>
214
+ <dim>-1</dim>
215
+ </port>
216
+ <port id="1" precision="I64">
217
+ <dim>1</dim>
218
+ </port>
219
+ </input>
220
+ <output>
221
+ <port id="2" precision="I32">
222
+ <dim>-1</dim>
223
+ <dim>-1</dim>
224
+ </port>
225
+ </output>
226
+ </layer>
227
+ <layer id="18" name="Reverse_237580" type="Convert" version="opset1">
228
+ <data destination_type="i64" />
229
+ <input>
230
+ <port id="0" precision="I32">
231
+ <dim>-1</dim>
232
+ <dim>-1</dim>
233
+ </port>
234
+ </input>
235
+ <output>
236
+ <port id="1" precision="I64" names="input_ids">
237
+ <dim>-1</dim>
238
+ <dim>-1</dim>
239
+ </port>
240
+ </output>
241
+ </layer>
242
+ <layer id="19" name="Result_237581" type="Result" version="opset1">
243
+ <input>
244
+ <port id="0" precision="I64">
245
+ <dim>-1</dim>
246
+ <dim>-1</dim>
247
+ </port>
248
+ </input>
249
+ </layer>
250
+ <layer id="12" name="Result_237582" type="Result" version="opset1">
251
+ <input>
252
+ <port id="0" precision="I64">
253
+ <dim>-1</dim>
254
+ <dim>-1</dim>
255
+ </port>
256
+ </input>
257
+ </layer>
258
+ </layers>
259
+ <edges>
260
+ <edge from-layer="0" from-port="0" to-layer="3" to-port="1" />
261
+ <edge from-layer="1" from-port="0" to-layer="4" to-port="0" />
262
+ <edge from-layer="2" from-port="0" to-layer="3" to-port="0" />
263
+ <edge from-layer="3" from-port="4" to-layer="4" to-port="1" />
264
+ <edge from-layer="3" from-port="3" to-layer="6" to-port="0" />
265
+ <edge from-layer="3" from-port="2" to-layer="8" to-port="1" />
266
+ <edge from-layer="3" from-port="3" to-layer="15" to-port="2" />
267
+ <edge from-layer="3" from-port="2" to-layer="15" to-port="1" />
268
+ <edge from-layer="3" from-port="4" to-layer="14" to-port="1" />
269
+ <edge from-layer="4" from-port="2" to-layer="8" to-port="0" />
270
+ <edge from-layer="5" from-port="0" to-layer="7" to-port="0" />
271
+ <edge from-layer="6" from-port="1" to-layer="7" to-port="1" />
272
+ <edge from-layer="7" from-port="2" to-layer="8" to-port="2" />
273
+ <edge from-layer="8" from-port="3" to-layer="10" to-port="0" />
274
+ <edge from-layer="9" from-port="0" to-layer="10" to-port="1" />
275
+ <edge from-layer="10" from-port="2" to-layer="11" to-port="0" />
276
+ <edge from-layer="11" from-port="1" to-layer="12" to-port="0" />
277
+ <edge from-layer="13" from-port="0" to-layer="14" to-port="0" />
278
+ <edge from-layer="14" from-port="2" to-layer="15" to-port="0" />
279
+ <edge from-layer="15" from-port="3" to-layer="17" to-port="0" />
280
+ <edge from-layer="16" from-port="0" to-layer="17" to-port="1" />
281
+ <edge from-layer="17" from-port="2" to-layer="18" to-port="0" />
282
+ <edge from-layer="18" from-port="1" to-layer="19" to-port="0" />
283
+ </edges>
284
+ <rt_info>
285
+ <bos_token_id value="1" />
286
+ <chat_template value="{% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'&lt;|system|>&#10;' + message['content'] + '&lt;|end|>&#10;'}}{% elif message['role'] == 'user' %}{{'&lt;|user|>&#10;' + message['content'] + '&lt;|end|>&#10;'}}{% elif message['role'] == 'assistant' %}{{'&lt;|assistant|>&#10;' + message['content'] + '&lt;|end|>&#10;'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '&lt;|assistant|>&#10;' }}{% else %}{{ eos_token }}{% endif %}" />
287
+ <eos_token_id value="32000" />
288
+ <original_tokenizer_class value="&lt;class 'transformers.models.llama.tokenization_llama_fast.LlamaTokenizerFast'>" />
289
+ <pad_token_id value="32000" />
290
+ </rt_info>
291
+ </net>
special_tokens_map.json ADDED
@@ -0,0 +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
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
3
+ size 499723
tokenizer_config.json ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": true,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "32000": {
31
+ "content": "<|endoftext|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "32001": {
39
+ "content": "<|assistant|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": true,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "32002": {
47
+ "content": "<|placeholder1|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": true,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "32003": {
55
+ "content": "<|placeholder2|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": true,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "32004": {
63
+ "content": "<|placeholder3|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": true,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "32005": {
71
+ "content": "<|placeholder4|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": true,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "32006": {
79
+ "content": "<|system|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": true,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "32007": {
87
+ "content": "<|end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": true,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "32008": {
95
+ "content": "<|placeholder5|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": true,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "32009": {
103
+ "content": "<|placeholder6|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": true,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "32010": {
111
+ "content": "<|user|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": true,
115
+ "single_word": false,
116
+ "special": true
117
+ }
118
+ },
119
+ "bos_token": "<s>",
120
+ "chat_template": "{% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'<|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 %}",
121
+ "clean_up_tokenization_spaces": false,
122
+ "eos_token": "<|endoftext|>",
123
+ "legacy": false,
124
+ "model_max_length": 131072,
125
+ "pad_token": "<|endoftext|>",
126
+ "padding_side": "left",
127
+ "sp_model_kwargs": {},
128
+ "tokenizer_class": "LlamaTokenizer",
129
+ "unk_token": "<unk>",
130
+ "use_default_system_prompt": false
131
+ }