camenduru commited on
Commit
eb368e7
1 Parent(s): 4662b13

thanks to Qwen ❤

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/hfagent_chat_1.png filter=lfs diff=lfs merge=lfs -text
37
+ assets/hfagent_chat_2.png filter=lfs diff=lfs merge=lfs -text
38
+ assets/hfagent_run.png filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Tongyi Qianwen LICENSE AGREEMENT
2
+
3
+ Tongyi Qianwen Release Date: August 3, 2023
4
+
5
+ By clicking to agree or by using or distributing any portion or element of the Tongyi Qianwen Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
6
+
7
+ 1. Definitions
8
+ a. This Tongyi Qianwen LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
9
+ b. "We"(or "Us") shall mean Alibaba Cloud.
10
+ c. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
11
+ d. "Third Parties" shall mean individuals or legal entities that are not under common control with Us or You.
12
+ e. "Tongyi Qianwen" shall mean the large language models (including Qwen model and Qwen-Chat model), and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by Us.
13
+ f. "Materials" shall mean, collectively, Alibaba Cloud's proprietary Tongyi Qianwen and Documentation (and any portion thereof) made available under this Agreement.
14
+ g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
15
+ h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation,
16
+ and conversions to other media types.
17
+
18
+ 2. Grant of Rights
19
+ You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Alibaba Cloud's intellectual property or other rights owned by Us embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials.
20
+
21
+ 3. Redistribution
22
+ You may reproduce and distribute copies of the Materials or derivative works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
23
+ a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
24
+ b. You shall cause any modified files to carry prominent notices stating that You changed the files;
25
+ c. You shall retain in all copies of the Materials that You distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "Tongyi Qianwen is licensed under the Tongyi Qianwen LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved."; and
26
+ d. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such derivative works as a whole, provided Your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
27
+
28
+ 4. Restrictions
29
+ If you are commercially using the Materials, and your product or service has more than 100 million monthly active users, You shall request a license from Us. You cannot exercise your rights under this Agreement without our express authorization.
30
+
31
+ 5. Rules of use
32
+ a. The Materials may be subject to export controls or restrictions in China, the United States or other countries or regions. You shall comply with applicable laws and regulations in your use of the Materials.
33
+ b. You can not use the Materials or any output therefrom to improve any other large language model (excluding Tongyi Qianwen or derivative works thereof).
34
+
35
+ 6. Intellectual Property
36
+ a. We retain ownership of all intellectual property rights in and to the Materials and derivatives made by or for Us. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by you, you are and will be the owner of such derivative works and modifications.
37
+ b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Us, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
38
+ c. If you commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against Us or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by you, then all licences granted to you under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
39
+
40
+ 7. Disclaimer of Warranty and Limitation of Liability
41
+
42
+ a. We are not obligated to support, update, provide training for, or develop any further version of the Tongyi Qianwen Materials or to grant any license thereto.
43
+ b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
44
+ c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
45
+ d. You will defend, indemnify and hold harmless Us from and against any claim by any third party arising out of or related to your use or distribution of the Materials.
46
+
47
+ 8. Survival and Termination.
48
+ a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
49
+ b. We may terminate this Agreement if you breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, you must delete and cease use of the Materials. Sections 7 and 9 shall survive the termination of this Agreement.
50
+
51
+ 9. Governing Law and Jurisdiction.
52
+ a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
53
+ b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
NOTICE ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ------------- LICENSE FOR NVIDIA Megatron-LM code --------------
2
+
3
+ Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions
7
+ are met:
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ * Neither the name of NVIDIA CORPORATION nor the names of its
14
+ contributors may be used to endorse or promote products derived
15
+ from this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
18
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+
30
+ ------------- LICENSE FOR OpenAI tiktoken code --------------
31
+
32
+ MIT License
33
+
34
+ Copyright (c) 2022 OpenAI, Shantanu Jain
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining a copy
37
+ of this software and associated documentation files (the "Software"), to deal
38
+ in the Software without restriction, including without limitation the rights
39
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40
+ copies of the Software, and to permit persons to whom the Software is
41
+ furnished to do so, subject to the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be included in all
44
+ copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,584 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ - en
5
+ tags:
6
+ - qwen
7
+ pipeline_tag: text-generation
8
+ inference: false
9
+ ---
10
+
11
+ # Qwen-14B-Chat-Int4
12
+
13
+ <p align="center">
14
+ <img src="https://qianwen-res.oss-cn-beijing.aliyuncs.com/logo_qwen.jpg" width="400"/>
15
+ <p>
16
+ <br>
17
+
18
+ <p align="center">
19
+ 🤗 <a href="https://huggingface.co/Qwen">Hugging Face</a>&nbsp&nbsp | &nbsp&nbsp🤖 <a href="https://modelscope.cn/models/qwen">ModelScope<a>&nbsp&nbsp | &nbsp&nbsp 📑 Paper&nbsp&nbsp | &nbsp&nbsp🖥️ <a href="https://modelscope.cn/studios/qwen/Qwen-7B-Chat-Demo/summary">Demo</a>
20
+ <br>
21
+ <a href="https://github.com/QwenLM/Qwen/blob/main/assets/wechat.png">WeChat (微信)</a>&nbsp&nbsp | &nbsp&nbsp DingTalk (钉钉) &nbsp&nbsp | &nbsp&nbsp<a href="https://discord.gg/z3GAxXZ9Ce">Discord</a>&nbsp&nbsp
22
+ </p>
23
+ <br>
24
+
25
+ ## 介绍(Introduction)
26
+
27
+ **通义千问-14B(Qwen-14B)**是阿里云研发的通义千问大模型系列的140亿参数规模的模型。Qwen-14B是基于Transformer的大语言模型, 在超大规模的预训练数据上进行训练得到。预训练数据类型多样,覆盖广泛,包括大量网络文本、专业书籍、代码等。同时,在Qwen-14B的基础上,我们使用对齐机制打造了基于大语言模型的AI助手Qwen-14B-Chat。本仓库为Qwen-14B-Chat的Int4量化模型的仓库。
28
+
29
+ 如果您想了解更多关于通义千问-14B开源模型的细节,我们建议您参阅[Github代码库](https://github.com/QwenLM/Qwen)。
30
+
31
+ **Qwen-14B** is the 14B-parameter version of the large language model series, Qwen (abbr. Tongyi Qianwen), proposed by Alibaba Cloud. Qwen-14B is a Transformer-based large language model, which is pretrained on a large volume of data, including web texts, books, codes, etc. Additionally, based on the pretrained Qwen-14B, we release Qwen-14B-Chat, a large-model-based AI assistant, which is trained with alignment techniques. This repository is the one for the Int4 quantized model of Qwen-14B-Chat.
32
+
33
+ For more details about the open-source model of Qwen-14B, please refer to the [Github](https://github.com/QwenLM/Qwen) code repository.
34
+ <br>
35
+
36
+
37
+ ## 要求(Requirements)
38
+
39
+ * python 3.8及以上版本
40
+ * pytorch 2.0及以上版本,推荐2.0及以上版本
41
+ * 建议使用CUDA 11.4及以上(GPU用户、flash-attention用户等需考虑此选项)
42
+ * python 3.8 and above
43
+ * pytorch 2.0 and above, 2.0 and above are recommended
44
+ * CUDA 11.4 and above are recommended (this is for GPU users, flash-attention users, etc.)
45
+ <br>
46
+
47
+
48
+ ## 依赖项(Dependency)
49
+
50
+ 运行Qwen-14B-Chat-Int4,请确保满足上述要求,再执行以下pip命令安装依赖库。如安装`auto-gptq`遇到问题,我们建议您到官方[repo](https://github.com/PanQiWei/AutoGPTQ)搜索合适的预编译wheel。
51
+
52
+ To run Qwen-14B-Chat-Int4, please make sure you meet the above requirements, and then execute the following pip commands to install the dependent libraries. If you meet problems installing `auto-gptq`, we advise you to check out the official [repo](https://github.com/PanQiWei/AutoGPTQ) to find a pre-build wheel.
53
+
54
+ ```bash
55
+ pip install transformers==4.32.0 accelerate tiktoken einops scipy transformers_stream_generator==0.0.4 peft deepspeed
56
+ pip install auto-gptq optimum
57
+ ```
58
+
59
+ 另外,推荐安装`flash-attention`库,以实现更高的效率和更低的显存占用。
60
+
61
+ In addition, it is recommended to install the `flash-attention` library for higher efficiency and lower memory usage.
62
+
63
+ ```bash
64
+ git clone -b v1.0.8 https://github.com/Dao-AILab/flash-attention
65
+ cd flash-attention && pip install .
66
+ # 下方安装可选,安装可能比较缓慢。
67
+ # Below are optional. Installing them might be slow.
68
+ # pip install csrc/layer_norm
69
+ # pip install csrc/rotary
70
+ ```
71
+ <br>
72
+
73
+
74
+
75
+ ## 快速使用(Quickstart)
76
+
77
+ 下面我们展示了一个使用Qwen-14B-Chat-Int4模型的样例:
78
+
79
+ We show an example of how to use Qwen-14B-Chat-Int4 in the following code:
80
+
81
+ ```python
82
+ from transformers import AutoTokenizer, AutoModelForCausalLM
83
+
84
+ # Note: The default behavior now has injection attack prevention off.
85
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen-14B-Chat-Int4", trust_remote_code=True)
86
+
87
+ model = AutoModelForCausalLM.from_pretrained(
88
+ "Qwen/Qwen-14B-Chat-Int4",
89
+ device_map="auto",
90
+ trust_remote_code=True
91
+ ).eval()
92
+ response, history = model.chat(tokenizer, "你好", history=None)
93
+ print(response)
94
+ # 你好!很高兴为你提供帮助。
95
+ ```
96
+
97
+ 关于更多的使用说明,请参考我们的[Github repo](https://github.com/QwenLM/Qwen)获取更多信息。
98
+
99
+ For more information, please refer to our [Github repo](https://github.com/QwenLM/Qwen) for more information.
100
+ <br>
101
+
102
+
103
+
104
+ ## 量化 (Quantization)
105
+
106
+ ### 效果评测
107
+
108
+ 我们对BF16和Int4模型在基准评测上做了测试(使用zero-shot设置),发现量化模型效果损失较小,结果如下所示:
109
+
110
+ We illustrate the zero-shot performance of both BF16 and Int4 models on the benchmark, and we find that the quantized model does not suffer from significant performance degradation. Results are shown below:
111
+
112
+ | Quantization | MMLU | CEval (val) | GSM8K | Humaneval |
113
+ | ------------- | :--------: | :----------: | :----: | :--------: |
114
+ | BF16 | 64.6 | 69.8 | 61.0 | 43.9 |
115
+ | Int4 | 63.3 | 69.0 | 59.8 | 45.7 |
116
+
117
+ ### 推理速度 (Inference Speed)
118
+
119
+ 我们测算了BF16和Int4模型生成2048和8192个token的平均推理速度。如图所示:
120
+
121
+ We measured the average inference speed of generating 2048 and 8192 tokens under BF16 precision and Int4 quantization level, respectively.
122
+
123
+ | Quantization | Speed (2048 tokens) | Speed (8192 tokens) |
124
+ | ------------- | :------------------:| :------------------:|
125
+ | BF16 | 30.70 | 21.73 |
126
+ | Int4 | 37.11 | 26.11 |
127
+
128
+ 具体而言,我们记录在长度为1的上下文的条件下生成8192个token的性能。评测运行于单张A100-SXM4-80G GPU,使用PyTorch 2.0.1和CUDA 11.4。推理速度是生成8192个token的速度均值。
129
+
130
+ In detail, the setting of profiling is generating 8192 new tokens with 1 context token. The profiling runs on a single A100-SXM4-80G GPU with PyTorch 2.0.1 and CUDA 11.4. The inference speed is averaged over the generated 8192 tokens.
131
+
132
+ ### 显存使用 (GPU Memory Usage)
133
+
134
+ 我们还测算了BF16和Int4模型编码2048个token及生成8192个token的峰值显存占用情况。结果如下所示:
135
+
136
+ We also profile the peak GPU memory usage for encoding 2048 tokens as context (and generating single token) and generating 8192 tokens (with single token as context) under BF16 or Int4 quantization level, respectively. The results are shown below.
137
+
138
+ | Quantization Level | Peak Usage for Encoding 2048 Tokens | Peak Usage for Generating 8192 Tokens |
139
+ | ------------------ | :---------------------------------: | :-----------------------------------: |
140
+ | BF16 | 30.15GB | 38.94GB |
141
+ | Int4 | 13.00GB | 21.79GB |
142
+
143
+ 上述性能测算使用[此脚本](https://qianwen-res.oss-cn-beijing.aliyuncs.com/profile.py)完成。
144
+
145
+ The above speed and memory profiling are conducted using [this script](https://qianwen-res.oss-cn-beijing.aliyuncs.com/profile.py).
146
+ <br>
147
+
148
+ ## Tokenizer
149
+
150
+ > 注:作为术语的“tokenization”在中文中尚无共识的概念对应,本文档采用英文表达以利说明。
151
+
152
+ 基于tiktoken的分词器有别于其他分词器,比如sentencepiece分词器。尤其在微调阶段,需要特别注意特殊token的使用。关于tokenizer的更多信息,以及微调时涉及的相关使用,请参阅[文档](https://github.com/QwenLM/Qwen/blob/main/tokenization_note_zh.md)。
153
+
154
+ Our tokenizer based on tiktoken is different from other tokenizers, e.g., sentencepiece tokenizer. You need to pay attention to special tokens, especially in finetuning. For more detailed information on the tokenizer and related use in fine-tuning, please refer to the [documentation](https://github.com/QwenLM/Qwen/blob/main/tokenization_note.md).
155
+ <br>
156
+
157
+
158
+
159
+ ## 模型细节(Model)
160
+
161
+ 与Qwen-14B预训练模型相同,Qwen-14B-Chat模型规模基本情况如下所示
162
+
163
+ The details of the model architecture of Qwen-14B-Chat are listed as follows
164
+
165
+ | Hyperparameter | Value |
166
+ | :------------- | :----: |
167
+ | n_layers | 40 |
168
+ | n_heads | 40 |
169
+ | d_model | 5120 |
170
+ | vocab size | 151851 |
171
+ | sequence length | 2048 |
172
+
173
+ 在位置编码、FFN激活函数和normalization的实现方式上,我们也采用了目前最流行的做法,
174
+ 即RoPE相对位置编码、SwiGLU激活函数、RMSNorm(可选安装flash-attention加速)。
175
+
176
+ 在分词器方面,相比目前主流开源模型以中英词表为主,Qwen-14B-Chat使用了约15万token大小的词表。
177
+ 该词表在GPT-4使用的BPE词表`cl100k_base`基础上,对中文、多语言进行了优化,在对中、英、代码数据的高效编解码的基础上,对部分多语言更加友好,方便用户在不扩展词表的情况下对部分语种进行能力增强。
178
+ 词表对数字按单个数字位切分。调用较为高效的[tiktoken分词库](https://github.com/openai/tiktoken)进行分词。
179
+
180
+ For position encoding, FFN activation function, and normalization calculation methods, we adopt the prevalent practices, i.e., RoPE relative position encoding, SwiGLU for activation function, and RMSNorm for normalization (optional installation of flash-attention for acceleration).
181
+
182
+ For tokenization, compared to the current mainstream open-source models based on Chinese and English vocabularies, Qwen-14B-Chat uses a vocabulary of over 150K tokens.
183
+ It first considers efficient encoding of Chinese, English, and code data, and is also more friendly to multilingual languages, enabling users to directly enhance the capability of some languages without expanding the vocabulary.
184
+ It segments numbers by single digit, and calls the [tiktoken](https://github.com/openai/tiktoken) tokenizer library for efficient tokenization.
185
+ <br>
186
+
187
+
188
+
189
+ ## 评测效果(Evaluation)
190
+
191
+ 对于Qwen-14B-Chat模型,我们同样评测了常规的中文理解(C-Eval)、英文理解(MMLU)、代码(HumanEval)和数学(GSM8K)等权威任务,同时包含了长序列任务的评测结果。由于Qwen-14B-Chat模型经过对齐后,激发了较强的外部系统调用能力,我们还进行了工具使用能力方面的评测。
192
+
193
+ 提示:由于硬件和框架造成的舍入误差,复现结果如有波动属于正常现象。
194
+
195
+ For Qwen-14B-Chat, we also evaluate the model on C-Eval, MMLU, HumanEval, GSM8K, etc., as well as the benchmark evaluation for long-context understanding, and tool usage.
196
+
197
+ Note: Due to rounding errors caused by hardware and framework, differences in reproduced results are possible.
198
+
199
+ ### 中文评测(Chinese Evaluation)
200
+
201
+ #### C-Eval
202
+
203
+ 在[C-Eval](https://arxiv.org/abs/2305.08322)验证集上,我们评价了Qwen-14B-Chat模型的0-shot & 5-shot准确率
204
+
205
+ We demonstrate the 0-shot & 5-shot accuracy of Qwen-14B-Chat on C-Eval validation set
206
+
207
+ | Model | Avg. Acc. |
208
+ |:--------------------------------:| :-------: |
209
+ | LLaMA2-7B-Chat | 31.9 |
210
+ | LLaMA2-13B-Chat | 36.2 |
211
+ | LLaMA2-70B-Chat | 44.3 |
212
+ | ChatGLM2-6B-Chat | 52.6 |
213
+ | InternLM-7B-Chat | 53.6 |
214
+ | Baichuan2-7B-Chat | 55.6 |
215
+ | Baichuan2-13B-Chat | 56.7 |
216
+ | Qwen-7B-Chat (original) (0-shot) | 54.2 |
217
+ | **Qwen-7B-Chat (0-shot)** | 59.7 |
218
+ | **Qwen-7B-Chat (5-shot)** | 59.3 |
219
+ | **Qwen-14B-Chat (0-shot)** | 69.8 |
220
+ | **Qwen-14B-Chat (5-shot)** | **71.7** |
221
+
222
+ C-Eval测试集上,Qwen-14B-Chat模型的zero-shot准确率结果如下:
223
+
224
+ The zero-shot accuracy of Qwen-14B-Chat on C-Eval testing set is provided below:
225
+
226
+ | Model | Avg. | STEM | Social Sciences | Humanities | Others |
227
+ | :---------------------- | :------: | :--: | :-------------: | :--------: | :----: |
228
+ | Chinese-Alpaca-Plus-13B | 41.5 | 36.6 | 49.7 | 43.1 | 41.2 |
229
+ | Chinese-Alpaca-2-7B | 40.3 | - | - | - | - |
230
+ | ChatGLM2-6B-Chat | 50.1 | 46.4 | 60.4 | 50.6 | 46.9 |
231
+ | Baichuan-13B-Chat | 51.5 | 43.7 | 64.6 | 56.2 | 49.2 |
232
+ | Qwen-7B-Chat (original) | 54.6 | 47.8 | 67.6 | 59.3 | 50.6 |
233
+ | **Qwen-7B-Chat** | 58.6 | 53.3 | 72.1 | 62.8 | 52.0 |
234
+ | **Qwen-14B-Chat** | **69.1** | 65.1 | 80.9 | 71.2 | 63.4 |
235
+
236
+ 在14B规模模型上,经过人类指令对齐的Qwen-14B-Chat模型,准确率在同类相近规模模型中仍然处于前列。
237
+
238
+ Compared with other pretrained models with comparable model size, the human-aligned Qwen-14B-Chat performs well in C-Eval accuracy.
239
+
240
+ ### 英文评测(English Evaluation)
241
+
242
+ #### MMLU
243
+
244
+ [MMLU](https://arxiv.org/abs/2009.03300)评测集上,Qwen-14B-Chat模型的 0-shot & 5-shot 准确率如下,效果同样在同类对齐模型中同样表现较优。
245
+
246
+ The 0-shot & 5-shot accuracy of Qwen-14B-Chat on MMLU is provided below.
247
+ The performance of Qwen-14B-Chat still on the top between other human-aligned models with comparable size.
248
+
249
+ | Model | Avg. Acc. |
250
+ |:--------------------------------:| :-------: |
251
+ | ChatGLM2-6B-Chat | 46.0 |
252
+ | LLaMA2-7B-Chat | 46.2 |
253
+ | InternLM-7B-Chat | 51.1 |
254
+ | Baichuan2-7B-Chat | 52.9 |
255
+ | LLaMA2-13B-Chat | 54.6 |
256
+ | Baichuan2-13B-Chat | 57.3 |
257
+ | LLaMA2-70B-Chat | 63.8 |
258
+ | Qwen-7B-Chat (original) (0-shot) | 53.9 |
259
+ | **Qwen-7B-Chat (0-shot)** | 55.8 |
260
+ | **Qwen-7B-Chat (5-shot)** | 57.0 |
261
+ | **Qwen-14B-Chat (0-shot)** | 64.6 |
262
+ | **Qwen-14B-Chat (5-shot)** | **66.5** |
263
+
264
+ ### 代码评测(Coding Evaluation)
265
+
266
+ Qwen-14B-Chat在[HumanEval](https://github.com/openai/human-eval)的zero-shot Pass@1效果如下
267
+
268
+ The zero-shot Pass@1 of Qwen-14B-Chat on [HumanEval](https://github.com/openai/human-eval) is demonstrated below
269
+
270
+ | Model | Pass@1 |
271
+ |:-----------------------:| :-------: |
272
+ | ChatGLM2-6B-Chat | 11.0 |
273
+ | LLaMA2-7B-Chat | 12.2 |
274
+ | InternLM-7B-Chat | 14.6 |
275
+ | Baichuan2-7B-Chat | 13.4 |
276
+ | LLaMA2-13B-Chat | 18.9 |
277
+ | Baichuan2-13B-Chat | 17.7 |
278
+ | LLaMA2-70B-Chat | 32.3 |
279
+ | Qwen-7B-Chat (original) | 24.4 |
280
+ | **Qwen-7B-Chat** | 37.2 |
281
+ | **Qwen-14B-Chat** | **43.9** |
282
+
283
+ ### 数学评测(Mathematics Evaluation)
284
+
285
+ 在评测数学能力的[GSM8K](https://github.com/openai/grade-school-math)上,Qwen-14B-Chat的���确率结果如下
286
+
287
+ The accuracy of Qwen-14B-Chat on GSM8K is shown below
288
+
289
+ | Model | Acc. |
290
+ |:--------------------------------:| :-------: |
291
+ | LLaMA2-7B-Chat | 26.3 |
292
+ | ChatGLM2-6B-Chat | 28.8 |
293
+ | Baichuan2-7B-Chat | 32.8 |
294
+ | InternLM-7B-Chat | 33.0 |
295
+ | LLaMA2-13B-Chat | 37.1 |
296
+ | Baichuan2-13B-Chat | 55.3 |
297
+ | LLaMA2-70B-Chat | 59.3 |
298
+ | Qwen-7B-Chat (original) (0-shot) | 41.1 |
299
+ | **Qwen-7B-Chat (0-shot)** | 50.3 |
300
+ | **Qwen-7B-Chat (8-shot)** | 54.1 |
301
+ | **Qwen-14B-Chat (0-shot)** | **60.1** |
302
+ | **Qwen-14B-Chat (8-shot)** | 59.3 |
303
+
304
+ ### 长序列评测(Long-Context Understanding)
305
+
306
+ 通过NTK插值,LogN注意力缩放可以扩展Qwen-14B-Chat的上下文长度。在长文本摘要数据集[VCSUM](https://arxiv.org/abs/2305.05280)上(文本平均长度在15K左右),Qwen-14B-Chat的Rouge-L结果如下:
307
+
308
+ **(若要启用这些技巧,请将config.json里的`use_dynamic_ntk`和`use_logn_attn`设置为true)**
309
+
310
+ We introduce NTK-aware interpolation, LogN attention scaling to extend the context length of Qwen-14B-Chat. The Rouge-L results of Qwen-14B-Chat on long-text summarization dataset [VCSUM](https://arxiv.org/abs/2305.05280) (The average length of this dataset is around 15K) are shown below:
311
+
312
+ **(To use these tricks, please set `use_dynamic_ntk` and `use_long_attn` to true in config.json.)**
313
+
314
+ | Model | VCSUM (zh) |
315
+ |:------------------|:----------:|
316
+ | GPT-3.5-Turbo-16k | 16.0 |
317
+ | LLama2-7B-Chat | 0.2 |
318
+ | InternLM-7B-Chat | 13.0 |
319
+ | ChatGLM2-6B-Chat | 16.3 |
320
+ | **Qwen-14B-Chat** | **17.3** |
321
+
322
+
323
+ ### 工具使用能力的评测(Tool Usage)
324
+
325
+ #### ReAct Prompting
326
+
327
+ 千问支持通过 [ReAct Prompting](https://arxiv.org/abs/2210.03629) 调用插件/工具/API。ReAct 也是 [LangChain](https://python.langchain.com/) 框架采用的主要方式之一。在我们开源的、用于评估工具使用能力的评测基准上,千问的表现如下:
328
+
329
+ Qwen-Chat supports calling plugins/tools/APIs through [ReAct Prompting](https://arxiv.org/abs/2210.03629). ReAct is also one of the main approaches used by the [LangChain](https://python.langchain.com/) framework. In our evaluation benchmark for assessing tool usage capabilities, Qwen-Chat's performance is as follows:
330
+
331
+ <table>
332
+ <tr>
333
+ <th colspan="4" align="center">Chinese Tool-Use Benchmark</th>
334
+ </tr>
335
+ <tr>
336
+ <th align="center">Model</th><th align="center">Tool Selection (Acc.↑)</th><th align="center">Tool Input (Rouge-L↑)</th><th align="center">False Positive Error↓</th>
337
+ </tr>
338
+ <tr>
339
+ <td>GPT-4</td><td align="center">95%</td><td align="center">0.90</td><td align="center">15.0%</td>
340
+ </tr>
341
+ <tr>
342
+ <td>GPT-3.5</td><td align="center">85%</td><td align="center">0.88</td><td align="center">75.0%</td>
343
+ </tr>
344
+ <tr>
345
+ <td>Qwen-7B-Chat</td><td align="center">98%</td><td align="center">0.91</td><td align="center">7.3%</td>
346
+ </tr>
347
+ <tr>
348
+ <td>Qwen-14B-Chat</td><td align="center">98%</td><td align="center">0.93</td><td align="center">2.4%</td>
349
+ </tr>
350
+ </table>
351
+
352
+ > 评测基准中出现的插件均没有出现在千问的训练集中。该基准评估了模型在多个候选插件中选择正确插件的准确率、传入插件的参数的合理性、以及假阳率。假阳率(False Positive)定义:在处理不该调用插件的请求时,错误地调用了插件。
353
+
354
+ > The plugins that appear in the evaluation set do not appear in the training set of Qwen. This benchmark evaluates the accuracy of the model in selecting the correct plugin from multiple candidate plugins, the rationality of the parameters passed into the plugin, and the false positive rate. False Positive: Incorrectly invoking a plugin when it should not have been called when responding to a query.
355
+
356
+ ![](assets/react_showcase_001.png)
357
+ ![](assets/react_showcase_002.png)
358
+
359
+ #### Code Interpreter
360
+
361
+ 为了考察Qwen使用Python Code Interpreter完成数学解题、数据可视化、及文件处理与爬虫等任务的能力,我们专门建设并开源了一个评测这方面能力的[评测基准](https://github.com/QwenLM/Qwen-Agent/tree/main/benchmark)。
362
+
363
+ 我们发现Qwen在生成代码的可执行率、结果正确性上均表现较好:
364
+
365
+ To assess Qwen's ability to use the Python Code Interpreter for tasks such as mathematical problem solving, data visualization, and other general-purpose tasks such as file handling and web scraping, we have created and open-sourced a benchmark specifically designed for evaluating these capabilities. You can find the benchmark at this [link](https://github.com/QwenLM/Qwen-Agent/tree/main/benchmark).
366
+
367
+ We have observed that Qwen performs well in terms of code executability and result accuracy when generating code:
368
+
369
+ <table>
370
+ <tr>
371
+ <th colspan="4" align="center">Executable Rate of Generated Code (%)</th>
372
+ </tr>
373
+ <tr>
374
+ <th align="center">Model</th><th align="center">Math↑</th><th align="center">Visualization↑</th><th align="center">General↑</th>
375
+ </tr>
376
+ <tr>
377
+ <td>GPT-4</td><td align="center">91.9</td><td align="center">85.9</td><td align="center">82.8</td>
378
+ </tr>
379
+ <tr>
380
+ <td>GPT-3.5</td><td align="center">89.2</td><td align="center">65.0</td><td align="center">74.1</td>
381
+ </tr>
382
+ <tr>
383
+ <td>LLaMA2-7B-Chat</td>
384
+ <td align="center">41.9</td>
385
+ <td align="center">33.1</td>
386
+ <td align="center">24.1 </td>
387
+ </tr>
388
+ <tr>
389
+ <td>LLaMA2-13B-Chat</td>
390
+ <td align="center">50.0</td>
391
+ <td align="center">40.5</td>
392
+ <td align="center">48.3 </td>
393
+ </tr>
394
+ <tr>
395
+ <td>CodeLLaMA-7B-Instruct</td>
396
+ <td align="center">85.1</td>
397
+ <td align="center">54.0</td>
398
+ <td align="center">70.7 </td>
399
+ </tr>
400
+ <tr>
401
+ <td>CodeLLaMA-13B-Instruct</td>
402
+ <td align="center">93.2</td>
403
+ <td align="center">55.8</td>
404
+ <td align="center">74.1 </td>
405
+ </tr>
406
+ <tr>
407
+ <td>InternLM-7B-Chat-v1.1</td>
408
+ <td align="center">78.4</td>
409
+ <td align="center">44.2</td>
410
+ <td align="center">62.1 </td>
411
+ </tr>
412
+ <tr>
413
+ <td>InternLM-20B-Chat</td>
414
+ <td align="center">70.3</td>
415
+ <td align="center">44.2</td>
416
+ <td align="center">65.5 </td>
417
+ </tr>
418
+ <tr>
419
+ <td>Qwen-7B-Chat</td>
420
+ <td align="center">82.4</td>
421
+ <td align="center">64.4</td>
422
+ <td align="center">67.2 </td>
423
+ </tr>
424
+ <tr>
425
+ <td>Qwen-14B-Chat</td>
426
+ <td align="center">89.2</td>
427
+ <td align="center">84.1</td>
428
+ <td align="center">65.5</td>
429
+ </tr>
430
+ </table>
431
+
432
+ <table>
433
+ <tr>
434
+ <th colspan="4" align="center">Accuracy of Code Execution Results (%)</th>
435
+ </tr>
436
+ <tr>
437
+ <th align="center">Model</th><th align="center">Math↑</th><th align="center">Visualization-Hard↑</th><th align="center">Visualization-Easy↑</th>
438
+ </tr>
439
+ <tr>
440
+ <td>GPT-4</td><td align="center">82.8</td><td align="center">66.7</td><td align="center">60.8</td>
441
+ </tr>
442
+ <tr>
443
+ <td>GPT-3.5</td><td align="center">47.3</td><td align="center">33.3</td><td align="center">55.7</td>
444
+ </tr>
445
+ <tr>
446
+ <td>LLaMA2-7B-Chat</td>
447
+ <td align="center">3.9</td>
448
+ <td align="center">14.3</td>
449
+ <td align="center">39.2 </td>
450
+ </tr>
451
+ <tr>
452
+ <td>LLaMA2-13B-Chat</td>
453
+ <td align="center">8.3</td>
454
+ <td align="center">8.3</td>
455
+ <td align="center">40.5 </td>
456
+ </tr>
457
+ <tr>
458
+ <td>CodeLLaMA-7B-Instruct</td>
459
+ <td align="center">14.3</td>
460
+ <td align="center">26.2</td>
461
+ <td align="center">60.8 </td>
462
+ </tr>
463
+ <tr>
464
+ <td>CodeLLaMA-13B-Instruct</td>
465
+ <td align="center">28.2</td>
466
+ <td align="center">27.4</td>
467
+ <td align="center">62.0 </td>
468
+ </tr>
469
+ <tr>
470
+ <td>InternLM-7B-Chat-v1.1</td>
471
+ <td align="center">28.5</td>
472
+ <td align="center">4.8</td>
473
+ <td align="center">40.5 </td>
474
+ </tr>
475
+ <tr>
476
+ <td>InternLM-20B-Chat</td>
477
+ <td align="center">34.6</td>
478
+ <td align="center">21.4</td>
479
+ <td align="center">45.6 </td>
480
+ </tr>
481
+ <tr>
482
+ <td>Qwen-7B-Chat</td>
483
+ <td align="center">41.9</td>
484
+ <td align="center">40.5</td>
485
+ <td align="center">54.4 </td>
486
+ </tr>
487
+ <tr>
488
+ <td>Qwen-14B-Chat</td>
489
+ <td align="center">58.4</td>
490
+ <td align="center">53.6</td>
491
+ <td align="center">59.5</td>
492
+ </tr>
493
+ </table>
494
+
495
+ <p align="center">
496
+ <br>
497
+ <img src="assets/code_interpreter_showcase_001.jpg" />
498
+ <br>
499
+ <p>
500
+
501
+ #### Huggingface Agent
502
+
503
+ 千问还具备作为 [HuggingFace Agent](https://huggingface.co/docs/transformers/transformers_agents) 的能力。它在 Huggingface 提供的run模式评测基准上的表现如下:
504
+
505
+ Qwen-Chat also has the capability to be used as a [HuggingFace Agent](https://huggingface.co/docs/transformers/transformers_agents). Its performance on the run-mode benchmark provided by HuggingFace is as follows:
506
+
507
+ <table>
508
+ <tr>
509
+ <th colspan="4" align="center">HuggingFace Agent Benchmark- Run Mode</th>
510
+ </tr>
511
+ <tr>
512
+ <th align="center">Model</th><th align="center">Tool Selection↑</th><th align="center">Tool Used↑</th><th align="center">Code↑</th>
513
+ </tr>
514
+ <tr>
515
+ <td>GPT-4</td><td align="center">100</td><td align="center">100</td><td align="center">97.4</td>
516
+ </tr>
517
+ <tr>
518
+ <td>GPT-3.5</td><td align="center">95.4</td><td align="center">96.3</td><td align="center">87.0</td>
519
+ </tr>
520
+ <tr>
521
+ <td>StarCoder-Base-15B</td><td align="center">86.1</td><td align="center">87.0</td><td align="center">68.9</td>
522
+ </tr>
523
+ <tr>
524
+ <td>StarCoder-15B</td><td align="center">87.0</td><td align="center">88.0</td><td align="center">68.9</td>
525
+ </tr>
526
+ <tr>
527
+ <td>Qwen-7B-Chat</td><td align="center">87.0</td><td align="center">87.0</td><td align="center">71.5</td>
528
+ </tr>
529
+ <tr>
530
+ <td>Qwen-14B-Chat</td><td align="center">93.5</td><td align="center">94.4</td><td align="center">87.0</td>
531
+ </tr>
532
+ </table>
533
+
534
+ <table>
535
+ <tr>
536
+ <th colspan="4" align="center">HuggingFace Agent Benchmark - Chat Mode</th>
537
+ </tr>
538
+ <tr>
539
+ <th align="center">Model</th><th align="center">Tool Selection↑</th><th align="center">Tool Used↑</th><th align="center">Code↑</th>
540
+ </tr>
541
+ <tr>
542
+ <td>GPT-4</td><td align="center">97.9</td><td align="center">97.9</td><td align="center">98.5</td>
543
+ </tr>
544
+ <tr>
545
+ <td>GPT-3.5</td><td align="center">97.3</td><td align="center">96.8</td><td align="center">89.6</td>
546
+ </tr>
547
+ <tr>
548
+ <td>StarCoder-Base-15B</td><td align="center">97.9</td><td align="center">97.9</td><td align="center">91.1</td>
549
+ </tr>
550
+ <tr>
551
+ <td>StarCoder-15B</td><td align="center">97.9</td><td align="center">97.9</td><td align="center">89.6</td>
552
+ </tr>
553
+ <tr>
554
+ <td>Qwen-7B-Chat</td><td align="center">94.7</td><td align="center">94.7</td><td align="center">85.1</td>
555
+ </tr>
556
+ <tr>
557
+ <td>Qwen-14B-Chat</td><td align="center">97.9</td><td align="center">97.9</td><td align="center">95.5</td>
558
+ </tr>
559
+ </table>
560
+
561
+ <br>
562
+
563
+ ## FAQ
564
+
565
+ 如遇到问题,敬请查阅[FAQ](https://github.com/QwenLM/Qwen/blob/main/FAQ_zh.md)以及issue区,如仍无法解决再提交issue。
566
+
567
+ If you meet problems, please refer to [FAQ](https://github.com/QwenLM/Qwen/blob/main/FAQ.md) and the issues first to search a solution before you launch a new issue.
568
+ <br>
569
+
570
+ ## 使用协议(License Agreement)
571
+
572
+ 我们的代码和模型权重对学术研究完全开放,并支持商用。请查看[LICENSE](https://github.com/QwenLM/Qwen/blob/main/LICENSE)了解具体的开源协议细节。如需商用,请填写[问卷](https://dashscope.console.aliyun.com/openModelApply/qianwen)申请。
573
+
574
+ Our code and checkpoints are open to research purpose, and they are allowed for commercial purposes. Check [LICENSE](https://github.com/QwenLM/Qwen/blob/main/LICENSE) for more details about the license. If you have requirements for commercial use, please fill out the [form](https://dashscope.console.aliyun.com/openModelApply/qianwen) to apply.
575
+ <br>
576
+
577
+
578
+
579
+ ## 联系我们(Contact Us)
580
+
581
+ 如果你想给我们的研发团队和产品团队留言,欢迎加入我们的微信群、钉钉群以及Discord!同时,也欢迎通过邮件([email protected])联系我们。
582
+
583
+ If you are interested to leave a message to either our research team or product team, join our Discord or WeChat groups! Also, feel free to send an email to [email protected].
584
+
assets/cli_demo.gif ADDED
assets/code_interpreter_showcase_001.jpg ADDED
assets/hfagent_chat_1.png ADDED

Git LFS Details

  • SHA256: 356ea19c2c4a656cae9d55e2d727d1651d1955ec67385615c6582b394478e889
  • Pointer size: 132 Bytes
  • Size of remote file: 1.71 MB
assets/hfagent_chat_2.png ADDED

Git LFS Details

  • SHA256: 7db53a1a77dfc19072ce418db6df56fd89f9e7cb2e30430ac8320f10fc8a8bc0
  • Pointer size: 132 Bytes
  • Size of remote file: 1.93 MB
assets/hfagent_run.png ADDED

Git LFS Details

  • SHA256: fbf4c1232c86e334b5425aacdcc9e7a878100f80d6d70725060cb312bae7d701
  • Pointer size: 132 Bytes
  • Size of remote file: 2.77 MB
assets/logo.jpg ADDED
assets/react_showcase_001.png ADDED
assets/react_showcase_002.png ADDED
assets/wechat.png ADDED
config.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "QWenLMHeadModel"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_qwen.QWenConfig",
7
+ "AutoModelForCausalLM": "modeling_qwen.QWenLMHeadModel"
8
+ },
9
+ "attn_dropout_prob": 0.0,
10
+ "bf16": false,
11
+ "emb_dropout_prob": 0.0,
12
+ "fp16": true,
13
+ "fp32": false,
14
+ "hidden_size": 5120,
15
+ "intermediate_size": 27392,
16
+ "initializer_range": 0.02,
17
+ "kv_channels": 128,
18
+ "layer_norm_epsilon": 1e-06,
19
+ "max_position_embeddings": 8192,
20
+ "model_type": "qwen",
21
+ "no_bias": true,
22
+ "num_attention_heads": 40,
23
+ "num_hidden_layers": 40,
24
+ "onnx_safe": null,
25
+ "quantization_config": {
26
+ "bits": 4,
27
+ "group_size": 128,
28
+ "damp_percent": 0.01,
29
+ "desc_act": false,
30
+ "static_groups": false,
31
+ "sym": true,
32
+ "true_sequential": true,
33
+ "model_name_or_path": null,
34
+ "model_file_base_name": "model",
35
+ "quant_method": "gptq"
36
+ },
37
+ "rotary_emb_base": 10000,
38
+ "rotary_pct": 1.0,
39
+ "scale_attn_weights": true,
40
+ "seq_length": 2048,
41
+ "tie_word_embeddings": false,
42
+ "tokenizer_class": "QWenTokenizer",
43
+ "transformers_version": "4.32.0",
44
+ "use_cache": true,
45
+ "use_dynamic_ntk": true,
46
+ "use_flash_attn": "auto",
47
+ "use_logn_attn": true,
48
+ "vocab_size": 152064
49
+ }
configuration_qwen.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Alibaba Cloud.
2
+ #
3
+ # This source code is licensed under the license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ from transformers import PretrainedConfig
7
+
8
+
9
+ class QWenConfig(PretrainedConfig):
10
+ model_type = "qwen"
11
+ keys_to_ignore_at_inference = ["past_key_values"]
12
+
13
+ def __init__(
14
+ self,
15
+ vocab_size=151936,
16
+ hidden_size=4096,
17
+ num_hidden_layers=32,
18
+ num_attention_heads=32,
19
+ emb_dropout_prob=0.0,
20
+ attn_dropout_prob=0.0,
21
+ layer_norm_epsilon=1e-6,
22
+ initializer_range=0.02,
23
+ max_position_embeddings=8192,
24
+ scale_attn_weights=True,
25
+ use_cache=True,
26
+ bf16=False,
27
+ fp16=False,
28
+ fp32=False,
29
+ kv_channels=128,
30
+ rotary_pct=1.0,
31
+ rotary_emb_base=10000,
32
+ use_dynamic_ntk=True,
33
+ use_logn_attn=True,
34
+ use_flash_attn="auto",
35
+ intermediate_size=22016,
36
+ no_bias=True,
37
+ tie_word_embeddings=False,
38
+ **kwargs,
39
+ ):
40
+ self.vocab_size = vocab_size
41
+ self.hidden_size = hidden_size
42
+ self.intermediate_size = intermediate_size
43
+ self.num_hidden_layers = num_hidden_layers
44
+ self.num_attention_heads = num_attention_heads
45
+ self.emb_dropout_prob = emb_dropout_prob
46
+ self.attn_dropout_prob = attn_dropout_prob
47
+ self.layer_norm_epsilon = layer_norm_epsilon
48
+ self.initializer_range = initializer_range
49
+ self.scale_attn_weights = scale_attn_weights
50
+ self.use_cache = use_cache
51
+ self.max_position_embeddings = max_position_embeddings
52
+ self.bf16 = bf16
53
+ self.fp16 = fp16
54
+ self.fp32 = fp32
55
+ self.kv_channels = kv_channels
56
+ self.rotary_pct = rotary_pct
57
+ self.rotary_emb_base = rotary_emb_base
58
+ self.use_dynamic_ntk = use_dynamic_ntk
59
+ self.use_logn_attn = use_logn_attn
60
+ self.use_flash_attn = use_flash_attn
61
+ self.no_bias = no_bias
62
+ super().__init__(
63
+ tie_word_embeddings=tie_word_embeddings,
64
+ **kwargs
65
+ )
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "chat_format": "chatml",
3
+ "eos_token_id": 151643,
4
+ "pad_token_id": 151643,
5
+ "max_window_size": 6144,
6
+ "max_new_tokens": 512,
7
+ "do_sample": true,
8
+ "top_k": 0,
9
+ "top_p": 0.5,
10
+ "transformers_version": "4.31.0"
11
+ }
model-00001-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d7f87e0f586c2ae7c5a22851a6d972492595bdd294938342411f2ce400f1aed
3
+ size 2047828192
model-00002-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4961663d52c95507af779cd6a5bb91c175477ef823d950c49c8688507454daed
3
+ size 2024441368
model-00003-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:117fcd5a2ab112f2899380994498bc290b95639a67f132ddd2e409c20bbb03ff
3
+ size 2041419864
model-00004-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b1c3cf6a5be7d1c43e9ced7c385658a588ae3c8eb5dea2390380875acb496f1
3
+ size 2004933264
model-00005-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86f46b278cb1bd33b7559bd7d3a33a29201234368dfb22462461657fbe20f421
3
+ size 1557135488
model.safetensors.index.json ADDED
@@ -0,0 +1,1090 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 9675642880
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00005-of-00005.safetensors",
7
+ "transformer.h.0.attn.c_attn.bias": "model-00001-of-00005.safetensors",
8
+ "transformer.h.0.attn.c_attn.g_idx": "model-00001-of-00005.safetensors",
9
+ "transformer.h.0.attn.c_attn.qweight": "model-00001-of-00005.safetensors",
10
+ "transformer.h.0.attn.c_attn.qzeros": "model-00001-of-00005.safetensors",
11
+ "transformer.h.0.attn.c_attn.scales": "model-00001-of-00005.safetensors",
12
+ "transformer.h.0.attn.c_proj.bias": "model-00001-of-00005.safetensors",
13
+ "transformer.h.0.attn.c_proj.g_idx": "model-00001-of-00005.safetensors",
14
+ "transformer.h.0.attn.c_proj.qweight": "model-00001-of-00005.safetensors",
15
+ "transformer.h.0.attn.c_proj.qzeros": "model-00001-of-00005.safetensors",
16
+ "transformer.h.0.attn.c_proj.scales": "model-00001-of-00005.safetensors",
17
+ "transformer.h.0.ln_1.weight": "model-00001-of-00005.safetensors",
18
+ "transformer.h.0.ln_2.weight": "model-00001-of-00005.safetensors",
19
+ "transformer.h.0.mlp.c_proj.bias": "model-00001-of-00005.safetensors",
20
+ "transformer.h.0.mlp.c_proj.g_idx": "model-00001-of-00005.safetensors",
21
+ "transformer.h.0.mlp.c_proj.qweight": "model-00001-of-00005.safetensors",
22
+ "transformer.h.0.mlp.c_proj.qzeros": "model-00001-of-00005.safetensors",
23
+ "transformer.h.0.mlp.c_proj.scales": "model-00001-of-00005.safetensors",
24
+ "transformer.h.0.mlp.w1.bias": "model-00001-of-00005.safetensors",
25
+ "transformer.h.0.mlp.w1.g_idx": "model-00001-of-00005.safetensors",
26
+ "transformer.h.0.mlp.w1.qweight": "model-00001-of-00005.safetensors",
27
+ "transformer.h.0.mlp.w1.qzeros": "model-00001-of-00005.safetensors",
28
+ "transformer.h.0.mlp.w1.scales": "model-00001-of-00005.safetensors",
29
+ "transformer.h.0.mlp.w2.bias": "model-00001-of-00005.safetensors",
30
+ "transformer.h.0.mlp.w2.g_idx": "model-00001-of-00005.safetensors",
31
+ "transformer.h.0.mlp.w2.qweight": "model-00001-of-00005.safetensors",
32
+ "transformer.h.0.mlp.w2.qzeros": "model-00001-of-00005.safetensors",
33
+ "transformer.h.0.mlp.w2.scales": "model-00001-of-00005.safetensors",
34
+ "transformer.h.1.attn.c_attn.bias": "model-00001-of-00005.safetensors",
35
+ "transformer.h.1.attn.c_attn.g_idx": "model-00001-of-00005.safetensors",
36
+ "transformer.h.1.attn.c_attn.qweight": "model-00001-of-00005.safetensors",
37
+ "transformer.h.1.attn.c_attn.qzeros": "model-00001-of-00005.safetensors",
38
+ "transformer.h.1.attn.c_attn.scales": "model-00001-of-00005.safetensors",
39
+ "transformer.h.1.attn.c_proj.bias": "model-00001-of-00005.safetensors",
40
+ "transformer.h.1.attn.c_proj.g_idx": "model-00001-of-00005.safetensors",
41
+ "transformer.h.1.attn.c_proj.qweight": "model-00001-of-00005.safetensors",
42
+ "transformer.h.1.attn.c_proj.qzeros": "model-00001-of-00005.safetensors",
43
+ "transformer.h.1.attn.c_proj.scales": "model-00001-of-00005.safetensors",
44
+ "transformer.h.1.ln_1.weight": "model-00001-of-00005.safetensors",
45
+ "transformer.h.1.ln_2.weight": "model-00001-of-00005.safetensors",
46
+ "transformer.h.1.mlp.c_proj.bias": "model-00001-of-00005.safetensors",
47
+ "transformer.h.1.mlp.c_proj.g_idx": "model-00001-of-00005.safetensors",
48
+ "transformer.h.1.mlp.c_proj.qweight": "model-00001-of-00005.safetensors",
49
+ "transformer.h.1.mlp.c_proj.qzeros": "model-00001-of-00005.safetensors",
50
+ "transformer.h.1.mlp.c_proj.scales": "model-00001-of-00005.safetensors",
51
+ "transformer.h.1.mlp.w1.bias": "model-00001-of-00005.safetensors",
52
+ "transformer.h.1.mlp.w1.g_idx": "model-00001-of-00005.safetensors",
53
+ "transformer.h.1.mlp.w1.qweight": "model-00001-of-00005.safetensors",
54
+ "transformer.h.1.mlp.w1.qzeros": "model-00001-of-00005.safetensors",
55
+ "transformer.h.1.mlp.w1.scales": "model-00001-of-00005.safetensors",
56
+ "transformer.h.1.mlp.w2.bias": "model-00001-of-00005.safetensors",
57
+ "transformer.h.1.mlp.w2.g_idx": "model-00001-of-00005.safetensors",
58
+ "transformer.h.1.mlp.w2.qweight": "model-00001-of-00005.safetensors",
59
+ "transformer.h.1.mlp.w2.qzeros": "model-00001-of-00005.safetensors",
60
+ "transformer.h.1.mlp.w2.scales": "model-00001-of-00005.safetensors",
61
+ "transformer.h.10.attn.c_attn.bias": "model-00002-of-00005.safetensors",
62
+ "transformer.h.10.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
63
+ "transformer.h.10.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
64
+ "transformer.h.10.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
65
+ "transformer.h.10.attn.c_attn.scales": "model-00002-of-00005.safetensors",
66
+ "transformer.h.10.attn.c_proj.bias": "model-00002-of-00005.safetensors",
67
+ "transformer.h.10.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
68
+ "transformer.h.10.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
69
+ "transformer.h.10.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
70
+ "transformer.h.10.attn.c_proj.scales": "model-00002-of-00005.safetensors",
71
+ "transformer.h.10.ln_1.weight": "model-00002-of-00005.safetensors",
72
+ "transformer.h.10.ln_2.weight": "model-00002-of-00005.safetensors",
73
+ "transformer.h.10.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
74
+ "transformer.h.10.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
75
+ "transformer.h.10.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
76
+ "transformer.h.10.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
77
+ "transformer.h.10.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
78
+ "transformer.h.10.mlp.w1.bias": "model-00002-of-00005.safetensors",
79
+ "transformer.h.10.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
80
+ "transformer.h.10.mlp.w1.qweight": "model-00002-of-00005.safetensors",
81
+ "transformer.h.10.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
82
+ "transformer.h.10.mlp.w1.scales": "model-00002-of-00005.safetensors",
83
+ "transformer.h.10.mlp.w2.bias": "model-00002-of-00005.safetensors",
84
+ "transformer.h.10.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
85
+ "transformer.h.10.mlp.w2.qweight": "model-00002-of-00005.safetensors",
86
+ "transformer.h.10.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
87
+ "transformer.h.10.mlp.w2.scales": "model-00002-of-00005.safetensors",
88
+ "transformer.h.11.attn.c_attn.bias": "model-00002-of-00005.safetensors",
89
+ "transformer.h.11.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
90
+ "transformer.h.11.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
91
+ "transformer.h.11.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
92
+ "transformer.h.11.attn.c_attn.scales": "model-00002-of-00005.safetensors",
93
+ "transformer.h.11.attn.c_proj.bias": "model-00002-of-00005.safetensors",
94
+ "transformer.h.11.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
95
+ "transformer.h.11.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
96
+ "transformer.h.11.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
97
+ "transformer.h.11.attn.c_proj.scales": "model-00002-of-00005.safetensors",
98
+ "transformer.h.11.ln_1.weight": "model-00002-of-00005.safetensors",
99
+ "transformer.h.11.ln_2.weight": "model-00002-of-00005.safetensors",
100
+ "transformer.h.11.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
101
+ "transformer.h.11.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
102
+ "transformer.h.11.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
103
+ "transformer.h.11.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
104
+ "transformer.h.11.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
105
+ "transformer.h.11.mlp.w1.bias": "model-00002-of-00005.safetensors",
106
+ "transformer.h.11.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
107
+ "transformer.h.11.mlp.w1.qweight": "model-00002-of-00005.safetensors",
108
+ "transformer.h.11.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
109
+ "transformer.h.11.mlp.w1.scales": "model-00002-of-00005.safetensors",
110
+ "transformer.h.11.mlp.w2.bias": "model-00002-of-00005.safetensors",
111
+ "transformer.h.11.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
112
+ "transformer.h.11.mlp.w2.qweight": "model-00002-of-00005.safetensors",
113
+ "transformer.h.11.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
114
+ "transformer.h.11.mlp.w2.scales": "model-00002-of-00005.safetensors",
115
+ "transformer.h.12.attn.c_attn.bias": "model-00002-of-00005.safetensors",
116
+ "transformer.h.12.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
117
+ "transformer.h.12.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
118
+ "transformer.h.12.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
119
+ "transformer.h.12.attn.c_attn.scales": "model-00002-of-00005.safetensors",
120
+ "transformer.h.12.attn.c_proj.bias": "model-00002-of-00005.safetensors",
121
+ "transformer.h.12.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
122
+ "transformer.h.12.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
123
+ "transformer.h.12.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
124
+ "transformer.h.12.attn.c_proj.scales": "model-00002-of-00005.safetensors",
125
+ "transformer.h.12.ln_1.weight": "model-00002-of-00005.safetensors",
126
+ "transformer.h.12.ln_2.weight": "model-00002-of-00005.safetensors",
127
+ "transformer.h.12.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
128
+ "transformer.h.12.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
129
+ "transformer.h.12.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
130
+ "transformer.h.12.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
131
+ "transformer.h.12.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
132
+ "transformer.h.12.mlp.w1.bias": "model-00002-of-00005.safetensors",
133
+ "transformer.h.12.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
134
+ "transformer.h.12.mlp.w1.qweight": "model-00002-of-00005.safetensors",
135
+ "transformer.h.12.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
136
+ "transformer.h.12.mlp.w1.scales": "model-00002-of-00005.safetensors",
137
+ "transformer.h.12.mlp.w2.bias": "model-00002-of-00005.safetensors",
138
+ "transformer.h.12.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
139
+ "transformer.h.12.mlp.w2.qweight": "model-00002-of-00005.safetensors",
140
+ "transformer.h.12.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
141
+ "transformer.h.12.mlp.w2.scales": "model-00002-of-00005.safetensors",
142
+ "transformer.h.13.attn.c_attn.bias": "model-00002-of-00005.safetensors",
143
+ "transformer.h.13.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
144
+ "transformer.h.13.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
145
+ "transformer.h.13.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
146
+ "transformer.h.13.attn.c_attn.scales": "model-00002-of-00005.safetensors",
147
+ "transformer.h.13.attn.c_proj.bias": "model-00002-of-00005.safetensors",
148
+ "transformer.h.13.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
149
+ "transformer.h.13.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
150
+ "transformer.h.13.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
151
+ "transformer.h.13.attn.c_proj.scales": "model-00002-of-00005.safetensors",
152
+ "transformer.h.13.ln_1.weight": "model-00002-of-00005.safetensors",
153
+ "transformer.h.13.ln_2.weight": "model-00002-of-00005.safetensors",
154
+ "transformer.h.13.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
155
+ "transformer.h.13.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
156
+ "transformer.h.13.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
157
+ "transformer.h.13.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
158
+ "transformer.h.13.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
159
+ "transformer.h.13.mlp.w1.bias": "model-00002-of-00005.safetensors",
160
+ "transformer.h.13.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
161
+ "transformer.h.13.mlp.w1.qweight": "model-00002-of-00005.safetensors",
162
+ "transformer.h.13.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
163
+ "transformer.h.13.mlp.w1.scales": "model-00002-of-00005.safetensors",
164
+ "transformer.h.13.mlp.w2.bias": "model-00002-of-00005.safetensors",
165
+ "transformer.h.13.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
166
+ "transformer.h.13.mlp.w2.qweight": "model-00002-of-00005.safetensors",
167
+ "transformer.h.13.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
168
+ "transformer.h.13.mlp.w2.scales": "model-00002-of-00005.safetensors",
169
+ "transformer.h.14.attn.c_attn.bias": "model-00002-of-00005.safetensors",
170
+ "transformer.h.14.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
171
+ "transformer.h.14.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
172
+ "transformer.h.14.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
173
+ "transformer.h.14.attn.c_attn.scales": "model-00002-of-00005.safetensors",
174
+ "transformer.h.14.attn.c_proj.bias": "model-00002-of-00005.safetensors",
175
+ "transformer.h.14.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
176
+ "transformer.h.14.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
177
+ "transformer.h.14.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
178
+ "transformer.h.14.attn.c_proj.scales": "model-00002-of-00005.safetensors",
179
+ "transformer.h.14.ln_1.weight": "model-00002-of-00005.safetensors",
180
+ "transformer.h.14.ln_2.weight": "model-00002-of-00005.safetensors",
181
+ "transformer.h.14.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
182
+ "transformer.h.14.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
183
+ "transformer.h.14.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
184
+ "transformer.h.14.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
185
+ "transformer.h.14.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
186
+ "transformer.h.14.mlp.w1.bias": "model-00002-of-00005.safetensors",
187
+ "transformer.h.14.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
188
+ "transformer.h.14.mlp.w1.qweight": "model-00002-of-00005.safetensors",
189
+ "transformer.h.14.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
190
+ "transformer.h.14.mlp.w1.scales": "model-00002-of-00005.safetensors",
191
+ "transformer.h.14.mlp.w2.bias": "model-00002-of-00005.safetensors",
192
+ "transformer.h.14.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
193
+ "transformer.h.14.mlp.w2.qweight": "model-00002-of-00005.safetensors",
194
+ "transformer.h.14.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
195
+ "transformer.h.14.mlp.w2.scales": "model-00002-of-00005.safetensors",
196
+ "transformer.h.15.attn.c_attn.bias": "model-00002-of-00005.safetensors",
197
+ "transformer.h.15.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
198
+ "transformer.h.15.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
199
+ "transformer.h.15.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
200
+ "transformer.h.15.attn.c_attn.scales": "model-00002-of-00005.safetensors",
201
+ "transformer.h.15.attn.c_proj.bias": "model-00002-of-00005.safetensors",
202
+ "transformer.h.15.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
203
+ "transformer.h.15.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
204
+ "transformer.h.15.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
205
+ "transformer.h.15.attn.c_proj.scales": "model-00002-of-00005.safetensors",
206
+ "transformer.h.15.ln_1.weight": "model-00002-of-00005.safetensors",
207
+ "transformer.h.15.ln_2.weight": "model-00002-of-00005.safetensors",
208
+ "transformer.h.15.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
209
+ "transformer.h.15.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
210
+ "transformer.h.15.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
211
+ "transformer.h.15.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
212
+ "transformer.h.15.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
213
+ "transformer.h.15.mlp.w1.bias": "model-00003-of-00005.safetensors",
214
+ "transformer.h.15.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
215
+ "transformer.h.15.mlp.w1.qweight": "model-00003-of-00005.safetensors",
216
+ "transformer.h.15.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
217
+ "transformer.h.15.mlp.w1.scales": "model-00003-of-00005.safetensors",
218
+ "transformer.h.15.mlp.w2.bias": "model-00003-of-00005.safetensors",
219
+ "transformer.h.15.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
220
+ "transformer.h.15.mlp.w2.qweight": "model-00003-of-00005.safetensors",
221
+ "transformer.h.15.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
222
+ "transformer.h.15.mlp.w2.scales": "model-00003-of-00005.safetensors",
223
+ "transformer.h.16.attn.c_attn.bias": "model-00003-of-00005.safetensors",
224
+ "transformer.h.16.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
225
+ "transformer.h.16.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
226
+ "transformer.h.16.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
227
+ "transformer.h.16.attn.c_attn.scales": "model-00003-of-00005.safetensors",
228
+ "transformer.h.16.attn.c_proj.bias": "model-00003-of-00005.safetensors",
229
+ "transformer.h.16.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
230
+ "transformer.h.16.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
231
+ "transformer.h.16.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
232
+ "transformer.h.16.attn.c_proj.scales": "model-00003-of-00005.safetensors",
233
+ "transformer.h.16.ln_1.weight": "model-00003-of-00005.safetensors",
234
+ "transformer.h.16.ln_2.weight": "model-00003-of-00005.safetensors",
235
+ "transformer.h.16.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
236
+ "transformer.h.16.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
237
+ "transformer.h.16.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
238
+ "transformer.h.16.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
239
+ "transformer.h.16.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
240
+ "transformer.h.16.mlp.w1.bias": "model-00003-of-00005.safetensors",
241
+ "transformer.h.16.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
242
+ "transformer.h.16.mlp.w1.qweight": "model-00003-of-00005.safetensors",
243
+ "transformer.h.16.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
244
+ "transformer.h.16.mlp.w1.scales": "model-00003-of-00005.safetensors",
245
+ "transformer.h.16.mlp.w2.bias": "model-00003-of-00005.safetensors",
246
+ "transformer.h.16.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
247
+ "transformer.h.16.mlp.w2.qweight": "model-00003-of-00005.safetensors",
248
+ "transformer.h.16.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
249
+ "transformer.h.16.mlp.w2.scales": "model-00003-of-00005.safetensors",
250
+ "transformer.h.17.attn.c_attn.bias": "model-00003-of-00005.safetensors",
251
+ "transformer.h.17.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
252
+ "transformer.h.17.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
253
+ "transformer.h.17.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
254
+ "transformer.h.17.attn.c_attn.scales": "model-00003-of-00005.safetensors",
255
+ "transformer.h.17.attn.c_proj.bias": "model-00003-of-00005.safetensors",
256
+ "transformer.h.17.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
257
+ "transformer.h.17.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
258
+ "transformer.h.17.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
259
+ "transformer.h.17.attn.c_proj.scales": "model-00003-of-00005.safetensors",
260
+ "transformer.h.17.ln_1.weight": "model-00003-of-00005.safetensors",
261
+ "transformer.h.17.ln_2.weight": "model-00003-of-00005.safetensors",
262
+ "transformer.h.17.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
263
+ "transformer.h.17.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
264
+ "transformer.h.17.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
265
+ "transformer.h.17.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
266
+ "transformer.h.17.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
267
+ "transformer.h.17.mlp.w1.bias": "model-00003-of-00005.safetensors",
268
+ "transformer.h.17.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
269
+ "transformer.h.17.mlp.w1.qweight": "model-00003-of-00005.safetensors",
270
+ "transformer.h.17.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
271
+ "transformer.h.17.mlp.w1.scales": "model-00003-of-00005.safetensors",
272
+ "transformer.h.17.mlp.w2.bias": "model-00003-of-00005.safetensors",
273
+ "transformer.h.17.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
274
+ "transformer.h.17.mlp.w2.qweight": "model-00003-of-00005.safetensors",
275
+ "transformer.h.17.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
276
+ "transformer.h.17.mlp.w2.scales": "model-00003-of-00005.safetensors",
277
+ "transformer.h.18.attn.c_attn.bias": "model-00003-of-00005.safetensors",
278
+ "transformer.h.18.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
279
+ "transformer.h.18.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
280
+ "transformer.h.18.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
281
+ "transformer.h.18.attn.c_attn.scales": "model-00003-of-00005.safetensors",
282
+ "transformer.h.18.attn.c_proj.bias": "model-00003-of-00005.safetensors",
283
+ "transformer.h.18.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
284
+ "transformer.h.18.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
285
+ "transformer.h.18.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
286
+ "transformer.h.18.attn.c_proj.scales": "model-00003-of-00005.safetensors",
287
+ "transformer.h.18.ln_1.weight": "model-00003-of-00005.safetensors",
288
+ "transformer.h.18.ln_2.weight": "model-00003-of-00005.safetensors",
289
+ "transformer.h.18.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
290
+ "transformer.h.18.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
291
+ "transformer.h.18.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
292
+ "transformer.h.18.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
293
+ "transformer.h.18.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
294
+ "transformer.h.18.mlp.w1.bias": "model-00003-of-00005.safetensors",
295
+ "transformer.h.18.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
296
+ "transformer.h.18.mlp.w1.qweight": "model-00003-of-00005.safetensors",
297
+ "transformer.h.18.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
298
+ "transformer.h.18.mlp.w1.scales": "model-00003-of-00005.safetensors",
299
+ "transformer.h.18.mlp.w2.bias": "model-00003-of-00005.safetensors",
300
+ "transformer.h.18.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
301
+ "transformer.h.18.mlp.w2.qweight": "model-00003-of-00005.safetensors",
302
+ "transformer.h.18.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
303
+ "transformer.h.18.mlp.w2.scales": "model-00003-of-00005.safetensors",
304
+ "transformer.h.19.attn.c_attn.bias": "model-00003-of-00005.safetensors",
305
+ "transformer.h.19.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
306
+ "transformer.h.19.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
307
+ "transformer.h.19.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
308
+ "transformer.h.19.attn.c_attn.scales": "model-00003-of-00005.safetensors",
309
+ "transformer.h.19.attn.c_proj.bias": "model-00003-of-00005.safetensors",
310
+ "transformer.h.19.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
311
+ "transformer.h.19.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
312
+ "transformer.h.19.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
313
+ "transformer.h.19.attn.c_proj.scales": "model-00003-of-00005.safetensors",
314
+ "transformer.h.19.ln_1.weight": "model-00003-of-00005.safetensors",
315
+ "transformer.h.19.ln_2.weight": "model-00003-of-00005.safetensors",
316
+ "transformer.h.19.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
317
+ "transformer.h.19.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
318
+ "transformer.h.19.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
319
+ "transformer.h.19.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
320
+ "transformer.h.19.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
321
+ "transformer.h.19.mlp.w1.bias": "model-00003-of-00005.safetensors",
322
+ "transformer.h.19.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
323
+ "transformer.h.19.mlp.w1.qweight": "model-00003-of-00005.safetensors",
324
+ "transformer.h.19.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
325
+ "transformer.h.19.mlp.w1.scales": "model-00003-of-00005.safetensors",
326
+ "transformer.h.19.mlp.w2.bias": "model-00003-of-00005.safetensors",
327
+ "transformer.h.19.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
328
+ "transformer.h.19.mlp.w2.qweight": "model-00003-of-00005.safetensors",
329
+ "transformer.h.19.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
330
+ "transformer.h.19.mlp.w2.scales": "model-00003-of-00005.safetensors",
331
+ "transformer.h.2.attn.c_attn.bias": "model-00001-of-00005.safetensors",
332
+ "transformer.h.2.attn.c_attn.g_idx": "model-00001-of-00005.safetensors",
333
+ "transformer.h.2.attn.c_attn.qweight": "model-00001-of-00005.safetensors",
334
+ "transformer.h.2.attn.c_attn.qzeros": "model-00001-of-00005.safetensors",
335
+ "transformer.h.2.attn.c_attn.scales": "model-00001-of-00005.safetensors",
336
+ "transformer.h.2.attn.c_proj.bias": "model-00001-of-00005.safetensors",
337
+ "transformer.h.2.attn.c_proj.g_idx": "model-00001-of-00005.safetensors",
338
+ "transformer.h.2.attn.c_proj.qweight": "model-00001-of-00005.safetensors",
339
+ "transformer.h.2.attn.c_proj.qzeros": "model-00001-of-00005.safetensors",
340
+ "transformer.h.2.attn.c_proj.scales": "model-00001-of-00005.safetensors",
341
+ "transformer.h.2.ln_1.weight": "model-00001-of-00005.safetensors",
342
+ "transformer.h.2.ln_2.weight": "model-00001-of-00005.safetensors",
343
+ "transformer.h.2.mlp.c_proj.bias": "model-00001-of-00005.safetensors",
344
+ "transformer.h.2.mlp.c_proj.g_idx": "model-00001-of-00005.safetensors",
345
+ "transformer.h.2.mlp.c_proj.qweight": "model-00001-of-00005.safetensors",
346
+ "transformer.h.2.mlp.c_proj.qzeros": "model-00001-of-00005.safetensors",
347
+ "transformer.h.2.mlp.c_proj.scales": "model-00001-of-00005.safetensors",
348
+ "transformer.h.2.mlp.w1.bias": "model-00001-of-00005.safetensors",
349
+ "transformer.h.2.mlp.w1.g_idx": "model-00001-of-00005.safetensors",
350
+ "transformer.h.2.mlp.w1.qweight": "model-00001-of-00005.safetensors",
351
+ "transformer.h.2.mlp.w1.qzeros": "model-00001-of-00005.safetensors",
352
+ "transformer.h.2.mlp.w1.scales": "model-00001-of-00005.safetensors",
353
+ "transformer.h.2.mlp.w2.bias": "model-00002-of-00005.safetensors",
354
+ "transformer.h.2.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
355
+ "transformer.h.2.mlp.w2.qweight": "model-00001-of-00005.safetensors",
356
+ "transformer.h.2.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
357
+ "transformer.h.2.mlp.w2.scales": "model-00002-of-00005.safetensors",
358
+ "transformer.h.20.attn.c_attn.bias": "model-00003-of-00005.safetensors",
359
+ "transformer.h.20.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
360
+ "transformer.h.20.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
361
+ "transformer.h.20.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
362
+ "transformer.h.20.attn.c_attn.scales": "model-00003-of-00005.safetensors",
363
+ "transformer.h.20.attn.c_proj.bias": "model-00003-of-00005.safetensors",
364
+ "transformer.h.20.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
365
+ "transformer.h.20.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
366
+ "transformer.h.20.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
367
+ "transformer.h.20.attn.c_proj.scales": "model-00003-of-00005.safetensors",
368
+ "transformer.h.20.ln_1.weight": "model-00003-of-00005.safetensors",
369
+ "transformer.h.20.ln_2.weight": "model-00003-of-00005.safetensors",
370
+ "transformer.h.20.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
371
+ "transformer.h.20.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
372
+ "transformer.h.20.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
373
+ "transformer.h.20.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
374
+ "transformer.h.20.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
375
+ "transformer.h.20.mlp.w1.bias": "model-00003-of-00005.safetensors",
376
+ "transformer.h.20.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
377
+ "transformer.h.20.mlp.w1.qweight": "model-00003-of-00005.safetensors",
378
+ "transformer.h.20.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
379
+ "transformer.h.20.mlp.w1.scales": "model-00003-of-00005.safetensors",
380
+ "transformer.h.20.mlp.w2.bias": "model-00003-of-00005.safetensors",
381
+ "transformer.h.20.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
382
+ "transformer.h.20.mlp.w2.qweight": "model-00003-of-00005.safetensors",
383
+ "transformer.h.20.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
384
+ "transformer.h.20.mlp.w2.scales": "model-00003-of-00005.safetensors",
385
+ "transformer.h.21.attn.c_attn.bias": "model-00003-of-00005.safetensors",
386
+ "transformer.h.21.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
387
+ "transformer.h.21.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
388
+ "transformer.h.21.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
389
+ "transformer.h.21.attn.c_attn.scales": "model-00003-of-00005.safetensors",
390
+ "transformer.h.21.attn.c_proj.bias": "model-00003-of-00005.safetensors",
391
+ "transformer.h.21.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
392
+ "transformer.h.21.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
393
+ "transformer.h.21.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
394
+ "transformer.h.21.attn.c_proj.scales": "model-00003-of-00005.safetensors",
395
+ "transformer.h.21.ln_1.weight": "model-00003-of-00005.safetensors",
396
+ "transformer.h.21.ln_2.weight": "model-00003-of-00005.safetensors",
397
+ "transformer.h.21.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
398
+ "transformer.h.21.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
399
+ "transformer.h.21.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
400
+ "transformer.h.21.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
401
+ "transformer.h.21.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
402
+ "transformer.h.21.mlp.w1.bias": "model-00003-of-00005.safetensors",
403
+ "transformer.h.21.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
404
+ "transformer.h.21.mlp.w1.qweight": "model-00003-of-00005.safetensors",
405
+ "transformer.h.21.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
406
+ "transformer.h.21.mlp.w1.scales": "model-00003-of-00005.safetensors",
407
+ "transformer.h.21.mlp.w2.bias": "model-00003-of-00005.safetensors",
408
+ "transformer.h.21.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
409
+ "transformer.h.21.mlp.w2.qweight": "model-00003-of-00005.safetensors",
410
+ "transformer.h.21.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
411
+ "transformer.h.21.mlp.w2.scales": "model-00003-of-00005.safetensors",
412
+ "transformer.h.22.attn.c_attn.bias": "model-00003-of-00005.safetensors",
413
+ "transformer.h.22.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
414
+ "transformer.h.22.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
415
+ "transformer.h.22.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
416
+ "transformer.h.22.attn.c_attn.scales": "model-00003-of-00005.safetensors",
417
+ "transformer.h.22.attn.c_proj.bias": "model-00003-of-00005.safetensors",
418
+ "transformer.h.22.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
419
+ "transformer.h.22.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
420
+ "transformer.h.22.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
421
+ "transformer.h.22.attn.c_proj.scales": "model-00003-of-00005.safetensors",
422
+ "transformer.h.22.ln_1.weight": "model-00003-of-00005.safetensors",
423
+ "transformer.h.22.ln_2.weight": "model-00003-of-00005.safetensors",
424
+ "transformer.h.22.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
425
+ "transformer.h.22.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
426
+ "transformer.h.22.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
427
+ "transformer.h.22.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
428
+ "transformer.h.22.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
429
+ "transformer.h.22.mlp.w1.bias": "model-00003-of-00005.safetensors",
430
+ "transformer.h.22.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
431
+ "transformer.h.22.mlp.w1.qweight": "model-00003-of-00005.safetensors",
432
+ "transformer.h.22.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
433
+ "transformer.h.22.mlp.w1.scales": "model-00003-of-00005.safetensors",
434
+ "transformer.h.22.mlp.w2.bias": "model-00003-of-00005.safetensors",
435
+ "transformer.h.22.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
436
+ "transformer.h.22.mlp.w2.qweight": "model-00003-of-00005.safetensors",
437
+ "transformer.h.22.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
438
+ "transformer.h.22.mlp.w2.scales": "model-00003-of-00005.safetensors",
439
+ "transformer.h.23.attn.c_attn.bias": "model-00003-of-00005.safetensors",
440
+ "transformer.h.23.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
441
+ "transformer.h.23.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
442
+ "transformer.h.23.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
443
+ "transformer.h.23.attn.c_attn.scales": "model-00003-of-00005.safetensors",
444
+ "transformer.h.23.attn.c_proj.bias": "model-00003-of-00005.safetensors",
445
+ "transformer.h.23.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
446
+ "transformer.h.23.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
447
+ "transformer.h.23.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
448
+ "transformer.h.23.attn.c_proj.scales": "model-00003-of-00005.safetensors",
449
+ "transformer.h.23.ln_1.weight": "model-00003-of-00005.safetensors",
450
+ "transformer.h.23.ln_2.weight": "model-00003-of-00005.safetensors",
451
+ "transformer.h.23.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
452
+ "transformer.h.23.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
453
+ "transformer.h.23.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
454
+ "transformer.h.23.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
455
+ "transformer.h.23.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
456
+ "transformer.h.23.mlp.w1.bias": "model-00003-of-00005.safetensors",
457
+ "transformer.h.23.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
458
+ "transformer.h.23.mlp.w1.qweight": "model-00003-of-00005.safetensors",
459
+ "transformer.h.23.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
460
+ "transformer.h.23.mlp.w1.scales": "model-00003-of-00005.safetensors",
461
+ "transformer.h.23.mlp.w2.bias": "model-00003-of-00005.safetensors",
462
+ "transformer.h.23.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
463
+ "transformer.h.23.mlp.w2.qweight": "model-00003-of-00005.safetensors",
464
+ "transformer.h.23.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
465
+ "transformer.h.23.mlp.w2.scales": "model-00003-of-00005.safetensors",
466
+ "transformer.h.24.attn.c_attn.bias": "model-00003-of-00005.safetensors",
467
+ "transformer.h.24.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
468
+ "transformer.h.24.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
469
+ "transformer.h.24.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
470
+ "transformer.h.24.attn.c_attn.scales": "model-00003-of-00005.safetensors",
471
+ "transformer.h.24.attn.c_proj.bias": "model-00003-of-00005.safetensors",
472
+ "transformer.h.24.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
473
+ "transformer.h.24.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
474
+ "transformer.h.24.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
475
+ "transformer.h.24.attn.c_proj.scales": "model-00003-of-00005.safetensors",
476
+ "transformer.h.24.ln_1.weight": "model-00003-of-00005.safetensors",
477
+ "transformer.h.24.ln_2.weight": "model-00003-of-00005.safetensors",
478
+ "transformer.h.24.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
479
+ "transformer.h.24.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
480
+ "transformer.h.24.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
481
+ "transformer.h.24.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
482
+ "transformer.h.24.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
483
+ "transformer.h.24.mlp.w1.bias": "model-00003-of-00005.safetensors",
484
+ "transformer.h.24.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
485
+ "transformer.h.24.mlp.w1.qweight": "model-00003-of-00005.safetensors",
486
+ "transformer.h.24.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
487
+ "transformer.h.24.mlp.w1.scales": "model-00003-of-00005.safetensors",
488
+ "transformer.h.24.mlp.w2.bias": "model-00003-of-00005.safetensors",
489
+ "transformer.h.24.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
490
+ "transformer.h.24.mlp.w2.qweight": "model-00003-of-00005.safetensors",
491
+ "transformer.h.24.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
492
+ "transformer.h.24.mlp.w2.scales": "model-00003-of-00005.safetensors",
493
+ "transformer.h.25.attn.c_attn.bias": "model-00003-of-00005.safetensors",
494
+ "transformer.h.25.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
495
+ "transformer.h.25.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
496
+ "transformer.h.25.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
497
+ "transformer.h.25.attn.c_attn.scales": "model-00003-of-00005.safetensors",
498
+ "transformer.h.25.attn.c_proj.bias": "model-00003-of-00005.safetensors",
499
+ "transformer.h.25.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
500
+ "transformer.h.25.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
501
+ "transformer.h.25.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
502
+ "transformer.h.25.attn.c_proj.scales": "model-00003-of-00005.safetensors",
503
+ "transformer.h.25.ln_1.weight": "model-00003-of-00005.safetensors",
504
+ "transformer.h.25.ln_2.weight": "model-00003-of-00005.safetensors",
505
+ "transformer.h.25.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
506
+ "transformer.h.25.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
507
+ "transformer.h.25.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
508
+ "transformer.h.25.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
509
+ "transformer.h.25.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
510
+ "transformer.h.25.mlp.w1.bias": "model-00003-of-00005.safetensors",
511
+ "transformer.h.25.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
512
+ "transformer.h.25.mlp.w1.qweight": "model-00003-of-00005.safetensors",
513
+ "transformer.h.25.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
514
+ "transformer.h.25.mlp.w1.scales": "model-00003-of-00005.safetensors",
515
+ "transformer.h.25.mlp.w2.bias": "model-00003-of-00005.safetensors",
516
+ "transformer.h.25.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
517
+ "transformer.h.25.mlp.w2.qweight": "model-00003-of-00005.safetensors",
518
+ "transformer.h.25.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
519
+ "transformer.h.25.mlp.w2.scales": "model-00003-of-00005.safetensors",
520
+ "transformer.h.26.attn.c_attn.bias": "model-00003-of-00005.safetensors",
521
+ "transformer.h.26.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
522
+ "transformer.h.26.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
523
+ "transformer.h.26.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
524
+ "transformer.h.26.attn.c_attn.scales": "model-00003-of-00005.safetensors",
525
+ "transformer.h.26.attn.c_proj.bias": "model-00003-of-00005.safetensors",
526
+ "transformer.h.26.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
527
+ "transformer.h.26.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
528
+ "transformer.h.26.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
529
+ "transformer.h.26.attn.c_proj.scales": "model-00003-of-00005.safetensors",
530
+ "transformer.h.26.ln_1.weight": "model-00003-of-00005.safetensors",
531
+ "transformer.h.26.ln_2.weight": "model-00003-of-00005.safetensors",
532
+ "transformer.h.26.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
533
+ "transformer.h.26.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
534
+ "transformer.h.26.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
535
+ "transformer.h.26.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
536
+ "transformer.h.26.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
537
+ "transformer.h.26.mlp.w1.bias": "model-00003-of-00005.safetensors",
538
+ "transformer.h.26.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
539
+ "transformer.h.26.mlp.w1.qweight": "model-00003-of-00005.safetensors",
540
+ "transformer.h.26.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
541
+ "transformer.h.26.mlp.w1.scales": "model-00003-of-00005.safetensors",
542
+ "transformer.h.26.mlp.w2.bias": "model-00003-of-00005.safetensors",
543
+ "transformer.h.26.mlp.w2.g_idx": "model-00003-of-00005.safetensors",
544
+ "transformer.h.26.mlp.w2.qweight": "model-00003-of-00005.safetensors",
545
+ "transformer.h.26.mlp.w2.qzeros": "model-00003-of-00005.safetensors",
546
+ "transformer.h.26.mlp.w2.scales": "model-00003-of-00005.safetensors",
547
+ "transformer.h.27.attn.c_attn.bias": "model-00003-of-00005.safetensors",
548
+ "transformer.h.27.attn.c_attn.g_idx": "model-00003-of-00005.safetensors",
549
+ "transformer.h.27.attn.c_attn.qweight": "model-00003-of-00005.safetensors",
550
+ "transformer.h.27.attn.c_attn.qzeros": "model-00003-of-00005.safetensors",
551
+ "transformer.h.27.attn.c_attn.scales": "model-00003-of-00005.safetensors",
552
+ "transformer.h.27.attn.c_proj.bias": "model-00003-of-00005.safetensors",
553
+ "transformer.h.27.attn.c_proj.g_idx": "model-00003-of-00005.safetensors",
554
+ "transformer.h.27.attn.c_proj.qweight": "model-00003-of-00005.safetensors",
555
+ "transformer.h.27.attn.c_proj.qzeros": "model-00003-of-00005.safetensors",
556
+ "transformer.h.27.attn.c_proj.scales": "model-00003-of-00005.safetensors",
557
+ "transformer.h.27.ln_1.weight": "model-00003-of-00005.safetensors",
558
+ "transformer.h.27.ln_2.weight": "model-00003-of-00005.safetensors",
559
+ "transformer.h.27.mlp.c_proj.bias": "model-00003-of-00005.safetensors",
560
+ "transformer.h.27.mlp.c_proj.g_idx": "model-00003-of-00005.safetensors",
561
+ "transformer.h.27.mlp.c_proj.qweight": "model-00003-of-00005.safetensors",
562
+ "transformer.h.27.mlp.c_proj.qzeros": "model-00003-of-00005.safetensors",
563
+ "transformer.h.27.mlp.c_proj.scales": "model-00003-of-00005.safetensors",
564
+ "transformer.h.27.mlp.w1.bias": "model-00003-of-00005.safetensors",
565
+ "transformer.h.27.mlp.w1.g_idx": "model-00003-of-00005.safetensors",
566
+ "transformer.h.27.mlp.w1.qweight": "model-00003-of-00005.safetensors",
567
+ "transformer.h.27.mlp.w1.qzeros": "model-00003-of-00005.safetensors",
568
+ "transformer.h.27.mlp.w1.scales": "model-00003-of-00005.safetensors",
569
+ "transformer.h.27.mlp.w2.bias": "model-00004-of-00005.safetensors",
570
+ "transformer.h.27.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
571
+ "transformer.h.27.mlp.w2.qweight": "model-00004-of-00005.safetensors",
572
+ "transformer.h.27.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
573
+ "transformer.h.27.mlp.w2.scales": "model-00004-of-00005.safetensors",
574
+ "transformer.h.28.attn.c_attn.bias": "model-00004-of-00005.safetensors",
575
+ "transformer.h.28.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
576
+ "transformer.h.28.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
577
+ "transformer.h.28.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
578
+ "transformer.h.28.attn.c_attn.scales": "model-00004-of-00005.safetensors",
579
+ "transformer.h.28.attn.c_proj.bias": "model-00004-of-00005.safetensors",
580
+ "transformer.h.28.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
581
+ "transformer.h.28.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
582
+ "transformer.h.28.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
583
+ "transformer.h.28.attn.c_proj.scales": "model-00004-of-00005.safetensors",
584
+ "transformer.h.28.ln_1.weight": "model-00004-of-00005.safetensors",
585
+ "transformer.h.28.ln_2.weight": "model-00004-of-00005.safetensors",
586
+ "transformer.h.28.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
587
+ "transformer.h.28.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
588
+ "transformer.h.28.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
589
+ "transformer.h.28.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
590
+ "transformer.h.28.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
591
+ "transformer.h.28.mlp.w1.bias": "model-00004-of-00005.safetensors",
592
+ "transformer.h.28.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
593
+ "transformer.h.28.mlp.w1.qweight": "model-00004-of-00005.safetensors",
594
+ "transformer.h.28.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
595
+ "transformer.h.28.mlp.w1.scales": "model-00004-of-00005.safetensors",
596
+ "transformer.h.28.mlp.w2.bias": "model-00004-of-00005.safetensors",
597
+ "transformer.h.28.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
598
+ "transformer.h.28.mlp.w2.qweight": "model-00004-of-00005.safetensors",
599
+ "transformer.h.28.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
600
+ "transformer.h.28.mlp.w2.scales": "model-00004-of-00005.safetensors",
601
+ "transformer.h.29.attn.c_attn.bias": "model-00004-of-00005.safetensors",
602
+ "transformer.h.29.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
603
+ "transformer.h.29.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
604
+ "transformer.h.29.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
605
+ "transformer.h.29.attn.c_attn.scales": "model-00004-of-00005.safetensors",
606
+ "transformer.h.29.attn.c_proj.bias": "model-00004-of-00005.safetensors",
607
+ "transformer.h.29.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
608
+ "transformer.h.29.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
609
+ "transformer.h.29.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
610
+ "transformer.h.29.attn.c_proj.scales": "model-00004-of-00005.safetensors",
611
+ "transformer.h.29.ln_1.weight": "model-00004-of-00005.safetensors",
612
+ "transformer.h.29.ln_2.weight": "model-00004-of-00005.safetensors",
613
+ "transformer.h.29.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
614
+ "transformer.h.29.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
615
+ "transformer.h.29.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
616
+ "transformer.h.29.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
617
+ "transformer.h.29.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
618
+ "transformer.h.29.mlp.w1.bias": "model-00004-of-00005.safetensors",
619
+ "transformer.h.29.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
620
+ "transformer.h.29.mlp.w1.qweight": "model-00004-of-00005.safetensors",
621
+ "transformer.h.29.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
622
+ "transformer.h.29.mlp.w1.scales": "model-00004-of-00005.safetensors",
623
+ "transformer.h.29.mlp.w2.bias": "model-00004-of-00005.safetensors",
624
+ "transformer.h.29.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
625
+ "transformer.h.29.mlp.w2.qweight": "model-00004-of-00005.safetensors",
626
+ "transformer.h.29.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
627
+ "transformer.h.29.mlp.w2.scales": "model-00004-of-00005.safetensors",
628
+ "transformer.h.3.attn.c_attn.bias": "model-00002-of-00005.safetensors",
629
+ "transformer.h.3.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
630
+ "transformer.h.3.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
631
+ "transformer.h.3.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
632
+ "transformer.h.3.attn.c_attn.scales": "model-00002-of-00005.safetensors",
633
+ "transformer.h.3.attn.c_proj.bias": "model-00002-of-00005.safetensors",
634
+ "transformer.h.3.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
635
+ "transformer.h.3.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
636
+ "transformer.h.3.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
637
+ "transformer.h.3.attn.c_proj.scales": "model-00002-of-00005.safetensors",
638
+ "transformer.h.3.ln_1.weight": "model-00002-of-00005.safetensors",
639
+ "transformer.h.3.ln_2.weight": "model-00002-of-00005.safetensors",
640
+ "transformer.h.3.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
641
+ "transformer.h.3.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
642
+ "transformer.h.3.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
643
+ "transformer.h.3.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
644
+ "transformer.h.3.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
645
+ "transformer.h.3.mlp.w1.bias": "model-00002-of-00005.safetensors",
646
+ "transformer.h.3.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
647
+ "transformer.h.3.mlp.w1.qweight": "model-00002-of-00005.safetensors",
648
+ "transformer.h.3.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
649
+ "transformer.h.3.mlp.w1.scales": "model-00002-of-00005.safetensors",
650
+ "transformer.h.3.mlp.w2.bias": "model-00002-of-00005.safetensors",
651
+ "transformer.h.3.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
652
+ "transformer.h.3.mlp.w2.qweight": "model-00002-of-00005.safetensors",
653
+ "transformer.h.3.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
654
+ "transformer.h.3.mlp.w2.scales": "model-00002-of-00005.safetensors",
655
+ "transformer.h.30.attn.c_attn.bias": "model-00004-of-00005.safetensors",
656
+ "transformer.h.30.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
657
+ "transformer.h.30.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
658
+ "transformer.h.30.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
659
+ "transformer.h.30.attn.c_attn.scales": "model-00004-of-00005.safetensors",
660
+ "transformer.h.30.attn.c_proj.bias": "model-00004-of-00005.safetensors",
661
+ "transformer.h.30.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
662
+ "transformer.h.30.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
663
+ "transformer.h.30.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
664
+ "transformer.h.30.attn.c_proj.scales": "model-00004-of-00005.safetensors",
665
+ "transformer.h.30.ln_1.weight": "model-00004-of-00005.safetensors",
666
+ "transformer.h.30.ln_2.weight": "model-00004-of-00005.safetensors",
667
+ "transformer.h.30.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
668
+ "transformer.h.30.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
669
+ "transformer.h.30.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
670
+ "transformer.h.30.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
671
+ "transformer.h.30.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
672
+ "transformer.h.30.mlp.w1.bias": "model-00004-of-00005.safetensors",
673
+ "transformer.h.30.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
674
+ "transformer.h.30.mlp.w1.qweight": "model-00004-of-00005.safetensors",
675
+ "transformer.h.30.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
676
+ "transformer.h.30.mlp.w1.scales": "model-00004-of-00005.safetensors",
677
+ "transformer.h.30.mlp.w2.bias": "model-00004-of-00005.safetensors",
678
+ "transformer.h.30.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
679
+ "transformer.h.30.mlp.w2.qweight": "model-00004-of-00005.safetensors",
680
+ "transformer.h.30.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
681
+ "transformer.h.30.mlp.w2.scales": "model-00004-of-00005.safetensors",
682
+ "transformer.h.31.attn.c_attn.bias": "model-00004-of-00005.safetensors",
683
+ "transformer.h.31.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
684
+ "transformer.h.31.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
685
+ "transformer.h.31.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
686
+ "transformer.h.31.attn.c_attn.scales": "model-00004-of-00005.safetensors",
687
+ "transformer.h.31.attn.c_proj.bias": "model-00004-of-00005.safetensors",
688
+ "transformer.h.31.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
689
+ "transformer.h.31.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
690
+ "transformer.h.31.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
691
+ "transformer.h.31.attn.c_proj.scales": "model-00004-of-00005.safetensors",
692
+ "transformer.h.31.ln_1.weight": "model-00004-of-00005.safetensors",
693
+ "transformer.h.31.ln_2.weight": "model-00004-of-00005.safetensors",
694
+ "transformer.h.31.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
695
+ "transformer.h.31.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
696
+ "transformer.h.31.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
697
+ "transformer.h.31.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
698
+ "transformer.h.31.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
699
+ "transformer.h.31.mlp.w1.bias": "model-00004-of-00005.safetensors",
700
+ "transformer.h.31.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
701
+ "transformer.h.31.mlp.w1.qweight": "model-00004-of-00005.safetensors",
702
+ "transformer.h.31.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
703
+ "transformer.h.31.mlp.w1.scales": "model-00004-of-00005.safetensors",
704
+ "transformer.h.31.mlp.w2.bias": "model-00004-of-00005.safetensors",
705
+ "transformer.h.31.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
706
+ "transformer.h.31.mlp.w2.qweight": "model-00004-of-00005.safetensors",
707
+ "transformer.h.31.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
708
+ "transformer.h.31.mlp.w2.scales": "model-00004-of-00005.safetensors",
709
+ "transformer.h.32.attn.c_attn.bias": "model-00004-of-00005.safetensors",
710
+ "transformer.h.32.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
711
+ "transformer.h.32.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
712
+ "transformer.h.32.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
713
+ "transformer.h.32.attn.c_attn.scales": "model-00004-of-00005.safetensors",
714
+ "transformer.h.32.attn.c_proj.bias": "model-00004-of-00005.safetensors",
715
+ "transformer.h.32.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
716
+ "transformer.h.32.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
717
+ "transformer.h.32.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
718
+ "transformer.h.32.attn.c_proj.scales": "model-00004-of-00005.safetensors",
719
+ "transformer.h.32.ln_1.weight": "model-00004-of-00005.safetensors",
720
+ "transformer.h.32.ln_2.weight": "model-00004-of-00005.safetensors",
721
+ "transformer.h.32.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
722
+ "transformer.h.32.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
723
+ "transformer.h.32.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
724
+ "transformer.h.32.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
725
+ "transformer.h.32.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
726
+ "transformer.h.32.mlp.w1.bias": "model-00004-of-00005.safetensors",
727
+ "transformer.h.32.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
728
+ "transformer.h.32.mlp.w1.qweight": "model-00004-of-00005.safetensors",
729
+ "transformer.h.32.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
730
+ "transformer.h.32.mlp.w1.scales": "model-00004-of-00005.safetensors",
731
+ "transformer.h.32.mlp.w2.bias": "model-00004-of-00005.safetensors",
732
+ "transformer.h.32.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
733
+ "transformer.h.32.mlp.w2.qweight": "model-00004-of-00005.safetensors",
734
+ "transformer.h.32.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
735
+ "transformer.h.32.mlp.w2.scales": "model-00004-of-00005.safetensors",
736
+ "transformer.h.33.attn.c_attn.bias": "model-00004-of-00005.safetensors",
737
+ "transformer.h.33.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
738
+ "transformer.h.33.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
739
+ "transformer.h.33.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
740
+ "transformer.h.33.attn.c_attn.scales": "model-00004-of-00005.safetensors",
741
+ "transformer.h.33.attn.c_proj.bias": "model-00004-of-00005.safetensors",
742
+ "transformer.h.33.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
743
+ "transformer.h.33.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
744
+ "transformer.h.33.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
745
+ "transformer.h.33.attn.c_proj.scales": "model-00004-of-00005.safetensors",
746
+ "transformer.h.33.ln_1.weight": "model-00004-of-00005.safetensors",
747
+ "transformer.h.33.ln_2.weight": "model-00004-of-00005.safetensors",
748
+ "transformer.h.33.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
749
+ "transformer.h.33.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
750
+ "transformer.h.33.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
751
+ "transformer.h.33.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
752
+ "transformer.h.33.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
753
+ "transformer.h.33.mlp.w1.bias": "model-00004-of-00005.safetensors",
754
+ "transformer.h.33.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
755
+ "transformer.h.33.mlp.w1.qweight": "model-00004-of-00005.safetensors",
756
+ "transformer.h.33.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
757
+ "transformer.h.33.mlp.w1.scales": "model-00004-of-00005.safetensors",
758
+ "transformer.h.33.mlp.w2.bias": "model-00004-of-00005.safetensors",
759
+ "transformer.h.33.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
760
+ "transformer.h.33.mlp.w2.qweight": "model-00004-of-00005.safetensors",
761
+ "transformer.h.33.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
762
+ "transformer.h.33.mlp.w2.scales": "model-00004-of-00005.safetensors",
763
+ "transformer.h.34.attn.c_attn.bias": "model-00004-of-00005.safetensors",
764
+ "transformer.h.34.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
765
+ "transformer.h.34.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
766
+ "transformer.h.34.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
767
+ "transformer.h.34.attn.c_attn.scales": "model-00004-of-00005.safetensors",
768
+ "transformer.h.34.attn.c_proj.bias": "model-00004-of-00005.safetensors",
769
+ "transformer.h.34.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
770
+ "transformer.h.34.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
771
+ "transformer.h.34.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
772
+ "transformer.h.34.attn.c_proj.scales": "model-00004-of-00005.safetensors",
773
+ "transformer.h.34.ln_1.weight": "model-00004-of-00005.safetensors",
774
+ "transformer.h.34.ln_2.weight": "model-00004-of-00005.safetensors",
775
+ "transformer.h.34.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
776
+ "transformer.h.34.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
777
+ "transformer.h.34.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
778
+ "transformer.h.34.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
779
+ "transformer.h.34.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
780
+ "transformer.h.34.mlp.w1.bias": "model-00004-of-00005.safetensors",
781
+ "transformer.h.34.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
782
+ "transformer.h.34.mlp.w1.qweight": "model-00004-of-00005.safetensors",
783
+ "transformer.h.34.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
784
+ "transformer.h.34.mlp.w1.scales": "model-00004-of-00005.safetensors",
785
+ "transformer.h.34.mlp.w2.bias": "model-00004-of-00005.safetensors",
786
+ "transformer.h.34.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
787
+ "transformer.h.34.mlp.w2.qweight": "model-00004-of-00005.safetensors",
788
+ "transformer.h.34.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
789
+ "transformer.h.34.mlp.w2.scales": "model-00004-of-00005.safetensors",
790
+ "transformer.h.35.attn.c_attn.bias": "model-00004-of-00005.safetensors",
791
+ "transformer.h.35.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
792
+ "transformer.h.35.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
793
+ "transformer.h.35.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
794
+ "transformer.h.35.attn.c_attn.scales": "model-00004-of-00005.safetensors",
795
+ "transformer.h.35.attn.c_proj.bias": "model-00004-of-00005.safetensors",
796
+ "transformer.h.35.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
797
+ "transformer.h.35.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
798
+ "transformer.h.35.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
799
+ "transformer.h.35.attn.c_proj.scales": "model-00004-of-00005.safetensors",
800
+ "transformer.h.35.ln_1.weight": "model-00004-of-00005.safetensors",
801
+ "transformer.h.35.ln_2.weight": "model-00004-of-00005.safetensors",
802
+ "transformer.h.35.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
803
+ "transformer.h.35.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
804
+ "transformer.h.35.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
805
+ "transformer.h.35.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
806
+ "transformer.h.35.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
807
+ "transformer.h.35.mlp.w1.bias": "model-00004-of-00005.safetensors",
808
+ "transformer.h.35.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
809
+ "transformer.h.35.mlp.w1.qweight": "model-00004-of-00005.safetensors",
810
+ "transformer.h.35.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
811
+ "transformer.h.35.mlp.w1.scales": "model-00004-of-00005.safetensors",
812
+ "transformer.h.35.mlp.w2.bias": "model-00004-of-00005.safetensors",
813
+ "transformer.h.35.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
814
+ "transformer.h.35.mlp.w2.qweight": "model-00004-of-00005.safetensors",
815
+ "transformer.h.35.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
816
+ "transformer.h.35.mlp.w2.scales": "model-00004-of-00005.safetensors",
817
+ "transformer.h.36.attn.c_attn.bias": "model-00004-of-00005.safetensors",
818
+ "transformer.h.36.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
819
+ "transformer.h.36.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
820
+ "transformer.h.36.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
821
+ "transformer.h.36.attn.c_attn.scales": "model-00004-of-00005.safetensors",
822
+ "transformer.h.36.attn.c_proj.bias": "model-00004-of-00005.safetensors",
823
+ "transformer.h.36.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
824
+ "transformer.h.36.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
825
+ "transformer.h.36.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
826
+ "transformer.h.36.attn.c_proj.scales": "model-00004-of-00005.safetensors",
827
+ "transformer.h.36.ln_1.weight": "model-00004-of-00005.safetensors",
828
+ "transformer.h.36.ln_2.weight": "model-00004-of-00005.safetensors",
829
+ "transformer.h.36.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
830
+ "transformer.h.36.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
831
+ "transformer.h.36.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
832
+ "transformer.h.36.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
833
+ "transformer.h.36.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
834
+ "transformer.h.36.mlp.w1.bias": "model-00004-of-00005.safetensors",
835
+ "transformer.h.36.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
836
+ "transformer.h.36.mlp.w1.qweight": "model-00004-of-00005.safetensors",
837
+ "transformer.h.36.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
838
+ "transformer.h.36.mlp.w1.scales": "model-00004-of-00005.safetensors",
839
+ "transformer.h.36.mlp.w2.bias": "model-00004-of-00005.safetensors",
840
+ "transformer.h.36.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
841
+ "transformer.h.36.mlp.w2.qweight": "model-00004-of-00005.safetensors",
842
+ "transformer.h.36.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
843
+ "transformer.h.36.mlp.w2.scales": "model-00004-of-00005.safetensors",
844
+ "transformer.h.37.attn.c_attn.bias": "model-00004-of-00005.safetensors",
845
+ "transformer.h.37.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
846
+ "transformer.h.37.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
847
+ "transformer.h.37.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
848
+ "transformer.h.37.attn.c_attn.scales": "model-00004-of-00005.safetensors",
849
+ "transformer.h.37.attn.c_proj.bias": "model-00004-of-00005.safetensors",
850
+ "transformer.h.37.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
851
+ "transformer.h.37.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
852
+ "transformer.h.37.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
853
+ "transformer.h.37.attn.c_proj.scales": "model-00004-of-00005.safetensors",
854
+ "transformer.h.37.ln_1.weight": "model-00004-of-00005.safetensors",
855
+ "transformer.h.37.ln_2.weight": "model-00004-of-00005.safetensors",
856
+ "transformer.h.37.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
857
+ "transformer.h.37.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
858
+ "transformer.h.37.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
859
+ "transformer.h.37.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
860
+ "transformer.h.37.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
861
+ "transformer.h.37.mlp.w1.bias": "model-00004-of-00005.safetensors",
862
+ "transformer.h.37.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
863
+ "transformer.h.37.mlp.w1.qweight": "model-00004-of-00005.safetensors",
864
+ "transformer.h.37.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
865
+ "transformer.h.37.mlp.w1.scales": "model-00004-of-00005.safetensors",
866
+ "transformer.h.37.mlp.w2.bias": "model-00004-of-00005.safetensors",
867
+ "transformer.h.37.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
868
+ "transformer.h.37.mlp.w2.qweight": "model-00004-of-00005.safetensors",
869
+ "transformer.h.37.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
870
+ "transformer.h.37.mlp.w2.scales": "model-00004-of-00005.safetensors",
871
+ "transformer.h.38.attn.c_attn.bias": "model-00004-of-00005.safetensors",
872
+ "transformer.h.38.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
873
+ "transformer.h.38.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
874
+ "transformer.h.38.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
875
+ "transformer.h.38.attn.c_attn.scales": "model-00004-of-00005.safetensors",
876
+ "transformer.h.38.attn.c_proj.bias": "model-00004-of-00005.safetensors",
877
+ "transformer.h.38.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
878
+ "transformer.h.38.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
879
+ "transformer.h.38.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
880
+ "transformer.h.38.attn.c_proj.scales": "model-00004-of-00005.safetensors",
881
+ "transformer.h.38.ln_1.weight": "model-00004-of-00005.safetensors",
882
+ "transformer.h.38.ln_2.weight": "model-00004-of-00005.safetensors",
883
+ "transformer.h.38.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
884
+ "transformer.h.38.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
885
+ "transformer.h.38.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
886
+ "transformer.h.38.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
887
+ "transformer.h.38.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
888
+ "transformer.h.38.mlp.w1.bias": "model-00004-of-00005.safetensors",
889
+ "transformer.h.38.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
890
+ "transformer.h.38.mlp.w1.qweight": "model-00004-of-00005.safetensors",
891
+ "transformer.h.38.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
892
+ "transformer.h.38.mlp.w1.scales": "model-00004-of-00005.safetensors",
893
+ "transformer.h.38.mlp.w2.bias": "model-00004-of-00005.safetensors",
894
+ "transformer.h.38.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
895
+ "transformer.h.38.mlp.w2.qweight": "model-00004-of-00005.safetensors",
896
+ "transformer.h.38.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
897
+ "transformer.h.38.mlp.w2.scales": "model-00004-of-00005.safetensors",
898
+ "transformer.h.39.attn.c_attn.bias": "model-00004-of-00005.safetensors",
899
+ "transformer.h.39.attn.c_attn.g_idx": "model-00004-of-00005.safetensors",
900
+ "transformer.h.39.attn.c_attn.qweight": "model-00004-of-00005.safetensors",
901
+ "transformer.h.39.attn.c_attn.qzeros": "model-00004-of-00005.safetensors",
902
+ "transformer.h.39.attn.c_attn.scales": "model-00004-of-00005.safetensors",
903
+ "transformer.h.39.attn.c_proj.bias": "model-00004-of-00005.safetensors",
904
+ "transformer.h.39.attn.c_proj.g_idx": "model-00004-of-00005.safetensors",
905
+ "transformer.h.39.attn.c_proj.qweight": "model-00004-of-00005.safetensors",
906
+ "transformer.h.39.attn.c_proj.qzeros": "model-00004-of-00005.safetensors",
907
+ "transformer.h.39.attn.c_proj.scales": "model-00004-of-00005.safetensors",
908
+ "transformer.h.39.ln_1.weight": "model-00004-of-00005.safetensors",
909
+ "transformer.h.39.ln_2.weight": "model-00004-of-00005.safetensors",
910
+ "transformer.h.39.mlp.c_proj.bias": "model-00004-of-00005.safetensors",
911
+ "transformer.h.39.mlp.c_proj.g_idx": "model-00004-of-00005.safetensors",
912
+ "transformer.h.39.mlp.c_proj.qweight": "model-00004-of-00005.safetensors",
913
+ "transformer.h.39.mlp.c_proj.qzeros": "model-00004-of-00005.safetensors",
914
+ "transformer.h.39.mlp.c_proj.scales": "model-00004-of-00005.safetensors",
915
+ "transformer.h.39.mlp.w1.bias": "model-00004-of-00005.safetensors",
916
+ "transformer.h.39.mlp.w1.g_idx": "model-00004-of-00005.safetensors",
917
+ "transformer.h.39.mlp.w1.qweight": "model-00004-of-00005.safetensors",
918
+ "transformer.h.39.mlp.w1.qzeros": "model-00004-of-00005.safetensors",
919
+ "transformer.h.39.mlp.w1.scales": "model-00004-of-00005.safetensors",
920
+ "transformer.h.39.mlp.w2.bias": "model-00004-of-00005.safetensors",
921
+ "transformer.h.39.mlp.w2.g_idx": "model-00004-of-00005.safetensors",
922
+ "transformer.h.39.mlp.w2.qweight": "model-00004-of-00005.safetensors",
923
+ "transformer.h.39.mlp.w2.qzeros": "model-00004-of-00005.safetensors",
924
+ "transformer.h.39.mlp.w2.scales": "model-00004-of-00005.safetensors",
925
+ "transformer.h.4.attn.c_attn.bias": "model-00002-of-00005.safetensors",
926
+ "transformer.h.4.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
927
+ "transformer.h.4.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
928
+ "transformer.h.4.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
929
+ "transformer.h.4.attn.c_attn.scales": "model-00002-of-00005.safetensors",
930
+ "transformer.h.4.attn.c_proj.bias": "model-00002-of-00005.safetensors",
931
+ "transformer.h.4.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
932
+ "transformer.h.4.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
933
+ "transformer.h.4.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
934
+ "transformer.h.4.attn.c_proj.scales": "model-00002-of-00005.safetensors",
935
+ "transformer.h.4.ln_1.weight": "model-00002-of-00005.safetensors",
936
+ "transformer.h.4.ln_2.weight": "model-00002-of-00005.safetensors",
937
+ "transformer.h.4.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
938
+ "transformer.h.4.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
939
+ "transformer.h.4.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
940
+ "transformer.h.4.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
941
+ "transformer.h.4.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
942
+ "transformer.h.4.mlp.w1.bias": "model-00002-of-00005.safetensors",
943
+ "transformer.h.4.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
944
+ "transformer.h.4.mlp.w1.qweight": "model-00002-of-00005.safetensors",
945
+ "transformer.h.4.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
946
+ "transformer.h.4.mlp.w1.scales": "model-00002-of-00005.safetensors",
947
+ "transformer.h.4.mlp.w2.bias": "model-00002-of-00005.safetensors",
948
+ "transformer.h.4.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
949
+ "transformer.h.4.mlp.w2.qweight": "model-00002-of-00005.safetensors",
950
+ "transformer.h.4.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
951
+ "transformer.h.4.mlp.w2.scales": "model-00002-of-00005.safetensors",
952
+ "transformer.h.5.attn.c_attn.bias": "model-00002-of-00005.safetensors",
953
+ "transformer.h.5.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
954
+ "transformer.h.5.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
955
+ "transformer.h.5.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
956
+ "transformer.h.5.attn.c_attn.scales": "model-00002-of-00005.safetensors",
957
+ "transformer.h.5.attn.c_proj.bias": "model-00002-of-00005.safetensors",
958
+ "transformer.h.5.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
959
+ "transformer.h.5.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
960
+ "transformer.h.5.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
961
+ "transformer.h.5.attn.c_proj.scales": "model-00002-of-00005.safetensors",
962
+ "transformer.h.5.ln_1.weight": "model-00002-of-00005.safetensors",
963
+ "transformer.h.5.ln_2.weight": "model-00002-of-00005.safetensors",
964
+ "transformer.h.5.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
965
+ "transformer.h.5.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
966
+ "transformer.h.5.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
967
+ "transformer.h.5.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
968
+ "transformer.h.5.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
969
+ "transformer.h.5.mlp.w1.bias": "model-00002-of-00005.safetensors",
970
+ "transformer.h.5.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
971
+ "transformer.h.5.mlp.w1.qweight": "model-00002-of-00005.safetensors",
972
+ "transformer.h.5.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
973
+ "transformer.h.5.mlp.w1.scales": "model-00002-of-00005.safetensors",
974
+ "transformer.h.5.mlp.w2.bias": "model-00002-of-00005.safetensors",
975
+ "transformer.h.5.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
976
+ "transformer.h.5.mlp.w2.qweight": "model-00002-of-00005.safetensors",
977
+ "transformer.h.5.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
978
+ "transformer.h.5.mlp.w2.scales": "model-00002-of-00005.safetensors",
979
+ "transformer.h.6.attn.c_attn.bias": "model-00002-of-00005.safetensors",
980
+ "transformer.h.6.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
981
+ "transformer.h.6.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
982
+ "transformer.h.6.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
983
+ "transformer.h.6.attn.c_attn.scales": "model-00002-of-00005.safetensors",
984
+ "transformer.h.6.attn.c_proj.bias": "model-00002-of-00005.safetensors",
985
+ "transformer.h.6.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
986
+ "transformer.h.6.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
987
+ "transformer.h.6.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
988
+ "transformer.h.6.attn.c_proj.scales": "model-00002-of-00005.safetensors",
989
+ "transformer.h.6.ln_1.weight": "model-00002-of-00005.safetensors",
990
+ "transformer.h.6.ln_2.weight": "model-00002-of-00005.safetensors",
991
+ "transformer.h.6.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
992
+ "transformer.h.6.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
993
+ "transformer.h.6.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
994
+ "transformer.h.6.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
995
+ "transformer.h.6.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
996
+ "transformer.h.6.mlp.w1.bias": "model-00002-of-00005.safetensors",
997
+ "transformer.h.6.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
998
+ "transformer.h.6.mlp.w1.qweight": "model-00002-of-00005.safetensors",
999
+ "transformer.h.6.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
1000
+ "transformer.h.6.mlp.w1.scales": "model-00002-of-00005.safetensors",
1001
+ "transformer.h.6.mlp.w2.bias": "model-00002-of-00005.safetensors",
1002
+ "transformer.h.6.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
1003
+ "transformer.h.6.mlp.w2.qweight": "model-00002-of-00005.safetensors",
1004
+ "transformer.h.6.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
1005
+ "transformer.h.6.mlp.w2.scales": "model-00002-of-00005.safetensors",
1006
+ "transformer.h.7.attn.c_attn.bias": "model-00002-of-00005.safetensors",
1007
+ "transformer.h.7.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
1008
+ "transformer.h.7.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
1009
+ "transformer.h.7.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
1010
+ "transformer.h.7.attn.c_attn.scales": "model-00002-of-00005.safetensors",
1011
+ "transformer.h.7.attn.c_proj.bias": "model-00002-of-00005.safetensors",
1012
+ "transformer.h.7.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
1013
+ "transformer.h.7.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
1014
+ "transformer.h.7.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
1015
+ "transformer.h.7.attn.c_proj.scales": "model-00002-of-00005.safetensors",
1016
+ "transformer.h.7.ln_1.weight": "model-00002-of-00005.safetensors",
1017
+ "transformer.h.7.ln_2.weight": "model-00002-of-00005.safetensors",
1018
+ "transformer.h.7.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
1019
+ "transformer.h.7.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
1020
+ "transformer.h.7.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
1021
+ "transformer.h.7.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
1022
+ "transformer.h.7.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
1023
+ "transformer.h.7.mlp.w1.bias": "model-00002-of-00005.safetensors",
1024
+ "transformer.h.7.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
1025
+ "transformer.h.7.mlp.w1.qweight": "model-00002-of-00005.safetensors",
1026
+ "transformer.h.7.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
1027
+ "transformer.h.7.mlp.w1.scales": "model-00002-of-00005.safetensors",
1028
+ "transformer.h.7.mlp.w2.bias": "model-00002-of-00005.safetensors",
1029
+ "transformer.h.7.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
1030
+ "transformer.h.7.mlp.w2.qweight": "model-00002-of-00005.safetensors",
1031
+ "transformer.h.7.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
1032
+ "transformer.h.7.mlp.w2.scales": "model-00002-of-00005.safetensors",
1033
+ "transformer.h.8.attn.c_attn.bias": "model-00002-of-00005.safetensors",
1034
+ "transformer.h.8.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
1035
+ "transformer.h.8.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
1036
+ "transformer.h.8.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
1037
+ "transformer.h.8.attn.c_attn.scales": "model-00002-of-00005.safetensors",
1038
+ "transformer.h.8.attn.c_proj.bias": "model-00002-of-00005.safetensors",
1039
+ "transformer.h.8.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
1040
+ "transformer.h.8.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
1041
+ "transformer.h.8.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
1042
+ "transformer.h.8.attn.c_proj.scales": "model-00002-of-00005.safetensors",
1043
+ "transformer.h.8.ln_1.weight": "model-00002-of-00005.safetensors",
1044
+ "transformer.h.8.ln_2.weight": "model-00002-of-00005.safetensors",
1045
+ "transformer.h.8.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
1046
+ "transformer.h.8.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
1047
+ "transformer.h.8.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
1048
+ "transformer.h.8.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
1049
+ "transformer.h.8.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
1050
+ "transformer.h.8.mlp.w1.bias": "model-00002-of-00005.safetensors",
1051
+ "transformer.h.8.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
1052
+ "transformer.h.8.mlp.w1.qweight": "model-00002-of-00005.safetensors",
1053
+ "transformer.h.8.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
1054
+ "transformer.h.8.mlp.w1.scales": "model-00002-of-00005.safetensors",
1055
+ "transformer.h.8.mlp.w2.bias": "model-00002-of-00005.safetensors",
1056
+ "transformer.h.8.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
1057
+ "transformer.h.8.mlp.w2.qweight": "model-00002-of-00005.safetensors",
1058
+ "transformer.h.8.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
1059
+ "transformer.h.8.mlp.w2.scales": "model-00002-of-00005.safetensors",
1060
+ "transformer.h.9.attn.c_attn.bias": "model-00002-of-00005.safetensors",
1061
+ "transformer.h.9.attn.c_attn.g_idx": "model-00002-of-00005.safetensors",
1062
+ "transformer.h.9.attn.c_attn.qweight": "model-00002-of-00005.safetensors",
1063
+ "transformer.h.9.attn.c_attn.qzeros": "model-00002-of-00005.safetensors",
1064
+ "transformer.h.9.attn.c_attn.scales": "model-00002-of-00005.safetensors",
1065
+ "transformer.h.9.attn.c_proj.bias": "model-00002-of-00005.safetensors",
1066
+ "transformer.h.9.attn.c_proj.g_idx": "model-00002-of-00005.safetensors",
1067
+ "transformer.h.9.attn.c_proj.qweight": "model-00002-of-00005.safetensors",
1068
+ "transformer.h.9.attn.c_proj.qzeros": "model-00002-of-00005.safetensors",
1069
+ "transformer.h.9.attn.c_proj.scales": "model-00002-of-00005.safetensors",
1070
+ "transformer.h.9.ln_1.weight": "model-00002-of-00005.safetensors",
1071
+ "transformer.h.9.ln_2.weight": "model-00002-of-00005.safetensors",
1072
+ "transformer.h.9.mlp.c_proj.bias": "model-00002-of-00005.safetensors",
1073
+ "transformer.h.9.mlp.c_proj.g_idx": "model-00002-of-00005.safetensors",
1074
+ "transformer.h.9.mlp.c_proj.qweight": "model-00002-of-00005.safetensors",
1075
+ "transformer.h.9.mlp.c_proj.qzeros": "model-00002-of-00005.safetensors",
1076
+ "transformer.h.9.mlp.c_proj.scales": "model-00002-of-00005.safetensors",
1077
+ "transformer.h.9.mlp.w1.bias": "model-00002-of-00005.safetensors",
1078
+ "transformer.h.9.mlp.w1.g_idx": "model-00002-of-00005.safetensors",
1079
+ "transformer.h.9.mlp.w1.qweight": "model-00002-of-00005.safetensors",
1080
+ "transformer.h.9.mlp.w1.qzeros": "model-00002-of-00005.safetensors",
1081
+ "transformer.h.9.mlp.w1.scales": "model-00002-of-00005.safetensors",
1082
+ "transformer.h.9.mlp.w2.bias": "model-00002-of-00005.safetensors",
1083
+ "transformer.h.9.mlp.w2.g_idx": "model-00002-of-00005.safetensors",
1084
+ "transformer.h.9.mlp.w2.qweight": "model-00002-of-00005.safetensors",
1085
+ "transformer.h.9.mlp.w2.qzeros": "model-00002-of-00005.safetensors",
1086
+ "transformer.h.9.mlp.w2.scales": "model-00002-of-00005.safetensors",
1087
+ "transformer.ln_f.weight": "model-00004-of-00005.safetensors",
1088
+ "transformer.wte.weight": "model-00001-of-00005.safetensors"
1089
+ }
1090
+ }
modeling_qwen.py ADDED
@@ -0,0 +1,1293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Alibaba Cloud.
2
+ #
3
+ # This source code is licensed under the license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ import importlib
7
+ import math
8
+ from typing import TYPE_CHECKING, Optional, Tuple, Union, Callable, List, Any, Generator
9
+
10
+ import torch
11
+ import torch.nn.functional as F
12
+ import torch.utils.checkpoint
13
+ from torch.cuda.amp import autocast
14
+
15
+ from torch.nn import CrossEntropyLoss
16
+ from transformers import PreTrainedTokenizer, GenerationConfig, StoppingCriteriaList
17
+ from transformers.generation.logits_process import LogitsProcessorList
18
+
19
+ if TYPE_CHECKING:
20
+ from transformers.generation.streamers import BaseStreamer
21
+ from transformers.generation.utils import GenerateOutput
22
+ from transformers.modeling_outputs import (
23
+ BaseModelOutputWithPast,
24
+ CausalLMOutputWithPast,
25
+ )
26
+ from transformers.modeling_utils import PreTrainedModel
27
+ from transformers.utils import logging
28
+
29
+ try:
30
+ from einops import rearrange
31
+ except ImportError:
32
+ rearrange = None
33
+ from torch import nn
34
+
35
+ SUPPORT_CUDA = torch.cuda.is_available()
36
+ SUPPORT_BF16 = SUPPORT_CUDA and torch.cuda.is_bf16_supported()
37
+ SUPPORT_FP16 = SUPPORT_CUDA and torch.cuda.get_device_capability(0)[0] >= 7
38
+
39
+ from .configuration_qwen import QWenConfig
40
+ from .qwen_generation_utils import (
41
+ HistoryType,
42
+ make_context,
43
+ decode_tokens,
44
+ get_stop_words_ids,
45
+ StopWordsLogitsProcessor,
46
+ )
47
+
48
+
49
+ logger = logging.get_logger(__name__)
50
+
51
+ _CHECKPOINT_FOR_DOC = "qwen"
52
+ _CONFIG_FOR_DOC = "QWenConfig"
53
+
54
+ QWen_PRETRAINED_MODEL_ARCHIVE_LIST = ["qwen-7b"]
55
+
56
+ _ERROR_BAD_CHAT_FORMAT = """\
57
+ We detect you are probably using the pretrained model (rather than chat model) for chatting, since the chat_format in generation_config is not "chatml".
58
+ If you are directly using the model downloaded from Huggingface, please make sure you are using our "Qwen/Qwen-7B-Chat" Huggingface model (rather than "Qwen/Qwen-7B") when you call model.chat().
59
+ 我们检测到您可能在使用预训练模型(而非chat模型)进行多轮chat,因为您当前在generation_config指定的chat_format,并未设置为我们在对话中所支持的"chatml"格式。
60
+ 如果您在直接使用我们从Huggingface提供的模型,请确保您在调用model.chat()时,使用的是"Qwen/Qwen-7B-Chat"模型(而非"Qwen/Qwen-7B"预训练模型)。
61
+ """
62
+
63
+ _SENTINEL = object()
64
+ _ERROR_STREAM_IN_CHAT = """\
65
+ Pass argument `stream` to model.chat() is buggy, deprecated, and marked for removal. Please use model.chat_stream(...) instead of model.chat(..., stream=True).
66
+ 向model.chat()传入参数stream的用法可能存在Bug,该用法已被废弃,将在未来被移除。请使用model.chat_stream(...)代替model.chat(..., stream=True)。
67
+ """
68
+
69
+ _ERROR_INPUT_CPU_QUERY_WITH_FLASH_ATTN_ACTIVATED = """\
70
+ We detect you have activated flash attention support, but running model computation on CPU. Please make sure that your input data has been placed on GPU. If you actually want to run CPU computation, please following the readme and set device_map="cpu" to disable flash attention when loading the model (calling AutoModelForCausalLM.from_pretrained).
71
+ 检测到您的模型已激活了flash attention支持,但正在执行CPU运算任务。如使用flash attention,请您确认模型输入已经传到GPU上。如果您确认要执行CPU运算,请您在载入模型(调用AutoModelForCausalLM.from_pretrained)时,按照readme说法,指定device_map="cpu"以禁用flash attention。
72
+ """
73
+
74
+ apply_rotary_emb_func = None
75
+ rms_norm = None
76
+ flash_attn_unpadded_func = None
77
+
78
+
79
+ def _import_flash_attn():
80
+ global apply_rotary_emb_func, rms_norm, flash_attn_unpadded_func
81
+ try:
82
+ from flash_attn.layers.rotary import apply_rotary_emb_func as __apply_rotary_emb_func
83
+ apply_rotary_emb_func = __apply_rotary_emb_func
84
+ except ImportError:
85
+ logger.warn(
86
+ "Warning: import flash_attn rotary fail, please install FlashAttention rotary to get higher efficiency "
87
+ "https://github.com/Dao-AILab/flash-attention/tree/main/csrc/rotary"
88
+ )
89
+
90
+ try:
91
+ from flash_attn.ops.rms_norm import rms_norm as __rms_norm
92
+ rms_norm = __rms_norm
93
+ except ImportError:
94
+ logger.warn(
95
+ "Warning: import flash_attn rms_norm fail, please install FlashAttention layer_norm to get higher efficiency "
96
+ "https://github.com/Dao-AILab/flash-attention/tree/main/csrc/layer_norm"
97
+ )
98
+
99
+ try:
100
+ import flash_attn
101
+ if not hasattr(flash_attn, '__version__'):
102
+ from flash_attn.flash_attn_interface import flash_attn_unpadded_func as __flash_attn_unpadded_func
103
+ else:
104
+ if int(flash_attn.__version__.split(".")[0]) >= 2:
105
+ from flash_attn.flash_attn_interface import flash_attn_varlen_func as __flash_attn_unpadded_func
106
+ else:
107
+ from flash_attn.flash_attn_interface import flash_attn_unpadded_func as __flash_attn_unpadded_func
108
+ flash_attn_unpadded_func = __flash_attn_unpadded_func
109
+ except ImportError:
110
+ logger.warn(
111
+ "Warning: import flash_attn fail, please install FlashAttention to get higher efficiency "
112
+ "https://github.com/Dao-AILab/flash-attention"
113
+ )
114
+
115
+
116
+ class FlashSelfAttention(torch.nn.Module):
117
+ def __init__(
118
+ self,
119
+ causal=False,
120
+ softmax_scale=None,
121
+ attention_dropout=0.0,
122
+ ):
123
+ super().__init__()
124
+ assert flash_attn_unpadded_func is not None, (
125
+ "Please install FlashAttention first, " "e.g., with pip install flash-attn"
126
+ )
127
+ assert (
128
+ rearrange is not None
129
+ ), "Please install einops first, e.g., with pip install einops"
130
+ self.causal = causal
131
+ self.softmax_scale = softmax_scale
132
+ self.dropout_p = attention_dropout
133
+
134
+ def unpad_input(self, hidden_states, attention_mask):
135
+ valid_mask = attention_mask.squeeze(1).squeeze(1).eq(0)
136
+ seqlens_in_batch = valid_mask.sum(dim=-1, dtype=torch.int32)
137
+ indices = torch.nonzero(valid_mask.flatten(), as_tuple=False).flatten()
138
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
139
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
140
+ hidden_states = hidden_states[indices]
141
+ return hidden_states, indices, cu_seqlens, max_seqlen_in_batch
142
+
143
+ def pad_input(self, hidden_states, indices, batch, seqlen):
144
+ output = torch.zeros(batch * seqlen, *hidden_states.shape[1:], device=hidden_states.device,
145
+ dtype=hidden_states.dtype)
146
+ output[indices] = hidden_states
147
+ return rearrange(output, '(b s) ... -> b s ...', b=batch)
148
+
149
+ def forward(self, q, k, v, attention_mask=None):
150
+ assert all((i.dtype in [torch.float16, torch.bfloat16] for i in (q, k, v)))
151
+ assert all((i.is_cuda for i in (q, k, v)))
152
+ batch_size, seqlen_q = q.shape[0], q.shape[1]
153
+ seqlen_k = k.shape[1]
154
+
155
+ q, k, v = [rearrange(x, "b s ... -> (b s) ...") for x in [q, k, v]]
156
+ cu_seqlens_q = torch.arange(
157
+ 0,
158
+ (batch_size + 1) * seqlen_q,
159
+ step=seqlen_q,
160
+ dtype=torch.int32,
161
+ device=q.device,
162
+ )
163
+
164
+ if attention_mask is not None:
165
+ k, indices_k, cu_seqlens_k, seqlen_k = self.unpad_input(k, attention_mask)
166
+ v = v[indices_k]
167
+ if seqlen_q == seqlen_k:
168
+ q = q[indices_k]
169
+ cu_seqlens_q = cu_seqlens_k
170
+ else:
171
+ cu_seqlens_k = torch.arange(
172
+ 0,
173
+ (batch_size + 1) * seqlen_k,
174
+ step=seqlen_k,
175
+ dtype=torch.int32,
176
+ device=q.device,
177
+ )
178
+
179
+ if self.training:
180
+ assert seqlen_k == seqlen_q
181
+ is_causal = self.causal
182
+ dropout_p = self.dropout_p
183
+ else:
184
+ is_causal = seqlen_q == seqlen_k
185
+ dropout_p = 0
186
+
187
+ output = flash_attn_unpadded_func(
188
+ q,
189
+ k,
190
+ v,
191
+ cu_seqlens_q,
192
+ cu_seqlens_k,
193
+ seqlen_q,
194
+ seqlen_k,
195
+ dropout_p,
196
+ softmax_scale=self.softmax_scale,
197
+ causal=is_causal,
198
+ )
199
+ if attention_mask is not None and seqlen_q == seqlen_k:
200
+ output = self.pad_input(output, indices_k, batch_size, seqlen_q)
201
+ else:
202
+ new_shape = (batch_size, output.shape[0] // batch_size) + output.shape[1:]
203
+ output = output.view(new_shape)
204
+ return output
205
+
206
+
207
+ class QWenAttention(nn.Module):
208
+ def __init__(self, config):
209
+ super().__init__()
210
+
211
+ self.register_buffer("masked_bias", torch.tensor(-1e4), persistent=False)
212
+ self.seq_length = config.seq_length
213
+
214
+ self.hidden_size = config.hidden_size
215
+ self.split_size = config.hidden_size
216
+ self.num_heads = config.num_attention_heads
217
+ self.head_dim = self.hidden_size // self.num_heads
218
+
219
+ self.use_flash_attn = config.use_flash_attn
220
+ self.scale_attn_weights = True
221
+
222
+ self.projection_size = config.kv_channels * config.num_attention_heads
223
+
224
+ assert self.projection_size % config.num_attention_heads == 0
225
+ self.hidden_size_per_attention_head = (
226
+ self.projection_size // config.num_attention_heads
227
+ )
228
+
229
+ self.c_attn = nn.Linear(config.hidden_size, 3 * self.projection_size)
230
+
231
+ self.c_proj = nn.Linear(
232
+ config.hidden_size, self.projection_size, bias=not config.no_bias
233
+ )
234
+
235
+ self.is_fp32 = not (config.bf16 or config.fp16)
236
+ if (
237
+ self.use_flash_attn
238
+ and flash_attn_unpadded_func is not None
239
+ and not self.is_fp32
240
+ ):
241
+ self.core_attention_flash = FlashSelfAttention(
242
+ causal=True, attention_dropout=config.attn_dropout_prob
243
+ )
244
+ self.bf16 = config.bf16
245
+
246
+ self.use_dynamic_ntk = config.use_dynamic_ntk
247
+ self.use_logn_attn = config.use_logn_attn
248
+
249
+ logn_list = [
250
+ math.log(i, self.seq_length) if i > self.seq_length else 1
251
+ for i in range(1, 32768)
252
+ ]
253
+ logn_tensor = torch.tensor(logn_list)[None, :, None, None]
254
+ self.register_buffer("logn_tensor", logn_tensor, persistent=False)
255
+
256
+ self.attn_dropout = nn.Dropout(config.attn_dropout_prob)
257
+
258
+ def _attn(self, query, key, value, registered_causal_mask, attention_mask=None, head_mask=None):
259
+ attn_weights = torch.matmul(query, key.transpose(-1, -2))
260
+
261
+ if self.scale_attn_weights:
262
+ attn_weights = attn_weights / torch.full(
263
+ [],
264
+ value.size(-1) ** 0.5,
265
+ dtype=attn_weights.dtype,
266
+ device=attn_weights.device,
267
+ )
268
+
269
+ query_length, key_length = query.size(-2), key.size(-2)
270
+ causal_mask = registered_causal_mask[
271
+ :, :, key_length - query_length : key_length, :key_length
272
+ ]
273
+ mask_value = torch.finfo(attn_weights.dtype).min
274
+ mask_value = torch.full([], mask_value, dtype=attn_weights.dtype).to(
275
+ attn_weights.device
276
+ )
277
+ attn_weights = torch.where(
278
+ causal_mask, attn_weights.to(attn_weights.dtype), mask_value
279
+ )
280
+
281
+ if attention_mask is not None:
282
+ attn_weights = attn_weights + attention_mask
283
+
284
+ attn_weights = nn.functional.softmax(attn_weights.float(), dim=-1)
285
+
286
+ attn_weights = attn_weights.type(value.dtype)
287
+ attn_weights = self.attn_dropout(attn_weights)
288
+
289
+ if head_mask is not None:
290
+ attn_weights = attn_weights * head_mask
291
+
292
+ attn_output = torch.matmul(attn_weights, value)
293
+ attn_output = attn_output.transpose(1, 2)
294
+
295
+ return attn_output, attn_weights
296
+
297
+ def _upcast_and_reordered_attn(
298
+ self, query, key, value, registered_causal_mask, attention_mask=None, head_mask=None
299
+ ):
300
+ bsz, num_heads, q_seq_len, dk = query.size()
301
+ _, _, k_seq_len, _ = key.size()
302
+
303
+ attn_weights = torch.empty(
304
+ bsz * num_heads,
305
+ q_seq_len,
306
+ k_seq_len,
307
+ dtype=torch.float32,
308
+ device=query.device,
309
+ )
310
+
311
+ scale_factor = 1.0
312
+ if self.scale_attn_weights:
313
+ scale_factor /= float(value.size(-1)) ** 0.5
314
+
315
+ with autocast(enabled=False):
316
+ q, k = query.reshape(-1, q_seq_len, dk), key.transpose(-1, -2).reshape(
317
+ -1, dk, k_seq_len
318
+ )
319
+ attn_weights = torch.baddbmm(
320
+ attn_weights, q.float(), k.float(), beta=0, alpha=scale_factor
321
+ )
322
+ attn_weights = attn_weights.reshape(bsz, num_heads, q_seq_len, k_seq_len)
323
+
324
+ query_length, key_length = query.size(-2), key.size(-2)
325
+ causal_mask = registered_causal_mask[
326
+ :, :, key_length - query_length : key_length, :key_length
327
+ ]
328
+ mask_value = torch.finfo(attn_weights.dtype).min
329
+ mask_value = torch.tensor(mask_value, dtype=attn_weights.dtype).to(
330
+ attn_weights.device
331
+ )
332
+ attn_weights = torch.where(causal_mask, attn_weights, mask_value)
333
+
334
+ if attention_mask is not None:
335
+ attn_weights = attn_weights + attention_mask
336
+
337
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1)
338
+
339
+ if attn_weights.dtype != torch.float32:
340
+ raise RuntimeError(
341
+ "Error with upcasting, attn_weights does not have dtype torch.float32"
342
+ )
343
+ attn_weights = attn_weights.type(value.dtype)
344
+ attn_weights = self.attn_dropout(attn_weights)
345
+
346
+ if head_mask is not None:
347
+ attn_weights = attn_weights * head_mask
348
+
349
+ attn_output = torch.matmul(attn_weights, value)
350
+
351
+ return attn_output, attn_weights
352
+
353
+ def _split_heads(self, tensor, num_heads, attn_head_size):
354
+ new_shape = tensor.size()[:-1] + (num_heads, attn_head_size)
355
+ tensor = tensor.view(new_shape)
356
+ return tensor
357
+
358
+ def _merge_heads(self, tensor, num_heads, attn_head_size):
359
+ tensor = tensor.contiguous()
360
+ new_shape = tensor.size()[:-2] + (num_heads * attn_head_size,)
361
+ return tensor.view(new_shape)
362
+
363
+ def forward(
364
+ self,
365
+ hidden_states: Optional[Tuple[torch.FloatTensor]],
366
+ rotary_pos_emb_list: Optional[List[torch.Tensor]] = None,
367
+ registered_causal_mask: Optional[torch.Tensor] = None,
368
+ layer_past: Optional[Tuple[torch.Tensor]] = None,
369
+ attention_mask: Optional[torch.FloatTensor] = None,
370
+ head_mask: Optional[torch.FloatTensor] = None,
371
+ encoder_hidden_states: Optional[torch.Tensor] = None,
372
+ encoder_attention_mask: Optional[torch.FloatTensor] = None,
373
+ output_attentions: Optional[bool] = False,
374
+ use_cache: Optional[bool] = False,
375
+ ):
376
+
377
+ mixed_x_layer = self.c_attn(hidden_states)
378
+
379
+ query, key, value = mixed_x_layer.split(self.split_size, dim=2)
380
+
381
+ query = self._split_heads(query, self.num_heads, self.head_dim)
382
+ key = self._split_heads(key, self.num_heads, self.head_dim)
383
+ value = self._split_heads(value, self.num_heads, self.head_dim)
384
+
385
+ if rotary_pos_emb_list is not None:
386
+ cur_len = query.shape[1]
387
+ if len(rotary_pos_emb_list) == 1:
388
+ rotary_pos_emb = rotary_pos_emb_list[0]
389
+ rotary_pos_emb = [i[:, -cur_len:, :, :] for i in rotary_pos_emb]
390
+ rotary_pos_emb = (rotary_pos_emb,) * 2
391
+ q_pos_emb, k_pos_emb = rotary_pos_emb
392
+ # Slice the pos emb for current inference
393
+ query = apply_rotary_pos_emb(query, q_pos_emb)
394
+ key = apply_rotary_pos_emb(key, k_pos_emb)
395
+ else:
396
+ query_list = []
397
+ key_list = []
398
+ for i, rotary_pos_emb in enumerate(rotary_pos_emb_list):
399
+ rotary_pos_emb = [i[:, -cur_len:, :, :] for i in rotary_pos_emb]
400
+ rotary_pos_emb = (rotary_pos_emb,) * 2
401
+ q_pos_emb, k_pos_emb = rotary_pos_emb
402
+ # Slice the pos emb for current inference
403
+ query_list += [apply_rotary_pos_emb(query[i:i+1, :, :], q_pos_emb)]
404
+ key_list += [apply_rotary_pos_emb(key[i:i+1, :, :], k_pos_emb)]
405
+ query = torch.cat(query_list, dim=0)
406
+ key = torch.cat(key_list, dim=0)
407
+
408
+ if layer_past is not None:
409
+ past_key, past_value = layer_past[0], layer_past[1]
410
+ key = torch.cat((past_key, key), dim=1)
411
+ value = torch.cat((past_value, value), dim=1)
412
+
413
+ if use_cache:
414
+ present = (key, value)
415
+ else:
416
+ present = None
417
+
418
+ if self.use_logn_attn and not self.training:
419
+ seq_start = key.size(1) - query.size(1)
420
+ seq_end = key.size(1)
421
+ logn_tensor = self.logn_tensor[:, seq_start:seq_end, :, :]
422
+ query = query * logn_tensor.expand_as(query)
423
+
424
+ if (
425
+ self.use_flash_attn
426
+ and flash_attn_unpadded_func is not None
427
+ and not self.is_fp32
428
+ and query.is_cuda
429
+ ):
430
+ q, k, v = query, key, value
431
+ context_layer = self.core_attention_flash(q, k, v, attention_mask=attention_mask)
432
+
433
+ # b s h d -> b s (h d)
434
+ context_layer = context_layer.flatten(2,3).contiguous()
435
+
436
+ else:
437
+ query = query.permute(0, 2, 1, 3)
438
+ key = key.permute(0, 2, 1, 3)
439
+ value = value.permute(0, 2, 1, 3)
440
+ if (
441
+ registered_causal_mask is None
442
+ and self.use_flash_attn
443
+ and flash_attn_unpadded_func is not None
444
+ and not self.is_fp32
445
+ and not query.is_cuda
446
+ ):
447
+ raise Exception(_ERROR_INPUT_CPU_QUERY_WITH_FLASH_ATTN_ACTIVATED)
448
+ attn_output, attn_weight = self._attn(
449
+ query, key, value, registered_causal_mask, attention_mask, head_mask
450
+ )
451
+ context_layer = self._merge_heads(
452
+ attn_output, self.num_heads, self.head_dim
453
+ )
454
+
455
+ attn_output = self.c_proj(context_layer)
456
+
457
+ outputs = (attn_output, present)
458
+ if output_attentions:
459
+ if (
460
+ self.use_flash_attn
461
+ and flash_attn_unpadded_func is not None
462
+ and not self.is_fp32
463
+ ):
464
+ raise ValueError("Cannot output attentions while using flash-attn")
465
+ else:
466
+ outputs += (attn_weight,)
467
+
468
+ return outputs
469
+
470
+
471
+ class QWenMLP(nn.Module):
472
+ def __init__(self, config):
473
+ super().__init__()
474
+ self.w1 = nn.Linear(
475
+ config.hidden_size, config.intermediate_size // 2, bias=not config.no_bias
476
+ )
477
+ self.w2 = nn.Linear(
478
+ config.hidden_size, config.intermediate_size // 2, bias=not config.no_bias
479
+ )
480
+ ff_dim_in = config.intermediate_size // 2
481
+ self.c_proj = nn.Linear(ff_dim_in, config.hidden_size, bias=not config.no_bias)
482
+
483
+ def forward(self, hidden_states):
484
+ a1 = self.w1(hidden_states)
485
+ a2 = self.w2(hidden_states)
486
+ intermediate_parallel = a1 * F.silu(a2)
487
+ output = self.c_proj(intermediate_parallel)
488
+ return output
489
+
490
+ class QWenBlock(nn.Module):
491
+ def __init__(self, config):
492
+ super().__init__()
493
+ hidden_size = config.hidden_size
494
+ self.bf16 = config.bf16
495
+
496
+ self.ln_1 = RMSNorm(
497
+ hidden_size,
498
+ eps=config.layer_norm_epsilon,
499
+ )
500
+ self.attn = QWenAttention(config)
501
+ self.ln_2 = RMSNorm(
502
+ hidden_size,
503
+ eps=config.layer_norm_epsilon,
504
+ )
505
+
506
+ self.mlp = QWenMLP(config)
507
+
508
+ def forward(
509
+ self,
510
+ hidden_states: Optional[Tuple[torch.FloatTensor]],
511
+ rotary_pos_emb_list: Optional[List[torch.Tensor]] = None,
512
+ registered_causal_mask: Optional[torch.Tensor] = None,
513
+ layer_past: Optional[Tuple[torch.Tensor]] = None,
514
+ attention_mask: Optional[torch.FloatTensor] = None,
515
+ head_mask: Optional[torch.FloatTensor] = None,
516
+ encoder_hidden_states: Optional[torch.Tensor] = None,
517
+ encoder_attention_mask: Optional[torch.FloatTensor] = None,
518
+ use_cache: Optional[bool] = False,
519
+ output_attentions: Optional[bool] = False,
520
+ ):
521
+ layernorm_output = self.ln_1(hidden_states)
522
+
523
+ attn_outputs = self.attn(
524
+ layernorm_output,
525
+ rotary_pos_emb_list,
526
+ registered_causal_mask=registered_causal_mask,
527
+ layer_past=layer_past,
528
+ attention_mask=attention_mask,
529
+ head_mask=head_mask,
530
+ use_cache=use_cache,
531
+ output_attentions=output_attentions,
532
+ )
533
+ attn_output = attn_outputs[0]
534
+
535
+ outputs = attn_outputs[1:]
536
+
537
+ residual = hidden_states
538
+ layernorm_input = attn_output + residual
539
+
540
+ layernorm_output = self.ln_2(layernorm_input)
541
+
542
+ residual = layernorm_input
543
+ mlp_output = self.mlp(layernorm_output)
544
+ hidden_states = residual + mlp_output
545
+
546
+ if use_cache:
547
+ outputs = (hidden_states,) + outputs
548
+ else:
549
+ outputs = (hidden_states,) + outputs[1:]
550
+
551
+ return outputs
552
+
553
+
554
+ class QWenPreTrainedModel(PreTrainedModel):
555
+ config_class = QWenConfig
556
+ base_model_prefix = "transformer"
557
+ is_parallelizable = False
558
+ supports_gradient_checkpointing = True
559
+ _no_split_modules = ["QWenBlock"]
560
+
561
+ def __init__(self, *inputs, **kwargs):
562
+ super().__init__(*inputs, **kwargs)
563
+
564
+ def _init_weights(self, module):
565
+ """Initialize the weights."""
566
+ if isinstance(module, nn.Linear):
567
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
568
+ if module.bias is not None:
569
+ module.bias.data.zero_()
570
+ elif isinstance(module, nn.Embedding):
571
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
572
+ if module.padding_idx is not None:
573
+ module.weight.data[module.padding_idx].zero_()
574
+ elif isinstance(module, RMSNorm):
575
+ module.weight.data.fill_(1.0)
576
+
577
+ for name, p in module.named_parameters():
578
+ if name == "c_proj.weight":
579
+ p.data.normal_(
580
+ mean=0.0,
581
+ std=(
582
+ self.config.initializer_range
583
+ / math.sqrt(2 * self.config.num_hidden_layers)
584
+ ),
585
+ )
586
+
587
+ def _set_gradient_checkpointing(self, module, value=False):
588
+ if isinstance(module, QWenModel):
589
+ module.gradient_checkpointing = value
590
+
591
+
592
+ class QWenModel(QWenPreTrainedModel):
593
+ _keys_to_ignore_on_load_missing = ["attn.masked_bias"]
594
+
595
+ def __init__(self, config):
596
+ super().__init__(config)
597
+ self.vocab_size = config.vocab_size
598
+ self.num_hidden_layers = config.num_hidden_layers
599
+ self.embed_dim = config.hidden_size
600
+
601
+ self.gradient_checkpointing = False
602
+ self.use_dynamic_ntk = config.use_dynamic_ntk
603
+ self.seq_length = config.seq_length
604
+
605
+ self.wte = nn.Embedding(self.vocab_size, self.embed_dim)
606
+
607
+ self.drop = nn.Dropout(config.emb_dropout_prob)
608
+
609
+ if config.rotary_pct == 1.0:
610
+ self.rotary_ndims = None
611
+ else:
612
+ assert config.rotary_pct < 1
613
+ self.rotary_ndims = int(
614
+ config.kv_channels * config.rotary_pct
615
+ )
616
+ dim = (
617
+ self.rotary_ndims
618
+ if self.rotary_ndims is not None
619
+ else config.kv_channels
620
+ )
621
+ self.rotary_emb = RotaryEmbedding(dim, base=config.rotary_emb_base)
622
+
623
+ self.use_flash_attn = config.use_flash_attn
624
+ self.is_fp32 = not (config.bf16 or config.fp16)
625
+ if (
626
+ self.use_flash_attn
627
+ and flash_attn_unpadded_func is not None
628
+ and not self.is_fp32
629
+ ):
630
+ self.registered_causal_mask = None
631
+ else:
632
+ max_positions = config.max_position_embeddings
633
+ self.register_buffer(
634
+ "registered_causal_mask",
635
+ torch.tril(
636
+ torch.ones((max_positions, max_positions), dtype=torch.bool)
637
+ ).view(1, 1, max_positions, max_positions),
638
+ persistent=False,
639
+ )
640
+
641
+ self.h = nn.ModuleList(
642
+ [
643
+ QWenBlock(
644
+ config
645
+ )
646
+ for i in range(config.num_hidden_layers)
647
+ ]
648
+ )
649
+ self.ln_f = RMSNorm(
650
+ self.embed_dim,
651
+ eps=config.layer_norm_epsilon,
652
+ )
653
+
654
+ self.post_init()
655
+
656
+ def get_input_embeddings(self):
657
+ return self.wte
658
+
659
+ def set_input_embeddings(self, new_embeddings):
660
+ self.wte = new_embeddings
661
+
662
+ def get_ntk_alpha(self, true_seq_len):
663
+ context_value = math.log(true_seq_len / self.seq_length, 2) + 1
664
+ ntk_alpha = 2 ** math.ceil(context_value) - 1
665
+ ntk_alpha = max(ntk_alpha, 1)
666
+ return ntk_alpha
667
+
668
+ def forward(
669
+ self,
670
+ input_ids: Optional[torch.LongTensor] = None,
671
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor]]] = None,
672
+ attention_mask: Optional[torch.FloatTensor] = None,
673
+ token_type_ids: Optional[torch.LongTensor] = None,
674
+ position_ids: Optional[torch.LongTensor] = None,
675
+ head_mask: Optional[torch.FloatTensor] = None,
676
+ inputs_embeds: Optional[torch.FloatTensor] = None,
677
+ encoder_hidden_states: Optional[torch.Tensor] = None,
678
+ encoder_attention_mask: Optional[torch.FloatTensor] = None,
679
+ use_cache: Optional[bool] = None,
680
+ output_attentions: Optional[bool] = None,
681
+ output_hidden_states: Optional[bool] = None,
682
+ return_dict: Optional[bool] = None,
683
+ ):
684
+ output_attentions = (
685
+ output_attentions
686
+ if output_attentions is not None
687
+ else self.config.output_attentions
688
+ )
689
+ output_hidden_states = (
690
+ output_hidden_states
691
+ if output_hidden_states is not None
692
+ else self.config.output_hidden_states
693
+ )
694
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
695
+ return_dict = (
696
+ return_dict if return_dict is not None else self.config.use_return_dict
697
+ )
698
+
699
+ if input_ids is not None and inputs_embeds is not None:
700
+ raise ValueError(
701
+ "You cannot specify both input_ids and inputs_embeds at the same time"
702
+ )
703
+ elif input_ids is not None:
704
+ input_shape = input_ids.size()
705
+ input_ids = input_ids.view(-1, input_shape[-1])
706
+ batch_size = input_ids.shape[0]
707
+ elif inputs_embeds is not None:
708
+ input_shape = inputs_embeds.size()[:-1]
709
+ batch_size = inputs_embeds.shape[0]
710
+ else:
711
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
712
+
713
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
714
+
715
+ if token_type_ids is not None:
716
+ token_type_ids = token_type_ids.view(-1, input_shape[-1])
717
+ if position_ids is not None:
718
+ position_ids = position_ids.view(-1, input_shape[-1])
719
+
720
+ if past_key_values is None:
721
+ past_length = 0
722
+ past_key_values = tuple([None] * len(self.h))
723
+ else:
724
+ past_length = past_key_values[0][0].size(-2)
725
+
726
+ if position_ids is None:
727
+ position_ids = torch.arange(
728
+ past_length,
729
+ input_shape[-1] + past_length,
730
+ dtype=torch.long,
731
+ device=device,
732
+ )
733
+ position_ids = position_ids.unsqueeze(0).view(-1, input_shape[-1])
734
+
735
+ if attention_mask is not None:
736
+ if batch_size <= 0:
737
+ raise ValueError("batch_size has to be defined and > 0")
738
+ attention_mask = attention_mask.view(batch_size, -1)
739
+ attention_mask = attention_mask[:, None, None, :]
740
+ attention_mask = attention_mask.to(dtype=self.dtype)
741
+ attention_mask = (1.0 - attention_mask) * torch.finfo(self.dtype).min
742
+
743
+ encoder_attention_mask = None
744
+ head_mask = self.get_head_mask(head_mask, self.config.num_hidden_layers)
745
+
746
+ if inputs_embeds is None:
747
+ inputs_embeds = self.wte(input_ids)
748
+ hidden_states = inputs_embeds
749
+
750
+ kv_seq_len = hidden_states.size()[1]
751
+ if past_key_values[0] is not None:
752
+ # past key values[0][0] shape: bs * seq_len * head_num * dim
753
+ kv_seq_len += past_key_values[0][0].shape[1]
754
+
755
+ if self.training or not self.use_dynamic_ntk:
756
+ ntk_alpha_list = [1.0]
757
+ elif kv_seq_len != hidden_states.size()[1]:
758
+ ntk_alpha_list = self.rotary_emb._ntk_alpha_cached_list
759
+ else:
760
+ ntk_alpha_list = []
761
+ if attention_mask is not None and kv_seq_len > self.seq_length:
762
+ true_seq_lens = attention_mask.squeeze(1).squeeze(1).eq(0).sum(dim=-1, dtype=torch.int32)
763
+ for i in range(hidden_states.size()[0]):
764
+ true_seq_len = true_seq_lens[i].item()
765
+ ntk_alpha = self.get_ntk_alpha(true_seq_len)
766
+ ntk_alpha_list.append(ntk_alpha)
767
+ else:
768
+ ntk_alpha = self.get_ntk_alpha(kv_seq_len)
769
+ ntk_alpha_list.append(ntk_alpha)
770
+ self.rotary_emb._ntk_alpha_cached_list = ntk_alpha_list
771
+
772
+ rotary_pos_emb_list = []
773
+ for ntk_alpha in ntk_alpha_list:
774
+ rotary_pos_emb = self.rotary_emb(kv_seq_len, ntk_alpha=ntk_alpha)
775
+ rotary_pos_emb_list.append(rotary_pos_emb)
776
+
777
+ hidden_states = self.drop(hidden_states)
778
+ output_shape = input_shape + (hidden_states.size(-1),)
779
+
780
+ if self.gradient_checkpointing and self.training:
781
+ if use_cache:
782
+ logger.warning_once(
783
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
784
+ )
785
+ use_cache = False
786
+
787
+ presents = () if use_cache else None
788
+ all_self_attentions = () if output_attentions else None
789
+ all_hidden_states = () if output_hidden_states else None
790
+ for i, (block, layer_past) in enumerate(zip(self.h, past_key_values)):
791
+
792
+ if output_hidden_states:
793
+ all_hidden_states = all_hidden_states + (hidden_states,)
794
+
795
+ if self.gradient_checkpointing and self.training:
796
+
797
+ def create_custom_forward(module):
798
+ def custom_forward(*inputs):
799
+ # None for past_key_value
800
+ return module(*inputs, use_cache, output_attentions)
801
+
802
+ return custom_forward
803
+
804
+ outputs = torch.utils.checkpoint.checkpoint(
805
+ create_custom_forward(block),
806
+ hidden_states,
807
+ rotary_pos_emb_list,
808
+ self.registered_causal_mask,
809
+ None,
810
+ attention_mask,
811
+ head_mask[i],
812
+ encoder_hidden_states,
813
+ encoder_attention_mask,
814
+ )
815
+ else:
816
+ outputs = block(
817
+ hidden_states,
818
+ layer_past=layer_past,
819
+ rotary_pos_emb_list=rotary_pos_emb_list,
820
+ registered_causal_mask=self.registered_causal_mask,
821
+ attention_mask=attention_mask,
822
+ head_mask=head_mask[i],
823
+ encoder_hidden_states=encoder_hidden_states,
824
+ encoder_attention_mask=encoder_attention_mask,
825
+ use_cache=use_cache,
826
+ output_attentions=output_attentions,
827
+ )
828
+
829
+ hidden_states = outputs[0]
830
+ if use_cache is True:
831
+ presents = presents + (outputs[1],)
832
+
833
+ if output_attentions:
834
+ all_self_attentions = all_self_attentions + (outputs[2 if use_cache else 1],)
835
+
836
+ hidden_states = self.ln_f(hidden_states)
837
+ hidden_states = hidden_states.view(output_shape)
838
+ # Add last hidden state
839
+ if output_hidden_states:
840
+ all_hidden_states = all_hidden_states + (hidden_states,)
841
+
842
+ if not return_dict:
843
+ return tuple(
844
+ v for v in [hidden_states, presents, all_hidden_states] if v is not None
845
+ )
846
+
847
+ return BaseModelOutputWithPast(
848
+ last_hidden_state=hidden_states,
849
+ past_key_values=presents,
850
+ hidden_states=all_hidden_states,
851
+ attentions=all_self_attentions,
852
+ )
853
+
854
+
855
+ class QWenLMHeadModel(QWenPreTrainedModel):
856
+ _keys_to_ignore_on_load_missing = [r"h\.\d+\.attn\.rotary_emb\.inv_freq"]
857
+ _keys_to_ignore_on_load_unexpected = [r"h\.\d+\.attn\.masked_bias"]
858
+
859
+ def __init__(self, config):
860
+ super().__init__(config)
861
+ assert (
862
+ config.bf16 + config.fp16 + config.fp32 <= 1
863
+ ), "Only one of \"bf16\", \"fp16\", \"fp32\" can be true"
864
+ logger.warn(
865
+ "Warning: please make sure that you are using the latest codes and checkpoints, "
866
+ "especially if you used Qwen-7B before 09.25.2023."
867
+ "请使用最新模型和代码,尤其如果你在9月25日前已经开始使用Qwen-7B,千万注意不要使用错误代码和模型。"
868
+ )
869
+
870
+ autoset_precision = config.bf16 + config.fp16 + config.fp32 == 0
871
+
872
+ if autoset_precision:
873
+ if SUPPORT_BF16:
874
+ logger.warn(
875
+ "The model is automatically converting to bf16 for faster inference. "
876
+ "If you want to disable the automatic precision, please manually add bf16/fp16/fp32=True to \"AutoModelForCausalLM.from_pretrained\"."
877
+ )
878
+ config.bf16 = True
879
+ elif SUPPORT_FP16:
880
+ logger.warn(
881
+ "The model is automatically converting to fp16 for faster inference. "
882
+ "If you want to disable the automatic precision, please manually add bf16/fp16/fp32=True to \"AutoModelForCausalLM.from_pretrained\"."
883
+ )
884
+ config.fp16 = True
885
+ else:
886
+ config.fp32 = True
887
+
888
+ if config.bf16 and SUPPORT_CUDA and not SUPPORT_BF16:
889
+ logger.warn("Your device does NOT seem to support bf16, you can switch to fp16 or fp32 by by passing fp16/fp32=True in \"AutoModelForCausalLM.from_pretrained\".")
890
+ if config.fp16 and SUPPORT_CUDA and not SUPPORT_FP16:
891
+ logger.warn("Your device does NOT support faster inference with fp16, please switch to fp32 which is likely to be faster")
892
+ if config.fp32:
893
+ if SUPPORT_BF16:
894
+ logger.warn("Your device support faster inference by passing bf16=True in \"AutoModelForCausalLM.from_pretrained\".")
895
+ elif SUPPORT_FP16:
896
+ logger.warn("Your device support faster inference by passing fp16=True in \"AutoModelForCausalLM.from_pretrained\".")
897
+
898
+ if config.use_flash_attn == "auto":
899
+ if config.bf16 or config.fp16:
900
+ logger.warn("Try importing flash-attention for faster inference...")
901
+ config.use_flash_attn = True
902
+ else:
903
+ config.use_flash_attn = False
904
+ if config.use_flash_attn and config.fp32:
905
+ logger.warn("Flash attention will be disabled because it does NOT support fp32.")
906
+
907
+ if config.use_flash_attn:
908
+ _import_flash_attn()
909
+
910
+ self.transformer = QWenModel(config)
911
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
912
+
913
+ if config.bf16:
914
+ self.transformer.bfloat16()
915
+ self.lm_head.bfloat16()
916
+ if config.fp16:
917
+ self.transformer.half()
918
+ self.lm_head.half()
919
+ self.post_init()
920
+
921
+ def get_output_embeddings(self):
922
+ return self.lm_head
923
+
924
+ def set_output_embeddings(self, new_embeddings):
925
+ self.lm_head = new_embeddings
926
+
927
+ def prepare_inputs_for_generation(
928
+ self, input_ids, past_key_values=None, inputs_embeds=None, **kwargs
929
+ ):
930
+ token_type_ids = kwargs.get("token_type_ids", None)
931
+ if past_key_values:
932
+ input_ids = input_ids[:, -1].unsqueeze(-1)
933
+ if token_type_ids is not None:
934
+ token_type_ids = token_type_ids[:, -1].unsqueeze(-1)
935
+
936
+ attention_mask = kwargs.get("attention_mask", None)
937
+ position_ids = kwargs.get("position_ids", None)
938
+
939
+ if attention_mask is not None and position_ids is None:
940
+ position_ids = attention_mask.long().cumsum(-1) - 1
941
+ position_ids.masked_fill_(attention_mask == 0, 1)
942
+ if past_key_values:
943
+ position_ids = position_ids[:, -1].unsqueeze(-1)
944
+ else:
945
+ position_ids = None
946
+
947
+ if inputs_embeds is not None and past_key_values is None:
948
+ model_inputs = {"inputs_embeds": inputs_embeds}
949
+ else:
950
+ model_inputs = {"input_ids": input_ids}
951
+
952
+ model_inputs.update(
953
+ {
954
+ "past_key_values": past_key_values,
955
+ "use_cache": kwargs.get("use_cache"),
956
+ "position_ids": position_ids,
957
+ "attention_mask": attention_mask,
958
+ "token_type_ids": token_type_ids,
959
+ }
960
+ )
961
+ return model_inputs
962
+
963
+ def forward(
964
+ self,
965
+ input_ids: Optional[torch.LongTensor] = None,
966
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor]]] = None,
967
+ attention_mask: Optional[torch.FloatTensor] = None,
968
+ token_type_ids: Optional[torch.LongTensor] = None,
969
+ position_ids: Optional[torch.LongTensor] = None,
970
+ head_mask: Optional[torch.FloatTensor] = None,
971
+ inputs_embeds: Optional[torch.FloatTensor] = None,
972
+ encoder_hidden_states: Optional[torch.Tensor] = None,
973
+ encoder_attention_mask: Optional[torch.FloatTensor] = None,
974
+ labels: Optional[torch.LongTensor] = None,
975
+ use_cache: Optional[bool] = None,
976
+ output_attentions: Optional[bool] = None,
977
+ output_hidden_states: Optional[bool] = None,
978
+ return_dict: Optional[bool] = None,
979
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
980
+
981
+ return_dict = (
982
+ return_dict if return_dict is not None else self.config.use_return_dict
983
+ )
984
+
985
+ transformer_outputs = self.transformer(
986
+ input_ids,
987
+ past_key_values=past_key_values,
988
+ attention_mask=attention_mask,
989
+ token_type_ids=token_type_ids,
990
+ position_ids=position_ids,
991
+ head_mask=head_mask,
992
+ inputs_embeds=inputs_embeds,
993
+ encoder_hidden_states=encoder_hidden_states,
994
+ encoder_attention_mask=encoder_attention_mask,
995
+ use_cache=use_cache,
996
+ output_attentions=output_attentions,
997
+ output_hidden_states=output_hidden_states,
998
+ return_dict=return_dict,
999
+ )
1000
+ hidden_states = transformer_outputs[0]
1001
+
1002
+ lm_logits = self.lm_head(hidden_states)
1003
+
1004
+ loss = None
1005
+ if labels is not None:
1006
+ labels = labels.to(lm_logits.device)
1007
+ shift_logits = lm_logits[..., :-1, :].contiguous()
1008
+ shift_labels = labels[..., 1:].contiguous()
1009
+ loss_fct = CrossEntropyLoss()
1010
+ loss = loss_fct(
1011
+ shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1)
1012
+ )
1013
+
1014
+ if not return_dict:
1015
+ output = (lm_logits,) + transformer_outputs[1:]
1016
+ return ((loss,) + output) if loss is not None else output
1017
+
1018
+ return CausalLMOutputWithPast(
1019
+ loss=loss,
1020
+ logits=lm_logits,
1021
+ past_key_values=transformer_outputs.past_key_values,
1022
+ hidden_states=transformer_outputs.hidden_states,
1023
+ attentions=transformer_outputs.attentions,
1024
+ )
1025
+
1026
+ @staticmethod
1027
+ def _reorder_cache(
1028
+ past_key_values: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor
1029
+ ) -> Tuple[Tuple[torch.Tensor]]:
1030
+
1031
+ return tuple(
1032
+ tuple(
1033
+ past_state.index_select(0, beam_idx.to(past_state.device))
1034
+ for past_state in layer_past
1035
+ )
1036
+ for layer_past in past_key_values
1037
+ )
1038
+
1039
+ def chat(
1040
+ self,
1041
+ tokenizer: PreTrainedTokenizer,
1042
+ query: str,
1043
+ history: Optional[HistoryType],
1044
+ system: str = "You are a helpful assistant.",
1045
+ append_history: bool = True,
1046
+ stream: Optional[bool] = _SENTINEL,
1047
+ stop_words_ids: Optional[List[List[int]]] = None,
1048
+ generation_config: Optional[GenerationConfig] = None,
1049
+ **kwargs,
1050
+ ) -> Tuple[str, HistoryType]:
1051
+ generation_config = generation_config if generation_config is not None else self.generation_config
1052
+
1053
+ assert stream is _SENTINEL, _ERROR_STREAM_IN_CHAT
1054
+ assert generation_config.chat_format == 'chatml', _ERROR_BAD_CHAT_FORMAT
1055
+ if history is None:
1056
+ history = []
1057
+ if stop_words_ids is None:
1058
+ stop_words_ids = []
1059
+
1060
+ max_window_size = kwargs.get('max_window_size', None)
1061
+ if max_window_size is None:
1062
+ max_window_size = generation_config.max_window_size
1063
+ raw_text, context_tokens = make_context(
1064
+ tokenizer,
1065
+ query,
1066
+ history=history,
1067
+ system=system,
1068
+ max_window_size=max_window_size,
1069
+ chat_format=generation_config.chat_format,
1070
+ )
1071
+
1072
+ stop_words_ids.extend(get_stop_words_ids(
1073
+ generation_config.chat_format, tokenizer
1074
+ ))
1075
+ input_ids = torch.tensor([context_tokens]).to(self.device)
1076
+ outputs = self.generate(
1077
+ input_ids,
1078
+ stop_words_ids=stop_words_ids,
1079
+ return_dict_in_generate=False,
1080
+ generation_config=generation_config,
1081
+ **kwargs,
1082
+ )
1083
+
1084
+ response = decode_tokens(
1085
+ outputs[0],
1086
+ tokenizer,
1087
+ raw_text_len=len(raw_text),
1088
+ context_length=len(context_tokens),
1089
+ chat_format=generation_config.chat_format,
1090
+ verbose=False,
1091
+ errors='replace'
1092
+ )
1093
+
1094
+ if append_history:
1095
+ history.append((query, response))
1096
+
1097
+ return response, history
1098
+
1099
+ def chat_stream(
1100
+ self,
1101
+ tokenizer: PreTrainedTokenizer,
1102
+ query: str,
1103
+ history: Optional[HistoryType],
1104
+ system: str = "You are a helpful assistant.",
1105
+ stop_words_ids: Optional[List[List[int]]] = None,
1106
+ logits_processor: Optional[LogitsProcessorList] = None,
1107
+ generation_config: Optional[GenerationConfig] = None,
1108
+ **kwargs,
1109
+ ) -> Generator[str, Any, None]:
1110
+ generation_config = generation_config if generation_config is not None else self.generation_config
1111
+ assert generation_config.chat_format == 'chatml', _ERROR_BAD_CHAT_FORMAT
1112
+ if history is None:
1113
+ history = []
1114
+ if stop_words_ids is None:
1115
+ stop_words_ids = []
1116
+
1117
+ max_window_size = kwargs.get('max_window_size', None)
1118
+ if max_window_size is None:
1119
+ max_window_size = generation_config.max_window_size
1120
+ raw_text, context_tokens = make_context(
1121
+ tokenizer,
1122
+ query,
1123
+ history=history,
1124
+ system=system,
1125
+ max_window_size=max_window_size,
1126
+ chat_format=generation_config.chat_format,
1127
+ )
1128
+
1129
+ stop_words_ids.extend(get_stop_words_ids(
1130
+ generation_config.chat_format, tokenizer
1131
+ ))
1132
+ if stop_words_ids is not None:
1133
+ stop_words_logits_processor = StopWordsLogitsProcessor(
1134
+ stop_words_ids=stop_words_ids,
1135
+ eos_token_id=generation_config.eos_token_id,
1136
+ )
1137
+ if logits_processor is None:
1138
+ logits_processor = LogitsProcessorList([stop_words_logits_processor])
1139
+ else:
1140
+ logits_processor.append(stop_words_logits_processor)
1141
+ input_ids = torch.tensor([context_tokens]).to(self.device)
1142
+
1143
+ from transformers_stream_generator.main import NewGenerationMixin, StreamGenerationConfig
1144
+ self.__class__.generate_stream = NewGenerationMixin.generate
1145
+ self.__class__.sample_stream = NewGenerationMixin.sample_stream
1146
+ stream_config = StreamGenerationConfig(**generation_config.to_dict(), do_stream=True)
1147
+
1148
+ def stream_generator():
1149
+ outputs = []
1150
+ for token in self.generate_stream(
1151
+ input_ids,
1152
+ return_dict_in_generate=False,
1153
+ generation_config=stream_config,
1154
+ logits_processor=logits_processor,
1155
+ seed=-1,
1156
+ **kwargs):
1157
+ outputs.append(token.item())
1158
+ yield tokenizer.decode(outputs, skip_special_tokens=True, errors='ignore')
1159
+
1160
+ return stream_generator()
1161
+
1162
+ def generate(
1163
+ self,
1164
+ inputs: Optional[torch.Tensor] = None,
1165
+ generation_config: Optional[GenerationConfig] = None,
1166
+ logits_processor: Optional[LogitsProcessorList] = None,
1167
+ stopping_criteria: Optional[StoppingCriteriaList] = None,
1168
+ prefix_allowed_tokens_fn: Optional[
1169
+ Callable[[int, torch.Tensor], List[int]]
1170
+ ] = None,
1171
+ synced_gpus: Optional[bool] = None,
1172
+ assistant_model: Optional["PreTrainedModel"] = None,
1173
+ streamer: Optional["BaseStreamer"] = None,
1174
+ **kwargs,
1175
+ ) -> Union[GenerateOutput, torch.LongTensor]:
1176
+ generation_config = generation_config if generation_config is not None else self.generation_config
1177
+
1178
+ # Process stop_words_ids.
1179
+ stop_words_ids = kwargs.pop("stop_words_ids", None)
1180
+ if stop_words_ids is None and generation_config is not None:
1181
+ stop_words_ids = getattr(generation_config, "stop_words_ids", None)
1182
+ if stop_words_ids is None:
1183
+ stop_words_ids = getattr(generation_config, "stop_words_ids", None)
1184
+
1185
+ if stop_words_ids is not None:
1186
+ stop_words_logits_processor = StopWordsLogitsProcessor(
1187
+ stop_words_ids=stop_words_ids,
1188
+ eos_token_id=generation_config.eos_token_id,
1189
+ )
1190
+ if logits_processor is None:
1191
+ logits_processor = LogitsProcessorList([stop_words_logits_processor])
1192
+ else:
1193
+ logits_processor.append(stop_words_logits_processor)
1194
+
1195
+ return super().generate(
1196
+ inputs,
1197
+ generation_config=generation_config,
1198
+ logits_processor=logits_processor,
1199
+ stopping_criteria=stopping_criteria,
1200
+ prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,
1201
+ synced_gpus=synced_gpus,
1202
+ assistant_model=assistant_model,
1203
+ streamer=streamer,
1204
+ **kwargs,
1205
+ )
1206
+
1207
+
1208
+ class RotaryEmbedding(torch.nn.Module):
1209
+ def __init__(self, dim, base=10000):
1210
+ super().__init__()
1211
+ self.dim = dim
1212
+ self.base = base
1213
+ inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2).float() / dim))
1214
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
1215
+ if importlib.util.find_spec("einops") is None:
1216
+ raise RuntimeError("einops is required for Rotary Embedding")
1217
+
1218
+ self._rotary_pos_emb_cache = None
1219
+ self._seq_len_cached = 0
1220
+ self._ntk_alpha_cached = 1.0
1221
+ self._ntk_alpha_cached_list = [1.0]
1222
+
1223
+ def update_rotary_pos_emb_cache(self, max_seq_len, offset=0, ntk_alpha=1.0):
1224
+ seqlen = max_seq_len + offset
1225
+ if seqlen > self._seq_len_cached or ntk_alpha != self._ntk_alpha_cached:
1226
+ base = self.base * ntk_alpha ** (self.dim / (self.dim - 2))
1227
+ self.inv_freq = 1.0 / (
1228
+ base
1229
+ ** (
1230
+ torch.arange(0, self.dim, 2, device=self.inv_freq.device).float()
1231
+ / self.dim
1232
+ )
1233
+ )
1234
+ self._seq_len_cached = max(2 * seqlen, 16)
1235
+ self._ntk_alpha_cached = ntk_alpha
1236
+ seq = torch.arange(self._seq_len_cached, device=self.inv_freq.device)
1237
+ freqs = torch.outer(seq.type_as(self.inv_freq), self.inv_freq)
1238
+
1239
+ emb = torch.cat((freqs, freqs), dim=-1)
1240
+ from einops import rearrange
1241
+
1242
+ emb = rearrange(emb, "n d -> 1 n 1 d")
1243
+
1244
+ cos, sin = emb.cos(), emb.sin()
1245
+ self._rotary_pos_emb_cache = [cos, sin]
1246
+
1247
+ def forward(self, max_seq_len, offset=0, ntk_alpha=1.0):
1248
+ self.update_rotary_pos_emb_cache(max_seq_len, offset, ntk_alpha)
1249
+ cos, sin = self._rotary_pos_emb_cache
1250
+ return [cos[:, offset : offset + max_seq_len], sin[:, offset : offset + max_seq_len]]
1251
+
1252
+
1253
+ def _rotate_half(x):
1254
+ from einops import rearrange
1255
+
1256
+ x = rearrange(x, "... (j d) -> ... j d", j=2)
1257
+ x1, x2 = x.unbind(dim=-2)
1258
+ return torch.cat((-x2, x1), dim=-1)
1259
+
1260
+
1261
+ def apply_rotary_pos_emb(t, freqs):
1262
+ cos, sin = freqs
1263
+ if apply_rotary_emb_func is not None and t.is_cuda:
1264
+ t_ = t.float()
1265
+ cos = cos.squeeze(0).squeeze(1)[:, : cos.shape[-1] // 2]
1266
+ sin = sin.squeeze(0).squeeze(1)[:, : sin.shape[-1] // 2]
1267
+ output = apply_rotary_emb_func(t_, cos, sin).type_as(t)
1268
+ return output
1269
+ else:
1270
+ rot_dim = freqs[0].shape[-1]
1271
+ cos, sin = freqs
1272
+ t_, t_pass_ = t[..., :rot_dim], t[..., rot_dim:]
1273
+ t_ = t_.float()
1274
+ t_pass_ = t_pass_.float()
1275
+ t_ = (t_ * cos) + (_rotate_half(t_) * sin)
1276
+ return torch.cat((t_, t_pass_), dim=-1).type_as(t)
1277
+
1278
+
1279
+ class RMSNorm(torch.nn.Module):
1280
+ def __init__(self, dim: int, eps: float = 1e-6):
1281
+ super().__init__()
1282
+ self.eps = eps
1283
+ self.weight = nn.Parameter(torch.ones(dim))
1284
+
1285
+ def _norm(self, x):
1286
+ return x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps)
1287
+
1288
+ def forward(self, x):
1289
+ if rms_norm is not None and x.is_cuda:
1290
+ return rms_norm(x, self.weight, self.eps)
1291
+ else:
1292
+ output = self._norm(x.float()).type_as(x)
1293
+ return output * self.weight
quantize_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bits": 4,
3
+ "group_size": 128,
4
+ "damp_percent": 0.01,
5
+ "desc_act": false,
6
+ "static_groups": false,
7
+ "sym": true,
8
+ "true_sequential": true,
9
+ "model_name_or_path": null,
10
+ "model_file_base_name": null
11
+ }
qwen.tiktoken ADDED
The diff for this file is too large to render. See raw diff
 
qwen_generation_utils.py ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Alibaba Cloud.
2
+ #
3
+ # This source code is licensed under the license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ """Generation support."""
7
+
8
+ from typing import Tuple, List, Union, Iterable
9
+
10
+ import numpy as np
11
+ import torch
12
+ import torch.nn.functional as F
13
+ from transformers import PreTrainedTokenizer
14
+ from transformers import logging
15
+ from transformers.generation import LogitsProcessor
16
+
17
+ logger = logging.get_logger(__name__)
18
+
19
+ # Types.
20
+ HistoryType = List[Tuple[str, str]]
21
+ TokensType = List[int]
22
+ BatchTokensType = List[List[int]]
23
+
24
+
25
+ def pad_batch(batch: BatchTokensType, pad_id: int, seq_length: int) -> BatchTokensType:
26
+ for tokens in batch:
27
+ context_length = len(tokens)
28
+ if context_length < seq_length:
29
+ tokens.extend([pad_id] * (seq_length - context_length))
30
+ return batch
31
+
32
+
33
+ def get_ltor_masks_and_position_ids(
34
+ data,
35
+ eod_token,
36
+ reset_position_ids,
37
+ reset_attention_mask,
38
+ eod_mask_loss,
39
+ ):
40
+ """Build masks and position id for left to right model."""
41
+
42
+ # Extract batch size and sequence length.
43
+ micro_batch_size, seq_length = data.size()
44
+
45
+ # Attention mask (lower triangular).
46
+ if reset_attention_mask:
47
+ att_mask_batch = micro_batch_size
48
+ else:
49
+ att_mask_batch = 1
50
+ attention_mask = torch.tril(
51
+ torch.ones((att_mask_batch, seq_length, seq_length), device=data.device)
52
+ ).view(att_mask_batch, 1, seq_length, seq_length)
53
+
54
+ # Loss mask.
55
+ loss_mask = torch.ones(data.size(), dtype=torch.float, device=data.device)
56
+ if eod_mask_loss:
57
+ loss_mask[data == eod_token] = 0.0
58
+
59
+ # Position ids.
60
+ position_ids = torch.arange(seq_length, dtype=torch.long, device=data.device)
61
+ position_ids = position_ids.unsqueeze(0).expand_as(data)
62
+ # We need to clone as the ids will be modifed based on batch index.
63
+ if reset_position_ids:
64
+ position_ids = position_ids.clone()
65
+
66
+ if reset_position_ids or reset_attention_mask:
67
+ # Loop through the batches:
68
+ for b in range(micro_batch_size):
69
+
70
+ # Find indecies where EOD token is.
71
+ eod_index = position_ids[b, data[b] == eod_token]
72
+ # Detach indecies from positions if going to modify positions.
73
+ if reset_position_ids:
74
+ eod_index = eod_index.clone()
75
+
76
+ # Loop through EOD indecies:
77
+ prev_index = 0
78
+ for j in range(eod_index.size()[0]):
79
+ i = eod_index[j]
80
+ # Mask attention loss.
81
+ if reset_attention_mask:
82
+ attention_mask[b, 0, (i + 1) :, : (i + 1)] = 0
83
+ # Reset positions.
84
+ if reset_position_ids:
85
+ position_ids[b, (i + 1) :] -= i + 1 - prev_index
86
+ prev_index = i + 1
87
+
88
+ # Convert attention mask to binary:
89
+ attention_mask = attention_mask < 0.5
90
+
91
+ return attention_mask, loss_mask, position_ids
92
+
93
+
94
+ def get_batch(context_tokens: torch.LongTensor, eod_id: int):
95
+ """Generate batch from context tokens."""
96
+ # Move to GPU.
97
+ tokens = context_tokens.contiguous().to(context_tokens.device)
98
+ # Get the attention mask and postition ids.
99
+ attention_mask, _, position_ids = get_ltor_masks_and_position_ids(
100
+ tokens,
101
+ eod_id,
102
+ reset_position_ids=False,
103
+ reset_attention_mask=False,
104
+ eod_mask_loss=False,
105
+ )
106
+ return tokens, attention_mask, position_ids
107
+
108
+
109
+ def get_stop_words_ids(chat_format, tokenizer):
110
+ if chat_format == "raw":
111
+ stop_words_ids = [tokenizer.encode("Human:"), [tokenizer.eod_id]]
112
+ elif chat_format == "chatml":
113
+ stop_words_ids = [[tokenizer.im_end_id], [tokenizer.im_start_id]]
114
+ else:
115
+ raise NotImplementedError(f"Unknown chat format {chat_format!r}")
116
+ return stop_words_ids
117
+
118
+
119
+ def make_context(
120
+ tokenizer: PreTrainedTokenizer,
121
+ query: str,
122
+ history: List[Tuple[str, str]] = None,
123
+ system: str = "",
124
+ max_window_size: int = 6144,
125
+ chat_format: str = "chatml",
126
+ ):
127
+ if history is None:
128
+ history = []
129
+
130
+ if chat_format == "chatml":
131
+ im_start, im_end = "<|im_start|>", "<|im_end|>"
132
+ im_start_tokens = [tokenizer.im_start_id]
133
+ im_end_tokens = [tokenizer.im_end_id]
134
+ nl_tokens = tokenizer.encode("\n")
135
+
136
+ def _tokenize_str(role, content):
137
+ return f"{role}\n{content}", tokenizer.encode(
138
+ role, allowed_special=set()
139
+ ) + nl_tokens + tokenizer.encode(content, allowed_special=set())
140
+
141
+ system_text, system_tokens_part = _tokenize_str("system", system)
142
+ system_tokens = im_start_tokens + system_tokens_part + im_end_tokens
143
+
144
+ raw_text = ""
145
+ context_tokens = []
146
+
147
+ for turn_query, turn_response in reversed(history):
148
+ query_text, query_tokens_part = _tokenize_str("user", turn_query)
149
+ query_tokens = im_start_tokens + query_tokens_part + im_end_tokens
150
+ response_text, response_tokens_part = _tokenize_str(
151
+ "assistant", turn_response
152
+ )
153
+ response_tokens = im_start_tokens + response_tokens_part + im_end_tokens
154
+
155
+ next_context_tokens = nl_tokens + query_tokens + nl_tokens + response_tokens
156
+ prev_chat = (
157
+ f"\n{im_start}{query_text}{im_end}\n{im_start}{response_text}{im_end}"
158
+ )
159
+
160
+ current_context_size = (
161
+ len(system_tokens) + len(next_context_tokens) + len(context_tokens)
162
+ )
163
+ if current_context_size < max_window_size:
164
+ context_tokens = next_context_tokens + context_tokens
165
+ raw_text = prev_chat + raw_text
166
+ else:
167
+ break
168
+
169
+ context_tokens = system_tokens + context_tokens
170
+ raw_text = f"{im_start}{system_text}{im_end}" + raw_text
171
+ context_tokens += (
172
+ nl_tokens
173
+ + im_start_tokens
174
+ + _tokenize_str("user", query)[1]
175
+ + im_end_tokens
176
+ + nl_tokens
177
+ + im_start_tokens
178
+ + tokenizer.encode("assistant")
179
+ + nl_tokens
180
+ )
181
+ raw_text += f"\n{im_start}user\n{query}{im_end}\n{im_start}assistant\n"
182
+
183
+ elif chat_format == "raw":
184
+ raw_text = query
185
+ context_tokens = tokenizer.encode(raw_text)
186
+ else:
187
+ raise NotImplementedError(f"Unknown chat format {chat_format!r}")
188
+
189
+ return raw_text, context_tokens
190
+
191
+
192
+ def _decode_default(
193
+ tokens: List[int],
194
+ *,
195
+ stop_words: List[str],
196
+ eod_words: List[str],
197
+ tokenizer: PreTrainedTokenizer,
198
+ raw_text_len: int,
199
+ verbose: bool = False,
200
+ return_end_reason: bool = False,
201
+ errors: str='replace',
202
+ ):
203
+ trim_decode_tokens = tokenizer.decode(tokens, errors=errors)[raw_text_len:]
204
+ if verbose:
205
+ print("\nRaw Generate: ", trim_decode_tokens)
206
+
207
+ end_reason = f"Gen length {len(tokens)}"
208
+ for stop_word in stop_words:
209
+ trim_decode_tokens = trim_decode_tokens.replace(stop_word, "").strip()
210
+ for eod_word in eod_words:
211
+ if eod_word in trim_decode_tokens:
212
+ end_reason = f"Gen {eod_word!r}"
213
+ trim_decode_tokens = trim_decode_tokens.split(eod_word)[0]
214
+ trim_decode_tokens = trim_decode_tokens.strip()
215
+ if verbose:
216
+ print("\nEnd Reason:", end_reason)
217
+ print("\nGenerate: ", trim_decode_tokens)
218
+
219
+ if return_end_reason:
220
+ return trim_decode_tokens, end_reason
221
+ else:
222
+ return trim_decode_tokens
223
+
224
+
225
+ def _decode_chatml(
226
+ tokens: List[int],
227
+ *,
228
+ stop_words: List[str],
229
+ eod_token_ids: List[int],
230
+ tokenizer: PreTrainedTokenizer,
231
+ raw_text_len: int,
232
+ context_length: int,
233
+ verbose: bool = False,
234
+ return_end_reason: bool = False,
235
+ errors: str='replace'
236
+ ):
237
+ end_reason = f"Gen length {len(tokens)}"
238
+ eod_token_idx = context_length
239
+ for eod_token_idx in range(context_length, len(tokens)):
240
+ if tokens[eod_token_idx] in eod_token_ids:
241
+ end_reason = f"Gen {tokenizer.decode([tokens[eod_token_idx]])!r}"
242
+ break
243
+
244
+ trim_decode_tokens = tokenizer.decode(tokens[:eod_token_idx], errors=errors)[raw_text_len:]
245
+ if verbose:
246
+ print("\nRaw Generate w/o EOD:", tokenizer.decode(tokens, errors=errors)[raw_text_len:])
247
+ print("\nRaw Generate:", trim_decode_tokens)
248
+ print("\nEnd Reason:", end_reason)
249
+ for stop_word in stop_words:
250
+ trim_decode_tokens = trim_decode_tokens.replace(stop_word, "").strip()
251
+ trim_decode_tokens = trim_decode_tokens.strip()
252
+ if verbose:
253
+ print("\nGenerate:", trim_decode_tokens)
254
+
255
+ if return_end_reason:
256
+ return trim_decode_tokens, end_reason
257
+ else:
258
+ return trim_decode_tokens
259
+
260
+
261
+ def decode_tokens(
262
+ tokens: Union[torch.LongTensor, TokensType],
263
+ tokenizer: PreTrainedTokenizer,
264
+ raw_text_len: int,
265
+ context_length: int,
266
+ chat_format: str,
267
+ verbose: bool = False,
268
+ return_end_reason: bool = False,
269
+ errors: str="replace",
270
+ ) -> str:
271
+ if torch.is_tensor(tokens):
272
+ tokens = tokens.cpu().numpy().tolist()
273
+
274
+ if chat_format == "chatml":
275
+ return _decode_chatml(
276
+ tokens,
277
+ stop_words=[],
278
+ eod_token_ids=[tokenizer.im_start_id, tokenizer.im_end_id],
279
+ tokenizer=tokenizer,
280
+ raw_text_len=raw_text_len,
281
+ context_length=context_length,
282
+ verbose=verbose,
283
+ return_end_reason=return_end_reason,
284
+ errors=errors,
285
+ )
286
+ elif chat_format == "raw":
287
+ return _decode_default(
288
+ tokens,
289
+ stop_words=["<|endoftext|>"],
290
+ eod_words=["<|endoftext|>"],
291
+ tokenizer=tokenizer,
292
+ raw_text_len=raw_text_len,
293
+ verbose=verbose,
294
+ return_end_reason=return_end_reason,
295
+ errors=errors,
296
+ )
297
+ else:
298
+ raise NotImplementedError(f"Unknown chat format {chat_format!r}")
299
+
300
+
301
+ class StopWordsLogitsProcessor(LogitsProcessor):
302
+ """
303
+ :class:`transformers.LogitsProcessor` that enforces that when specified sequences appear, stop geration.
304
+
305
+ Args:
306
+ stop_words_ids (:obj:`List[List[int]]`):
307
+ List of list of token ids of stop ids. In order to get the tokens of the words
308
+ that should not appear in the generated text, use :obj:`tokenizer(bad_word,
309
+ add_prefix_space=True).input_ids`.
310
+ eos_token_id (:obj:`int`):
311
+ The id of the `end-of-sequence` token.
312
+ """
313
+
314
+ def __init__(self, stop_words_ids: Iterable[Iterable[int]], eos_token_id: int):
315
+
316
+ if not isinstance(stop_words_ids, List) or len(stop_words_ids) == 0:
317
+ raise ValueError(
318
+ f"`stop_words_ids` has to be a non-emtpy list, but is {stop_words_ids}."
319
+ )
320
+ if any(not isinstance(bad_word_ids, list) for bad_word_ids in stop_words_ids):
321
+ raise ValueError(
322
+ f"`stop_words_ids` has to be a list of lists, but is {stop_words_ids}."
323
+ )
324
+ if any(
325
+ any(
326
+ (not isinstance(token_id, (int, np.integer)) or token_id < 0)
327
+ for token_id in stop_word_ids
328
+ )
329
+ for stop_word_ids in stop_words_ids
330
+ ):
331
+ raise ValueError(
332
+ f"Each list in `stop_words_ids` has to be a list of positive integers, but is {stop_words_ids}."
333
+ )
334
+
335
+ self.stop_words_ids = list(
336
+ filter(
337
+ lambda bad_token_seq: bad_token_seq != [eos_token_id], stop_words_ids
338
+ )
339
+ )
340
+ self.eos_token_id = eos_token_id
341
+ for stop_token_seq in self.stop_words_ids:
342
+ assert (
343
+ len(stop_token_seq) > 0
344
+ ), "Stop words token sequences {} cannot have an empty list".format(
345
+ stop_words_ids
346
+ )
347
+
348
+ def __call__(
349
+ self, input_ids: torch.LongTensor, scores: torch.FloatTensor
350
+ ) -> torch.FloatTensor:
351
+ stopped_samples = self._calc_stopped_samples(input_ids)
352
+ for i, should_stop in enumerate(stopped_samples):
353
+ if should_stop:
354
+ scores[i, self.eos_token_id] = float(2**15)
355
+ return scores
356
+
357
+ def _tokens_match(self, prev_tokens: torch.LongTensor, tokens: List[int]) -> bool:
358
+ if len(tokens) == 0:
359
+ # if bad word tokens is just one token always ban it
360
+ return True
361
+ elif len(tokens) > len(prev_tokens):
362
+ # if bad word tokens are longer then prev input_ids they can't be equal
363
+ return False
364
+ elif prev_tokens[-len(tokens) :].tolist() == tokens:
365
+ # if tokens match
366
+ return True
367
+ else:
368
+ return False
369
+
370
+ def _calc_stopped_samples(self, prev_input_ids: Iterable[int]) -> Iterable[int]:
371
+ stopped_samples = []
372
+ for prev_input_ids_slice in prev_input_ids:
373
+ match = False
374
+ for stop_token_seq in self.stop_words_ids:
375
+ if self._tokens_match(prev_input_ids_slice, stop_token_seq):
376
+ # if tokens do not match continue
377
+ match = True
378
+ break
379
+ stopped_samples.append(match)
380
+
381
+ return stopped_samples
382
+
383
+
384
+ def top_k_logits(logits, top_k=0, top_p=0.0, filter_value=-float("Inf")):
385
+ """This function has been mostly taken from huggingface conversational
386
+ ai code at
387
+ https://medium.com/huggingface/how-to-build-a-state-of-the-art-
388
+ conversational-ai-with-transfer-learning-2d818ac26313"""
389
+
390
+ if top_k > 0:
391
+ # Remove all tokens with a probability less than the
392
+ # last token of the top-k
393
+ indices_to_remove = logits < torch.topk(logits, top_k)[0][..., -1, None]
394
+ logits[indices_to_remove] = filter_value
395
+
396
+ if top_p > 0.0:
397
+ # Cconvert to 1D
398
+ sorted_logits, sorted_indices = torch.sort(logits, descending=True, dim=-1)
399
+ cumulative_probs = torch.cumsum(F.softmax(sorted_logits, dim=-1), dim=-1)
400
+
401
+ # Remove tokens with cumulative probability above the threshold
402
+ sorted_indices_to_remove = cumulative_probs > top_p
403
+ # Shift the indices to the right to keep also the first token
404
+ # above the threshold
405
+ sorted_indices_to_remove[..., 1:] = sorted_indices_to_remove[..., :-1].clone()
406
+ sorted_indices_to_remove[..., 0] = 0
407
+ for i in range(sorted_indices.size(0)):
408
+ indices_to_remove = sorted_indices[i][sorted_indices_to_remove[i]]
409
+ logits[i][indices_to_remove] = filter_value
410
+
411
+ return logits
412
+
413
+
414
+ def switch(val1, val2, boolean):
415
+ boolean = boolean.type_as(val1)
416
+ return (1 - boolean) * val1 + boolean * val2
tokenization_qwen.py ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Alibaba Cloud.
2
+ #
3
+ # This source code is licensed under the license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ """Tokenization classes for QWen."""
7
+
8
+ import base64
9
+ import logging
10
+ import os
11
+ import unicodedata
12
+ from typing import Collection, Dict, List, Set, Tuple, Union
13
+
14
+ import tiktoken
15
+ from transformers import PreTrainedTokenizer, AddedToken
16
+
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+ VOCAB_FILES_NAMES = {"vocab_file": "qwen.tiktoken"}
21
+
22
+ PAT_STR = r"""(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+"""
23
+ ENDOFTEXT = "<|endoftext|>"
24
+ IMSTART = "<|im_start|>"
25
+ IMEND = "<|im_end|>"
26
+ # as the default behavior is changed to allow special tokens in
27
+ # regular texts, the surface forms of special tokens need to be
28
+ # as different as possible to minimize the impact
29
+ EXTRAS = tuple((f"<|extra_{i}|>" for i in range(205)))
30
+ SPECIAL_TOKENS = (
31
+ ENDOFTEXT,
32
+ IMSTART,
33
+ IMEND,
34
+ ) + EXTRAS
35
+
36
+
37
+ def _load_tiktoken_bpe(tiktoken_bpe_file: str) -> Dict[bytes, int]:
38
+ with open(tiktoken_bpe_file, "rb") as f:
39
+ contents = f.read()
40
+ return {
41
+ base64.b64decode(token): int(rank)
42
+ for token, rank in (line.split() for line in contents.splitlines() if line)
43
+ }
44
+
45
+ class QWenTokenizer(PreTrainedTokenizer):
46
+ """QWen tokenizer."""
47
+
48
+ vocab_files_names = VOCAB_FILES_NAMES
49
+
50
+ def __init__(
51
+ self,
52
+ vocab_file,
53
+ errors="replace",
54
+ **kwargs,
55
+ ):
56
+ super().__init__(**kwargs)
57
+
58
+ self.errors = errors # how to handle errors in decoding
59
+
60
+ self.mergeable_ranks = _load_tiktoken_bpe(vocab_file) # type: dict[bytes, int]
61
+ self.special_tokens = {
62
+ token: index
63
+ for index, token in enumerate(
64
+ SPECIAL_TOKENS, start=len(self.mergeable_ranks)
65
+ )
66
+ }
67
+
68
+ enc = tiktoken.Encoding(
69
+ "Qwen",
70
+ pat_str=PAT_STR,
71
+ mergeable_ranks=self.mergeable_ranks,
72
+ special_tokens=self.special_tokens,
73
+ )
74
+ assert (
75
+ len(self.mergeable_ranks) + len(self.special_tokens) == enc.n_vocab
76
+ ), f"{len(self.mergeable_ranks) + len(self.special_tokens)} != {enc.n_vocab} in encoding"
77
+
78
+ self.decoder = {
79
+ v: k for k, v in self.mergeable_ranks.items()
80
+ } # type: dict[int, bytes|str]
81
+ self.decoder.update({v: k for k, v in self.special_tokens.items()})
82
+
83
+ self.tokenizer = enc # type: tiktoken.Encoding
84
+
85
+ self.eod_id = self.tokenizer.eot_token
86
+ self.im_start_id = self.special_tokens[IMSTART]
87
+ self.im_end_id = self.special_tokens[IMEND]
88
+
89
+ def __getstate__(self):
90
+ # for pickle lovers
91
+ state = self.__dict__.copy()
92
+ del state['tokenizer']
93
+ return state
94
+
95
+ def __setstate__(self, state):
96
+ # tokenizer is not python native; don't pass it; rebuild it
97
+ self.__dict__.update(state)
98
+ enc = tiktoken.Encoding(
99
+ "Qwen",
100
+ pat_str=PAT_STR,
101
+ mergeable_ranks=self.mergeable_ranks,
102
+ special_tokens=self.special_tokens,
103
+ )
104
+ self.tokenizer = enc
105
+
106
+
107
+ def __len__(self) -> int:
108
+ return self.tokenizer.n_vocab
109
+
110
+ def get_vocab(self) -> Dict[bytes, int]:
111
+ return self.mergeable_ranks
112
+
113
+ def convert_tokens_to_ids(
114
+ self, tokens: Union[bytes, str, List[Union[bytes, str]]]
115
+ ) -> List[int]:
116
+ ids = []
117
+ if isinstance(tokens, (str, bytes)):
118
+ if tokens in self.special_tokens:
119
+ return self.special_tokens[tokens]
120
+ else:
121
+ return self.mergeable_ranks.get(tokens)
122
+ for token in tokens:
123
+ if token in self.special_tokens:
124
+ ids.append(self.special_tokens[token])
125
+ else:
126
+ ids.append(self.mergeable_ranks.get(token))
127
+ return ids
128
+
129
+ def _add_tokens(self, new_tokens: Union[List[str], List[AddedToken]], special_tokens: bool = False) -> int:
130
+ if not special_tokens and new_tokens:
131
+ raise ValueError('Adding regular tokens is not supported')
132
+ for token in new_tokens:
133
+ surface_form = token.content if isinstance(token, AddedToken) else token
134
+ if surface_form not in SPECIAL_TOKENS:
135
+ raise ValueError('Adding unknown special tokens is not supported')
136
+ return 0
137
+
138
+ def save_vocabulary(self, save_directory: str, **kwargs) -> Tuple[str]:
139
+ """
140
+ Save only the vocabulary of the tokenizer (vocabulary).
141
+
142
+ Returns:
143
+ `Tuple(str)`: Paths to the files saved.
144
+ """
145
+ file_path = os.path.join(save_directory, "qwen.tiktoken")
146
+ with open(file_path, "w", encoding="utf8") as w:
147
+ for k, v in self.mergeable_ranks.items():
148
+ line = base64.b64encode(k).decode("utf8") + " " + str(v) + "\n"
149
+ w.write(line)
150
+ return (file_path,)
151
+
152
+ def tokenize(
153
+ self,
154
+ text: str,
155
+ allowed_special: Union[Set, str] = "all",
156
+ disallowed_special: Union[Collection, str] = (),
157
+ **kwargs,
158
+ ) -> List[Union[bytes, str]]:
159
+ """
160
+ Converts a string in a sequence of tokens.
161
+
162
+ Args:
163
+ text (`str`):
164
+ The sequence to be encoded.
165
+ allowed_special (`Literal["all"]` or `set`):
166
+ The surface forms of the tokens to be encoded as special tokens in regular texts.
167
+ Default to "all".
168
+ disallowed_special (`Literal["all"]` or `Collection`):
169
+ The surface forms of the tokens that should not be in regular texts and trigger errors.
170
+ Default to an empty tuple.
171
+
172
+ kwargs (additional keyword arguments, *optional*):
173
+ Will be passed to the underlying model specific encode method.
174
+
175
+ Returns:
176
+ `List[bytes|str]`: The list of tokens.
177
+ """
178
+ tokens = []
179
+ text = unicodedata.normalize("NFC", text)
180
+
181
+ # this implementation takes a detour: text -> token id -> token surface forms
182
+ for t in self.tokenizer.encode(
183
+ text, allowed_special=allowed_special, disallowed_special=disallowed_special
184
+ ):
185
+ tokens.append(self.decoder[t])
186
+ return tokens
187
+
188
+ def convert_tokens_to_string(self, tokens: List[Union[bytes, str]]) -> str:
189
+ """
190
+ Converts a sequence of tokens in a single string.
191
+ """
192
+ text = ""
193
+ temp = b""
194
+ for t in tokens:
195
+ if isinstance(t, str):
196
+ if temp:
197
+ text += temp.decode("utf-8", errors=self.errors)
198
+ temp = b""
199
+ text += t
200
+ elif isinstance(t, bytes):
201
+ temp += t
202
+ else:
203
+ raise TypeError("token should only be of type types or str")
204
+ if temp:
205
+ text += temp.decode("utf-8", errors=self.errors)
206
+ return text
207
+
208
+ @property
209
+ def vocab_size(self):
210
+ return self.tokenizer.n_vocab
211
+
212
+ def _convert_id_to_token(self, index: int) -> Union[bytes, str]:
213
+ """Converts an id to a token, special tokens included"""
214
+ if index in self.decoder:
215
+ return self.decoder[index]
216
+ raise ValueError("unknown ids")
217
+
218
+ def _convert_token_to_id(self, token: Union[bytes, str]) -> int:
219
+ """Converts a token to an id using the vocab, special tokens included"""
220
+ if token in self.special_tokens:
221
+ return self.special_tokens[token]
222
+ if token in self.mergeable_ranks:
223
+ return self.mergeable_ranks[token]
224
+ raise ValueError("unknown token")
225
+
226
+ def _tokenize(self, text: str, **kwargs):
227
+ """
228
+ Converts a string in a sequence of tokens (string), using the tokenizer. Split in words for word-based
229
+ vocabulary or sub-words for sub-word-based vocabularies (BPE/SentencePieces/WordPieces).
230
+
231
+ Do NOT take care of added tokens.
232
+ """
233
+ raise NotImplementedError
234
+
235
+ def _decode(
236
+ self,
237
+ token_ids: Union[int, List[int]],
238
+ skip_special_tokens: bool = False,
239
+ errors: str = None,
240
+ **kwargs,
241
+ ) -> str:
242
+ if isinstance(token_ids, int):
243
+ token_ids = [token_ids]
244
+ if skip_special_tokens:
245
+ token_ids = [i for i in token_ids if i < self.eod_id]
246
+ return self.tokenizer.decode(token_ids, errors=errors or self.errors)
tokenizer_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_max_length": 8192,
3
+ "tokenizer_class": "QWenTokenizer",
4
+ "auto_map": {
5
+ "AutoTokenizer": [
6
+ "tokenization_qwen.QWenTokenizer",
7
+ null
8
+ ]
9
+ }
10
+ }
11
+