batmac commited on
Commit
983d213
1 Parent(s): b236995

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: other
5
+ tags:
6
+ - facebook
7
+ - meta
8
+ - pytorch
9
+ - llama
10
+ - llama-3
11
+ - mlx
12
+ pipeline_tag: text-generation
13
+ license_name: llama3
14
+ license_link: LICENSE
15
+ extra_gated_prompt: "### META LLAMA 3 COMMUNITY LICENSE AGREEMENT\nMeta Llama 3 Version\
16
+ \ Release Date: April 18, 2024\n\"Agreement\" means the terms and conditions for\
17
+ \ use, reproduction, distribution and modification of the Llama Materials set forth\
18
+ \ herein.\n\"Documentation\" means the specifications, manuals and documentation\
19
+ \ accompanying Meta Llama 3 distributed by Meta at https://llama.meta.com/get-started/.\n\
20
+ \"Licensee\" or \"you\" means you, or your employer or any other person or entity\
21
+ \ (if you are entering into this Agreement on such person or entity’s behalf), of\
22
+ \ the age required under applicable laws, rules or regulations to provide legal\
23
+ \ consent and that has legal authority to bind your employer or such other person\
24
+ \ or entity if you are entering in this Agreement on their behalf.\n\"Meta Llama\
25
+ \ 3\" means the foundational large language models and software and algorithms,\
26
+ \ including machine-learning model code, trained model weights, inference-enabling\
27
+ \ code, training-enabling code, fine-tuning enabling code and other elements of\
28
+ \ the foregoing distributed by Meta at https://llama.meta.com/llama-downloads.\n\
29
+ \"Llama Materials\" means, collectively, Meta’s proprietary Meta Llama 3 and Documentation\
30
+ \ (and any portion thereof) made available under this Agreement.\n\"Meta\" or \"\
31
+ we\" means Meta Platforms Ireland Limited (if you are located in or, if you are\
32
+ \ an entity, your principal place of business is in the EEA or Switzerland) and\
33
+ \ Meta Platforms, Inc. (if you are located outside of the EEA or Switzerland).\n\
34
+ \ \n1. License Rights and Redistribution.\na. Grant of Rights. You are granted\
35
+ \ a non-exclusive, worldwide, non-transferable and royalty-free limited license\
36
+ \ under Meta’s intellectual property or other rights owned by Meta embodied in the\
37
+ \ Llama Materials to use, reproduce, distribute, copy, create derivative works of,\
38
+ \ and make modifications to the Llama Materials.\nb. Redistribution and Use.\ni.\
39
+ \ If you distribute or make available the Llama Materials (or any derivative works\
40
+ \ thereof), or a product or service that uses any of them, including another AI\
41
+ \ model, you shall (A) provide a copy of this Agreement with any such Llama Materials;\
42
+ \ and (B) prominently display “Built with Meta Llama 3” on a related website, user\
43
+ \ interface, blogpost, about page, or product documentation. If you use the Llama\
44
+ \ Materials to create, train, fine tune, or otherwise improve an AI model, which\
45
+ \ is distributed or made available, you shall also include “Llama 3” at the beginning\
46
+ \ of any such AI model name.\nii. If you receive Llama Materials, or any derivative\
47
+ \ works thereof, from a Licensee as part of an integrated end user product, then\
48
+ \ Section 2 of this Agreement will not apply to you.\niii. You must retain in all\
49
+ \ copies of the Llama Materials that you distribute the following attribution notice\
50
+ \ within a “Notice” text file distributed as a part of such copies: “Meta Llama\
51
+ \ 3 is licensed under the Meta Llama 3 Community License, Copyright © Meta Platforms,\
52
+ \ Inc. All Rights Reserved.”\niv. Your use of the Llama Materials must comply with\
53
+ \ applicable laws and regulations (including trade compliance laws and regulations)\
54
+ \ and adhere to the Acceptable Use Policy for the Llama Materials (available at\
55
+ \ https://llama.meta.com/llama3/use-policy), which is hereby incorporated by reference\
56
+ \ into this Agreement.\nv. You will not use the Llama Materials or any output or\
57
+ \ results of the Llama Materials to improve any other large language model (excluding\
58
+ \ Meta Llama 3 or derivative works thereof).\n2. Additional Commercial Terms. If,\
59
+ \ on the Meta Llama 3 version release date, the monthly active users of the products\
60
+ \ or services made available by or for Licensee, or Licensee’s affiliates, is greater\
61
+ \ than 700 million monthly active users in the preceding calendar month, you must\
62
+ \ request a license from Meta, which Meta may grant to you in its sole discretion,\
63
+ \ and you are not authorized to exercise any of the rights under this Agreement\
64
+ \ unless or until Meta otherwise expressly grants you such rights.\n3. Disclaimer\
65
+ \ of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE LLAMA MATERIALS AND ANY OUTPUT\
66
+ \ AND RESULTS THEREFROM ARE PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OF\
67
+ \ ANY KIND, AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED,\
68
+ \ INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY,\
69
+ \ OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING\
70
+ \ THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLAMA MATERIALS AND ASSUME\
71
+ \ ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND RESULTS.\n\
72
+ 4. Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE UNDER\
73
+ \ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY,\
74
+ \ OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY INDIRECT,\
75
+ \ SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF META\
76
+ \ OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.\n\
77
+ 5. Intellectual Property.\na. No trademark licenses are granted under this Agreement,\
78
+ \ and in connection with the Llama Materials, neither Meta nor Licensee may use\
79
+ \ any name or mark owned by or associated with the other or any of its affiliates,\
80
+ \ except as required for reasonable and customary use in describing and redistributing\
81
+ \ the Llama Materials or as set forth in this Section 5(a). Meta hereby grants you\
82
+ \ a license to use “Llama 3” (the “Mark”) solely as required to comply with the\
83
+ \ last sentence of Section 1.b.i. You will comply with Meta’s brand guidelines (currently\
84
+ \ accessible at https://about.meta.com/brand/resources/meta/company-brand/ ). All\
85
+ \ goodwill arising out of your use of the Mark will inure to the benefit of Meta.\n\
86
+ b. Subject to Meta’s ownership of Llama Materials and derivatives made by or for\
87
+ \ Meta, with respect to any derivative works and modifications of the Llama Materials\
88
+ \ that are made by you, as between you and Meta, you are and will be the owner of\
89
+ \ such derivative works and modifications.\nc. If you institute litigation or other\
90
+ \ proceedings against Meta or any entity (including a cross-claim or counterclaim\
91
+ \ in a lawsuit) alleging that the Llama Materials or Meta Llama 3 outputs or results,\
92
+ \ or any portion of any of the foregoing, constitutes infringement of intellectual\
93
+ \ property or other rights owned or licensable by you, then any licenses granted\
94
+ \ to you under this Agreement shall terminate as of the date such litigation or\
95
+ \ claim is filed or instituted. You will indemnify and hold harmless Meta from and\
96
+ \ against any claim by any third party arising out of or related to your use or\
97
+ \ distribution of the Llama Materials.\n6. Term and Termination. The term of this\
98
+ \ Agreement will commence upon your acceptance of this Agreement or access to the\
99
+ \ Llama Materials and will continue in full force and effect until terminated in\
100
+ \ accordance with the terms and conditions herein. Meta may terminate this Agreement\
101
+ \ if you are in breach of any term or condition of this Agreement. Upon termination\
102
+ \ of this Agreement, you shall delete and cease use of the Llama Materials. Sections\
103
+ \ 3, 4 and 7 shall survive the termination of this Agreement.\n7. Governing Law\
104
+ \ and Jurisdiction. This Agreement will be governed and construed under the laws\
105
+ \ of the State of California without regard to choice of law principles, and the\
106
+ \ UN Convention on Contracts for the International Sale of Goods does not apply\
107
+ \ to this Agreement. The courts of California shall have exclusive jurisdiction\
108
+ \ of any dispute arising out of this Agreement.\n### Meta Llama 3 Acceptable Use\
109
+ \ Policy\nMeta is committed to promoting safe and fair use of its tools and features,\
110
+ \ including Meta Llama 3. If you access or use Meta Llama 3, you agree to this Acceptable\
111
+ \ Use Policy (“Policy”). The most recent copy of this policy can be found at [https://llama.meta.com/llama3/use-policy](https://llama.meta.com/llama3/use-policy)\n\
112
+ #### Prohibited Uses\nWe want everyone to use Meta Llama 3 safely and responsibly.\
113
+ \ You agree you will not use, or allow others to use, Meta Llama 3 to: 1. Violate\
114
+ \ the law or others’ rights, including to:\n 1. Engage in, promote, generate,\
115
+ \ contribute to, encourage, plan, incite, or further illegal or unlawful activity\
116
+ \ or content, such as:\n 1. Violence or terrorism\n 2. Exploitation\
117
+ \ or harm to children, including the solicitation, creation, acquisition, or dissemination\
118
+ \ of child exploitative content or failure to report Child Sexual Abuse Material\n\
119
+ \ 3. Human trafficking, exploitation, and sexual violence\n 4. The\
120
+ \ illegal distribution of information or materials to minors, including obscene\
121
+ \ materials, or failure to employ legally required age-gating in connection with\
122
+ \ such information or materials.\n 5. Sexual solicitation\n 6. Any\
123
+ \ other criminal activity\n 2. Engage in, promote, incite, or facilitate the\
124
+ \ harassment, abuse, threatening, or bullying of individuals or groups of individuals\n\
125
+ \ 3. Engage in, promote, incite, or facilitate discrimination or other unlawful\
126
+ \ or harmful conduct in the provision of employment, employment benefits, credit,\
127
+ \ housing, other economic benefits, or other essential goods and services\n 4.\
128
+ \ Engage in the unauthorized or unlicensed practice of any profession including,\
129
+ \ but not limited to, financial, legal, medical/health, or related professional\
130
+ \ practices\n 5. Collect, process, disclose, generate, or infer health, demographic,\
131
+ \ or other sensitive personal or private information about individuals without rights\
132
+ \ and consents required by applicable laws\n 6. Engage in or facilitate any action\
133
+ \ or generate any content that infringes, misappropriates, or otherwise violates\
134
+ \ any third-party rights, including the outputs or results of any products or services\
135
+ \ using the Llama Materials\n 7. Create, generate, or facilitate the creation\
136
+ \ of malicious code, malware, computer viruses or do anything else that could disable,\
137
+ \ overburden, interfere with or impair the proper working, integrity, operation\
138
+ \ or appearance of a website or computer system\n2. Engage in, promote, incite,\
139
+ \ facilitate, or assist in the planning or development of activities that present\
140
+ \ a risk of death or bodily harm to individuals, including use of Meta Llama 3 related\
141
+ \ to the following:\n 1. Military, warfare, nuclear industries or applications,\
142
+ \ espionage, use for materials or activities that are subject to the International\
143
+ \ Traffic Arms Regulations (ITAR) maintained by the United States Department of\
144
+ \ State\n 2. Guns and illegal weapons (including weapon development)\n 3.\
145
+ \ Illegal drugs and regulated/controlled substances\n 4. Operation of critical\
146
+ \ infrastructure, transportation technologies, or heavy machinery\n 5. Self-harm\
147
+ \ or harm to others, including suicide, cutting, and eating disorders\n 6. Any\
148
+ \ content intended to incite or promote violence, abuse, or any infliction of bodily\
149
+ \ harm to an individual\n3. Intentionally deceive or mislead others, including use\
150
+ \ of Meta Llama 3 related to the following:\n 1. Generating, promoting, or furthering\
151
+ \ fraud or the creation or promotion of disinformation\n 2. Generating, promoting,\
152
+ \ or furthering defamatory content, including the creation of defamatory statements,\
153
+ \ images, or other content\n 3. Generating, promoting, or further distributing\
154
+ \ spam\n 4. Impersonating another individual without consent, authorization,\
155
+ \ or legal right\n 5. Representing that the use of Meta Llama 3 or outputs are\
156
+ \ human-generated\n 6. Generating or facilitating false online engagement, including\
157
+ \ fake reviews and other means of fake online engagement\n4. Fail to appropriately\
158
+ \ disclose to end users any known dangers of your AI system\nPlease report any violation\
159
+ \ of this Policy, software “bug,” or other problems that could lead to a violation\
160
+ \ of this Policy through one of the following means:\n * Reporting issues with\
161
+ \ the model: [https://github.com/meta-llama/llama3](https://github.com/meta-llama/llama3)\n\
162
+ \ * Reporting risky content generated by the model:\n developers.facebook.com/llama_output_feedback\n\
163
+ \ * Reporting bugs and security concerns: facebook.com/whitehat/info\n * Reporting\
164
+ \ violations of the Acceptable Use Policy or unlicensed uses of Meta Llama 3: LlamaUseReport@meta.com"
165
+ extra_gated_fields:
166
+ First Name: text
167
+ Last Name: text
168
+ Date of birth: date_picker
169
+ Country: country
170
+ Affiliation: text
171
+ geo: ip_location
172
+ ? By clicking Submit below I accept the terms of the license and acknowledge that
173
+ the information I provide will be collected stored processed and shared in accordance
174
+ with the Meta Privacy Policy
175
+ : checkbox
176
+ extra_gated_description: The information you provide will be collected, stored, processed
177
+ and shared in accordance with the [Meta Privacy Policy](https://www.facebook.com/privacy/policy/).
178
+ extra_gated_button_content: Submit
179
+ widget:
180
+ - example_title: Hello
181
+ messages:
182
+ - role: user
183
+ content: Hey my name is Julien! How are you?
184
+ - example_title: Winter holidays
185
+ messages:
186
+ - role: system
187
+ content: You are a helpful and honest assistant. Please, respond concisely and
188
+ truthfully.
189
+ - role: user
190
+ content: Can you recommend a good destination for Winter holidays?
191
+ - example_title: Programming assistant
192
+ messages:
193
+ - role: system
194
+ content: You are a helpful and honest code and programming assistant. Please,
195
+ respond concisely and truthfully.
196
+ - role: user
197
+ content: Write a function that computes the nth fibonacci number.
198
+ inference:
199
+ parameters:
200
+ max_new_tokens: 300
201
+ stop:
202
+ - <|end_of_text|>
203
+ - <|eot_id|>
204
+ ---
205
+
206
+ # batmac/Meta-Llama-3-8B-Instruct-mlx-4bit
207
+ This model was converted to MLX format from [`meta-llama/Meta-Llama-3-8B-Instruct`]() using mlx-lm version **0.12.0**.
208
+ Refer to the [original model card](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) for more details on the model.
209
+ ## Use with mlx
210
+
211
+ ```bash
212
+ pip install mlx-lm
213
+ ```
214
+
215
+ ```python
216
+ from mlx_lm import load, generate
217
+
218
+ model, tokenizer = load("batmac/Meta-Llama-3-8B-Instruct-mlx-4bit")
219
+ response = generate(model, tokenizer, prompt="hello", verbose=True)
220
+ ```
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 128000,
8
+ "eos_token_id": 128001,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 4096,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 14336,
13
+ "max_position_embeddings": 8192,
14
+ "model_type": "llama",
15
+ "num_attention_heads": 32,
16
+ "num_hidden_layers": 32,
17
+ "num_key_value_heads": 8,
18
+ "pretraining_tp": 1,
19
+ "quantization": {
20
+ "group_size": 64,
21
+ "bits": 4
22
+ },
23
+ "rms_norm_eps": 1e-05,
24
+ "rope_scaling": null,
25
+ "rope_theta": 500000.0,
26
+ "tie_word_embeddings": false,
27
+ "torch_dtype": "bfloat16",
28
+ "transformers_version": "4.40.0.dev0",
29
+ "use_cache": true,
30
+ "vocab_size": 128256
31
+ }
configuration_phi3.py ADDED
@@ -0,0 +1,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 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
+ )
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75df5b8012fefd643dc20dd351e0eb31fad80291603fd59ff5e502f2b3239075
3
+ size 4517489037
model.safetensors.index.json ADDED
@@ -0,0 +1,750 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 4517404672
4
+ },
5
+ "weight_map": {
6
+ "lm_head.biases": "model.safetensors",
7
+ "lm_head.scales": "model.safetensors",
8
+ "lm_head.weight": "model.safetensors",
9
+ "model.embed_tokens.biases": "model.safetensors",
10
+ "model.embed_tokens.scales": "model.safetensors",
11
+ "model.embed_tokens.weight": "model.safetensors",
12
+ "model.layers.0.input_layernorm.weight": "model.safetensors",
13
+ "model.layers.0.mlp.down_proj.biases": "model.safetensors",
14
+ "model.layers.0.mlp.down_proj.scales": "model.safetensors",
15
+ "model.layers.0.mlp.down_proj.weight": "model.safetensors",
16
+ "model.layers.0.mlp.gate_proj.biases": "model.safetensors",
17
+ "model.layers.0.mlp.gate_proj.scales": "model.safetensors",
18
+ "model.layers.0.mlp.gate_proj.weight": "model.safetensors",
19
+ "model.layers.0.mlp.up_proj.biases": "model.safetensors",
20
+ "model.layers.0.mlp.up_proj.scales": "model.safetensors",
21
+ "model.layers.0.mlp.up_proj.weight": "model.safetensors",
22
+ "model.layers.0.post_attention_layernorm.weight": "model.safetensors",
23
+ "model.layers.0.self_attn.k_proj.biases": "model.safetensors",
24
+ "model.layers.0.self_attn.k_proj.scales": "model.safetensors",
25
+ "model.layers.0.self_attn.k_proj.weight": "model.safetensors",
26
+ "model.layers.0.self_attn.o_proj.biases": "model.safetensors",
27
+ "model.layers.0.self_attn.o_proj.scales": "model.safetensors",
28
+ "model.layers.0.self_attn.o_proj.weight": "model.safetensors",
29
+ "model.layers.0.self_attn.q_proj.biases": "model.safetensors",
30
+ "model.layers.0.self_attn.q_proj.scales": "model.safetensors",
31
+ "model.layers.0.self_attn.q_proj.weight": "model.safetensors",
32
+ "model.layers.0.self_attn.v_proj.biases": "model.safetensors",
33
+ "model.layers.0.self_attn.v_proj.scales": "model.safetensors",
34
+ "model.layers.0.self_attn.v_proj.weight": "model.safetensors",
35
+ "model.layers.1.input_layernorm.weight": "model.safetensors",
36
+ "model.layers.1.mlp.down_proj.biases": "model.safetensors",
37
+ "model.layers.1.mlp.down_proj.scales": "model.safetensors",
38
+ "model.layers.1.mlp.down_proj.weight": "model.safetensors",
39
+ "model.layers.1.mlp.gate_proj.biases": "model.safetensors",
40
+ "model.layers.1.mlp.gate_proj.scales": "model.safetensors",
41
+ "model.layers.1.mlp.gate_proj.weight": "model.safetensors",
42
+ "model.layers.1.mlp.up_proj.biases": "model.safetensors",
43
+ "model.layers.1.mlp.up_proj.scales": "model.safetensors",
44
+ "model.layers.1.mlp.up_proj.weight": "model.safetensors",
45
+ "model.layers.1.post_attention_layernorm.weight": "model.safetensors",
46
+ "model.layers.1.self_attn.k_proj.biases": "model.safetensors",
47
+ "model.layers.1.self_attn.k_proj.scales": "model.safetensors",
48
+ "model.layers.1.self_attn.k_proj.weight": "model.safetensors",
49
+ "model.layers.1.self_attn.o_proj.biases": "model.safetensors",
50
+ "model.layers.1.self_attn.o_proj.scales": "model.safetensors",
51
+ "model.layers.1.self_attn.o_proj.weight": "model.safetensors",
52
+ "model.layers.1.self_attn.q_proj.biases": "model.safetensors",
53
+ "model.layers.1.self_attn.q_proj.scales": "model.safetensors",
54
+ "model.layers.1.self_attn.q_proj.weight": "model.safetensors",
55
+ "model.layers.1.self_attn.v_proj.biases": "model.safetensors",
56
+ "model.layers.1.self_attn.v_proj.scales": "model.safetensors",
57
+ "model.layers.1.self_attn.v_proj.weight": "model.safetensors",
58
+ "model.layers.10.input_layernorm.weight": "model.safetensors",
59
+ "model.layers.10.mlp.down_proj.biases": "model.safetensors",
60
+ "model.layers.10.mlp.down_proj.scales": "model.safetensors",
61
+ "model.layers.10.mlp.down_proj.weight": "model.safetensors",
62
+ "model.layers.10.mlp.gate_proj.biases": "model.safetensors",
63
+ "model.layers.10.mlp.gate_proj.scales": "model.safetensors",
64
+ "model.layers.10.mlp.gate_proj.weight": "model.safetensors",
65
+ "model.layers.10.mlp.up_proj.biases": "model.safetensors",
66
+ "model.layers.10.mlp.up_proj.scales": "model.safetensors",
67
+ "model.layers.10.mlp.up_proj.weight": "model.safetensors",
68
+ "model.layers.10.post_attention_layernorm.weight": "model.safetensors",
69
+ "model.layers.10.self_attn.k_proj.biases": "model.safetensors",
70
+ "model.layers.10.self_attn.k_proj.scales": "model.safetensors",
71
+ "model.layers.10.self_attn.k_proj.weight": "model.safetensors",
72
+ "model.layers.10.self_attn.o_proj.biases": "model.safetensors",
73
+ "model.layers.10.self_attn.o_proj.scales": "model.safetensors",
74
+ "model.layers.10.self_attn.o_proj.weight": "model.safetensors",
75
+ "model.layers.10.self_attn.q_proj.biases": "model.safetensors",
76
+ "model.layers.10.self_attn.q_proj.scales": "model.safetensors",
77
+ "model.layers.10.self_attn.q_proj.weight": "model.safetensors",
78
+ "model.layers.10.self_attn.v_proj.biases": "model.safetensors",
79
+ "model.layers.10.self_attn.v_proj.scales": "model.safetensors",
80
+ "model.layers.10.self_attn.v_proj.weight": "model.safetensors",
81
+ "model.layers.11.input_layernorm.weight": "model.safetensors",
82
+ "model.layers.11.mlp.down_proj.biases": "model.safetensors",
83
+ "model.layers.11.mlp.down_proj.scales": "model.safetensors",
84
+ "model.layers.11.mlp.down_proj.weight": "model.safetensors",
85
+ "model.layers.11.mlp.gate_proj.biases": "model.safetensors",
86
+ "model.layers.11.mlp.gate_proj.scales": "model.safetensors",
87
+ "model.layers.11.mlp.gate_proj.weight": "model.safetensors",
88
+ "model.layers.11.mlp.up_proj.biases": "model.safetensors",
89
+ "model.layers.11.mlp.up_proj.scales": "model.safetensors",
90
+ "model.layers.11.mlp.up_proj.weight": "model.safetensors",
91
+ "model.layers.11.post_attention_layernorm.weight": "model.safetensors",
92
+ "model.layers.11.self_attn.k_proj.biases": "model.safetensors",
93
+ "model.layers.11.self_attn.k_proj.scales": "model.safetensors",
94
+ "model.layers.11.self_attn.k_proj.weight": "model.safetensors",
95
+ "model.layers.11.self_attn.o_proj.biases": "model.safetensors",
96
+ "model.layers.11.self_attn.o_proj.scales": "model.safetensors",
97
+ "model.layers.11.self_attn.o_proj.weight": "model.safetensors",
98
+ "model.layers.11.self_attn.q_proj.biases": "model.safetensors",
99
+ "model.layers.11.self_attn.q_proj.scales": "model.safetensors",
100
+ "model.layers.11.self_attn.q_proj.weight": "model.safetensors",
101
+ "model.layers.11.self_attn.v_proj.biases": "model.safetensors",
102
+ "model.layers.11.self_attn.v_proj.scales": "model.safetensors",
103
+ "model.layers.11.self_attn.v_proj.weight": "model.safetensors",
104
+ "model.layers.12.input_layernorm.weight": "model.safetensors",
105
+ "model.layers.12.mlp.down_proj.biases": "model.safetensors",
106
+ "model.layers.12.mlp.down_proj.scales": "model.safetensors",
107
+ "model.layers.12.mlp.down_proj.weight": "model.safetensors",
108
+ "model.layers.12.mlp.gate_proj.biases": "model.safetensors",
109
+ "model.layers.12.mlp.gate_proj.scales": "model.safetensors",
110
+ "model.layers.12.mlp.gate_proj.weight": "model.safetensors",
111
+ "model.layers.12.mlp.up_proj.biases": "model.safetensors",
112
+ "model.layers.12.mlp.up_proj.scales": "model.safetensors",
113
+ "model.layers.12.mlp.up_proj.weight": "model.safetensors",
114
+ "model.layers.12.post_attention_layernorm.weight": "model.safetensors",
115
+ "model.layers.12.self_attn.k_proj.biases": "model.safetensors",
116
+ "model.layers.12.self_attn.k_proj.scales": "model.safetensors",
117
+ "model.layers.12.self_attn.k_proj.weight": "model.safetensors",
118
+ "model.layers.12.self_attn.o_proj.biases": "model.safetensors",
119
+ "model.layers.12.self_attn.o_proj.scales": "model.safetensors",
120
+ "model.layers.12.self_attn.o_proj.weight": "model.safetensors",
121
+ "model.layers.12.self_attn.q_proj.biases": "model.safetensors",
122
+ "model.layers.12.self_attn.q_proj.scales": "model.safetensors",
123
+ "model.layers.12.self_attn.q_proj.weight": "model.safetensors",
124
+ "model.layers.12.self_attn.v_proj.biases": "model.safetensors",
125
+ "model.layers.12.self_attn.v_proj.scales": "model.safetensors",
126
+ "model.layers.12.self_attn.v_proj.weight": "model.safetensors",
127
+ "model.layers.13.input_layernorm.weight": "model.safetensors",
128
+ "model.layers.13.mlp.down_proj.biases": "model.safetensors",
129
+ "model.layers.13.mlp.down_proj.scales": "model.safetensors",
130
+ "model.layers.13.mlp.down_proj.weight": "model.safetensors",
131
+ "model.layers.13.mlp.gate_proj.biases": "model.safetensors",
132
+ "model.layers.13.mlp.gate_proj.scales": "model.safetensors",
133
+ "model.layers.13.mlp.gate_proj.weight": "model.safetensors",
134
+ "model.layers.13.mlp.up_proj.biases": "model.safetensors",
135
+ "model.layers.13.mlp.up_proj.scales": "model.safetensors",
136
+ "model.layers.13.mlp.up_proj.weight": "model.safetensors",
137
+ "model.layers.13.post_attention_layernorm.weight": "model.safetensors",
138
+ "model.layers.13.self_attn.k_proj.biases": "model.safetensors",
139
+ "model.layers.13.self_attn.k_proj.scales": "model.safetensors",
140
+ "model.layers.13.self_attn.k_proj.weight": "model.safetensors",
141
+ "model.layers.13.self_attn.o_proj.biases": "model.safetensors",
142
+ "model.layers.13.self_attn.o_proj.scales": "model.safetensors",
143
+ "model.layers.13.self_attn.o_proj.weight": "model.safetensors",
144
+ "model.layers.13.self_attn.q_proj.biases": "model.safetensors",
145
+ "model.layers.13.self_attn.q_proj.scales": "model.safetensors",
146
+ "model.layers.13.self_attn.q_proj.weight": "model.safetensors",
147
+ "model.layers.13.self_attn.v_proj.biases": "model.safetensors",
148
+ "model.layers.13.self_attn.v_proj.scales": "model.safetensors",
149
+ "model.layers.13.self_attn.v_proj.weight": "model.safetensors",
150
+ "model.layers.14.input_layernorm.weight": "model.safetensors",
151
+ "model.layers.14.mlp.down_proj.biases": "model.safetensors",
152
+ "model.layers.14.mlp.down_proj.scales": "model.safetensors",
153
+ "model.layers.14.mlp.down_proj.weight": "model.safetensors",
154
+ "model.layers.14.mlp.gate_proj.biases": "model.safetensors",
155
+ "model.layers.14.mlp.gate_proj.scales": "model.safetensors",
156
+ "model.layers.14.mlp.gate_proj.weight": "model.safetensors",
157
+ "model.layers.14.mlp.up_proj.biases": "model.safetensors",
158
+ "model.layers.14.mlp.up_proj.scales": "model.safetensors",
159
+ "model.layers.14.mlp.up_proj.weight": "model.safetensors",
160
+ "model.layers.14.post_attention_layernorm.weight": "model.safetensors",
161
+ "model.layers.14.self_attn.k_proj.biases": "model.safetensors",
162
+ "model.layers.14.self_attn.k_proj.scales": "model.safetensors",
163
+ "model.layers.14.self_attn.k_proj.weight": "model.safetensors",
164
+ "model.layers.14.self_attn.o_proj.biases": "model.safetensors",
165
+ "model.layers.14.self_attn.o_proj.scales": "model.safetensors",
166
+ "model.layers.14.self_attn.o_proj.weight": "model.safetensors",
167
+ "model.layers.14.self_attn.q_proj.biases": "model.safetensors",
168
+ "model.layers.14.self_attn.q_proj.scales": "model.safetensors",
169
+ "model.layers.14.self_attn.q_proj.weight": "model.safetensors",
170
+ "model.layers.14.self_attn.v_proj.biases": "model.safetensors",
171
+ "model.layers.14.self_attn.v_proj.scales": "model.safetensors",
172
+ "model.layers.14.self_attn.v_proj.weight": "model.safetensors",
173
+ "model.layers.15.input_layernorm.weight": "model.safetensors",
174
+ "model.layers.15.mlp.down_proj.biases": "model.safetensors",
175
+ "model.layers.15.mlp.down_proj.scales": "model.safetensors",
176
+ "model.layers.15.mlp.down_proj.weight": "model.safetensors",
177
+ "model.layers.15.mlp.gate_proj.biases": "model.safetensors",
178
+ "model.layers.15.mlp.gate_proj.scales": "model.safetensors",
179
+ "model.layers.15.mlp.gate_proj.weight": "model.safetensors",
180
+ "model.layers.15.mlp.up_proj.biases": "model.safetensors",
181
+ "model.layers.15.mlp.up_proj.scales": "model.safetensors",
182
+ "model.layers.15.mlp.up_proj.weight": "model.safetensors",
183
+ "model.layers.15.post_attention_layernorm.weight": "model.safetensors",
184
+ "model.layers.15.self_attn.k_proj.biases": "model.safetensors",
185
+ "model.layers.15.self_attn.k_proj.scales": "model.safetensors",
186
+ "model.layers.15.self_attn.k_proj.weight": "model.safetensors",
187
+ "model.layers.15.self_attn.o_proj.biases": "model.safetensors",
188
+ "model.layers.15.self_attn.o_proj.scales": "model.safetensors",
189
+ "model.layers.15.self_attn.o_proj.weight": "model.safetensors",
190
+ "model.layers.15.self_attn.q_proj.biases": "model.safetensors",
191
+ "model.layers.15.self_attn.q_proj.scales": "model.safetensors",
192
+ "model.layers.15.self_attn.q_proj.weight": "model.safetensors",
193
+ "model.layers.15.self_attn.v_proj.biases": "model.safetensors",
194
+ "model.layers.15.self_attn.v_proj.scales": "model.safetensors",
195
+ "model.layers.15.self_attn.v_proj.weight": "model.safetensors",
196
+ "model.layers.16.input_layernorm.weight": "model.safetensors",
197
+ "model.layers.16.mlp.down_proj.biases": "model.safetensors",
198
+ "model.layers.16.mlp.down_proj.scales": "model.safetensors",
199
+ "model.layers.16.mlp.down_proj.weight": "model.safetensors",
200
+ "model.layers.16.mlp.gate_proj.biases": "model.safetensors",
201
+ "model.layers.16.mlp.gate_proj.scales": "model.safetensors",
202
+ "model.layers.16.mlp.gate_proj.weight": "model.safetensors",
203
+ "model.layers.16.mlp.up_proj.biases": "model.safetensors",
204
+ "model.layers.16.mlp.up_proj.scales": "model.safetensors",
205
+ "model.layers.16.mlp.up_proj.weight": "model.safetensors",
206
+ "model.layers.16.post_attention_layernorm.weight": "model.safetensors",
207
+ "model.layers.16.self_attn.k_proj.biases": "model.safetensors",
208
+ "model.layers.16.self_attn.k_proj.scales": "model.safetensors",
209
+ "model.layers.16.self_attn.k_proj.weight": "model.safetensors",
210
+ "model.layers.16.self_attn.o_proj.biases": "model.safetensors",
211
+ "model.layers.16.self_attn.o_proj.scales": "model.safetensors",
212
+ "model.layers.16.self_attn.o_proj.weight": "model.safetensors",
213
+ "model.layers.16.self_attn.q_proj.biases": "model.safetensors",
214
+ "model.layers.16.self_attn.q_proj.scales": "model.safetensors",
215
+ "model.layers.16.self_attn.q_proj.weight": "model.safetensors",
216
+ "model.layers.16.self_attn.v_proj.biases": "model.safetensors",
217
+ "model.layers.16.self_attn.v_proj.scales": "model.safetensors",
218
+ "model.layers.16.self_attn.v_proj.weight": "model.safetensors",
219
+ "model.layers.17.input_layernorm.weight": "model.safetensors",
220
+ "model.layers.17.mlp.down_proj.biases": "model.safetensors",
221
+ "model.layers.17.mlp.down_proj.scales": "model.safetensors",
222
+ "model.layers.17.mlp.down_proj.weight": "model.safetensors",
223
+ "model.layers.17.mlp.gate_proj.biases": "model.safetensors",
224
+ "model.layers.17.mlp.gate_proj.scales": "model.safetensors",
225
+ "model.layers.17.mlp.gate_proj.weight": "model.safetensors",
226
+ "model.layers.17.mlp.up_proj.biases": "model.safetensors",
227
+ "model.layers.17.mlp.up_proj.scales": "model.safetensors",
228
+ "model.layers.17.mlp.up_proj.weight": "model.safetensors",
229
+ "model.layers.17.post_attention_layernorm.weight": "model.safetensors",
230
+ "model.layers.17.self_attn.k_proj.biases": "model.safetensors",
231
+ "model.layers.17.self_attn.k_proj.scales": "model.safetensors",
232
+ "model.layers.17.self_attn.k_proj.weight": "model.safetensors",
233
+ "model.layers.17.self_attn.o_proj.biases": "model.safetensors",
234
+ "model.layers.17.self_attn.o_proj.scales": "model.safetensors",
235
+ "model.layers.17.self_attn.o_proj.weight": "model.safetensors",
236
+ "model.layers.17.self_attn.q_proj.biases": "model.safetensors",
237
+ "model.layers.17.self_attn.q_proj.scales": "model.safetensors",
238
+ "model.layers.17.self_attn.q_proj.weight": "model.safetensors",
239
+ "model.layers.17.self_attn.v_proj.biases": "model.safetensors",
240
+ "model.layers.17.self_attn.v_proj.scales": "model.safetensors",
241
+ "model.layers.17.self_attn.v_proj.weight": "model.safetensors",
242
+ "model.layers.18.input_layernorm.weight": "model.safetensors",
243
+ "model.layers.18.mlp.down_proj.biases": "model.safetensors",
244
+ "model.layers.18.mlp.down_proj.scales": "model.safetensors",
245
+ "model.layers.18.mlp.down_proj.weight": "model.safetensors",
246
+ "model.layers.18.mlp.gate_proj.biases": "model.safetensors",
247
+ "model.layers.18.mlp.gate_proj.scales": "model.safetensors",
248
+ "model.layers.18.mlp.gate_proj.weight": "model.safetensors",
249
+ "model.layers.18.mlp.up_proj.biases": "model.safetensors",
250
+ "model.layers.18.mlp.up_proj.scales": "model.safetensors",
251
+ "model.layers.18.mlp.up_proj.weight": "model.safetensors",
252
+ "model.layers.18.post_attention_layernorm.weight": "model.safetensors",
253
+ "model.layers.18.self_attn.k_proj.biases": "model.safetensors",
254
+ "model.layers.18.self_attn.k_proj.scales": "model.safetensors",
255
+ "model.layers.18.self_attn.k_proj.weight": "model.safetensors",
256
+ "model.layers.18.self_attn.o_proj.biases": "model.safetensors",
257
+ "model.layers.18.self_attn.o_proj.scales": "model.safetensors",
258
+ "model.layers.18.self_attn.o_proj.weight": "model.safetensors",
259
+ "model.layers.18.self_attn.q_proj.biases": "model.safetensors",
260
+ "model.layers.18.self_attn.q_proj.scales": "model.safetensors",
261
+ "model.layers.18.self_attn.q_proj.weight": "model.safetensors",
262
+ "model.layers.18.self_attn.v_proj.biases": "model.safetensors",
263
+ "model.layers.18.self_attn.v_proj.scales": "model.safetensors",
264
+ "model.layers.18.self_attn.v_proj.weight": "model.safetensors",
265
+ "model.layers.19.input_layernorm.weight": "model.safetensors",
266
+ "model.layers.19.mlp.down_proj.biases": "model.safetensors",
267
+ "model.layers.19.mlp.down_proj.scales": "model.safetensors",
268
+ "model.layers.19.mlp.down_proj.weight": "model.safetensors",
269
+ "model.layers.19.mlp.gate_proj.biases": "model.safetensors",
270
+ "model.layers.19.mlp.gate_proj.scales": "model.safetensors",
271
+ "model.layers.19.mlp.gate_proj.weight": "model.safetensors",
272
+ "model.layers.19.mlp.up_proj.biases": "model.safetensors",
273
+ "model.layers.19.mlp.up_proj.scales": "model.safetensors",
274
+ "model.layers.19.mlp.up_proj.weight": "model.safetensors",
275
+ "model.layers.19.post_attention_layernorm.weight": "model.safetensors",
276
+ "model.layers.19.self_attn.k_proj.biases": "model.safetensors",
277
+ "model.layers.19.self_attn.k_proj.scales": "model.safetensors",
278
+ "model.layers.19.self_attn.k_proj.weight": "model.safetensors",
279
+ "model.layers.19.self_attn.o_proj.biases": "model.safetensors",
280
+ "model.layers.19.self_attn.o_proj.scales": "model.safetensors",
281
+ "model.layers.19.self_attn.o_proj.weight": "model.safetensors",
282
+ "model.layers.19.self_attn.q_proj.biases": "model.safetensors",
283
+ "model.layers.19.self_attn.q_proj.scales": "model.safetensors",
284
+ "model.layers.19.self_attn.q_proj.weight": "model.safetensors",
285
+ "model.layers.19.self_attn.v_proj.biases": "model.safetensors",
286
+ "model.layers.19.self_attn.v_proj.scales": "model.safetensors",
287
+ "model.layers.19.self_attn.v_proj.weight": "model.safetensors",
288
+ "model.layers.2.input_layernorm.weight": "model.safetensors",
289
+ "model.layers.2.mlp.down_proj.biases": "model.safetensors",
290
+ "model.layers.2.mlp.down_proj.scales": "model.safetensors",
291
+ "model.layers.2.mlp.down_proj.weight": "model.safetensors",
292
+ "model.layers.2.mlp.gate_proj.biases": "model.safetensors",
293
+ "model.layers.2.mlp.gate_proj.scales": "model.safetensors",
294
+ "model.layers.2.mlp.gate_proj.weight": "model.safetensors",
295
+ "model.layers.2.mlp.up_proj.biases": "model.safetensors",
296
+ "model.layers.2.mlp.up_proj.scales": "model.safetensors",
297
+ "model.layers.2.mlp.up_proj.weight": "model.safetensors",
298
+ "model.layers.2.post_attention_layernorm.weight": "model.safetensors",
299
+ "model.layers.2.self_attn.k_proj.biases": "model.safetensors",
300
+ "model.layers.2.self_attn.k_proj.scales": "model.safetensors",
301
+ "model.layers.2.self_attn.k_proj.weight": "model.safetensors",
302
+ "model.layers.2.self_attn.o_proj.biases": "model.safetensors",
303
+ "model.layers.2.self_attn.o_proj.scales": "model.safetensors",
304
+ "model.layers.2.self_attn.o_proj.weight": "model.safetensors",
305
+ "model.layers.2.self_attn.q_proj.biases": "model.safetensors",
306
+ "model.layers.2.self_attn.q_proj.scales": "model.safetensors",
307
+ "model.layers.2.self_attn.q_proj.weight": "model.safetensors",
308
+ "model.layers.2.self_attn.v_proj.biases": "model.safetensors",
309
+ "model.layers.2.self_attn.v_proj.scales": "model.safetensors",
310
+ "model.layers.2.self_attn.v_proj.weight": "model.safetensors",
311
+ "model.layers.20.input_layernorm.weight": "model.safetensors",
312
+ "model.layers.20.mlp.down_proj.biases": "model.safetensors",
313
+ "model.layers.20.mlp.down_proj.scales": "model.safetensors",
314
+ "model.layers.20.mlp.down_proj.weight": "model.safetensors",
315
+ "model.layers.20.mlp.gate_proj.biases": "model.safetensors",
316
+ "model.layers.20.mlp.gate_proj.scales": "model.safetensors",
317
+ "model.layers.20.mlp.gate_proj.weight": "model.safetensors",
318
+ "model.layers.20.mlp.up_proj.biases": "model.safetensors",
319
+ "model.layers.20.mlp.up_proj.scales": "model.safetensors",
320
+ "model.layers.20.mlp.up_proj.weight": "model.safetensors",
321
+ "model.layers.20.post_attention_layernorm.weight": "model.safetensors",
322
+ "model.layers.20.self_attn.k_proj.biases": "model.safetensors",
323
+ "model.layers.20.self_attn.k_proj.scales": "model.safetensors",
324
+ "model.layers.20.self_attn.k_proj.weight": "model.safetensors",
325
+ "model.layers.20.self_attn.o_proj.biases": "model.safetensors",
326
+ "model.layers.20.self_attn.o_proj.scales": "model.safetensors",
327
+ "model.layers.20.self_attn.o_proj.weight": "model.safetensors",
328
+ "model.layers.20.self_attn.q_proj.biases": "model.safetensors",
329
+ "model.layers.20.self_attn.q_proj.scales": "model.safetensors",
330
+ "model.layers.20.self_attn.q_proj.weight": "model.safetensors",
331
+ "model.layers.20.self_attn.v_proj.biases": "model.safetensors",
332
+ "model.layers.20.self_attn.v_proj.scales": "model.safetensors",
333
+ "model.layers.20.self_attn.v_proj.weight": "model.safetensors",
334
+ "model.layers.21.input_layernorm.weight": "model.safetensors",
335
+ "model.layers.21.mlp.down_proj.biases": "model.safetensors",
336
+ "model.layers.21.mlp.down_proj.scales": "model.safetensors",
337
+ "model.layers.21.mlp.down_proj.weight": "model.safetensors",
338
+ "model.layers.21.mlp.gate_proj.biases": "model.safetensors",
339
+ "model.layers.21.mlp.gate_proj.scales": "model.safetensors",
340
+ "model.layers.21.mlp.gate_proj.weight": "model.safetensors",
341
+ "model.layers.21.mlp.up_proj.biases": "model.safetensors",
342
+ "model.layers.21.mlp.up_proj.scales": "model.safetensors",
343
+ "model.layers.21.mlp.up_proj.weight": "model.safetensors",
344
+ "model.layers.21.post_attention_layernorm.weight": "model.safetensors",
345
+ "model.layers.21.self_attn.k_proj.biases": "model.safetensors",
346
+ "model.layers.21.self_attn.k_proj.scales": "model.safetensors",
347
+ "model.layers.21.self_attn.k_proj.weight": "model.safetensors",
348
+ "model.layers.21.self_attn.o_proj.biases": "model.safetensors",
349
+ "model.layers.21.self_attn.o_proj.scales": "model.safetensors",
350
+ "model.layers.21.self_attn.o_proj.weight": "model.safetensors",
351
+ "model.layers.21.self_attn.q_proj.biases": "model.safetensors",
352
+ "model.layers.21.self_attn.q_proj.scales": "model.safetensors",
353
+ "model.layers.21.self_attn.q_proj.weight": "model.safetensors",
354
+ "model.layers.21.self_attn.v_proj.biases": "model.safetensors",
355
+ "model.layers.21.self_attn.v_proj.scales": "model.safetensors",
356
+ "model.layers.21.self_attn.v_proj.weight": "model.safetensors",
357
+ "model.layers.22.input_layernorm.weight": "model.safetensors",
358
+ "model.layers.22.mlp.down_proj.biases": "model.safetensors",
359
+ "model.layers.22.mlp.down_proj.scales": "model.safetensors",
360
+ "model.layers.22.mlp.down_proj.weight": "model.safetensors",
361
+ "model.layers.22.mlp.gate_proj.biases": "model.safetensors",
362
+ "model.layers.22.mlp.gate_proj.scales": "model.safetensors",
363
+ "model.layers.22.mlp.gate_proj.weight": "model.safetensors",
364
+ "model.layers.22.mlp.up_proj.biases": "model.safetensors",
365
+ "model.layers.22.mlp.up_proj.scales": "model.safetensors",
366
+ "model.layers.22.mlp.up_proj.weight": "model.safetensors",
367
+ "model.layers.22.post_attention_layernorm.weight": "model.safetensors",
368
+ "model.layers.22.self_attn.k_proj.biases": "model.safetensors",
369
+ "model.layers.22.self_attn.k_proj.scales": "model.safetensors",
370
+ "model.layers.22.self_attn.k_proj.weight": "model.safetensors",
371
+ "model.layers.22.self_attn.o_proj.biases": "model.safetensors",
372
+ "model.layers.22.self_attn.o_proj.scales": "model.safetensors",
373
+ "model.layers.22.self_attn.o_proj.weight": "model.safetensors",
374
+ "model.layers.22.self_attn.q_proj.biases": "model.safetensors",
375
+ "model.layers.22.self_attn.q_proj.scales": "model.safetensors",
376
+ "model.layers.22.self_attn.q_proj.weight": "model.safetensors",
377
+ "model.layers.22.self_attn.v_proj.biases": "model.safetensors",
378
+ "model.layers.22.self_attn.v_proj.scales": "model.safetensors",
379
+ "model.layers.22.self_attn.v_proj.weight": "model.safetensors",
380
+ "model.layers.23.input_layernorm.weight": "model.safetensors",
381
+ "model.layers.23.mlp.down_proj.biases": "model.safetensors",
382
+ "model.layers.23.mlp.down_proj.scales": "model.safetensors",
383
+ "model.layers.23.mlp.down_proj.weight": "model.safetensors",
384
+ "model.layers.23.mlp.gate_proj.biases": "model.safetensors",
385
+ "model.layers.23.mlp.gate_proj.scales": "model.safetensors",
386
+ "model.layers.23.mlp.gate_proj.weight": "model.safetensors",
387
+ "model.layers.23.mlp.up_proj.biases": "model.safetensors",
388
+ "model.layers.23.mlp.up_proj.scales": "model.safetensors",
389
+ "model.layers.23.mlp.up_proj.weight": "model.safetensors",
390
+ "model.layers.23.post_attention_layernorm.weight": "model.safetensors",
391
+ "model.layers.23.self_attn.k_proj.biases": "model.safetensors",
392
+ "model.layers.23.self_attn.k_proj.scales": "model.safetensors",
393
+ "model.layers.23.self_attn.k_proj.weight": "model.safetensors",
394
+ "model.layers.23.self_attn.o_proj.biases": "model.safetensors",
395
+ "model.layers.23.self_attn.o_proj.scales": "model.safetensors",
396
+ "model.layers.23.self_attn.o_proj.weight": "model.safetensors",
397
+ "model.layers.23.self_attn.q_proj.biases": "model.safetensors",
398
+ "model.layers.23.self_attn.q_proj.scales": "model.safetensors",
399
+ "model.layers.23.self_attn.q_proj.weight": "model.safetensors",
400
+ "model.layers.23.self_attn.v_proj.biases": "model.safetensors",
401
+ "model.layers.23.self_attn.v_proj.scales": "model.safetensors",
402
+ "model.layers.23.self_attn.v_proj.weight": "model.safetensors",
403
+ "model.layers.24.input_layernorm.weight": "model.safetensors",
404
+ "model.layers.24.mlp.down_proj.biases": "model.safetensors",
405
+ "model.layers.24.mlp.down_proj.scales": "model.safetensors",
406
+ "model.layers.24.mlp.down_proj.weight": "model.safetensors",
407
+ "model.layers.24.mlp.gate_proj.biases": "model.safetensors",
408
+ "model.layers.24.mlp.gate_proj.scales": "model.safetensors",
409
+ "model.layers.24.mlp.gate_proj.weight": "model.safetensors",
410
+ "model.layers.24.mlp.up_proj.biases": "model.safetensors",
411
+ "model.layers.24.mlp.up_proj.scales": "model.safetensors",
412
+ "model.layers.24.mlp.up_proj.weight": "model.safetensors",
413
+ "model.layers.24.post_attention_layernorm.weight": "model.safetensors",
414
+ "model.layers.24.self_attn.k_proj.biases": "model.safetensors",
415
+ "model.layers.24.self_attn.k_proj.scales": "model.safetensors",
416
+ "model.layers.24.self_attn.k_proj.weight": "model.safetensors",
417
+ "model.layers.24.self_attn.o_proj.biases": "model.safetensors",
418
+ "model.layers.24.self_attn.o_proj.scales": "model.safetensors",
419
+ "model.layers.24.self_attn.o_proj.weight": "model.safetensors",
420
+ "model.layers.24.self_attn.q_proj.biases": "model.safetensors",
421
+ "model.layers.24.self_attn.q_proj.scales": "model.safetensors",
422
+ "model.layers.24.self_attn.q_proj.weight": "model.safetensors",
423
+ "model.layers.24.self_attn.v_proj.biases": "model.safetensors",
424
+ "model.layers.24.self_attn.v_proj.scales": "model.safetensors",
425
+ "model.layers.24.self_attn.v_proj.weight": "model.safetensors",
426
+ "model.layers.25.input_layernorm.weight": "model.safetensors",
427
+ "model.layers.25.mlp.down_proj.biases": "model.safetensors",
428
+ "model.layers.25.mlp.down_proj.scales": "model.safetensors",
429
+ "model.layers.25.mlp.down_proj.weight": "model.safetensors",
430
+ "model.layers.25.mlp.gate_proj.biases": "model.safetensors",
431
+ "model.layers.25.mlp.gate_proj.scales": "model.safetensors",
432
+ "model.layers.25.mlp.gate_proj.weight": "model.safetensors",
433
+ "model.layers.25.mlp.up_proj.biases": "model.safetensors",
434
+ "model.layers.25.mlp.up_proj.scales": "model.safetensors",
435
+ "model.layers.25.mlp.up_proj.weight": "model.safetensors",
436
+ "model.layers.25.post_attention_layernorm.weight": "model.safetensors",
437
+ "model.layers.25.self_attn.k_proj.biases": "model.safetensors",
438
+ "model.layers.25.self_attn.k_proj.scales": "model.safetensors",
439
+ "model.layers.25.self_attn.k_proj.weight": "model.safetensors",
440
+ "model.layers.25.self_attn.o_proj.biases": "model.safetensors",
441
+ "model.layers.25.self_attn.o_proj.scales": "model.safetensors",
442
+ "model.layers.25.self_attn.o_proj.weight": "model.safetensors",
443
+ "model.layers.25.self_attn.q_proj.biases": "model.safetensors",
444
+ "model.layers.25.self_attn.q_proj.scales": "model.safetensors",
445
+ "model.layers.25.self_attn.q_proj.weight": "model.safetensors",
446
+ "model.layers.25.self_attn.v_proj.biases": "model.safetensors",
447
+ "model.layers.25.self_attn.v_proj.scales": "model.safetensors",
448
+ "model.layers.25.self_attn.v_proj.weight": "model.safetensors",
449
+ "model.layers.26.input_layernorm.weight": "model.safetensors",
450
+ "model.layers.26.mlp.down_proj.biases": "model.safetensors",
451
+ "model.layers.26.mlp.down_proj.scales": "model.safetensors",
452
+ "model.layers.26.mlp.down_proj.weight": "model.safetensors",
453
+ "model.layers.26.mlp.gate_proj.biases": "model.safetensors",
454
+ "model.layers.26.mlp.gate_proj.scales": "model.safetensors",
455
+ "model.layers.26.mlp.gate_proj.weight": "model.safetensors",
456
+ "model.layers.26.mlp.up_proj.biases": "model.safetensors",
457
+ "model.layers.26.mlp.up_proj.scales": "model.safetensors",
458
+ "model.layers.26.mlp.up_proj.weight": "model.safetensors",
459
+ "model.layers.26.post_attention_layernorm.weight": "model.safetensors",
460
+ "model.layers.26.self_attn.k_proj.biases": "model.safetensors",
461
+ "model.layers.26.self_attn.k_proj.scales": "model.safetensors",
462
+ "model.layers.26.self_attn.k_proj.weight": "model.safetensors",
463
+ "model.layers.26.self_attn.o_proj.biases": "model.safetensors",
464
+ "model.layers.26.self_attn.o_proj.scales": "model.safetensors",
465
+ "model.layers.26.self_attn.o_proj.weight": "model.safetensors",
466
+ "model.layers.26.self_attn.q_proj.biases": "model.safetensors",
467
+ "model.layers.26.self_attn.q_proj.scales": "model.safetensors",
468
+ "model.layers.26.self_attn.q_proj.weight": "model.safetensors",
469
+ "model.layers.26.self_attn.v_proj.biases": "model.safetensors",
470
+ "model.layers.26.self_attn.v_proj.scales": "model.safetensors",
471
+ "model.layers.26.self_attn.v_proj.weight": "model.safetensors",
472
+ "model.layers.27.input_layernorm.weight": "model.safetensors",
473
+ "model.layers.27.mlp.down_proj.biases": "model.safetensors",
474
+ "model.layers.27.mlp.down_proj.scales": "model.safetensors",
475
+ "model.layers.27.mlp.down_proj.weight": "model.safetensors",
476
+ "model.layers.27.mlp.gate_proj.biases": "model.safetensors",
477
+ "model.layers.27.mlp.gate_proj.scales": "model.safetensors",
478
+ "model.layers.27.mlp.gate_proj.weight": "model.safetensors",
479
+ "model.layers.27.mlp.up_proj.biases": "model.safetensors",
480
+ "model.layers.27.mlp.up_proj.scales": "model.safetensors",
481
+ "model.layers.27.mlp.up_proj.weight": "model.safetensors",
482
+ "model.layers.27.post_attention_layernorm.weight": "model.safetensors",
483
+ "model.layers.27.self_attn.k_proj.biases": "model.safetensors",
484
+ "model.layers.27.self_attn.k_proj.scales": "model.safetensors",
485
+ "model.layers.27.self_attn.k_proj.weight": "model.safetensors",
486
+ "model.layers.27.self_attn.o_proj.biases": "model.safetensors",
487
+ "model.layers.27.self_attn.o_proj.scales": "model.safetensors",
488
+ "model.layers.27.self_attn.o_proj.weight": "model.safetensors",
489
+ "model.layers.27.self_attn.q_proj.biases": "model.safetensors",
490
+ "model.layers.27.self_attn.q_proj.scales": "model.safetensors",
491
+ "model.layers.27.self_attn.q_proj.weight": "model.safetensors",
492
+ "model.layers.27.self_attn.v_proj.biases": "model.safetensors",
493
+ "model.layers.27.self_attn.v_proj.scales": "model.safetensors",
494
+ "model.layers.27.self_attn.v_proj.weight": "model.safetensors",
495
+ "model.layers.28.input_layernorm.weight": "model.safetensors",
496
+ "model.layers.28.mlp.down_proj.biases": "model.safetensors",
497
+ "model.layers.28.mlp.down_proj.scales": "model.safetensors",
498
+ "model.layers.28.mlp.down_proj.weight": "model.safetensors",
499
+ "model.layers.28.mlp.gate_proj.biases": "model.safetensors",
500
+ "model.layers.28.mlp.gate_proj.scales": "model.safetensors",
501
+ "model.layers.28.mlp.gate_proj.weight": "model.safetensors",
502
+ "model.layers.28.mlp.up_proj.biases": "model.safetensors",
503
+ "model.layers.28.mlp.up_proj.scales": "model.safetensors",
504
+ "model.layers.28.mlp.up_proj.weight": "model.safetensors",
505
+ "model.layers.28.post_attention_layernorm.weight": "model.safetensors",
506
+ "model.layers.28.self_attn.k_proj.biases": "model.safetensors",
507
+ "model.layers.28.self_attn.k_proj.scales": "model.safetensors",
508
+ "model.layers.28.self_attn.k_proj.weight": "model.safetensors",
509
+ "model.layers.28.self_attn.o_proj.biases": "model.safetensors",
510
+ "model.layers.28.self_attn.o_proj.scales": "model.safetensors",
511
+ "model.layers.28.self_attn.o_proj.weight": "model.safetensors",
512
+ "model.layers.28.self_attn.q_proj.biases": "model.safetensors",
513
+ "model.layers.28.self_attn.q_proj.scales": "model.safetensors",
514
+ "model.layers.28.self_attn.q_proj.weight": "model.safetensors",
515
+ "model.layers.28.self_attn.v_proj.biases": "model.safetensors",
516
+ "model.layers.28.self_attn.v_proj.scales": "model.safetensors",
517
+ "model.layers.28.self_attn.v_proj.weight": "model.safetensors",
518
+ "model.layers.29.input_layernorm.weight": "model.safetensors",
519
+ "model.layers.29.mlp.down_proj.biases": "model.safetensors",
520
+ "model.layers.29.mlp.down_proj.scales": "model.safetensors",
521
+ "model.layers.29.mlp.down_proj.weight": "model.safetensors",
522
+ "model.layers.29.mlp.gate_proj.biases": "model.safetensors",
523
+ "model.layers.29.mlp.gate_proj.scales": "model.safetensors",
524
+ "model.layers.29.mlp.gate_proj.weight": "model.safetensors",
525
+ "model.layers.29.mlp.up_proj.biases": "model.safetensors",
526
+ "model.layers.29.mlp.up_proj.scales": "model.safetensors",
527
+ "model.layers.29.mlp.up_proj.weight": "model.safetensors",
528
+ "model.layers.29.post_attention_layernorm.weight": "model.safetensors",
529
+ "model.layers.29.self_attn.k_proj.biases": "model.safetensors",
530
+ "model.layers.29.self_attn.k_proj.scales": "model.safetensors",
531
+ "model.layers.29.self_attn.k_proj.weight": "model.safetensors",
532
+ "model.layers.29.self_attn.o_proj.biases": "model.safetensors",
533
+ "model.layers.29.self_attn.o_proj.scales": "model.safetensors",
534
+ "model.layers.29.self_attn.o_proj.weight": "model.safetensors",
535
+ "model.layers.29.self_attn.q_proj.biases": "model.safetensors",
536
+ "model.layers.29.self_attn.q_proj.scales": "model.safetensors",
537
+ "model.layers.29.self_attn.q_proj.weight": "model.safetensors",
538
+ "model.layers.29.self_attn.v_proj.biases": "model.safetensors",
539
+ "model.layers.29.self_attn.v_proj.scales": "model.safetensors",
540
+ "model.layers.29.self_attn.v_proj.weight": "model.safetensors",
541
+ "model.layers.3.input_layernorm.weight": "model.safetensors",
542
+ "model.layers.3.mlp.down_proj.biases": "model.safetensors",
543
+ "model.layers.3.mlp.down_proj.scales": "model.safetensors",
544
+ "model.layers.3.mlp.down_proj.weight": "model.safetensors",
545
+ "model.layers.3.mlp.gate_proj.biases": "model.safetensors",
546
+ "model.layers.3.mlp.gate_proj.scales": "model.safetensors",
547
+ "model.layers.3.mlp.gate_proj.weight": "model.safetensors",
548
+ "model.layers.3.mlp.up_proj.biases": "model.safetensors",
549
+ "model.layers.3.mlp.up_proj.scales": "model.safetensors",
550
+ "model.layers.3.mlp.up_proj.weight": "model.safetensors",
551
+ "model.layers.3.post_attention_layernorm.weight": "model.safetensors",
552
+ "model.layers.3.self_attn.k_proj.biases": "model.safetensors",
553
+ "model.layers.3.self_attn.k_proj.scales": "model.safetensors",
554
+ "model.layers.3.self_attn.k_proj.weight": "model.safetensors",
555
+ "model.layers.3.self_attn.o_proj.biases": "model.safetensors",
556
+ "model.layers.3.self_attn.o_proj.scales": "model.safetensors",
557
+ "model.layers.3.self_attn.o_proj.weight": "model.safetensors",
558
+ "model.layers.3.self_attn.q_proj.biases": "model.safetensors",
559
+ "model.layers.3.self_attn.q_proj.scales": "model.safetensors",
560
+ "model.layers.3.self_attn.q_proj.weight": "model.safetensors",
561
+ "model.layers.3.self_attn.v_proj.biases": "model.safetensors",
562
+ "model.layers.3.self_attn.v_proj.scales": "model.safetensors",
563
+ "model.layers.3.self_attn.v_proj.weight": "model.safetensors",
564
+ "model.layers.30.input_layernorm.weight": "model.safetensors",
565
+ "model.layers.30.mlp.down_proj.biases": "model.safetensors",
566
+ "model.layers.30.mlp.down_proj.scales": "model.safetensors",
567
+ "model.layers.30.mlp.down_proj.weight": "model.safetensors",
568
+ "model.layers.30.mlp.gate_proj.biases": "model.safetensors",
569
+ "model.layers.30.mlp.gate_proj.scales": "model.safetensors",
570
+ "model.layers.30.mlp.gate_proj.weight": "model.safetensors",
571
+ "model.layers.30.mlp.up_proj.biases": "model.safetensors",
572
+ "model.layers.30.mlp.up_proj.scales": "model.safetensors",
573
+ "model.layers.30.mlp.up_proj.weight": "model.safetensors",
574
+ "model.layers.30.post_attention_layernorm.weight": "model.safetensors",
575
+ "model.layers.30.self_attn.k_proj.biases": "model.safetensors",
576
+ "model.layers.30.self_attn.k_proj.scales": "model.safetensors",
577
+ "model.layers.30.self_attn.k_proj.weight": "model.safetensors",
578
+ "model.layers.30.self_attn.o_proj.biases": "model.safetensors",
579
+ "model.layers.30.self_attn.o_proj.scales": "model.safetensors",
580
+ "model.layers.30.self_attn.o_proj.weight": "model.safetensors",
581
+ "model.layers.30.self_attn.q_proj.biases": "model.safetensors",
582
+ "model.layers.30.self_attn.q_proj.scales": "model.safetensors",
583
+ "model.layers.30.self_attn.q_proj.weight": "model.safetensors",
584
+ "model.layers.30.self_attn.v_proj.biases": "model.safetensors",
585
+ "model.layers.30.self_attn.v_proj.scales": "model.safetensors",
586
+ "model.layers.30.self_attn.v_proj.weight": "model.safetensors",
587
+ "model.layers.31.input_layernorm.weight": "model.safetensors",
588
+ "model.layers.31.mlp.down_proj.biases": "model.safetensors",
589
+ "model.layers.31.mlp.down_proj.scales": "model.safetensors",
590
+ "model.layers.31.mlp.down_proj.weight": "model.safetensors",
591
+ "model.layers.31.mlp.gate_proj.biases": "model.safetensors",
592
+ "model.layers.31.mlp.gate_proj.scales": "model.safetensors",
593
+ "model.layers.31.mlp.gate_proj.weight": "model.safetensors",
594
+ "model.layers.31.mlp.up_proj.biases": "model.safetensors",
595
+ "model.layers.31.mlp.up_proj.scales": "model.safetensors",
596
+ "model.layers.31.mlp.up_proj.weight": "model.safetensors",
597
+ "model.layers.31.post_attention_layernorm.weight": "model.safetensors",
598
+ "model.layers.31.self_attn.k_proj.biases": "model.safetensors",
599
+ "model.layers.31.self_attn.k_proj.scales": "model.safetensors",
600
+ "model.layers.31.self_attn.k_proj.weight": "model.safetensors",
601
+ "model.layers.31.self_attn.o_proj.biases": "model.safetensors",
602
+ "model.layers.31.self_attn.o_proj.scales": "model.safetensors",
603
+ "model.layers.31.self_attn.o_proj.weight": "model.safetensors",
604
+ "model.layers.31.self_attn.q_proj.biases": "model.safetensors",
605
+ "model.layers.31.self_attn.q_proj.scales": "model.safetensors",
606
+ "model.layers.31.self_attn.q_proj.weight": "model.safetensors",
607
+ "model.layers.31.self_attn.v_proj.biases": "model.safetensors",
608
+ "model.layers.31.self_attn.v_proj.scales": "model.safetensors",
609
+ "model.layers.31.self_attn.v_proj.weight": "model.safetensors",
610
+ "model.layers.4.input_layernorm.weight": "model.safetensors",
611
+ "model.layers.4.mlp.down_proj.biases": "model.safetensors",
612
+ "model.layers.4.mlp.down_proj.scales": "model.safetensors",
613
+ "model.layers.4.mlp.down_proj.weight": "model.safetensors",
614
+ "model.layers.4.mlp.gate_proj.biases": "model.safetensors",
615
+ "model.layers.4.mlp.gate_proj.scales": "model.safetensors",
616
+ "model.layers.4.mlp.gate_proj.weight": "model.safetensors",
617
+ "model.layers.4.mlp.up_proj.biases": "model.safetensors",
618
+ "model.layers.4.mlp.up_proj.scales": "model.safetensors",
619
+ "model.layers.4.mlp.up_proj.weight": "model.safetensors",
620
+ "model.layers.4.post_attention_layernorm.weight": "model.safetensors",
621
+ "model.layers.4.self_attn.k_proj.biases": "model.safetensors",
622
+ "model.layers.4.self_attn.k_proj.scales": "model.safetensors",
623
+ "model.layers.4.self_attn.k_proj.weight": "model.safetensors",
624
+ "model.layers.4.self_attn.o_proj.biases": "model.safetensors",
625
+ "model.layers.4.self_attn.o_proj.scales": "model.safetensors",
626
+ "model.layers.4.self_attn.o_proj.weight": "model.safetensors",
627
+ "model.layers.4.self_attn.q_proj.biases": "model.safetensors",
628
+ "model.layers.4.self_attn.q_proj.scales": "model.safetensors",
629
+ "model.layers.4.self_attn.q_proj.weight": "model.safetensors",
630
+ "model.layers.4.self_attn.v_proj.biases": "model.safetensors",
631
+ "model.layers.4.self_attn.v_proj.scales": "model.safetensors",
632
+ "model.layers.4.self_attn.v_proj.weight": "model.safetensors",
633
+ "model.layers.5.input_layernorm.weight": "model.safetensors",
634
+ "model.layers.5.mlp.down_proj.biases": "model.safetensors",
635
+ "model.layers.5.mlp.down_proj.scales": "model.safetensors",
636
+ "model.layers.5.mlp.down_proj.weight": "model.safetensors",
637
+ "model.layers.5.mlp.gate_proj.biases": "model.safetensors",
638
+ "model.layers.5.mlp.gate_proj.scales": "model.safetensors",
639
+ "model.layers.5.mlp.gate_proj.weight": "model.safetensors",
640
+ "model.layers.5.mlp.up_proj.biases": "model.safetensors",
641
+ "model.layers.5.mlp.up_proj.scales": "model.safetensors",
642
+ "model.layers.5.mlp.up_proj.weight": "model.safetensors",
643
+ "model.layers.5.post_attention_layernorm.weight": "model.safetensors",
644
+ "model.layers.5.self_attn.k_proj.biases": "model.safetensors",
645
+ "model.layers.5.self_attn.k_proj.scales": "model.safetensors",
646
+ "model.layers.5.self_attn.k_proj.weight": "model.safetensors",
647
+ "model.layers.5.self_attn.o_proj.biases": "model.safetensors",
648
+ "model.layers.5.self_attn.o_proj.scales": "model.safetensors",
649
+ "model.layers.5.self_attn.o_proj.weight": "model.safetensors",
650
+ "model.layers.5.self_attn.q_proj.biases": "model.safetensors",
651
+ "model.layers.5.self_attn.q_proj.scales": "model.safetensors",
652
+ "model.layers.5.self_attn.q_proj.weight": "model.safetensors",
653
+ "model.layers.5.self_attn.v_proj.biases": "model.safetensors",
654
+ "model.layers.5.self_attn.v_proj.scales": "model.safetensors",
655
+ "model.layers.5.self_attn.v_proj.weight": "model.safetensors",
656
+ "model.layers.6.input_layernorm.weight": "model.safetensors",
657
+ "model.layers.6.mlp.down_proj.biases": "model.safetensors",
658
+ "model.layers.6.mlp.down_proj.scales": "model.safetensors",
659
+ "model.layers.6.mlp.down_proj.weight": "model.safetensors",
660
+ "model.layers.6.mlp.gate_proj.biases": "model.safetensors",
661
+ "model.layers.6.mlp.gate_proj.scales": "model.safetensors",
662
+ "model.layers.6.mlp.gate_proj.weight": "model.safetensors",
663
+ "model.layers.6.mlp.up_proj.biases": "model.safetensors",
664
+ "model.layers.6.mlp.up_proj.scales": "model.safetensors",
665
+ "model.layers.6.mlp.up_proj.weight": "model.safetensors",
666
+ "model.layers.6.post_attention_layernorm.weight": "model.safetensors",
667
+ "model.layers.6.self_attn.k_proj.biases": "model.safetensors",
668
+ "model.layers.6.self_attn.k_proj.scales": "model.safetensors",
669
+ "model.layers.6.self_attn.k_proj.weight": "model.safetensors",
670
+ "model.layers.6.self_attn.o_proj.biases": "model.safetensors",
671
+ "model.layers.6.self_attn.o_proj.scales": "model.safetensors",
672
+ "model.layers.6.self_attn.o_proj.weight": "model.safetensors",
673
+ "model.layers.6.self_attn.q_proj.biases": "model.safetensors",
674
+ "model.layers.6.self_attn.q_proj.scales": "model.safetensors",
675
+ "model.layers.6.self_attn.q_proj.weight": "model.safetensors",
676
+ "model.layers.6.self_attn.v_proj.biases": "model.safetensors",
677
+ "model.layers.6.self_attn.v_proj.scales": "model.safetensors",
678
+ "model.layers.6.self_attn.v_proj.weight": "model.safetensors",
679
+ "model.layers.7.input_layernorm.weight": "model.safetensors",
680
+ "model.layers.7.mlp.down_proj.biases": "model.safetensors",
681
+ "model.layers.7.mlp.down_proj.scales": "model.safetensors",
682
+ "model.layers.7.mlp.down_proj.weight": "model.safetensors",
683
+ "model.layers.7.mlp.gate_proj.biases": "model.safetensors",
684
+ "model.layers.7.mlp.gate_proj.scales": "model.safetensors",
685
+ "model.layers.7.mlp.gate_proj.weight": "model.safetensors",
686
+ "model.layers.7.mlp.up_proj.biases": "model.safetensors",
687
+ "model.layers.7.mlp.up_proj.scales": "model.safetensors",
688
+ "model.layers.7.mlp.up_proj.weight": "model.safetensors",
689
+ "model.layers.7.post_attention_layernorm.weight": "model.safetensors",
690
+ "model.layers.7.self_attn.k_proj.biases": "model.safetensors",
691
+ "model.layers.7.self_attn.k_proj.scales": "model.safetensors",
692
+ "model.layers.7.self_attn.k_proj.weight": "model.safetensors",
693
+ "model.layers.7.self_attn.o_proj.biases": "model.safetensors",
694
+ "model.layers.7.self_attn.o_proj.scales": "model.safetensors",
695
+ "model.layers.7.self_attn.o_proj.weight": "model.safetensors",
696
+ "model.layers.7.self_attn.q_proj.biases": "model.safetensors",
697
+ "model.layers.7.self_attn.q_proj.scales": "model.safetensors",
698
+ "model.layers.7.self_attn.q_proj.weight": "model.safetensors",
699
+ "model.layers.7.self_attn.v_proj.biases": "model.safetensors",
700
+ "model.layers.7.self_attn.v_proj.scales": "model.safetensors",
701
+ "model.layers.7.self_attn.v_proj.weight": "model.safetensors",
702
+ "model.layers.8.input_layernorm.weight": "model.safetensors",
703
+ "model.layers.8.mlp.down_proj.biases": "model.safetensors",
704
+ "model.layers.8.mlp.down_proj.scales": "model.safetensors",
705
+ "model.layers.8.mlp.down_proj.weight": "model.safetensors",
706
+ "model.layers.8.mlp.gate_proj.biases": "model.safetensors",
707
+ "model.layers.8.mlp.gate_proj.scales": "model.safetensors",
708
+ "model.layers.8.mlp.gate_proj.weight": "model.safetensors",
709
+ "model.layers.8.mlp.up_proj.biases": "model.safetensors",
710
+ "model.layers.8.mlp.up_proj.scales": "model.safetensors",
711
+ "model.layers.8.mlp.up_proj.weight": "model.safetensors",
712
+ "model.layers.8.post_attention_layernorm.weight": "model.safetensors",
713
+ "model.layers.8.self_attn.k_proj.biases": "model.safetensors",
714
+ "model.layers.8.self_attn.k_proj.scales": "model.safetensors",
715
+ "model.layers.8.self_attn.k_proj.weight": "model.safetensors",
716
+ "model.layers.8.self_attn.o_proj.biases": "model.safetensors",
717
+ "model.layers.8.self_attn.o_proj.scales": "model.safetensors",
718
+ "model.layers.8.self_attn.o_proj.weight": "model.safetensors",
719
+ "model.layers.8.self_attn.q_proj.biases": "model.safetensors",
720
+ "model.layers.8.self_attn.q_proj.scales": "model.safetensors",
721
+ "model.layers.8.self_attn.q_proj.weight": "model.safetensors",
722
+ "model.layers.8.self_attn.v_proj.biases": "model.safetensors",
723
+ "model.layers.8.self_attn.v_proj.scales": "model.safetensors",
724
+ "model.layers.8.self_attn.v_proj.weight": "model.safetensors",
725
+ "model.layers.9.input_layernorm.weight": "model.safetensors",
726
+ "model.layers.9.mlp.down_proj.biases": "model.safetensors",
727
+ "model.layers.9.mlp.down_proj.scales": "model.safetensors",
728
+ "model.layers.9.mlp.down_proj.weight": "model.safetensors",
729
+ "model.layers.9.mlp.gate_proj.biases": "model.safetensors",
730
+ "model.layers.9.mlp.gate_proj.scales": "model.safetensors",
731
+ "model.layers.9.mlp.gate_proj.weight": "model.safetensors",
732
+ "model.layers.9.mlp.up_proj.biases": "model.safetensors",
733
+ "model.layers.9.mlp.up_proj.scales": "model.safetensors",
734
+ "model.layers.9.mlp.up_proj.weight": "model.safetensors",
735
+ "model.layers.9.post_attention_layernorm.weight": "model.safetensors",
736
+ "model.layers.9.self_attn.k_proj.biases": "model.safetensors",
737
+ "model.layers.9.self_attn.k_proj.scales": "model.safetensors",
738
+ "model.layers.9.self_attn.k_proj.weight": "model.safetensors",
739
+ "model.layers.9.self_attn.o_proj.biases": "model.safetensors",
740
+ "model.layers.9.self_attn.o_proj.scales": "model.safetensors",
741
+ "model.layers.9.self_attn.o_proj.weight": "model.safetensors",
742
+ "model.layers.9.self_attn.q_proj.biases": "model.safetensors",
743
+ "model.layers.9.self_attn.q_proj.scales": "model.safetensors",
744
+ "model.layers.9.self_attn.q_proj.weight": "model.safetensors",
745
+ "model.layers.9.self_attn.v_proj.biases": "model.safetensors",
746
+ "model.layers.9.self_attn.v_proj.scales": "model.safetensors",
747
+ "model.layers.9.self_attn.v_proj.weight": "model.safetensors",
748
+ "model.norm.weight": "model.safetensors"
749
+ }
750
+ }
modeling_phi3.py ADDED
@@ -0,0 +1,1606 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """ PyTorch Phi-3 model."""
17
+
18
+ import inspect
19
+ import math
20
+ import warnings
21
+ from typing import List, Optional, Tuple, Union
22
+
23
+ import torch
24
+ import torch.nn.functional as F
25
+ import torch.utils.checkpoint
26
+ from torch import nn
27
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
28
+
29
+ from transformers.activations import ACT2FN
30
+ from transformers.cache_utils import Cache, DynamicCache
31
+ from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
32
+ from transformers.modeling_outputs import (
33
+ BaseModelOutputWithPast,
34
+ CausalLMOutputWithPast,
35
+ SequenceClassifierOutputWithPast,
36
+ TokenClassifierOutput,
37
+ )
38
+ from transformers.modeling_utils import PreTrainedModel
39
+ from transformers.utils import (
40
+ add_code_sample_docstrings,
41
+ add_start_docstrings,
42
+ add_start_docstrings_to_model_forward,
43
+ is_flash_attn_2_available,
44
+ is_flash_attn_greater_or_equal_2_10,
45
+ logging,
46
+ replace_return_docstrings,
47
+ )
48
+ from .configuration_phi3 import Phi3Config
49
+
50
+
51
+ logger = logging.get_logger(__name__)
52
+
53
+ # Transformers scans dependencies in the modeling file, causing issues on conditional loading. The regex only ignores try/catch blocks, but not if statements
54
+ # if is_flash_attn_2_available():
55
+ _flash_supports_window_size = False
56
+ try:
57
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
58
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
59
+
60
+ _flash_supports_window_size = "window_size" in list(inspect.signature(flash_attn_func).parameters)
61
+ except ImportError as error:
62
+ logger.warning(
63
+ f"`flash-attention` package not found, consider installing for better performance: {error}."
64
+ )
65
+ if not _flash_supports_window_size:
66
+ logger.warning(
67
+ "Current `flash-attenton` does not support `window_size`. Either upgrade or use `attn_implementation='eager'`."
68
+ )
69
+
70
+ _CHECKPOINT_FOR_DOC = "microsoft/Phi-3-mini-4k-instruct"
71
+ _CONFIG_FOR_DOC = "Phi3Config"
72
+
73
+ PHI3_PRETRAINED_MODEL_ARCHIVE_LIST = [
74
+ "microsoft/Phi-3-mini-4k-instruct",
75
+ "microsoft/Phi-3-mini-128k-instruct",
76
+ # See all Phi-3 models at https://huggingface.co/models?filter=Phi-3
77
+ ]
78
+
79
+
80
+ # Copied from transformers.models.llama.modeling_llama.LlamaRMSNorm with Llama->Phi3
81
+ class Phi3RMSNorm(nn.Module):
82
+ def __init__(self, hidden_size, eps=1e-6):
83
+ """
84
+ Phi3RMSNorm is equivalent to T5LayerNorm
85
+ """
86
+ super().__init__()
87
+ self.weight = nn.Parameter(torch.ones(hidden_size))
88
+ self.variance_epsilon = eps
89
+
90
+ def forward(self, hidden_states):
91
+ input_dtype = hidden_states.dtype
92
+ hidden_states = hidden_states.to(torch.float32)
93
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
94
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
95
+ return self.weight * hidden_states.to(input_dtype)
96
+
97
+
98
+ # Copied from transformers.models.llama.modeling_llama._get_unpad_data
99
+ def _get_unpad_data(attention_mask):
100
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
101
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
102
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
103
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.int32), (1, 0))
104
+ return (
105
+ indices,
106
+ cu_seqlens,
107
+ max_seqlen_in_batch,
108
+ )
109
+
110
+
111
+ # Copied from transformers.models.gemma.modeling_gemma.GemmaRotaryEmbedding with gemma->phi3, Gemma->Phi3
112
+ class Phi3RotaryEmbedding(nn.Module):
113
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
114
+ super().__init__()
115
+
116
+ self.dim = dim
117
+ self.max_position_embeddings = max_position_embeddings
118
+ self.base = base
119
+ self.register_buffer("inv_freq", None, persistent=False)
120
+
121
+ @torch.no_grad()
122
+ def forward(self, x, position_ids, seq_len=None):
123
+ # x: [bs, num_attention_heads, seq_len, head_size]
124
+ if self.inv_freq is None:
125
+ self.inv_freq = 1.0 / (
126
+ self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim)
127
+ )
128
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
129
+ position_ids_expanded = position_ids[:, None, :].float()
130
+ # Force float32 since bfloat16 loses precision on long contexts
131
+ # See https://github.com/huggingface/transformers/pull/29285
132
+ device_type = x.device.type
133
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
134
+ with torch.autocast(device_type=device_type, enabled=False):
135
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
136
+ emb = torch.cat((freqs, freqs), dim=-1)
137
+ cos = emb.cos()
138
+ sin = emb.sin()
139
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
140
+
141
+
142
+ class Phi3SuScaledRotaryEmbedding(Phi3RotaryEmbedding):
143
+ def __init__(self, dim, config, device=None):
144
+ super().__init__(dim, config.max_position_embeddings, config.rope_theta, device)
145
+
146
+ self.short_factor = config.rope_scaling["short_factor"]
147
+ self.long_factor = config.rope_scaling["long_factor"]
148
+ self.original_max_position_embeddings = config.original_max_position_embeddings
149
+
150
+ @torch.no_grad()
151
+ def forward(self, x, position_ids, seq_len=None):
152
+ seq_len = torch.max(position_ids) + 1
153
+ if seq_len > self.original_max_position_embeddings:
154
+ ext_factors = torch.tensor(self.long_factor, dtype=torch.float32, device=x.device)
155
+ else:
156
+ ext_factors = torch.tensor(self.short_factor, dtype=torch.float32, device=x.device)
157
+
158
+ inv_freq_shape = torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim
159
+ self.inv_freq = 1.0 / (ext_factors * self.base**inv_freq_shape)
160
+
161
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
162
+ position_ids_expanded = position_ids[:, None, :].float()
163
+
164
+ # Force float32 since bfloat16 loses precision on long contexts
165
+ # See https://github.com/huggingface/transformers/pull/29285
166
+ device_type = x.device.type
167
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
168
+ with torch.autocast(device_type=device_type, enabled=False):
169
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
170
+ emb = torch.cat((freqs, freqs), dim=-1)
171
+
172
+ scale = self.max_position_embeddings / self.original_max_position_embeddings
173
+ if scale <= 1.0:
174
+ scaling_factor = 1.0
175
+ else:
176
+ scaling_factor = math.sqrt(1 + math.log(scale) / math.log(self.original_max_position_embeddings))
177
+
178
+ cos = emb.cos() * scaling_factor
179
+ sin = emb.sin() * scaling_factor
180
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
181
+
182
+
183
+ class Phi3YarnScaledRotaryEmbedding(Phi3RotaryEmbedding):
184
+ def __init__(self, dim, config, device=None):
185
+ super().__init__(dim, config.max_position_embeddings, config.rope_theta, device)
186
+
187
+ self.short_factor = config.rope_scaling["short_factor"]
188
+ self.long_factor = config.rope_scaling["long_factor"]
189
+ self.original_max_position_embeddings = config.original_max_position_embeddings
190
+
191
+ @torch.no_grad()
192
+ def forward(self, x, position_ids, seq_len=None):
193
+ seq_len = torch.max(position_ids) + 1
194
+ if seq_len > self.original_max_position_embeddings:
195
+ ext_factors = torch.tensor(self.long_factor, dtype=torch.float32, device=x.device)
196
+ else:
197
+ ext_factors = torch.tensor(self.short_factor, dtype=torch.float32, device=x.device)
198
+
199
+ inv_freq_shape = torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim
200
+ self.inv_freq = 1.0 / (ext_factors * self.base**inv_freq_shape)
201
+
202
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
203
+ position_ids_expanded = position_ids[:, None, :].float()
204
+
205
+ # Force float32 since bfloat16 loses precision on long contexts
206
+ # See https://github.com/huggingface/transformers/pull/29285
207
+ device_type = x.device.type
208
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
209
+ with torch.autocast(device_type=device_type, enabled=False):
210
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
211
+ emb = torch.cat((freqs, freqs), dim=-1)
212
+
213
+ scale = self.max_position_embeddings / self.original_max_position_embeddings
214
+ if scale <= 1.0:
215
+ scaling_factor = 1.0
216
+ else:
217
+ scaling_factor = 0.1 * math.log(scale) + 1.0
218
+
219
+ cos = emb.cos() * scaling_factor
220
+ sin = emb.sin() * scaling_factor
221
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
222
+
223
+
224
+ # Copied from transformers.models.llama.modeling_llama.rotate_half
225
+ def rotate_half(x):
226
+ """Rotates half the hidden dims of the input."""
227
+ x1 = x[..., : x.shape[-1] // 2]
228
+ x2 = x[..., x.shape[-1] // 2 :]
229
+ return torch.cat((-x2, x1), dim=-1)
230
+
231
+
232
+ # Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
233
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
234
+ """Applies Rotary Position Embedding to the query and key tensors.
235
+
236
+ Args:
237
+ q (`torch.Tensor`): The query tensor.
238
+ k (`torch.Tensor`): The key tensor.
239
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
240
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
241
+ position_ids (`torch.Tensor`, *optional*):
242
+ Deprecated and unused.
243
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
244
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
245
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
246
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
247
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
248
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
249
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
250
+ Returns:
251
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
252
+ """
253
+ cos = cos.unsqueeze(unsqueeze_dim)
254
+ sin = sin.unsqueeze(unsqueeze_dim)
255
+ q_embed = (q * cos) + (rotate_half(q) * sin)
256
+ k_embed = (k * cos) + (rotate_half(k) * sin)
257
+ return q_embed, k_embed
258
+
259
+
260
+ class Phi3MLP(nn.Module):
261
+ def __init__(self, config):
262
+ super().__init__()
263
+
264
+ self.config = config
265
+ self.gate_up_proj = nn.Linear(config.hidden_size, 2 * config.intermediate_size, bias=False)
266
+ self.down_proj = nn.Linear(config.intermediate_size, config.hidden_size, bias=False)
267
+
268
+ self.activation_fn = ACT2FN[config.hidden_act]
269
+
270
+ def forward(self, hidden_states: torch.FloatTensor) -> torch.FloatTensor:
271
+ up_states = self.gate_up_proj(hidden_states)
272
+
273
+ gate, up_states = up_states.chunk(2, dim=-1)
274
+ up_states = up_states * self.activation_fn(gate)
275
+
276
+ return self.down_proj(up_states)
277
+
278
+
279
+ # Copied from transformers.models.llama.modeling_llama.repeat_kv with llama->phi
280
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
281
+ """
282
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
283
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
284
+ """
285
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
286
+ if n_rep == 1:
287
+ return hidden_states
288
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
289
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
290
+
291
+
292
+ class Phi3Attention(nn.Module):
293
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
294
+
295
+ def __init__(self, config: Phi3Config, layer_idx: Optional[int] = None):
296
+ super().__init__()
297
+ self.config = config
298
+ self.layer_idx = layer_idx
299
+ if layer_idx is None:
300
+ logger.warning_once(
301
+ f"Instantiating {self.__class__.__name__} without passing a `layer_idx` is not recommended and will "
302
+ "lead to errors during the forward call if caching is used. Please make sure to provide a `layer_idx` "
303
+ "when creating this class."
304
+ )
305
+
306
+ self.attention_dropout = config.attention_dropout
307
+ self.hidden_size = config.hidden_size
308
+ self.num_heads = config.num_attention_heads
309
+ self.head_dim = self.hidden_size // self.num_heads
310
+ self.num_key_value_heads = config.num_key_value_heads
311
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
312
+ self.max_position_embeddings = config.max_position_embeddings
313
+ self.original_max_position_embeddings = config.original_max_position_embeddings
314
+ self.rope_theta = config.rope_theta
315
+ self.rope_scaling = config.rope_scaling
316
+ self.is_causal = True
317
+
318
+ if (self.head_dim * self.num_heads) != self.hidden_size:
319
+ raise ValueError(
320
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
321
+ f" and `num_heads`: {self.num_heads})."
322
+ )
323
+
324
+ op_size = self.num_heads * self.head_dim + 2 * (self.num_key_value_heads * self.head_dim)
325
+ self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
326
+ self.qkv_proj = nn.Linear(self.hidden_size, op_size, bias=False)
327
+ self._init_rope()
328
+
329
+ def _init_rope(self):
330
+ if self.rope_scaling is None:
331
+ self.rotary_emb = Phi3RotaryEmbedding(
332
+ self.head_dim,
333
+ max_position_embeddings=self.max_position_embeddings,
334
+ base=self.rope_theta,
335
+ )
336
+ else:
337
+ scaling_type = self.config.rope_scaling["type"]
338
+ if scaling_type == "su":
339
+ self.rotary_emb = Phi3SuScaledRotaryEmbedding(self.head_dim, self.config)
340
+ elif scaling_type == "yarn":
341
+ self.rotary_emb = Phi3YarnScaledRotaryEmbedding(self.head_dim, self.config)
342
+ else:
343
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
344
+
345
+ def forward(
346
+ self,
347
+ hidden_states: torch.Tensor,
348
+ attention_mask: Optional[torch.Tensor] = None,
349
+ position_ids: Optional[torch.LongTensor] = None,
350
+ past_key_value: Optional[Cache] = None,
351
+ output_attentions: bool = False,
352
+ use_cache: bool = False,
353
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
354
+ logger.warning_once("You are not running the flash-attention implementation, expect numerical differences.")
355
+
356
+ bsz, q_len, _ = hidden_states.size()
357
+
358
+ qkv = self.qkv_proj(hidden_states)
359
+ query_pos = self.num_heads * self.head_dim
360
+ query_states = qkv[..., :query_pos]
361
+ key_states = qkv[..., query_pos : query_pos + self.num_key_value_heads * self.head_dim]
362
+ value_states = qkv[..., query_pos + self.num_key_value_heads * self.head_dim :]
363
+
364
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
365
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
366
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
367
+
368
+ kv_seq_len = key_states.shape[-2]
369
+ if past_key_value is not None:
370
+ if self.layer_idx is None:
371
+ raise ValueError(
372
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
373
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
374
+ "with a layer index."
375
+ )
376
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
377
+ cos, sin = self.rotary_emb(value_states, position_ids, seq_len=kv_seq_len)
378
+
379
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
380
+
381
+ if past_key_value is not None:
382
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
383
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
384
+
385
+ # repeat k/v heads if n_kv_heads < n_heads
386
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
387
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
388
+
389
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
390
+
391
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
392
+ raise ValueError(
393
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
394
+ f" {attn_weights.size()}"
395
+ )
396
+
397
+ if attention_mask is not None:
398
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
399
+ raise ValueError(
400
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
401
+ )
402
+ attn_weights = attn_weights + attention_mask
403
+
404
+ # upcast attention to fp32
405
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(value_states.dtype)
406
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
407
+
408
+ attn_output = torch.matmul(attn_weights, value_states)
409
+
410
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
411
+ raise ValueError(
412
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
413
+ f" {attn_output.size()}"
414
+ )
415
+
416
+ attn_output = attn_output.transpose(1, 2).contiguous()
417
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
418
+
419
+ attn_output = self.o_proj(attn_output)
420
+
421
+ if not output_attentions:
422
+ attn_weights = None
423
+
424
+ return attn_output, attn_weights, past_key_value
425
+
426
+
427
+ class Phi3FlashAttention2(Phi3Attention):
428
+ """
429
+ Phi-3 flash attention module. This module inherits from `Phi3Attention` as the weights of the module stays
430
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
431
+ flash attention and deal with padding tokens in case the input contains any of them.
432
+ """
433
+
434
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2.__init__
435
+ def __init__(self, *args, **kwargs):
436
+ super().__init__(*args, **kwargs)
437
+
438
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
439
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
440
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
441
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
442
+
443
+ def forward(
444
+ self,
445
+ hidden_states: torch.Tensor,
446
+ attention_mask: Optional[torch.LongTensor] = None,
447
+ position_ids: Optional[torch.LongTensor] = None,
448
+ past_key_value: Optional[Cache] = None,
449
+ output_attentions: bool = False,
450
+ use_cache: bool = False,
451
+ **kwargs,
452
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
453
+ # Phi3FlashAttention2 attention does not support output_attentions
454
+
455
+ if not _flash_supports_window_size:
456
+ logger.warning_once(
457
+ "The current flash attention version does not support sliding window attention. Please use `attn_implementation='eager'` or upgrade flash-attn library."
458
+ )
459
+ raise ValueError("The current flash attention version does not support sliding window attention.")
460
+
461
+ output_attentions = False
462
+
463
+ if "padding_mask" in kwargs:
464
+ warnings.warn(
465
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
466
+ )
467
+
468
+ # overwrite attention_mask with padding_mask
469
+ attention_mask = kwargs.pop("padding_mask")
470
+
471
+ bsz, q_len, _ = hidden_states.size()
472
+
473
+ qkv = self.qkv_proj(hidden_states)
474
+ query_pos = self.num_heads * self.head_dim
475
+ query_states = qkv[..., :query_pos]
476
+ key_states = qkv[..., query_pos : query_pos + self.num_key_value_heads * self.head_dim]
477
+ value_states = qkv[..., query_pos + self.num_key_value_heads * self.head_dim :]
478
+
479
+ # Flash attention requires the input to have the shape
480
+ # batch_size x seq_length x head_dim x hidden_dim
481
+ # therefore we just need to keep the original shape
482
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
483
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
484
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
485
+
486
+ kv_seq_len = key_states.shape[-2]
487
+ if past_key_value is not None:
488
+ if self.layer_idx is None:
489
+ raise ValueError(
490
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
491
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
492
+ "with a layer index."
493
+ )
494
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
495
+
496
+ # Because the input can be padded, the absolute sequence length depends on the max position id.
497
+ rotary_seq_len = max(kv_seq_len, position_ids[:, -1].max().item()) + 1
498
+ cos, sin = self.rotary_emb(value_states, position_ids, seq_len=rotary_seq_len)
499
+
500
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
501
+
502
+ use_sliding_windows = (
503
+ _flash_supports_window_size
504
+ and getattr(self.config, "sliding_window", None) is not None
505
+ and kv_seq_len > self.config.sliding_window
506
+ )
507
+
508
+ if past_key_value is not None:
509
+ # Activate slicing cache only if the config has a value `sliding_windows` attribute
510
+ cache_has_contents = past_key_value.get_seq_length(self.layer_idx) > 0
511
+ if (
512
+ getattr(self.config, "sliding_window", None) is not None
513
+ and kv_seq_len > self.config.sliding_window
514
+ and cache_has_contents
515
+ ):
516
+ slicing_tokens = 1 - self.config.sliding_window
517
+
518
+ past_key = past_key_value[self.layer_idx][0]
519
+ past_value = past_key_value[self.layer_idx][1]
520
+
521
+ past_key = past_key[:, :, slicing_tokens:, :].contiguous()
522
+ past_value = past_value[:, :, slicing_tokens:, :].contiguous()
523
+
524
+ if past_key.shape[-2] != self.config.sliding_window - 1:
525
+ raise ValueError(
526
+ f"past key must have a shape of (`batch_size, num_heads, self.config.sliding_window-1, head_dim`), got"
527
+ f" {past_key.shape}"
528
+ )
529
+
530
+ if attention_mask is not None:
531
+ attention_mask = attention_mask[:, slicing_tokens:]
532
+ attention_mask = torch.cat([attention_mask, torch.ones_like(attention_mask[:, -1:])], dim=-1)
533
+
534
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
535
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
536
+
537
+ # repeat k/v heads if n_kv_heads < n_heads
538
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
539
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
540
+
541
+ attn_dropout = self.attention_dropout if self.training else 0.0
542
+
543
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
544
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
545
+ # cast them back in the correct dtype just to be sure everything works as expected.
546
+ # This might slowdown training & inference so it is recommended to not cast the LayerNorms
547
+ # in fp32.
548
+
549
+ if query_states.dtype == torch.float32:
550
+ if torch.is_autocast_enabled():
551
+ target_dtype = torch.get_autocast_gpu_dtype()
552
+ # Handle the case where the model is quantized
553
+ elif hasattr(self.config, "_pre_quantization_dtype"):
554
+ target_dtype = self.config._pre_quantization_dtype
555
+ else:
556
+ target_dtype = self.qkv_proj.weight.dtype
557
+
558
+ logger.warning_once(
559
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
560
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
561
+ f" {target_dtype}."
562
+ )
563
+
564
+ query_states = query_states.to(target_dtype)
565
+ key_states = key_states.to(target_dtype)
566
+ value_states = value_states.to(target_dtype)
567
+
568
+ # Reashape to the expected shape for Flash Attention
569
+ query_states = query_states.transpose(1, 2)
570
+ key_states = key_states.transpose(1, 2)
571
+ value_states = value_states.transpose(1, 2)
572
+
573
+ attn_output = self._flash_attention_forward(
574
+ query_states,
575
+ key_states,
576
+ value_states,
577
+ attention_mask,
578
+ q_len,
579
+ dropout=attn_dropout,
580
+ use_sliding_windows=use_sliding_windows,
581
+ )
582
+
583
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
584
+ attn_output = self.o_proj(attn_output)
585
+
586
+ if not output_attentions:
587
+ attn_weights = None
588
+
589
+ return attn_output, attn_weights, past_key_value
590
+
591
+ # Copied from transformers.models.mistral.modeling_mistral.MistralFlashAttention2._flash_attention_forward
592
+ def _flash_attention_forward(
593
+ self,
594
+ query_states,
595
+ key_states,
596
+ value_states,
597
+ attention_mask,
598
+ query_length,
599
+ dropout=0.0,
600
+ softmax_scale=None,
601
+ use_sliding_windows=False,
602
+ ):
603
+ """
604
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
605
+ first unpad the input, then computes the attention scores and pad the final attention scores.
606
+
607
+ Args:
608
+ query_states (`torch.Tensor`):
609
+ Input query states to be passed to Flash Attention API
610
+ key_states (`torch.Tensor`):
611
+ Input key states to be passed to Flash Attention API
612
+ value_states (`torch.Tensor`):
613
+ Input value states to be passed to Flash Attention API
614
+ attention_mask (`torch.Tensor`):
615
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
616
+ position of padding tokens and 1 for the position of non-padding tokens.
617
+ dropout (`float`):
618
+ Attention dropout
619
+ softmax_scale (`float`, *optional*):
620
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
621
+ use_sliding_windows (`bool`, *optional*):
622
+ Whether to activate sliding window attention.
623
+ """
624
+ if not self._flash_attn_uses_top_left_mask:
625
+ causal = self.is_causal
626
+ else:
627
+ # TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in LlamaFlashAttention2 __init__.
628
+ causal = self.is_causal and query_length != 1
629
+
630
+ # Contains at least one padding token in the sequence
631
+ if attention_mask is not None:
632
+ batch_size = query_states.shape[0]
633
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
634
+ query_states, key_states, value_states, attention_mask, query_length
635
+ )
636
+
637
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
638
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
639
+
640
+ if not use_sliding_windows:
641
+ attn_output_unpad = flash_attn_varlen_func(
642
+ query_states,
643
+ key_states,
644
+ value_states,
645
+ cu_seqlens_q=cu_seqlens_q,
646
+ cu_seqlens_k=cu_seqlens_k,
647
+ max_seqlen_q=max_seqlen_in_batch_q,
648
+ max_seqlen_k=max_seqlen_in_batch_k,
649
+ dropout_p=dropout,
650
+ softmax_scale=softmax_scale,
651
+ causal=causal,
652
+ )
653
+ else:
654
+ attn_output_unpad = flash_attn_varlen_func(
655
+ query_states,
656
+ key_states,
657
+ value_states,
658
+ cu_seqlens_q=cu_seqlens_q,
659
+ cu_seqlens_k=cu_seqlens_k,
660
+ max_seqlen_q=max_seqlen_in_batch_q,
661
+ max_seqlen_k=max_seqlen_in_batch_k,
662
+ dropout_p=dropout,
663
+ softmax_scale=softmax_scale,
664
+ causal=causal,
665
+ window_size=(self.config.sliding_window, self.config.sliding_window),
666
+ )
667
+
668
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
669
+ else:
670
+ if not use_sliding_windows:
671
+ attn_output = flash_attn_func(
672
+ query_states,
673
+ key_states,
674
+ value_states,
675
+ dropout,
676
+ softmax_scale=softmax_scale,
677
+ causal=causal,
678
+ )
679
+ else:
680
+ attn_output = flash_attn_func(
681
+ query_states,
682
+ key_states,
683
+ value_states,
684
+ dropout,
685
+ softmax_scale=softmax_scale,
686
+ causal=causal,
687
+ window_size=(self.config.sliding_window, self.config.sliding_window),
688
+ )
689
+
690
+ return attn_output
691
+
692
+ # Copied from transformers.models.mistral.modeling_mistral.MistralFlashAttention2._upad_input
693
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
694
+ batch_size, kv_seq_len, num_heads, head_dim = key_layer.shape
695
+
696
+ # On the first iteration we need to properly re-create the padding mask
697
+ # by slicing it on the proper place
698
+ if kv_seq_len != attention_mask.shape[-1]:
699
+ attention_mask_num_tokens = attention_mask.shape[-1]
700
+ attention_mask = attention_mask[:, attention_mask_num_tokens - kv_seq_len :]
701
+
702
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
703
+
704
+ key_layer = index_first_axis(key_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
705
+ value_layer = index_first_axis(value_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
706
+
707
+ if query_length == kv_seq_len:
708
+ query_layer = index_first_axis(
709
+ query_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k
710
+ )
711
+ cu_seqlens_q = cu_seqlens_k
712
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
713
+ indices_q = indices_k
714
+ elif query_length == 1:
715
+ max_seqlen_in_batch_q = 1
716
+ cu_seqlens_q = torch.arange(
717
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
718
+ ) # There is a memcpy here, that is very bad.
719
+ indices_q = cu_seqlens_q[:-1]
720
+ query_layer = query_layer.squeeze(1)
721
+ else:
722
+ # The -q_len: slice assumes left padding.
723
+ attention_mask = attention_mask[:, -query_length:]
724
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
725
+
726
+ return (
727
+ query_layer,
728
+ key_layer,
729
+ value_layer,
730
+ indices_q,
731
+ (cu_seqlens_q, cu_seqlens_k),
732
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
733
+ )
734
+
735
+
736
+ # copied from transformers.models.llama.modeling_llama.LlamaSdpaAttention with Llama->Phi3
737
+ # TODO @Arthur no longer copied from LLama after static cache
738
+ class Phi3SdpaAttention(Phi3Attention):
739
+ """
740
+ Phi3 attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
741
+ `Phi3Attention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
742
+ SDPA API.
743
+ """
744
+
745
+ # Adapted from Phi3Attention.forward
746
+ def forward(
747
+ self,
748
+ hidden_states: torch.Tensor,
749
+ attention_mask: Optional[torch.Tensor] = None,
750
+ position_ids: Optional[torch.LongTensor] = None,
751
+ past_key_value: Optional[Cache] = None,
752
+ output_attentions: bool = False,
753
+ use_cache: bool = False,
754
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
755
+ if output_attentions:
756
+ # TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
757
+ logger.warning_once(
758
+ "Phi3Model is using Phi3SdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
759
+ 'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
760
+ )
761
+ return super().forward(
762
+ hidden_states=hidden_states,
763
+ attention_mask=attention_mask,
764
+ position_ids=position_ids,
765
+ past_key_value=past_key_value,
766
+ output_attentions=output_attentions,
767
+ use_cache=use_cache,
768
+ )
769
+
770
+ bsz, q_len, _ = hidden_states.size()
771
+
772
+ qkv = self.qkv_proj(hidden_states)
773
+ query_pos = self.num_heads * self.head_dim
774
+ query_states = qkv[..., :query_pos]
775
+ key_states = qkv[..., query_pos : query_pos + self.num_key_value_heads * self.head_dim]
776
+ value_states = qkv[..., query_pos + self.num_key_value_heads * self.head_dim :]
777
+
778
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
779
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
780
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
781
+
782
+ kv_seq_len = key_states.shape[-2]
783
+ if past_key_value is not None:
784
+ kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
785
+ cos, sin = self.rotary_emb(value_states, position_ids, seq_len=kv_seq_len)
786
+
787
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
788
+
789
+ if past_key_value is not None:
790
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
791
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
792
+
793
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
794
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
795
+
796
+ if attention_mask is not None:
797
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
798
+ raise ValueError(
799
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
800
+ )
801
+
802
+ # SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
803
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
804
+ if query_states.device.type == "cuda" and attention_mask is not None:
805
+ query_states = query_states.contiguous()
806
+ key_states = key_states.contiguous()
807
+ value_states = value_states.contiguous()
808
+
809
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
810
+ query_states,
811
+ key_states,
812
+ value_states,
813
+ attn_mask=attention_mask,
814
+ dropout_p=self.attention_dropout if self.training else 0.0,
815
+ # The q_len > 1 is necessary to match with AttentionMaskConverter.to_causal_4d that does not create a causal mask in case q_len == 1.
816
+ is_causal=self.is_causal and attention_mask is None and q_len > 1,
817
+ )
818
+
819
+ attn_output = attn_output.transpose(1, 2).contiguous()
820
+ attn_output = attn_output.view(bsz, q_len, self.hidden_size)
821
+
822
+ attn_output = self.o_proj(attn_output)
823
+
824
+ return attn_output, None, past_key_value
825
+
826
+
827
+ PHI3_ATTENTION_CLASSES = {
828
+ "eager": Phi3Attention,
829
+ "flash_attention_2": Phi3FlashAttention2,
830
+ "sdpa": Phi3SdpaAttention,
831
+ }
832
+
833
+
834
+ class Phi3DecoderLayer(nn.Module):
835
+ def __init__(self, config: Phi3Config, layer_idx: int):
836
+ super().__init__()
837
+
838
+ self.config = config
839
+ self.self_attn = PHI3_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx=layer_idx)
840
+
841
+ self.mlp = Phi3MLP(config)
842
+ self.input_layernorm = Phi3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
843
+
844
+ self.resid_attn_dropout = nn.Dropout(config.resid_pdrop)
845
+ self.resid_mlp_dropout = nn.Dropout(config.resid_pdrop)
846
+ self.post_attention_layernorm = Phi3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
847
+
848
+ def forward(
849
+ self,
850
+ hidden_states: torch.Tensor,
851
+ attention_mask: Optional[torch.Tensor] = None,
852
+ position_ids: Optional[torch.LongTensor] = None,
853
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
854
+ output_attentions: Optional[bool] = False,
855
+ use_cache: Optional[bool] = False,
856
+ **kwargs,
857
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
858
+ if "padding_mask" in kwargs:
859
+ warnings.warn(
860
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
861
+ )
862
+ """
863
+ Args:
864
+ hidden_states (`torch.FloatTensor`):
865
+ input to the layer of shape `(batch, seq_len, embed_dim)`
866
+ attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
867
+ `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
868
+ position_ids (`torch.LongTensor` of shape `({0})`, *optional*):
869
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range
870
+ `[0, config.n_positions - 1]`. [What are position IDs?](../glossary#position-ids)
871
+ output_attentions (`bool`, *optional*):
872
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
873
+ returned tensors for more detail.
874
+ use_cache (`bool`, *optional*):
875
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
876
+ (see `past_key_values`).
877
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
878
+ """
879
+
880
+ residual = hidden_states
881
+
882
+ hidden_states = self.input_layernorm(hidden_states)
883
+
884
+ # Self Attention
885
+ attn_outputs, self_attn_weights, present_key_value = self.self_attn(
886
+ hidden_states=hidden_states,
887
+ attention_mask=attention_mask,
888
+ position_ids=position_ids,
889
+ past_key_value=past_key_value,
890
+ output_attentions=output_attentions,
891
+ use_cache=use_cache,
892
+ )
893
+
894
+ hidden_states = residual + self.resid_attn_dropout(attn_outputs)
895
+
896
+ residual = hidden_states
897
+ hidden_states = self.post_attention_layernorm(hidden_states)
898
+ hidden_states = self.mlp(hidden_states)
899
+ hidden_states = residual + self.resid_mlp_dropout(hidden_states)
900
+
901
+ outputs = (hidden_states,)
902
+
903
+ if output_attentions:
904
+ outputs += (self_attn_weights,)
905
+
906
+ if use_cache:
907
+ outputs += (present_key_value,)
908
+
909
+ return outputs
910
+
911
+
912
+ PHI3_START_DOCSTRING = r"""
913
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
914
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
915
+ etc.)
916
+
917
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
918
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
919
+ and behavior.
920
+
921
+ Parameters:
922
+ config ([`Phi3Config`]):
923
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
924
+ load the weights associated with the model, only the configuration. Check out the
925
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
926
+ """
927
+
928
+
929
+ @add_start_docstrings(
930
+ "The bare Phi-3 model outputting raw hidden-states without any specific head on top.",
931
+ PHI3_START_DOCSTRING,
932
+ )
933
+ class Phi3PreTrainedModel(PreTrainedModel):
934
+ config_class = Phi3Config
935
+ base_model_prefix = "model"
936
+ supports_gradient_checkpointing = True
937
+ _no_split_modules = ["Phi3DecoderLayer"]
938
+ _skip_keys_device_placement = "past_key_values"
939
+ _supports_flash_attn_2 = True
940
+ _supports_sdpa = False
941
+ _supports_cache_class = True
942
+
943
+ _version = "0.0.5"
944
+
945
+ def _init_weights(self, module):
946
+ std = self.config.initializer_range
947
+ if isinstance(module, nn.Linear):
948
+ module.weight.data.normal_(mean=0.0, std=std)
949
+ if module.bias is not None:
950
+ module.bias.data.zero_()
951
+ elif isinstance(module, nn.Embedding):
952
+ module.weight.data.normal_(mean=0.0, std=std)
953
+ if module.padding_idx is not None:
954
+ module.weight.data[module.padding_idx].zero_()
955
+
956
+
957
+ PHI3_INPUTS_DOCSTRING = r"""
958
+ Args:
959
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
960
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
961
+ it.
962
+
963
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
964
+ [`PreTrainedTokenizer.__call__`] for details.
965
+
966
+ [What are input IDs?](../glossary#input-ids)
967
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
968
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
969
+
970
+ - 1 for tokens that are **not masked**,
971
+ - 0 for tokens that are **masked**.
972
+
973
+ [What are attention masks?](../glossary#attention-mask)
974
+
975
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
976
+ [`PreTrainedTokenizer.__call__`] for details.
977
+
978
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
979
+ `past_key_values`).
980
+
981
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
982
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
983
+ information on the default strategy.
984
+
985
+ - 1 indicates the head is **not masked**,
986
+ - 0 indicates the head is **masked**.
987
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
988
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
989
+ config.n_positions - 1]`.
990
+
991
+ [What are position IDs?](../glossary#position-ids)
992
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
993
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
994
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
995
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
996
+
997
+ Two formats are allowed:
998
+ - a [`~cache_utils.Cache`] instance;
999
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
1000
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
1001
+ cache format.
1002
+
1003
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
1004
+ legacy cache format will be returned.
1005
+
1006
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
1007
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
1008
+ of shape `(batch_size, sequence_length)`.
1009
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
1010
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
1011
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
1012
+ model's internal embedding lookup matrix.
1013
+ use_cache (`bool`, *optional*):
1014
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
1015
+ `past_key_values`).
1016
+ output_attentions (`bool`, *optional*):
1017
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
1018
+ tensors for more detail.
1019
+ output_hidden_states (`bool`, *optional*):
1020
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
1021
+ more detail.
1022
+ return_dict (`bool`, *optional*):
1023
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
1024
+ """
1025
+
1026
+
1027
+ @add_start_docstrings(
1028
+ "The bare Phi-3 model outputting raw hidden-states without any specific head on top.",
1029
+ PHI3_START_DOCSTRING,
1030
+ )
1031
+ class Phi3Model(Phi3PreTrainedModel):
1032
+ """
1033
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`Phi3DecoderLayer`]
1034
+
1035
+ Args:
1036
+ config: Phi3Config
1037
+ """
1038
+
1039
+ def __init__(self, config: Phi3Config):
1040
+ super().__init__(config)
1041
+ self.padding_idx = config.pad_token_id
1042
+ self.vocab_size = config.vocab_size
1043
+
1044
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
1045
+ self.embed_dropout = nn.Dropout(config.embd_pdrop)
1046
+ self.layers = nn.ModuleList(
1047
+ [Phi3DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
1048
+ )
1049
+ self._attn_implementation = config._attn_implementation
1050
+ self.norm = Phi3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
1051
+
1052
+ self.gradient_checkpointing = False
1053
+ # Initialize weights and apply final processing
1054
+ self.post_init()
1055
+
1056
+ def get_input_embeddings(self):
1057
+ return self.embed_tokens
1058
+
1059
+ def set_input_embeddings(self, value):
1060
+ self.embed_tokens = value
1061
+
1062
+ @add_start_docstrings_to_model_forward(PHI3_INPUTS_DOCSTRING)
1063
+ def forward(
1064
+ self,
1065
+ input_ids: torch.LongTensor = None,
1066
+ attention_mask: Optional[torch.Tensor] = None,
1067
+ position_ids: Optional[torch.LongTensor] = None,
1068
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1069
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1070
+ use_cache: Optional[bool] = None,
1071
+ output_attentions: Optional[bool] = None,
1072
+ output_hidden_states: Optional[bool] = None,
1073
+ return_dict: Optional[bool] = None,
1074
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
1075
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1076
+ output_hidden_states = (
1077
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1078
+ )
1079
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
1080
+
1081
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1082
+
1083
+ # retrieve input_ids and inputs_embeds
1084
+ if input_ids is not None and inputs_embeds is not None:
1085
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
1086
+ elif input_ids is not None:
1087
+ batch_size, seq_length = input_ids.shape[:2]
1088
+ elif inputs_embeds is not None:
1089
+ batch_size, seq_length = inputs_embeds.shape[:2]
1090
+ else:
1091
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
1092
+
1093
+ past_key_values_length = 0
1094
+
1095
+ if self.gradient_checkpointing and self.training:
1096
+ if use_cache:
1097
+ logger.warning_once(
1098
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
1099
+ )
1100
+ use_cache = False
1101
+
1102
+ if use_cache:
1103
+ use_legacy_cache = not isinstance(past_key_values, Cache)
1104
+ if use_legacy_cache:
1105
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
1106
+ past_key_values_length = past_key_values.get_usable_length(seq_length)
1107
+
1108
+ if position_ids is None:
1109
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
1110
+ position_ids = torch.arange(
1111
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
1112
+ )
1113
+ position_ids = position_ids.unsqueeze(0).view(-1, seq_length)
1114
+ else:
1115
+ position_ids = position_ids.view(-1, seq_length).long()
1116
+
1117
+ if inputs_embeds is None:
1118
+ inputs_embeds = self.embed_tokens(input_ids)
1119
+
1120
+ if attention_mask is not None and self._attn_implementation == "flash_attention_2" and use_cache:
1121
+ is_padding_right = attention_mask[:, -1].sum().item() != batch_size
1122
+ if is_padding_right:
1123
+ raise ValueError(
1124
+ "You are attempting to perform batched generation with padding_side='right'"
1125
+ " this may lead to unexpected behaviour for Flash Attention version of Phi3. Make sure to "
1126
+ " call `tokenizer.padding_side = 'left'` before tokenizing the input. "
1127
+ )
1128
+
1129
+ if self._attn_implementation == "flash_attention_2":
1130
+ # 2d mask is passed through the layers
1131
+ attention_mask = attention_mask if (attention_mask is not None and 0 in attention_mask) else None
1132
+ else:
1133
+ # 4d mask is passed through the layers
1134
+ attention_mask = _prepare_4d_causal_attention_mask(
1135
+ attention_mask,
1136
+ (batch_size, seq_length),
1137
+ inputs_embeds,
1138
+ past_key_values_length,
1139
+ sliding_window=self.config.sliding_window,
1140
+ )
1141
+
1142
+ hidden_states = inputs_embeds
1143
+
1144
+ # decoder layers
1145
+ all_hidden_states = () if output_hidden_states else None
1146
+ all_self_attns = () if output_attentions else None
1147
+ next_decoder_cache = None
1148
+
1149
+ for decoder_layer in self.layers:
1150
+ if output_hidden_states:
1151
+ all_hidden_states += (hidden_states,)
1152
+
1153
+ if self.gradient_checkpointing and self.training:
1154
+ layer_outputs = self._gradient_checkpointing_func(
1155
+ decoder_layer.__call__,
1156
+ hidden_states,
1157
+ attention_mask,
1158
+ position_ids,
1159
+ past_key_values,
1160
+ output_attentions,
1161
+ use_cache,
1162
+ )
1163
+ else:
1164
+ layer_outputs = decoder_layer(
1165
+ hidden_states,
1166
+ attention_mask=attention_mask,
1167
+ position_ids=position_ids,
1168
+ past_key_value=past_key_values,
1169
+ output_attentions=output_attentions,
1170
+ use_cache=use_cache,
1171
+ )
1172
+
1173
+ hidden_states = layer_outputs[0]
1174
+
1175
+ if use_cache:
1176
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1177
+
1178
+ if output_attentions:
1179
+ all_self_attns += (layer_outputs[1],)
1180
+
1181
+ hidden_states = self.norm(hidden_states)
1182
+
1183
+ # add hidden states from the last decoder layer
1184
+ if output_hidden_states:
1185
+ all_hidden_states += (hidden_states,)
1186
+
1187
+ next_cache = None
1188
+ if use_cache:
1189
+ next_cache = next_decoder_cache.to_legacy_cache() if use_legacy_cache else next_decoder_cache
1190
+ if not return_dict:
1191
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
1192
+ return BaseModelOutputWithPast(
1193
+ last_hidden_state=hidden_states,
1194
+ past_key_values=next_cache,
1195
+ hidden_states=all_hidden_states,
1196
+ attentions=all_self_attns,
1197
+ )
1198
+
1199
+
1200
+ class Phi3ForCausalLM(Phi3PreTrainedModel):
1201
+ _tied_weights_keys = ["lm_head.weight"]
1202
+
1203
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.__init__ with Llama->Phi3
1204
+ def __init__(self, config):
1205
+ super().__init__(config)
1206
+ self.model = Phi3Model(config)
1207
+ self.vocab_size = config.vocab_size
1208
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1209
+
1210
+ # Initialize weights and apply final processing
1211
+ self.post_init()
1212
+
1213
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_input_embeddings
1214
+ def get_input_embeddings(self):
1215
+ return self.model.embed_tokens
1216
+
1217
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_input_embeddings
1218
+ def set_input_embeddings(self, value):
1219
+ self.model.embed_tokens = value
1220
+
1221
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_output_embeddings
1222
+ def get_output_embeddings(self):
1223
+ return self.lm_head
1224
+
1225
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_output_embeddings
1226
+ def set_output_embeddings(self, new_embeddings):
1227
+ self.lm_head = new_embeddings
1228
+
1229
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.set_decoder
1230
+ def set_decoder(self, decoder):
1231
+ self.model = decoder
1232
+
1233
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM.get_decoder
1234
+ def get_decoder(self):
1235
+ return self.model
1236
+
1237
+ # Ignore copy
1238
+ @add_start_docstrings_to_model_forward(PHI3_INPUTS_DOCSTRING)
1239
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1240
+ def forward(
1241
+ self,
1242
+ input_ids: torch.LongTensor = None,
1243
+ attention_mask: Optional[torch.Tensor] = None,
1244
+ position_ids: Optional[torch.LongTensor] = None,
1245
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1246
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1247
+ labels: Optional[torch.LongTensor] = None,
1248
+ use_cache: Optional[bool] = None,
1249
+ output_attentions: Optional[bool] = None,
1250
+ output_hidden_states: Optional[bool] = None,
1251
+ return_dict: Optional[bool] = None,
1252
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1253
+ r"""
1254
+ Args:
1255
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1256
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1257
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1258
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1259
+
1260
+ Returns:
1261
+
1262
+ Example:
1263
+
1264
+ ```python
1265
+ >>> from transformers import AutoTokenizer, Phi3ForCausalLM
1266
+
1267
+ >>> model = Phi3ForCausalLM.from_pretrained("microsoft/phi-3-mini-4k-instruct")
1268
+ >>> tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-3-mini-4k-instruct")
1269
+
1270
+ >>> prompt = "This is an example script ."
1271
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1272
+
1273
+ >>> # Generate
1274
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1275
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1276
+ 'This is an example script .\n Certainly! Below is a sample script that demonstrates a simple task, such as calculating the sum'
1277
+ ```"""
1278
+
1279
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1280
+ output_hidden_states = (
1281
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1282
+ )
1283
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1284
+
1285
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1286
+ outputs = self.model(
1287
+ input_ids=input_ids,
1288
+ attention_mask=attention_mask,
1289
+ position_ids=position_ids,
1290
+ past_key_values=past_key_values,
1291
+ inputs_embeds=inputs_embeds,
1292
+ use_cache=use_cache,
1293
+ output_attentions=output_attentions,
1294
+ output_hidden_states=output_hidden_states,
1295
+ return_dict=return_dict,
1296
+ )
1297
+
1298
+ hidden_states = outputs[0]
1299
+ logits = self.lm_head(hidden_states)
1300
+ logits = logits.float()
1301
+
1302
+ loss = None
1303
+ if labels is not None:
1304
+ # Shift so that tokens < n predict n
1305
+ shift_logits = logits[..., :-1, :].contiguous()
1306
+ shift_labels = labels[..., 1:].contiguous()
1307
+ # Flatten the tokens
1308
+ loss_fct = CrossEntropyLoss()
1309
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
1310
+ shift_labels = shift_labels.view(-1)
1311
+ # Enable model parallelism
1312
+ shift_labels = shift_labels.to(shift_logits.device)
1313
+ loss = loss_fct(shift_logits, shift_labels)
1314
+
1315
+ if not return_dict:
1316
+ output = (logits,) + outputs[1:]
1317
+ return (loss,) + output if loss is not None else output
1318
+
1319
+ return CausalLMOutputWithPast(
1320
+ loss=loss,
1321
+ logits=logits,
1322
+ past_key_values=outputs.past_key_values,
1323
+ hidden_states=outputs.hidden_states,
1324
+ attentions=outputs.attentions,
1325
+ )
1326
+
1327
+ # Copied from transformers.models.persimmon.modeling_persimmon.PersimmonForCausalLM.prepare_inputs_for_generation
1328
+ def prepare_inputs_for_generation(
1329
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
1330
+ ):
1331
+ if past_key_values is not None:
1332
+ if isinstance(past_key_values, Cache):
1333
+ cache_length = past_key_values.get_seq_length()
1334
+ past_length = past_key_values.seen_tokens
1335
+ max_cache_length = past_key_values.get_max_length()
1336
+ else:
1337
+ cache_length = past_length = past_key_values[0][0].shape[2]
1338
+ max_cache_length = None
1339
+
1340
+ # Keep only the unprocessed tokens:
1341
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
1342
+ # some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as
1343
+ # input)
1344
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
1345
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
1346
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
1347
+ # input_ids based on the past_length.
1348
+ elif past_length < input_ids.shape[1]:
1349
+ input_ids = input_ids[:, past_length:]
1350
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
1351
+
1352
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
1353
+ if (
1354
+ max_cache_length is not None
1355
+ and attention_mask is not None
1356
+ and cache_length + input_ids.shape[1] > max_cache_length
1357
+ ):
1358
+ attention_mask = attention_mask[:, -max_cache_length:]
1359
+
1360
+ position_ids = kwargs.get("position_ids", None)
1361
+ if attention_mask is not None and position_ids is None:
1362
+ # create position_ids on the fly for batch generation
1363
+ position_ids = attention_mask.long().cumsum(-1) - 1
1364
+ position_ids.masked_fill_(attention_mask == 0, 1)
1365
+ if past_key_values:
1366
+ position_ids = position_ids[:, -input_ids.shape[1] :]
1367
+
1368
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
1369
+ if inputs_embeds is not None and past_key_values is None:
1370
+ model_inputs = {"inputs_embeds": inputs_embeds}
1371
+ else:
1372
+ model_inputs = {"input_ids": input_ids}
1373
+
1374
+ model_inputs.update(
1375
+ {
1376
+ "position_ids": position_ids,
1377
+ "past_key_values": past_key_values,
1378
+ "use_cache": kwargs.get("use_cache"),
1379
+ "attention_mask": attention_mask,
1380
+ }
1381
+ )
1382
+ return model_inputs
1383
+
1384
+ @staticmethod
1385
+ # Copied from transformers.models.llama.modeling_llama.LlamaForCausalLM._reorder_cache
1386
+ def _reorder_cache(past_key_values, beam_idx):
1387
+ reordered_past = ()
1388
+ for layer_past in past_key_values:
1389
+ reordered_past += (
1390
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1391
+ )
1392
+ return reordered_past
1393
+
1394
+
1395
+ @add_start_docstrings(
1396
+ """
1397
+ The [`Phi3Model`] with a sequence classification head on top (linear layer).
1398
+
1399
+ [`Phi3ForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1400
+ (e.g. GPT-2) do.
1401
+
1402
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1403
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1404
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1405
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1406
+ each row of the batch).
1407
+ """,
1408
+ PHI3_START_DOCSTRING,
1409
+ )
1410
+ # Copied from transformers.models.llama.modeling_llama.LlamaForSequenceClassification with Llama->Phi3, LLAMA->PHI3, self.transformer->self.model, transformer_outputs->model_outputs
1411
+ class Phi3ForSequenceClassification(Phi3PreTrainedModel):
1412
+ def __init__(self, config):
1413
+ super().__init__(config)
1414
+ self.num_labels = config.num_labels
1415
+ self.model = Phi3Model(config)
1416
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1417
+
1418
+ # Initialize weights and apply final processing
1419
+ self.post_init()
1420
+
1421
+ def get_input_embeddings(self):
1422
+ return self.model.embed_tokens
1423
+
1424
+ def set_input_embeddings(self, value):
1425
+ self.model.embed_tokens = value
1426
+
1427
+ @add_start_docstrings_to_model_forward(PHI3_INPUTS_DOCSTRING)
1428
+ def forward(
1429
+ self,
1430
+ input_ids: torch.LongTensor = None,
1431
+ attention_mask: Optional[torch.Tensor] = None,
1432
+ position_ids: Optional[torch.LongTensor] = None,
1433
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1434
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1435
+ labels: Optional[torch.LongTensor] = None,
1436
+ use_cache: Optional[bool] = None,
1437
+ output_attentions: Optional[bool] = None,
1438
+ output_hidden_states: Optional[bool] = None,
1439
+ return_dict: Optional[bool] = None,
1440
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1441
+ r"""
1442
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1443
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1444
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1445
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1446
+ """
1447
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1448
+
1449
+ model_outputs = self.model(
1450
+ input_ids,
1451
+ attention_mask=attention_mask,
1452
+ position_ids=position_ids,
1453
+ past_key_values=past_key_values,
1454
+ inputs_embeds=inputs_embeds,
1455
+ use_cache=use_cache,
1456
+ output_attentions=output_attentions,
1457
+ output_hidden_states=output_hidden_states,
1458
+ return_dict=return_dict,
1459
+ )
1460
+ hidden_states = model_outputs[0]
1461
+ logits = self.score(hidden_states)
1462
+
1463
+ if input_ids is not None:
1464
+ batch_size = input_ids.shape[0]
1465
+ else:
1466
+ batch_size = inputs_embeds.shape[0]
1467
+
1468
+ if self.config.pad_token_id is None and batch_size != 1:
1469
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1470
+ if self.config.pad_token_id is None:
1471
+ sequence_lengths = -1
1472
+ else:
1473
+ if input_ids is not None:
1474
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1475
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1476
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1477
+ sequence_lengths = sequence_lengths.to(logits.device)
1478
+ else:
1479
+ sequence_lengths = -1
1480
+
1481
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1482
+
1483
+ loss = None
1484
+ if labels is not None:
1485
+ labels = labels.to(logits.device)
1486
+ if self.config.problem_type is None:
1487
+ if self.num_labels == 1:
1488
+ self.config.problem_type = "regression"
1489
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1490
+ self.config.problem_type = "single_label_classification"
1491
+ else:
1492
+ self.config.problem_type = "multi_label_classification"
1493
+
1494
+ if self.config.problem_type == "regression":
1495
+ loss_fct = MSELoss()
1496
+ if self.num_labels == 1:
1497
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1498
+ else:
1499
+ loss = loss_fct(pooled_logits, labels)
1500
+ elif self.config.problem_type == "single_label_classification":
1501
+ loss_fct = CrossEntropyLoss()
1502
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1503
+ elif self.config.problem_type == "multi_label_classification":
1504
+ loss_fct = BCEWithLogitsLoss()
1505
+ loss = loss_fct(pooled_logits, labels)
1506
+ if not return_dict:
1507
+ output = (pooled_logits,) + model_outputs[1:]
1508
+ return ((loss,) + output) if loss is not None else output
1509
+
1510
+ return SequenceClassifierOutputWithPast(
1511
+ loss=loss,
1512
+ logits=pooled_logits,
1513
+ past_key_values=model_outputs.past_key_values,
1514
+ hidden_states=model_outputs.hidden_states,
1515
+ attentions=model_outputs.attentions,
1516
+ )
1517
+
1518
+
1519
+ @add_start_docstrings(
1520
+ """
1521
+ [`Phi3Model`] with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
1522
+ Named-Entity-Recognition (NER) tasks.
1523
+ """,
1524
+ PHI3_START_DOCSTRING,
1525
+ )
1526
+ # Copied from transformers.models.mpt.modeling_mpt.MptForTokenClassification with Mpt->Phi3,MPT->PHI3,self.transformer->self.model,transformer_outputs->model_outputs
1527
+ class Phi3ForTokenClassification(Phi3PreTrainedModel):
1528
+ def __init__(self, config: Phi3Config):
1529
+ super().__init__(config)
1530
+ self.num_labels = config.num_labels
1531
+
1532
+ self.model = Phi3Model(config)
1533
+ if hasattr(config, "classifier_dropout") and config.classifier_dropout is not None:
1534
+ classifier_dropout = config.classifier_dropout
1535
+ elif hasattr(config, "hidden_dropout") and config.hidden_dropout is not None:
1536
+ classifier_dropout = config.hidden_dropout
1537
+ else:
1538
+ classifier_dropout = 0.1
1539
+ self.dropout = nn.Dropout(classifier_dropout)
1540
+ self.classifier = nn.Linear(config.hidden_size, config.num_labels)
1541
+
1542
+ # Initialize weights and apply final processing
1543
+ self.post_init()
1544
+
1545
+ @add_start_docstrings_to_model_forward(PHI3_INPUTS_DOCSTRING)
1546
+ @add_code_sample_docstrings(
1547
+ checkpoint=_CHECKPOINT_FOR_DOC,
1548
+ output_type=TokenClassifierOutput,
1549
+ config_class=_CONFIG_FOR_DOC,
1550
+ )
1551
+ def forward(
1552
+ self,
1553
+ input_ids: Optional[torch.LongTensor] = None,
1554
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
1555
+ attention_mask: Optional[torch.Tensor] = None,
1556
+ inputs_embeds: Optional[torch.Tensor] = None,
1557
+ labels: Optional[torch.Tensor] = None,
1558
+ use_cache: Optional[bool] = None,
1559
+ output_attentions: Optional[bool] = None,
1560
+ output_hidden_states: Optional[bool] = None,
1561
+ return_dict: Optional[bool] = None,
1562
+ **deprecated_arguments,
1563
+ ) -> Union[Tuple[torch.Tensor], TokenClassifierOutput]:
1564
+ r"""
1565
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1566
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1567
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1568
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1569
+ """
1570
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1571
+
1572
+ model_outputs = self.model(
1573
+ input_ids,
1574
+ past_key_values=past_key_values,
1575
+ attention_mask=attention_mask,
1576
+ inputs_embeds=inputs_embeds,
1577
+ use_cache=use_cache,
1578
+ output_attentions=output_attentions,
1579
+ output_hidden_states=output_hidden_states,
1580
+ return_dict=return_dict,
1581
+ )
1582
+
1583
+ hidden_states = model_outputs[0]
1584
+ hidden_states = self.dropout(hidden_states)
1585
+ logits = self.classifier(hidden_states)
1586
+
1587
+ loss = None
1588
+ if labels is not None:
1589
+ # move labels to correct device to enable model parallelism
1590
+ labels = labels.to(logits.device)
1591
+ batch_size, seq_length = labels.shape
1592
+ loss_fct = CrossEntropyLoss()
1593
+ loss = loss_fct(
1594
+ logits.view(batch_size * seq_length, self.num_labels), labels.view(batch_size * seq_length)
1595
+ )
1596
+
1597
+ if not return_dict:
1598
+ output = (logits,) + model_outputs[2:]
1599
+ return ((loss,) + output) if loss is not None else output
1600
+
1601
+ return TokenClassifierOutput(
1602
+ loss=loss,
1603
+ logits=logits,
1604
+ hidden_states=model_outputs.hidden_states,
1605
+ attentions=model_outputs.attentions,
1606
+ )
sample_finetune.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
+ # Add an empty system message if there is none
155
+ if messages[0]["role"] != "system":
156
+ messages.insert(0, {"role": "system", "content": ""})
157
+ example["text"] = tokenizer.apply_chat_template(
158
+ messages, tokenize=False, add_generation_prompt=False)
159
+ return example
160
+
161
+ raw_dataset = load_dataset("HuggingFaceH4/ultrachat_200k")
162
+ train_dataset = raw_dataset["train_sft"]
163
+ test_dataset = raw_dataset["test_sft"]
164
+ column_names = list(train_dataset.features)
165
+
166
+ processed_train_dataset = train_dataset.map(
167
+ apply_chat_template,
168
+ fn_kwargs={"tokenizer": tokenizer},
169
+ num_proc=10,
170
+ remove_columns=column_names,
171
+ desc="Applying chat template to train_sft",
172
+ )
173
+
174
+ processed_test_dataset = test_dataset.map(
175
+ apply_chat_template,
176
+ fn_kwargs={"tokenizer": tokenizer},
177
+ num_proc=10,
178
+ remove_columns=column_names,
179
+ desc="Applying chat template to test_sft",
180
+ )
181
+
182
+
183
+ ###########
184
+ # Training
185
+ ###########
186
+ trainer = SFTTrainer(
187
+ model=model,
188
+ args=train_conf,
189
+ peft_config=peft_conf,
190
+ train_dataset=processed_train_dataset,
191
+ eval_dataset=processed_test_dataset,
192
+ max_seq_length=2048,
193
+ dataset_text_field="text",
194
+ tokenizer=tokenizer,
195
+ packing=True
196
+ )
197
+ train_result = trainer.train()
198
+ metrics = train_result.metrics
199
+ trainer.log_metrics("train", metrics)
200
+ trainer.save_metrics("train", metrics)
201
+ trainer.save_state()
202
+
203
+
204
+ #############
205
+ # Evaluation
206
+ #############
207
+ tokenizer.padding_side = 'left'
208
+ metrics = trainer.evaluate()
209
+ metrics["eval_samples"] = len(processed_test_dataset)
210
+ trainer.log_metrics("eval", metrics)
211
+ trainer.save_metrics("eval", metrics)
212
+
213
+
214
+ # ############
215
+ # # Save model
216
+ # ############
217
+ trainer.save_model(train_conf.output_dir)
special_tokens_map.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|begin_of_text|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|end_of_text|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ }
16
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,2062 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "128000": {
4
+ "content": "<|begin_of_text|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "128001": {
12
+ "content": "<|end_of_text|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "128002": {
20
+ "content": "<|reserved_special_token_0|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "128003": {
28
+ "content": "<|reserved_special_token_1|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128004": {
36
+ "content": "<|reserved_special_token_2|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "128005": {
44
+ "content": "<|reserved_special_token_3|>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "128006": {
52
+ "content": "<|start_header_id|>",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ },
59
+ "128007": {
60
+ "content": "<|end_header_id|>",
61
+ "lstrip": false,
62
+ "normalized": false,
63
+ "rstrip": false,
64
+ "single_word": false,
65
+ "special": true
66
+ },
67
+ "128008": {
68
+ "content": "<|reserved_special_token_4|>",
69
+ "lstrip": false,
70
+ "normalized": false,
71
+ "rstrip": false,
72
+ "single_word": false,
73
+ "special": true
74
+ },
75
+ "128009": {
76
+ "content": "<|eot_id|>",
77
+ "lstrip": false,
78
+ "normalized": false,
79
+ "rstrip": false,
80
+ "single_word": false,
81
+ "special": true
82
+ },
83
+ "128010": {
84
+ "content": "<|reserved_special_token_5|>",
85
+ "lstrip": false,
86
+ "normalized": false,
87
+ "rstrip": false,
88
+ "single_word": false,
89
+ "special": true
90
+ },
91
+ "128011": {
92
+ "content": "<|reserved_special_token_6|>",
93
+ "lstrip": false,
94
+ "normalized": false,
95
+ "rstrip": false,
96
+ "single_word": false,
97
+ "special": true
98
+ },
99
+ "128012": {
100
+ "content": "<|reserved_special_token_7|>",
101
+ "lstrip": false,
102
+ "normalized": false,
103
+ "rstrip": false,
104
+ "single_word": false,
105
+ "special": true
106
+ },
107
+ "128013": {
108
+ "content": "<|reserved_special_token_8|>",
109
+ "lstrip": false,
110
+ "normalized": false,
111
+ "rstrip": false,
112
+ "single_word": false,
113
+ "special": true
114
+ },
115
+ "128014": {
116
+ "content": "<|reserved_special_token_9|>",
117
+ "lstrip": false,
118
+ "normalized": false,
119
+ "rstrip": false,
120
+ "single_word": false,
121
+ "special": true
122
+ },
123
+ "128015": {
124
+ "content": "<|reserved_special_token_10|>",
125
+ "lstrip": false,
126
+ "normalized": false,
127
+ "rstrip": false,
128
+ "single_word": false,
129
+ "special": true
130
+ },
131
+ "128016": {
132
+ "content": "<|reserved_special_token_11|>",
133
+ "lstrip": false,
134
+ "normalized": false,
135
+ "rstrip": false,
136
+ "single_word": false,
137
+ "special": true
138
+ },
139
+ "128017": {
140
+ "content": "<|reserved_special_token_12|>",
141
+ "lstrip": false,
142
+ "normalized": false,
143
+ "rstrip": false,
144
+ "single_word": false,
145
+ "special": true
146
+ },
147
+ "128018": {
148
+ "content": "<|reserved_special_token_13|>",
149
+ "lstrip": false,
150
+ "normalized": false,
151
+ "rstrip": false,
152
+ "single_word": false,
153
+ "special": true
154
+ },
155
+ "128019": {
156
+ "content": "<|reserved_special_token_14|>",
157
+ "lstrip": false,
158
+ "normalized": false,
159
+ "rstrip": false,
160
+ "single_word": false,
161
+ "special": true
162
+ },
163
+ "128020": {
164
+ "content": "<|reserved_special_token_15|>",
165
+ "lstrip": false,
166
+ "normalized": false,
167
+ "rstrip": false,
168
+ "single_word": false,
169
+ "special": true
170
+ },
171
+ "128021": {
172
+ "content": "<|reserved_special_token_16|>",
173
+ "lstrip": false,
174
+ "normalized": false,
175
+ "rstrip": false,
176
+ "single_word": false,
177
+ "special": true
178
+ },
179
+ "128022": {
180
+ "content": "<|reserved_special_token_17|>",
181
+ "lstrip": false,
182
+ "normalized": false,
183
+ "rstrip": false,
184
+ "single_word": false,
185
+ "special": true
186
+ },
187
+ "128023": {
188
+ "content": "<|reserved_special_token_18|>",
189
+ "lstrip": false,
190
+ "normalized": false,
191
+ "rstrip": false,
192
+ "single_word": false,
193
+ "special": true
194
+ },
195
+ "128024": {
196
+ "content": "<|reserved_special_token_19|>",
197
+ "lstrip": false,
198
+ "normalized": false,
199
+ "rstrip": false,
200
+ "single_word": false,
201
+ "special": true
202
+ },
203
+ "128025": {
204
+ "content": "<|reserved_special_token_20|>",
205
+ "lstrip": false,
206
+ "normalized": false,
207
+ "rstrip": false,
208
+ "single_word": false,
209
+ "special": true
210
+ },
211
+ "128026": {
212
+ "content": "<|reserved_special_token_21|>",
213
+ "lstrip": false,
214
+ "normalized": false,
215
+ "rstrip": false,
216
+ "single_word": false,
217
+ "special": true
218
+ },
219
+ "128027": {
220
+ "content": "<|reserved_special_token_22|>",
221
+ "lstrip": false,
222
+ "normalized": false,
223
+ "rstrip": false,
224
+ "single_word": false,
225
+ "special": true
226
+ },
227
+ "128028": {
228
+ "content": "<|reserved_special_token_23|>",
229
+ "lstrip": false,
230
+ "normalized": false,
231
+ "rstrip": false,
232
+ "single_word": false,
233
+ "special": true
234
+ },
235
+ "128029": {
236
+ "content": "<|reserved_special_token_24|>",
237
+ "lstrip": false,
238
+ "normalized": false,
239
+ "rstrip": false,
240
+ "single_word": false,
241
+ "special": true
242
+ },
243
+ "128030": {
244
+ "content": "<|reserved_special_token_25|>",
245
+ "lstrip": false,
246
+ "normalized": false,
247
+ "rstrip": false,
248
+ "single_word": false,
249
+ "special": true
250
+ },
251
+ "128031": {
252
+ "content": "<|reserved_special_token_26|>",
253
+ "lstrip": false,
254
+ "normalized": false,
255
+ "rstrip": false,
256
+ "single_word": false,
257
+ "special": true
258
+ },
259
+ "128032": {
260
+ "content": "<|reserved_special_token_27|>",
261
+ "lstrip": false,
262
+ "normalized": false,
263
+ "rstrip": false,
264
+ "single_word": false,
265
+ "special": true
266
+ },
267
+ "128033": {
268
+ "content": "<|reserved_special_token_28|>",
269
+ "lstrip": false,
270
+ "normalized": false,
271
+ "rstrip": false,
272
+ "single_word": false,
273
+ "special": true
274
+ },
275
+ "128034": {
276
+ "content": "<|reserved_special_token_29|>",
277
+ "lstrip": false,
278
+ "normalized": false,
279
+ "rstrip": false,
280
+ "single_word": false,
281
+ "special": true
282
+ },
283
+ "128035": {
284
+ "content": "<|reserved_special_token_30|>",
285
+ "lstrip": false,
286
+ "normalized": false,
287
+ "rstrip": false,
288
+ "single_word": false,
289
+ "special": true
290
+ },
291
+ "128036": {
292
+ "content": "<|reserved_special_token_31|>",
293
+ "lstrip": false,
294
+ "normalized": false,
295
+ "rstrip": false,
296
+ "single_word": false,
297
+ "special": true
298
+ },
299
+ "128037": {
300
+ "content": "<|reserved_special_token_32|>",
301
+ "lstrip": false,
302
+ "normalized": false,
303
+ "rstrip": false,
304
+ "single_word": false,
305
+ "special": true
306
+ },
307
+ "128038": {
308
+ "content": "<|reserved_special_token_33|>",
309
+ "lstrip": false,
310
+ "normalized": false,
311
+ "rstrip": false,
312
+ "single_word": false,
313
+ "special": true
314
+ },
315
+ "128039": {
316
+ "content": "<|reserved_special_token_34|>",
317
+ "lstrip": false,
318
+ "normalized": false,
319
+ "rstrip": false,
320
+ "single_word": false,
321
+ "special": true
322
+ },
323
+ "128040": {
324
+ "content": "<|reserved_special_token_35|>",
325
+ "lstrip": false,
326
+ "normalized": false,
327
+ "rstrip": false,
328
+ "single_word": false,
329
+ "special": true
330
+ },
331
+ "128041": {
332
+ "content": "<|reserved_special_token_36|>",
333
+ "lstrip": false,
334
+ "normalized": false,
335
+ "rstrip": false,
336
+ "single_word": false,
337
+ "special": true
338
+ },
339
+ "128042": {
340
+ "content": "<|reserved_special_token_37|>",
341
+ "lstrip": false,
342
+ "normalized": false,
343
+ "rstrip": false,
344
+ "single_word": false,
345
+ "special": true
346
+ },
347
+ "128043": {
348
+ "content": "<|reserved_special_token_38|>",
349
+ "lstrip": false,
350
+ "normalized": false,
351
+ "rstrip": false,
352
+ "single_word": false,
353
+ "special": true
354
+ },
355
+ "128044": {
356
+ "content": "<|reserved_special_token_39|>",
357
+ "lstrip": false,
358
+ "normalized": false,
359
+ "rstrip": false,
360
+ "single_word": false,
361
+ "special": true
362
+ },
363
+ "128045": {
364
+ "content": "<|reserved_special_token_40|>",
365
+ "lstrip": false,
366
+ "normalized": false,
367
+ "rstrip": false,
368
+ "single_word": false,
369
+ "special": true
370
+ },
371
+ "128046": {
372
+ "content": "<|reserved_special_token_41|>",
373
+ "lstrip": false,
374
+ "normalized": false,
375
+ "rstrip": false,
376
+ "single_word": false,
377
+ "special": true
378
+ },
379
+ "128047": {
380
+ "content": "<|reserved_special_token_42|>",
381
+ "lstrip": false,
382
+ "normalized": false,
383
+ "rstrip": false,
384
+ "single_word": false,
385
+ "special": true
386
+ },
387
+ "128048": {
388
+ "content": "<|reserved_special_token_43|>",
389
+ "lstrip": false,
390
+ "normalized": false,
391
+ "rstrip": false,
392
+ "single_word": false,
393
+ "special": true
394
+ },
395
+ "128049": {
396
+ "content": "<|reserved_special_token_44|>",
397
+ "lstrip": false,
398
+ "normalized": false,
399
+ "rstrip": false,
400
+ "single_word": false,
401
+ "special": true
402
+ },
403
+ "128050": {
404
+ "content": "<|reserved_special_token_45|>",
405
+ "lstrip": false,
406
+ "normalized": false,
407
+ "rstrip": false,
408
+ "single_word": false,
409
+ "special": true
410
+ },
411
+ "128051": {
412
+ "content": "<|reserved_special_token_46|>",
413
+ "lstrip": false,
414
+ "normalized": false,
415
+ "rstrip": false,
416
+ "single_word": false,
417
+ "special": true
418
+ },
419
+ "128052": {
420
+ "content": "<|reserved_special_token_47|>",
421
+ "lstrip": false,
422
+ "normalized": false,
423
+ "rstrip": false,
424
+ "single_word": false,
425
+ "special": true
426
+ },
427
+ "128053": {
428
+ "content": "<|reserved_special_token_48|>",
429
+ "lstrip": false,
430
+ "normalized": false,
431
+ "rstrip": false,
432
+ "single_word": false,
433
+ "special": true
434
+ },
435
+ "128054": {
436
+ "content": "<|reserved_special_token_49|>",
437
+ "lstrip": false,
438
+ "normalized": false,
439
+ "rstrip": false,
440
+ "single_word": false,
441
+ "special": true
442
+ },
443
+ "128055": {
444
+ "content": "<|reserved_special_token_50|>",
445
+ "lstrip": false,
446
+ "normalized": false,
447
+ "rstrip": false,
448
+ "single_word": false,
449
+ "special": true
450
+ },
451
+ "128056": {
452
+ "content": "<|reserved_special_token_51|>",
453
+ "lstrip": false,
454
+ "normalized": false,
455
+ "rstrip": false,
456
+ "single_word": false,
457
+ "special": true
458
+ },
459
+ "128057": {
460
+ "content": "<|reserved_special_token_52|>",
461
+ "lstrip": false,
462
+ "normalized": false,
463
+ "rstrip": false,
464
+ "single_word": false,
465
+ "special": true
466
+ },
467
+ "128058": {
468
+ "content": "<|reserved_special_token_53|>",
469
+ "lstrip": false,
470
+ "normalized": false,
471
+ "rstrip": false,
472
+ "single_word": false,
473
+ "special": true
474
+ },
475
+ "128059": {
476
+ "content": "<|reserved_special_token_54|>",
477
+ "lstrip": false,
478
+ "normalized": false,
479
+ "rstrip": false,
480
+ "single_word": false,
481
+ "special": true
482
+ },
483
+ "128060": {
484
+ "content": "<|reserved_special_token_55|>",
485
+ "lstrip": false,
486
+ "normalized": false,
487
+ "rstrip": false,
488
+ "single_word": false,
489
+ "special": true
490
+ },
491
+ "128061": {
492
+ "content": "<|reserved_special_token_56|>",
493
+ "lstrip": false,
494
+ "normalized": false,
495
+ "rstrip": false,
496
+ "single_word": false,
497
+ "special": true
498
+ },
499
+ "128062": {
500
+ "content": "<|reserved_special_token_57|>",
501
+ "lstrip": false,
502
+ "normalized": false,
503
+ "rstrip": false,
504
+ "single_word": false,
505
+ "special": true
506
+ },
507
+ "128063": {
508
+ "content": "<|reserved_special_token_58|>",
509
+ "lstrip": false,
510
+ "normalized": false,
511
+ "rstrip": false,
512
+ "single_word": false,
513
+ "special": true
514
+ },
515
+ "128064": {
516
+ "content": "<|reserved_special_token_59|>",
517
+ "lstrip": false,
518
+ "normalized": false,
519
+ "rstrip": false,
520
+ "single_word": false,
521
+ "special": true
522
+ },
523
+ "128065": {
524
+ "content": "<|reserved_special_token_60|>",
525
+ "lstrip": false,
526
+ "normalized": false,
527
+ "rstrip": false,
528
+ "single_word": false,
529
+ "special": true
530
+ },
531
+ "128066": {
532
+ "content": "<|reserved_special_token_61|>",
533
+ "lstrip": false,
534
+ "normalized": false,
535
+ "rstrip": false,
536
+ "single_word": false,
537
+ "special": true
538
+ },
539
+ "128067": {
540
+ "content": "<|reserved_special_token_62|>",
541
+ "lstrip": false,
542
+ "normalized": false,
543
+ "rstrip": false,
544
+ "single_word": false,
545
+ "special": true
546
+ },
547
+ "128068": {
548
+ "content": "<|reserved_special_token_63|>",
549
+ "lstrip": false,
550
+ "normalized": false,
551
+ "rstrip": false,
552
+ "single_word": false,
553
+ "special": true
554
+ },
555
+ "128069": {
556
+ "content": "<|reserved_special_token_64|>",
557
+ "lstrip": false,
558
+ "normalized": false,
559
+ "rstrip": false,
560
+ "single_word": false,
561
+ "special": true
562
+ },
563
+ "128070": {
564
+ "content": "<|reserved_special_token_65|>",
565
+ "lstrip": false,
566
+ "normalized": false,
567
+ "rstrip": false,
568
+ "single_word": false,
569
+ "special": true
570
+ },
571
+ "128071": {
572
+ "content": "<|reserved_special_token_66|>",
573
+ "lstrip": false,
574
+ "normalized": false,
575
+ "rstrip": false,
576
+ "single_word": false,
577
+ "special": true
578
+ },
579
+ "128072": {
580
+ "content": "<|reserved_special_token_67|>",
581
+ "lstrip": false,
582
+ "normalized": false,
583
+ "rstrip": false,
584
+ "single_word": false,
585
+ "special": true
586
+ },
587
+ "128073": {
588
+ "content": "<|reserved_special_token_68|>",
589
+ "lstrip": false,
590
+ "normalized": false,
591
+ "rstrip": false,
592
+ "single_word": false,
593
+ "special": true
594
+ },
595
+ "128074": {
596
+ "content": "<|reserved_special_token_69|>",
597
+ "lstrip": false,
598
+ "normalized": false,
599
+ "rstrip": false,
600
+ "single_word": false,
601
+ "special": true
602
+ },
603
+ "128075": {
604
+ "content": "<|reserved_special_token_70|>",
605
+ "lstrip": false,
606
+ "normalized": false,
607
+ "rstrip": false,
608
+ "single_word": false,
609
+ "special": true
610
+ },
611
+ "128076": {
612
+ "content": "<|reserved_special_token_71|>",
613
+ "lstrip": false,
614
+ "normalized": false,
615
+ "rstrip": false,
616
+ "single_word": false,
617
+ "special": true
618
+ },
619
+ "128077": {
620
+ "content": "<|reserved_special_token_72|>",
621
+ "lstrip": false,
622
+ "normalized": false,
623
+ "rstrip": false,
624
+ "single_word": false,
625
+ "special": true
626
+ },
627
+ "128078": {
628
+ "content": "<|reserved_special_token_73|>",
629
+ "lstrip": false,
630
+ "normalized": false,
631
+ "rstrip": false,
632
+ "single_word": false,
633
+ "special": true
634
+ },
635
+ "128079": {
636
+ "content": "<|reserved_special_token_74|>",
637
+ "lstrip": false,
638
+ "normalized": false,
639
+ "rstrip": false,
640
+ "single_word": false,
641
+ "special": true
642
+ },
643
+ "128080": {
644
+ "content": "<|reserved_special_token_75|>",
645
+ "lstrip": false,
646
+ "normalized": false,
647
+ "rstrip": false,
648
+ "single_word": false,
649
+ "special": true
650
+ },
651
+ "128081": {
652
+ "content": "<|reserved_special_token_76|>",
653
+ "lstrip": false,
654
+ "normalized": false,
655
+ "rstrip": false,
656
+ "single_word": false,
657
+ "special": true
658
+ },
659
+ "128082": {
660
+ "content": "<|reserved_special_token_77|>",
661
+ "lstrip": false,
662
+ "normalized": false,
663
+ "rstrip": false,
664
+ "single_word": false,
665
+ "special": true
666
+ },
667
+ "128083": {
668
+ "content": "<|reserved_special_token_78|>",
669
+ "lstrip": false,
670
+ "normalized": false,
671
+ "rstrip": false,
672
+ "single_word": false,
673
+ "special": true
674
+ },
675
+ "128084": {
676
+ "content": "<|reserved_special_token_79|>",
677
+ "lstrip": false,
678
+ "normalized": false,
679
+ "rstrip": false,
680
+ "single_word": false,
681
+ "special": true
682
+ },
683
+ "128085": {
684
+ "content": "<|reserved_special_token_80|>",
685
+ "lstrip": false,
686
+ "normalized": false,
687
+ "rstrip": false,
688
+ "single_word": false,
689
+ "special": true
690
+ },
691
+ "128086": {
692
+ "content": "<|reserved_special_token_81|>",
693
+ "lstrip": false,
694
+ "normalized": false,
695
+ "rstrip": false,
696
+ "single_word": false,
697
+ "special": true
698
+ },
699
+ "128087": {
700
+ "content": "<|reserved_special_token_82|>",
701
+ "lstrip": false,
702
+ "normalized": false,
703
+ "rstrip": false,
704
+ "single_word": false,
705
+ "special": true
706
+ },
707
+ "128088": {
708
+ "content": "<|reserved_special_token_83|>",
709
+ "lstrip": false,
710
+ "normalized": false,
711
+ "rstrip": false,
712
+ "single_word": false,
713
+ "special": true
714
+ },
715
+ "128089": {
716
+ "content": "<|reserved_special_token_84|>",
717
+ "lstrip": false,
718
+ "normalized": false,
719
+ "rstrip": false,
720
+ "single_word": false,
721
+ "special": true
722
+ },
723
+ "128090": {
724
+ "content": "<|reserved_special_token_85|>",
725
+ "lstrip": false,
726
+ "normalized": false,
727
+ "rstrip": false,
728
+ "single_word": false,
729
+ "special": true
730
+ },
731
+ "128091": {
732
+ "content": "<|reserved_special_token_86|>",
733
+ "lstrip": false,
734
+ "normalized": false,
735
+ "rstrip": false,
736
+ "single_word": false,
737
+ "special": true
738
+ },
739
+ "128092": {
740
+ "content": "<|reserved_special_token_87|>",
741
+ "lstrip": false,
742
+ "normalized": false,
743
+ "rstrip": false,
744
+ "single_word": false,
745
+ "special": true
746
+ },
747
+ "128093": {
748
+ "content": "<|reserved_special_token_88|>",
749
+ "lstrip": false,
750
+ "normalized": false,
751
+ "rstrip": false,
752
+ "single_word": false,
753
+ "special": true
754
+ },
755
+ "128094": {
756
+ "content": "<|reserved_special_token_89|>",
757
+ "lstrip": false,
758
+ "normalized": false,
759
+ "rstrip": false,
760
+ "single_word": false,
761
+ "special": true
762
+ },
763
+ "128095": {
764
+ "content": "<|reserved_special_token_90|>",
765
+ "lstrip": false,
766
+ "normalized": false,
767
+ "rstrip": false,
768
+ "single_word": false,
769
+ "special": true
770
+ },
771
+ "128096": {
772
+ "content": "<|reserved_special_token_91|>",
773
+ "lstrip": false,
774
+ "normalized": false,
775
+ "rstrip": false,
776
+ "single_word": false,
777
+ "special": true
778
+ },
779
+ "128097": {
780
+ "content": "<|reserved_special_token_92|>",
781
+ "lstrip": false,
782
+ "normalized": false,
783
+ "rstrip": false,
784
+ "single_word": false,
785
+ "special": true
786
+ },
787
+ "128098": {
788
+ "content": "<|reserved_special_token_93|>",
789
+ "lstrip": false,
790
+ "normalized": false,
791
+ "rstrip": false,
792
+ "single_word": false,
793
+ "special": true
794
+ },
795
+ "128099": {
796
+ "content": "<|reserved_special_token_94|>",
797
+ "lstrip": false,
798
+ "normalized": false,
799
+ "rstrip": false,
800
+ "single_word": false,
801
+ "special": true
802
+ },
803
+ "128100": {
804
+ "content": "<|reserved_special_token_95|>",
805
+ "lstrip": false,
806
+ "normalized": false,
807
+ "rstrip": false,
808
+ "single_word": false,
809
+ "special": true
810
+ },
811
+ "128101": {
812
+ "content": "<|reserved_special_token_96|>",
813
+ "lstrip": false,
814
+ "normalized": false,
815
+ "rstrip": false,
816
+ "single_word": false,
817
+ "special": true
818
+ },
819
+ "128102": {
820
+ "content": "<|reserved_special_token_97|>",
821
+ "lstrip": false,
822
+ "normalized": false,
823
+ "rstrip": false,
824
+ "single_word": false,
825
+ "special": true
826
+ },
827
+ "128103": {
828
+ "content": "<|reserved_special_token_98|>",
829
+ "lstrip": false,
830
+ "normalized": false,
831
+ "rstrip": false,
832
+ "single_word": false,
833
+ "special": true
834
+ },
835
+ "128104": {
836
+ "content": "<|reserved_special_token_99|>",
837
+ "lstrip": false,
838
+ "normalized": false,
839
+ "rstrip": false,
840
+ "single_word": false,
841
+ "special": true
842
+ },
843
+ "128105": {
844
+ "content": "<|reserved_special_token_100|>",
845
+ "lstrip": false,
846
+ "normalized": false,
847
+ "rstrip": false,
848
+ "single_word": false,
849
+ "special": true
850
+ },
851
+ "128106": {
852
+ "content": "<|reserved_special_token_101|>",
853
+ "lstrip": false,
854
+ "normalized": false,
855
+ "rstrip": false,
856
+ "single_word": false,
857
+ "special": true
858
+ },
859
+ "128107": {
860
+ "content": "<|reserved_special_token_102|>",
861
+ "lstrip": false,
862
+ "normalized": false,
863
+ "rstrip": false,
864
+ "single_word": false,
865
+ "special": true
866
+ },
867
+ "128108": {
868
+ "content": "<|reserved_special_token_103|>",
869
+ "lstrip": false,
870
+ "normalized": false,
871
+ "rstrip": false,
872
+ "single_word": false,
873
+ "special": true
874
+ },
875
+ "128109": {
876
+ "content": "<|reserved_special_token_104|>",
877
+ "lstrip": false,
878
+ "normalized": false,
879
+ "rstrip": false,
880
+ "single_word": false,
881
+ "special": true
882
+ },
883
+ "128110": {
884
+ "content": "<|reserved_special_token_105|>",
885
+ "lstrip": false,
886
+ "normalized": false,
887
+ "rstrip": false,
888
+ "single_word": false,
889
+ "special": true
890
+ },
891
+ "128111": {
892
+ "content": "<|reserved_special_token_106|>",
893
+ "lstrip": false,
894
+ "normalized": false,
895
+ "rstrip": false,
896
+ "single_word": false,
897
+ "special": true
898
+ },
899
+ "128112": {
900
+ "content": "<|reserved_special_token_107|>",
901
+ "lstrip": false,
902
+ "normalized": false,
903
+ "rstrip": false,
904
+ "single_word": false,
905
+ "special": true
906
+ },
907
+ "128113": {
908
+ "content": "<|reserved_special_token_108|>",
909
+ "lstrip": false,
910
+ "normalized": false,
911
+ "rstrip": false,
912
+ "single_word": false,
913
+ "special": true
914
+ },
915
+ "128114": {
916
+ "content": "<|reserved_special_token_109|>",
917
+ "lstrip": false,
918
+ "normalized": false,
919
+ "rstrip": false,
920
+ "single_word": false,
921
+ "special": true
922
+ },
923
+ "128115": {
924
+ "content": "<|reserved_special_token_110|>",
925
+ "lstrip": false,
926
+ "normalized": false,
927
+ "rstrip": false,
928
+ "single_word": false,
929
+ "special": true
930
+ },
931
+ "128116": {
932
+ "content": "<|reserved_special_token_111|>",
933
+ "lstrip": false,
934
+ "normalized": false,
935
+ "rstrip": false,
936
+ "single_word": false,
937
+ "special": true
938
+ },
939
+ "128117": {
940
+ "content": "<|reserved_special_token_112|>",
941
+ "lstrip": false,
942
+ "normalized": false,
943
+ "rstrip": false,
944
+ "single_word": false,
945
+ "special": true
946
+ },
947
+ "128118": {
948
+ "content": "<|reserved_special_token_113|>",
949
+ "lstrip": false,
950
+ "normalized": false,
951
+ "rstrip": false,
952
+ "single_word": false,
953
+ "special": true
954
+ },
955
+ "128119": {
956
+ "content": "<|reserved_special_token_114|>",
957
+ "lstrip": false,
958
+ "normalized": false,
959
+ "rstrip": false,
960
+ "single_word": false,
961
+ "special": true
962
+ },
963
+ "128120": {
964
+ "content": "<|reserved_special_token_115|>",
965
+ "lstrip": false,
966
+ "normalized": false,
967
+ "rstrip": false,
968
+ "single_word": false,
969
+ "special": true
970
+ },
971
+ "128121": {
972
+ "content": "<|reserved_special_token_116|>",
973
+ "lstrip": false,
974
+ "normalized": false,
975
+ "rstrip": false,
976
+ "single_word": false,
977
+ "special": true
978
+ },
979
+ "128122": {
980
+ "content": "<|reserved_special_token_117|>",
981
+ "lstrip": false,
982
+ "normalized": false,
983
+ "rstrip": false,
984
+ "single_word": false,
985
+ "special": true
986
+ },
987
+ "128123": {
988
+ "content": "<|reserved_special_token_118|>",
989
+ "lstrip": false,
990
+ "normalized": false,
991
+ "rstrip": false,
992
+ "single_word": false,
993
+ "special": true
994
+ },
995
+ "128124": {
996
+ "content": "<|reserved_special_token_119|>",
997
+ "lstrip": false,
998
+ "normalized": false,
999
+ "rstrip": false,
1000
+ "single_word": false,
1001
+ "special": true
1002
+ },
1003
+ "128125": {
1004
+ "content": "<|reserved_special_token_120|>",
1005
+ "lstrip": false,
1006
+ "normalized": false,
1007
+ "rstrip": false,
1008
+ "single_word": false,
1009
+ "special": true
1010
+ },
1011
+ "128126": {
1012
+ "content": "<|reserved_special_token_121|>",
1013
+ "lstrip": false,
1014
+ "normalized": false,
1015
+ "rstrip": false,
1016
+ "single_word": false,
1017
+ "special": true
1018
+ },
1019
+ "128127": {
1020
+ "content": "<|reserved_special_token_122|>",
1021
+ "lstrip": false,
1022
+ "normalized": false,
1023
+ "rstrip": false,
1024
+ "single_word": false,
1025
+ "special": true
1026
+ },
1027
+ "128128": {
1028
+ "content": "<|reserved_special_token_123|>",
1029
+ "lstrip": false,
1030
+ "normalized": false,
1031
+ "rstrip": false,
1032
+ "single_word": false,
1033
+ "special": true
1034
+ },
1035
+ "128129": {
1036
+ "content": "<|reserved_special_token_124|>",
1037
+ "lstrip": false,
1038
+ "normalized": false,
1039
+ "rstrip": false,
1040
+ "single_word": false,
1041
+ "special": true
1042
+ },
1043
+ "128130": {
1044
+ "content": "<|reserved_special_token_125|>",
1045
+ "lstrip": false,
1046
+ "normalized": false,
1047
+ "rstrip": false,
1048
+ "single_word": false,
1049
+ "special": true
1050
+ },
1051
+ "128131": {
1052
+ "content": "<|reserved_special_token_126|>",
1053
+ "lstrip": false,
1054
+ "normalized": false,
1055
+ "rstrip": false,
1056
+ "single_word": false,
1057
+ "special": true
1058
+ },
1059
+ "128132": {
1060
+ "content": "<|reserved_special_token_127|>",
1061
+ "lstrip": false,
1062
+ "normalized": false,
1063
+ "rstrip": false,
1064
+ "single_word": false,
1065
+ "special": true
1066
+ },
1067
+ "128133": {
1068
+ "content": "<|reserved_special_token_128|>",
1069
+ "lstrip": false,
1070
+ "normalized": false,
1071
+ "rstrip": false,
1072
+ "single_word": false,
1073
+ "special": true
1074
+ },
1075
+ "128134": {
1076
+ "content": "<|reserved_special_token_129|>",
1077
+ "lstrip": false,
1078
+ "normalized": false,
1079
+ "rstrip": false,
1080
+ "single_word": false,
1081
+ "special": true
1082
+ },
1083
+ "128135": {
1084
+ "content": "<|reserved_special_token_130|>",
1085
+ "lstrip": false,
1086
+ "normalized": false,
1087
+ "rstrip": false,
1088
+ "single_word": false,
1089
+ "special": true
1090
+ },
1091
+ "128136": {
1092
+ "content": "<|reserved_special_token_131|>",
1093
+ "lstrip": false,
1094
+ "normalized": false,
1095
+ "rstrip": false,
1096
+ "single_word": false,
1097
+ "special": true
1098
+ },
1099
+ "128137": {
1100
+ "content": "<|reserved_special_token_132|>",
1101
+ "lstrip": false,
1102
+ "normalized": false,
1103
+ "rstrip": false,
1104
+ "single_word": false,
1105
+ "special": true
1106
+ },
1107
+ "128138": {
1108
+ "content": "<|reserved_special_token_133|>",
1109
+ "lstrip": false,
1110
+ "normalized": false,
1111
+ "rstrip": false,
1112
+ "single_word": false,
1113
+ "special": true
1114
+ },
1115
+ "128139": {
1116
+ "content": "<|reserved_special_token_134|>",
1117
+ "lstrip": false,
1118
+ "normalized": false,
1119
+ "rstrip": false,
1120
+ "single_word": false,
1121
+ "special": true
1122
+ },
1123
+ "128140": {
1124
+ "content": "<|reserved_special_token_135|>",
1125
+ "lstrip": false,
1126
+ "normalized": false,
1127
+ "rstrip": false,
1128
+ "single_word": false,
1129
+ "special": true
1130
+ },
1131
+ "128141": {
1132
+ "content": "<|reserved_special_token_136|>",
1133
+ "lstrip": false,
1134
+ "normalized": false,
1135
+ "rstrip": false,
1136
+ "single_word": false,
1137
+ "special": true
1138
+ },
1139
+ "128142": {
1140
+ "content": "<|reserved_special_token_137|>",
1141
+ "lstrip": false,
1142
+ "normalized": false,
1143
+ "rstrip": false,
1144
+ "single_word": false,
1145
+ "special": true
1146
+ },
1147
+ "128143": {
1148
+ "content": "<|reserved_special_token_138|>",
1149
+ "lstrip": false,
1150
+ "normalized": false,
1151
+ "rstrip": false,
1152
+ "single_word": false,
1153
+ "special": true
1154
+ },
1155
+ "128144": {
1156
+ "content": "<|reserved_special_token_139|>",
1157
+ "lstrip": false,
1158
+ "normalized": false,
1159
+ "rstrip": false,
1160
+ "single_word": false,
1161
+ "special": true
1162
+ },
1163
+ "128145": {
1164
+ "content": "<|reserved_special_token_140|>",
1165
+ "lstrip": false,
1166
+ "normalized": false,
1167
+ "rstrip": false,
1168
+ "single_word": false,
1169
+ "special": true
1170
+ },
1171
+ "128146": {
1172
+ "content": "<|reserved_special_token_141|>",
1173
+ "lstrip": false,
1174
+ "normalized": false,
1175
+ "rstrip": false,
1176
+ "single_word": false,
1177
+ "special": true
1178
+ },
1179
+ "128147": {
1180
+ "content": "<|reserved_special_token_142|>",
1181
+ "lstrip": false,
1182
+ "normalized": false,
1183
+ "rstrip": false,
1184
+ "single_word": false,
1185
+ "special": true
1186
+ },
1187
+ "128148": {
1188
+ "content": "<|reserved_special_token_143|>",
1189
+ "lstrip": false,
1190
+ "normalized": false,
1191
+ "rstrip": false,
1192
+ "single_word": false,
1193
+ "special": true
1194
+ },
1195
+ "128149": {
1196
+ "content": "<|reserved_special_token_144|>",
1197
+ "lstrip": false,
1198
+ "normalized": false,
1199
+ "rstrip": false,
1200
+ "single_word": false,
1201
+ "special": true
1202
+ },
1203
+ "128150": {
1204
+ "content": "<|reserved_special_token_145|>",
1205
+ "lstrip": false,
1206
+ "normalized": false,
1207
+ "rstrip": false,
1208
+ "single_word": false,
1209
+ "special": true
1210
+ },
1211
+ "128151": {
1212
+ "content": "<|reserved_special_token_146|>",
1213
+ "lstrip": false,
1214
+ "normalized": false,
1215
+ "rstrip": false,
1216
+ "single_word": false,
1217
+ "special": true
1218
+ },
1219
+ "128152": {
1220
+ "content": "<|reserved_special_token_147|>",
1221
+ "lstrip": false,
1222
+ "normalized": false,
1223
+ "rstrip": false,
1224
+ "single_word": false,
1225
+ "special": true
1226
+ },
1227
+ "128153": {
1228
+ "content": "<|reserved_special_token_148|>",
1229
+ "lstrip": false,
1230
+ "normalized": false,
1231
+ "rstrip": false,
1232
+ "single_word": false,
1233
+ "special": true
1234
+ },
1235
+ "128154": {
1236
+ "content": "<|reserved_special_token_149|>",
1237
+ "lstrip": false,
1238
+ "normalized": false,
1239
+ "rstrip": false,
1240
+ "single_word": false,
1241
+ "special": true
1242
+ },
1243
+ "128155": {
1244
+ "content": "<|reserved_special_token_150|>",
1245
+ "lstrip": false,
1246
+ "normalized": false,
1247
+ "rstrip": false,
1248
+ "single_word": false,
1249
+ "special": true
1250
+ },
1251
+ "128156": {
1252
+ "content": "<|reserved_special_token_151|>",
1253
+ "lstrip": false,
1254
+ "normalized": false,
1255
+ "rstrip": false,
1256
+ "single_word": false,
1257
+ "special": true
1258
+ },
1259
+ "128157": {
1260
+ "content": "<|reserved_special_token_152|>",
1261
+ "lstrip": false,
1262
+ "normalized": false,
1263
+ "rstrip": false,
1264
+ "single_word": false,
1265
+ "special": true
1266
+ },
1267
+ "128158": {
1268
+ "content": "<|reserved_special_token_153|>",
1269
+ "lstrip": false,
1270
+ "normalized": false,
1271
+ "rstrip": false,
1272
+ "single_word": false,
1273
+ "special": true
1274
+ },
1275
+ "128159": {
1276
+ "content": "<|reserved_special_token_154|>",
1277
+ "lstrip": false,
1278
+ "normalized": false,
1279
+ "rstrip": false,
1280
+ "single_word": false,
1281
+ "special": true
1282
+ },
1283
+ "128160": {
1284
+ "content": "<|reserved_special_token_155|>",
1285
+ "lstrip": false,
1286
+ "normalized": false,
1287
+ "rstrip": false,
1288
+ "single_word": false,
1289
+ "special": true
1290
+ },
1291
+ "128161": {
1292
+ "content": "<|reserved_special_token_156|>",
1293
+ "lstrip": false,
1294
+ "normalized": false,
1295
+ "rstrip": false,
1296
+ "single_word": false,
1297
+ "special": true
1298
+ },
1299
+ "128162": {
1300
+ "content": "<|reserved_special_token_157|>",
1301
+ "lstrip": false,
1302
+ "normalized": false,
1303
+ "rstrip": false,
1304
+ "single_word": false,
1305
+ "special": true
1306
+ },
1307
+ "128163": {
1308
+ "content": "<|reserved_special_token_158|>",
1309
+ "lstrip": false,
1310
+ "normalized": false,
1311
+ "rstrip": false,
1312
+ "single_word": false,
1313
+ "special": true
1314
+ },
1315
+ "128164": {
1316
+ "content": "<|reserved_special_token_159|>",
1317
+ "lstrip": false,
1318
+ "normalized": false,
1319
+ "rstrip": false,
1320
+ "single_word": false,
1321
+ "special": true
1322
+ },
1323
+ "128165": {
1324
+ "content": "<|reserved_special_token_160|>",
1325
+ "lstrip": false,
1326
+ "normalized": false,
1327
+ "rstrip": false,
1328
+ "single_word": false,
1329
+ "special": true
1330
+ },
1331
+ "128166": {
1332
+ "content": "<|reserved_special_token_161|>",
1333
+ "lstrip": false,
1334
+ "normalized": false,
1335
+ "rstrip": false,
1336
+ "single_word": false,
1337
+ "special": true
1338
+ },
1339
+ "128167": {
1340
+ "content": "<|reserved_special_token_162|>",
1341
+ "lstrip": false,
1342
+ "normalized": false,
1343
+ "rstrip": false,
1344
+ "single_word": false,
1345
+ "special": true
1346
+ },
1347
+ "128168": {
1348
+ "content": "<|reserved_special_token_163|>",
1349
+ "lstrip": false,
1350
+ "normalized": false,
1351
+ "rstrip": false,
1352
+ "single_word": false,
1353
+ "special": true
1354
+ },
1355
+ "128169": {
1356
+ "content": "<|reserved_special_token_164|>",
1357
+ "lstrip": false,
1358
+ "normalized": false,
1359
+ "rstrip": false,
1360
+ "single_word": false,
1361
+ "special": true
1362
+ },
1363
+ "128170": {
1364
+ "content": "<|reserved_special_token_165|>",
1365
+ "lstrip": false,
1366
+ "normalized": false,
1367
+ "rstrip": false,
1368
+ "single_word": false,
1369
+ "special": true
1370
+ },
1371
+ "128171": {
1372
+ "content": "<|reserved_special_token_166|>",
1373
+ "lstrip": false,
1374
+ "normalized": false,
1375
+ "rstrip": false,
1376
+ "single_word": false,
1377
+ "special": true
1378
+ },
1379
+ "128172": {
1380
+ "content": "<|reserved_special_token_167|>",
1381
+ "lstrip": false,
1382
+ "normalized": false,
1383
+ "rstrip": false,
1384
+ "single_word": false,
1385
+ "special": true
1386
+ },
1387
+ "128173": {
1388
+ "content": "<|reserved_special_token_168|>",
1389
+ "lstrip": false,
1390
+ "normalized": false,
1391
+ "rstrip": false,
1392
+ "single_word": false,
1393
+ "special": true
1394
+ },
1395
+ "128174": {
1396
+ "content": "<|reserved_special_token_169|>",
1397
+ "lstrip": false,
1398
+ "normalized": false,
1399
+ "rstrip": false,
1400
+ "single_word": false,
1401
+ "special": true
1402
+ },
1403
+ "128175": {
1404
+ "content": "<|reserved_special_token_170|>",
1405
+ "lstrip": false,
1406
+ "normalized": false,
1407
+ "rstrip": false,
1408
+ "single_word": false,
1409
+ "special": true
1410
+ },
1411
+ "128176": {
1412
+ "content": "<|reserved_special_token_171|>",
1413
+ "lstrip": false,
1414
+ "normalized": false,
1415
+ "rstrip": false,
1416
+ "single_word": false,
1417
+ "special": true
1418
+ },
1419
+ "128177": {
1420
+ "content": "<|reserved_special_token_172|>",
1421
+ "lstrip": false,
1422
+ "normalized": false,
1423
+ "rstrip": false,
1424
+ "single_word": false,
1425
+ "special": true
1426
+ },
1427
+ "128178": {
1428
+ "content": "<|reserved_special_token_173|>",
1429
+ "lstrip": false,
1430
+ "normalized": false,
1431
+ "rstrip": false,
1432
+ "single_word": false,
1433
+ "special": true
1434
+ },
1435
+ "128179": {
1436
+ "content": "<|reserved_special_token_174|>",
1437
+ "lstrip": false,
1438
+ "normalized": false,
1439
+ "rstrip": false,
1440
+ "single_word": false,
1441
+ "special": true
1442
+ },
1443
+ "128180": {
1444
+ "content": "<|reserved_special_token_175|>",
1445
+ "lstrip": false,
1446
+ "normalized": false,
1447
+ "rstrip": false,
1448
+ "single_word": false,
1449
+ "special": true
1450
+ },
1451
+ "128181": {
1452
+ "content": "<|reserved_special_token_176|>",
1453
+ "lstrip": false,
1454
+ "normalized": false,
1455
+ "rstrip": false,
1456
+ "single_word": false,
1457
+ "special": true
1458
+ },
1459
+ "128182": {
1460
+ "content": "<|reserved_special_token_177|>",
1461
+ "lstrip": false,
1462
+ "normalized": false,
1463
+ "rstrip": false,
1464
+ "single_word": false,
1465
+ "special": true
1466
+ },
1467
+ "128183": {
1468
+ "content": "<|reserved_special_token_178|>",
1469
+ "lstrip": false,
1470
+ "normalized": false,
1471
+ "rstrip": false,
1472
+ "single_word": false,
1473
+ "special": true
1474
+ },
1475
+ "128184": {
1476
+ "content": "<|reserved_special_token_179|>",
1477
+ "lstrip": false,
1478
+ "normalized": false,
1479
+ "rstrip": false,
1480
+ "single_word": false,
1481
+ "special": true
1482
+ },
1483
+ "128185": {
1484
+ "content": "<|reserved_special_token_180|>",
1485
+ "lstrip": false,
1486
+ "normalized": false,
1487
+ "rstrip": false,
1488
+ "single_word": false,
1489
+ "special": true
1490
+ },
1491
+ "128186": {
1492
+ "content": "<|reserved_special_token_181|>",
1493
+ "lstrip": false,
1494
+ "normalized": false,
1495
+ "rstrip": false,
1496
+ "single_word": false,
1497
+ "special": true
1498
+ },
1499
+ "128187": {
1500
+ "content": "<|reserved_special_token_182|>",
1501
+ "lstrip": false,
1502
+ "normalized": false,
1503
+ "rstrip": false,
1504
+ "single_word": false,
1505
+ "special": true
1506
+ },
1507
+ "128188": {
1508
+ "content": "<|reserved_special_token_183|>",
1509
+ "lstrip": false,
1510
+ "normalized": false,
1511
+ "rstrip": false,
1512
+ "single_word": false,
1513
+ "special": true
1514
+ },
1515
+ "128189": {
1516
+ "content": "<|reserved_special_token_184|>",
1517
+ "lstrip": false,
1518
+ "normalized": false,
1519
+ "rstrip": false,
1520
+ "single_word": false,
1521
+ "special": true
1522
+ },
1523
+ "128190": {
1524
+ "content": "<|reserved_special_token_185|>",
1525
+ "lstrip": false,
1526
+ "normalized": false,
1527
+ "rstrip": false,
1528
+ "single_word": false,
1529
+ "special": true
1530
+ },
1531
+ "128191": {
1532
+ "content": "<|reserved_special_token_186|>",
1533
+ "lstrip": false,
1534
+ "normalized": false,
1535
+ "rstrip": false,
1536
+ "single_word": false,
1537
+ "special": true
1538
+ },
1539
+ "128192": {
1540
+ "content": "<|reserved_special_token_187|>",
1541
+ "lstrip": false,
1542
+ "normalized": false,
1543
+ "rstrip": false,
1544
+ "single_word": false,
1545
+ "special": true
1546
+ },
1547
+ "128193": {
1548
+ "content": "<|reserved_special_token_188|>",
1549
+ "lstrip": false,
1550
+ "normalized": false,
1551
+ "rstrip": false,
1552
+ "single_word": false,
1553
+ "special": true
1554
+ },
1555
+ "128194": {
1556
+ "content": "<|reserved_special_token_189|>",
1557
+ "lstrip": false,
1558
+ "normalized": false,
1559
+ "rstrip": false,
1560
+ "single_word": false,
1561
+ "special": true
1562
+ },
1563
+ "128195": {
1564
+ "content": "<|reserved_special_token_190|>",
1565
+ "lstrip": false,
1566
+ "normalized": false,
1567
+ "rstrip": false,
1568
+ "single_word": false,
1569
+ "special": true
1570
+ },
1571
+ "128196": {
1572
+ "content": "<|reserved_special_token_191|>",
1573
+ "lstrip": false,
1574
+ "normalized": false,
1575
+ "rstrip": false,
1576
+ "single_word": false,
1577
+ "special": true
1578
+ },
1579
+ "128197": {
1580
+ "content": "<|reserved_special_token_192|>",
1581
+ "lstrip": false,
1582
+ "normalized": false,
1583
+ "rstrip": false,
1584
+ "single_word": false,
1585
+ "special": true
1586
+ },
1587
+ "128198": {
1588
+ "content": "<|reserved_special_token_193|>",
1589
+ "lstrip": false,
1590
+ "normalized": false,
1591
+ "rstrip": false,
1592
+ "single_word": false,
1593
+ "special": true
1594
+ },
1595
+ "128199": {
1596
+ "content": "<|reserved_special_token_194|>",
1597
+ "lstrip": false,
1598
+ "normalized": false,
1599
+ "rstrip": false,
1600
+ "single_word": false,
1601
+ "special": true
1602
+ },
1603
+ "128200": {
1604
+ "content": "<|reserved_special_token_195|>",
1605
+ "lstrip": false,
1606
+ "normalized": false,
1607
+ "rstrip": false,
1608
+ "single_word": false,
1609
+ "special": true
1610
+ },
1611
+ "128201": {
1612
+ "content": "<|reserved_special_token_196|>",
1613
+ "lstrip": false,
1614
+ "normalized": false,
1615
+ "rstrip": false,
1616
+ "single_word": false,
1617
+ "special": true
1618
+ },
1619
+ "128202": {
1620
+ "content": "<|reserved_special_token_197|>",
1621
+ "lstrip": false,
1622
+ "normalized": false,
1623
+ "rstrip": false,
1624
+ "single_word": false,
1625
+ "special": true
1626
+ },
1627
+ "128203": {
1628
+ "content": "<|reserved_special_token_198|>",
1629
+ "lstrip": false,
1630
+ "normalized": false,
1631
+ "rstrip": false,
1632
+ "single_word": false,
1633
+ "special": true
1634
+ },
1635
+ "128204": {
1636
+ "content": "<|reserved_special_token_199|>",
1637
+ "lstrip": false,
1638
+ "normalized": false,
1639
+ "rstrip": false,
1640
+ "single_word": false,
1641
+ "special": true
1642
+ },
1643
+ "128205": {
1644
+ "content": "<|reserved_special_token_200|>",
1645
+ "lstrip": false,
1646
+ "normalized": false,
1647
+ "rstrip": false,
1648
+ "single_word": false,
1649
+ "special": true
1650
+ },
1651
+ "128206": {
1652
+ "content": "<|reserved_special_token_201|>",
1653
+ "lstrip": false,
1654
+ "normalized": false,
1655
+ "rstrip": false,
1656
+ "single_word": false,
1657
+ "special": true
1658
+ },
1659
+ "128207": {
1660
+ "content": "<|reserved_special_token_202|>",
1661
+ "lstrip": false,
1662
+ "normalized": false,
1663
+ "rstrip": false,
1664
+ "single_word": false,
1665
+ "special": true
1666
+ },
1667
+ "128208": {
1668
+ "content": "<|reserved_special_token_203|>",
1669
+ "lstrip": false,
1670
+ "normalized": false,
1671
+ "rstrip": false,
1672
+ "single_word": false,
1673
+ "special": true
1674
+ },
1675
+ "128209": {
1676
+ "content": "<|reserved_special_token_204|>",
1677
+ "lstrip": false,
1678
+ "normalized": false,
1679
+ "rstrip": false,
1680
+ "single_word": false,
1681
+ "special": true
1682
+ },
1683
+ "128210": {
1684
+ "content": "<|reserved_special_token_205|>",
1685
+ "lstrip": false,
1686
+ "normalized": false,
1687
+ "rstrip": false,
1688
+ "single_word": false,
1689
+ "special": true
1690
+ },
1691
+ "128211": {
1692
+ "content": "<|reserved_special_token_206|>",
1693
+ "lstrip": false,
1694
+ "normalized": false,
1695
+ "rstrip": false,
1696
+ "single_word": false,
1697
+ "special": true
1698
+ },
1699
+ "128212": {
1700
+ "content": "<|reserved_special_token_207|>",
1701
+ "lstrip": false,
1702
+ "normalized": false,
1703
+ "rstrip": false,
1704
+ "single_word": false,
1705
+ "special": true
1706
+ },
1707
+ "128213": {
1708
+ "content": "<|reserved_special_token_208|>",
1709
+ "lstrip": false,
1710
+ "normalized": false,
1711
+ "rstrip": false,
1712
+ "single_word": false,
1713
+ "special": true
1714
+ },
1715
+ "128214": {
1716
+ "content": "<|reserved_special_token_209|>",
1717
+ "lstrip": false,
1718
+ "normalized": false,
1719
+ "rstrip": false,
1720
+ "single_word": false,
1721
+ "special": true
1722
+ },
1723
+ "128215": {
1724
+ "content": "<|reserved_special_token_210|>",
1725
+ "lstrip": false,
1726
+ "normalized": false,
1727
+ "rstrip": false,
1728
+ "single_word": false,
1729
+ "special": true
1730
+ },
1731
+ "128216": {
1732
+ "content": "<|reserved_special_token_211|>",
1733
+ "lstrip": false,
1734
+ "normalized": false,
1735
+ "rstrip": false,
1736
+ "single_word": false,
1737
+ "special": true
1738
+ },
1739
+ "128217": {
1740
+ "content": "<|reserved_special_token_212|>",
1741
+ "lstrip": false,
1742
+ "normalized": false,
1743
+ "rstrip": false,
1744
+ "single_word": false,
1745
+ "special": true
1746
+ },
1747
+ "128218": {
1748
+ "content": "<|reserved_special_token_213|>",
1749
+ "lstrip": false,
1750
+ "normalized": false,
1751
+ "rstrip": false,
1752
+ "single_word": false,
1753
+ "special": true
1754
+ },
1755
+ "128219": {
1756
+ "content": "<|reserved_special_token_214|>",
1757
+ "lstrip": false,
1758
+ "normalized": false,
1759
+ "rstrip": false,
1760
+ "single_word": false,
1761
+ "special": true
1762
+ },
1763
+ "128220": {
1764
+ "content": "<|reserved_special_token_215|>",
1765
+ "lstrip": false,
1766
+ "normalized": false,
1767
+ "rstrip": false,
1768
+ "single_word": false,
1769
+ "special": true
1770
+ },
1771
+ "128221": {
1772
+ "content": "<|reserved_special_token_216|>",
1773
+ "lstrip": false,
1774
+ "normalized": false,
1775
+ "rstrip": false,
1776
+ "single_word": false,
1777
+ "special": true
1778
+ },
1779
+ "128222": {
1780
+ "content": "<|reserved_special_token_217|>",
1781
+ "lstrip": false,
1782
+ "normalized": false,
1783
+ "rstrip": false,
1784
+ "single_word": false,
1785
+ "special": true
1786
+ },
1787
+ "128223": {
1788
+ "content": "<|reserved_special_token_218|>",
1789
+ "lstrip": false,
1790
+ "normalized": false,
1791
+ "rstrip": false,
1792
+ "single_word": false,
1793
+ "special": true
1794
+ },
1795
+ "128224": {
1796
+ "content": "<|reserved_special_token_219|>",
1797
+ "lstrip": false,
1798
+ "normalized": false,
1799
+ "rstrip": false,
1800
+ "single_word": false,
1801
+ "special": true
1802
+ },
1803
+ "128225": {
1804
+ "content": "<|reserved_special_token_220|>",
1805
+ "lstrip": false,
1806
+ "normalized": false,
1807
+ "rstrip": false,
1808
+ "single_word": false,
1809
+ "special": true
1810
+ },
1811
+ "128226": {
1812
+ "content": "<|reserved_special_token_221|>",
1813
+ "lstrip": false,
1814
+ "normalized": false,
1815
+ "rstrip": false,
1816
+ "single_word": false,
1817
+ "special": true
1818
+ },
1819
+ "128227": {
1820
+ "content": "<|reserved_special_token_222|>",
1821
+ "lstrip": false,
1822
+ "normalized": false,
1823
+ "rstrip": false,
1824
+ "single_word": false,
1825
+ "special": true
1826
+ },
1827
+ "128228": {
1828
+ "content": "<|reserved_special_token_223|>",
1829
+ "lstrip": false,
1830
+ "normalized": false,
1831
+ "rstrip": false,
1832
+ "single_word": false,
1833
+ "special": true
1834
+ },
1835
+ "128229": {
1836
+ "content": "<|reserved_special_token_224|>",
1837
+ "lstrip": false,
1838
+ "normalized": false,
1839
+ "rstrip": false,
1840
+ "single_word": false,
1841
+ "special": true
1842
+ },
1843
+ "128230": {
1844
+ "content": "<|reserved_special_token_225|>",
1845
+ "lstrip": false,
1846
+ "normalized": false,
1847
+ "rstrip": false,
1848
+ "single_word": false,
1849
+ "special": true
1850
+ },
1851
+ "128231": {
1852
+ "content": "<|reserved_special_token_226|>",
1853
+ "lstrip": false,
1854
+ "normalized": false,
1855
+ "rstrip": false,
1856
+ "single_word": false,
1857
+ "special": true
1858
+ },
1859
+ "128232": {
1860
+ "content": "<|reserved_special_token_227|>",
1861
+ "lstrip": false,
1862
+ "normalized": false,
1863
+ "rstrip": false,
1864
+ "single_word": false,
1865
+ "special": true
1866
+ },
1867
+ "128233": {
1868
+ "content": "<|reserved_special_token_228|>",
1869
+ "lstrip": false,
1870
+ "normalized": false,
1871
+ "rstrip": false,
1872
+ "single_word": false,
1873
+ "special": true
1874
+ },
1875
+ "128234": {
1876
+ "content": "<|reserved_special_token_229|>",
1877
+ "lstrip": false,
1878
+ "normalized": false,
1879
+ "rstrip": false,
1880
+ "single_word": false,
1881
+ "special": true
1882
+ },
1883
+ "128235": {
1884
+ "content": "<|reserved_special_token_230|>",
1885
+ "lstrip": false,
1886
+ "normalized": false,
1887
+ "rstrip": false,
1888
+ "single_word": false,
1889
+ "special": true
1890
+ },
1891
+ "128236": {
1892
+ "content": "<|reserved_special_token_231|>",
1893
+ "lstrip": false,
1894
+ "normalized": false,
1895
+ "rstrip": false,
1896
+ "single_word": false,
1897
+ "special": true
1898
+ },
1899
+ "128237": {
1900
+ "content": "<|reserved_special_token_232|>",
1901
+ "lstrip": false,
1902
+ "normalized": false,
1903
+ "rstrip": false,
1904
+ "single_word": false,
1905
+ "special": true
1906
+ },
1907
+ "128238": {
1908
+ "content": "<|reserved_special_token_233|>",
1909
+ "lstrip": false,
1910
+ "normalized": false,
1911
+ "rstrip": false,
1912
+ "single_word": false,
1913
+ "special": true
1914
+ },
1915
+ "128239": {
1916
+ "content": "<|reserved_special_token_234|>",
1917
+ "lstrip": false,
1918
+ "normalized": false,
1919
+ "rstrip": false,
1920
+ "single_word": false,
1921
+ "special": true
1922
+ },
1923
+ "128240": {
1924
+ "content": "<|reserved_special_token_235|>",
1925
+ "lstrip": false,
1926
+ "normalized": false,
1927
+ "rstrip": false,
1928
+ "single_word": false,
1929
+ "special": true
1930
+ },
1931
+ "128241": {
1932
+ "content": "<|reserved_special_token_236|>",
1933
+ "lstrip": false,
1934
+ "normalized": false,
1935
+ "rstrip": false,
1936
+ "single_word": false,
1937
+ "special": true
1938
+ },
1939
+ "128242": {
1940
+ "content": "<|reserved_special_token_237|>",
1941
+ "lstrip": false,
1942
+ "normalized": false,
1943
+ "rstrip": false,
1944
+ "single_word": false,
1945
+ "special": true
1946
+ },
1947
+ "128243": {
1948
+ "content": "<|reserved_special_token_238|>",
1949
+ "lstrip": false,
1950
+ "normalized": false,
1951
+ "rstrip": false,
1952
+ "single_word": false,
1953
+ "special": true
1954
+ },
1955
+ "128244": {
1956
+ "content": "<|reserved_special_token_239|>",
1957
+ "lstrip": false,
1958
+ "normalized": false,
1959
+ "rstrip": false,
1960
+ "single_word": false,
1961
+ "special": true
1962
+ },
1963
+ "128245": {
1964
+ "content": "<|reserved_special_token_240|>",
1965
+ "lstrip": false,
1966
+ "normalized": false,
1967
+ "rstrip": false,
1968
+ "single_word": false,
1969
+ "special": true
1970
+ },
1971
+ "128246": {
1972
+ "content": "<|reserved_special_token_241|>",
1973
+ "lstrip": false,
1974
+ "normalized": false,
1975
+ "rstrip": false,
1976
+ "single_word": false,
1977
+ "special": true
1978
+ },
1979
+ "128247": {
1980
+ "content": "<|reserved_special_token_242|>",
1981
+ "lstrip": false,
1982
+ "normalized": false,
1983
+ "rstrip": false,
1984
+ "single_word": false,
1985
+ "special": true
1986
+ },
1987
+ "128248": {
1988
+ "content": "<|reserved_special_token_243|>",
1989
+ "lstrip": false,
1990
+ "normalized": false,
1991
+ "rstrip": false,
1992
+ "single_word": false,
1993
+ "special": true
1994
+ },
1995
+ "128249": {
1996
+ "content": "<|reserved_special_token_244|>",
1997
+ "lstrip": false,
1998
+ "normalized": false,
1999
+ "rstrip": false,
2000
+ "single_word": false,
2001
+ "special": true
2002
+ },
2003
+ "128250": {
2004
+ "content": "<|reserved_special_token_245|>",
2005
+ "lstrip": false,
2006
+ "normalized": false,
2007
+ "rstrip": false,
2008
+ "single_word": false,
2009
+ "special": true
2010
+ },
2011
+ "128251": {
2012
+ "content": "<|reserved_special_token_246|>",
2013
+ "lstrip": false,
2014
+ "normalized": false,
2015
+ "rstrip": false,
2016
+ "single_word": false,
2017
+ "special": true
2018
+ },
2019
+ "128252": {
2020
+ "content": "<|reserved_special_token_247|>",
2021
+ "lstrip": false,
2022
+ "normalized": false,
2023
+ "rstrip": false,
2024
+ "single_word": false,
2025
+ "special": true
2026
+ },
2027
+ "128253": {
2028
+ "content": "<|reserved_special_token_248|>",
2029
+ "lstrip": false,
2030
+ "normalized": false,
2031
+ "rstrip": false,
2032
+ "single_word": false,
2033
+ "special": true
2034
+ },
2035
+ "128254": {
2036
+ "content": "<|reserved_special_token_249|>",
2037
+ "lstrip": false,
2038
+ "normalized": false,
2039
+ "rstrip": false,
2040
+ "single_word": false,
2041
+ "special": true
2042
+ },
2043
+ "128255": {
2044
+ "content": "<|reserved_special_token_250|>",
2045
+ "lstrip": false,
2046
+ "normalized": false,
2047
+ "rstrip": false,
2048
+ "single_word": false,
2049
+ "special": true
2050
+ }
2051
+ },
2052
+ "bos_token": "<|begin_of_text|>",
2053
+ "chat_template": "{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}{% endif %}",
2054
+ "clean_up_tokenization_spaces": true,
2055
+ "eos_token": "<|end_of_text|>",
2056
+ "model_input_names": [
2057
+ "input_ids",
2058
+ "attention_mask"
2059
+ ],
2060
+ "model_max_length": 1000000000000000019884624838656,
2061
+ "tokenizer_class": "PreTrainedTokenizerFast"
2062
+ }