Add chatglm-6b

This commit is contained in:
Sengxian 2023-03-14 00:21:01 +08:00
commit d11c6aaed8
20 changed files with 2557 additions and 0 deletions

34
.gitattributes vendored Normal file
View File

@ -0,0 +1,34 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text

201
LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"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,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
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 conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright Zhengxiao Du
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

33
MODEL_LICENSE Normal file
View File

@ -0,0 +1,33 @@
The GLM-130B License
1. Definitions
“Licensor” means the GLM-130B Model Team that distributes its Software.
“Software” means the GLM-130B model parameters made available under this license.
2. License Grant
Subject to the terms and conditions of this License, the Licensor hereby grants to you a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable, royalty-free copyright license to use the Software solely for your non-commercial research purposes.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
3. Restriction
You will not use, copy, modify, merge, publish, distribute, reproduce, or create derivative works of the Software, in whole or in part, for any commercial, military, or illegal purposes.
You will not use the Software for any act that may undermine China's national security and national unity, harm the public interest of society, or infringe upon the rights and interests of human beings.
4. Disclaimer
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5. Limitation of Liability
EXCEPT TO THE EXTENT PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER BASED IN TORT, NEGLIGENCE, CONTRACT, LIABILITY, OR OTHERWISE WILL ANY LICENSOR BE LIABLE TO YOU FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, OR ANY OTHER COMMERCIAL LOSSES, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
6. Dispute Resolution
This license shall be governed and construed in accordance with the laws of Peoples Republic of China. Any dispute arising from or in connection with this License shall be submitted to Haidian District People's Court in Beijing.
Note that the license is subject to update to a more comprehensive version. For any questions related to the license and copyright, please contact us at glm-130b@googlegroups.com.

81
README.md Normal file
View File

@ -0,0 +1,81 @@
---
language:
- zh
- en
tags:
- glm
- chatglm
- thudm
---
# ChatGLM-6B
## 介绍
ChatGLM-6B 是一个开源的、支持中英双语问答和对话的预训练语言模型,基于 [GLM](https://github.com/THUDM/GLM) 架构,具有 62 亿参数。ChatGLM-6B 使用了和 ChatGLM内测中地址 [https://chatglm.cn](https://chatglm.cn))相同的技术面向中文问答和对话进行优化。
## 使用方式
使用前请先安装`transformers>=4.23.1`和`icetk`。
```shell
pip install "transformers>=4.23.1,icetk"
```
### 代码调用
可以通过如下代码调用 ChatGLM-6B 模型来生成对话。
```python
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda()
model = model.eval()
history = []
query = "你好"
response, history = model.chat(tokenizer, query, history=history)
print(response)
query = "晚上睡不着应该怎么办"
response, history = model.chat(tokenizer, query, history=history)
print(history)
```
关于更多的使用说明以及如何运行命令行和Web版本的demo请参考我们的[Github repo](https://github.com/THUDM/ChatGLM-6B)。
## INT8 量化
默认情况下,模型以 FP16 精度加载,运行上述代码需要大概 13GB 显存。如果你的 GPU 显存有限,可以尝试使用 `transformers` 提供的 8bit 量化功能,即将代码中的
```python
model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda()
```
替换为
```python
model = AutoModel.from_pretrained("THUDM/chatglm-6b", device_map="auto", load_in_8bit=True, trust_remote_code=True)
```
使用 8-bit 量化之后大约需要 9.5GB 的 GPU 显存。
## 引用
如果你觉得我们的工作有帮助的话,请考虑引用下列论文
```
@inproceedings{
zeng2023glm-130b,
title={{GLM}-130B: An Open Bilingual Pre-trained Model},
author={Aohan Zeng and Xiao Liu and Zhengxiao Du and Zihan Wang and Hanyu Lai and Ming Ding and Zhuoyi Yang and Yifan Xu and Wendi Zheng and Xiao Xia and Weng Lam Tam and Zixuan Ma and Yufei Xue and Jidong Zhai and Wenguang Chen and Zhiyuan Liu and Peng Zhang and Yuxiao Dong and Jie Tang},
booktitle={The Eleventh International Conference on Learning Representations (ICLR)},
year={2023},
url={https://openreview.net/forum?id=-Aw0rrrPUF}
}
```
```
@inproceedings{du2022glm,
title={GLM: General Language Model Pretraining with Autoregressive Blank Infilling},
author={Du, Zhengxiao and Qian, Yujie and Liu, Xiao and Ding, Ming and Qiu, Jiezhong and Yang, Zhilin and Tang, Jie},
booktitle={Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
pages={320--335},
year={2022}
}
```

25
config.json Normal file
View File

@ -0,0 +1,25 @@
{
"_name_or_path": "THUDM/chatglm-6b",
"architectures": [
"ChatGLMModel"
],
"auto_map": {
"AutoConfig": "configuration_chatglm.ChatGLMConfig",
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
},
"bos_token_id": 150004,
"eos_token_id": 150005,
"hidden_size": 4096,
"inner_hidden_size": 16384,
"layernorm_epsilon": 1e-05,
"max_sequence_length": 2048,
"model_type": "chatglm",
"num_attention_heads": 32,
"num_layers": 28,
"position_encoding_2d": true,
"torch_dtype": "float16",
"transformers_version": "4.23.1",
"use_cache": true,
"vocab_size": 150528
}

92
configuration_chatglm.py Normal file
View File

@ -0,0 +1,92 @@
""" ChatGLM model configuration """
from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging
logger = logging.get_logger(__name__)
class ChatGLMConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`~ChatGLMModel`].
It is used to instantiate an ChatGLM model according to the specified arguments, defining the model
architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of
the ChatGLM-6B [THUDM/ChatGLM-6B](https://huggingface.co/THUDM/chatglm-6b) architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used
to control the model outputs. Read the documentation from [`PretrainedConfig`]
for more information.
Args:
vocab_size (`int`, *optional*, defaults to 150528):
Vocabulary size of the ChatGLM-6B model. Defines the number of different tokens that can be represented by the
`inputs_ids` passed when calling [`~ChatGLMModel`] or
[`~TFChatGLMModel`].
hidden_size (`int`, *optional*, defaults to 4096):
Dimension of the encoder layers and the pooler layer.
num_hidden_layers (`int`, *optional*, defaults to 28):
Number of hidden layers in the Transformer encoder.
num_attention_heads (`int`, *optional*, defaults to 32):
Number of attention heads for each attention layer in the Transformer encoder.
inner_hidden_size (`int`, *optional*, defaults to 16384):
Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
max_sequence_length (`int`, *optional*, defaults to 512):
The maximum sequence length that this model might ever be used with.
Typically set this to something large just in case (e.g., 512 or 1024 or 2048).
layernorm_epsilon (`float`, *optional*, defaults to 1e-5):
The epsilon used by the layer normalization layers.
use_cache (`bool`, *optional*, defaults to `True`):
Whether the model should return the last key/values attentions (not used by all models).
Example:
```python
>>> from configuration_chatglm import ChatGLMConfig
>>> from modeling_chatglm import ChatGLMModel
>>> # Initializing a ChatGLM-6B THUDM/ChatGLM-6B style configuration
>>> configuration = ChatGLMConfig()
>>> # Initializing a model from the THUDM/ChatGLM-6B style configuration
>>> model = ChatGLMModel(configuration)
>>> # Accessing the model configuration
>>> configuration = model.config
```
"""
model_type = "chatglm"
def __init__(
self,
vocab_size=150528,
hidden_size=4096,
num_layers=28,
num_attention_heads=32,
layernorm_epsilon=1e-5,
use_cache=False,
bos_token_id=150004,
eos_token_id=150005,
pad_token_id=0,
max_sequence_length=2048,
inner_hidden_size=16384,
position_encoding_2d=True,
**kwargs
):
self.num_layers = num_layers
self.vocab_size = vocab_size
self.hidden_size = hidden_size
self.num_attention_heads = num_attention_heads
self.max_sequence_length = max_sequence_length
self.layernorm_epsilon = layernorm_epsilon
self.inner_hidden_size = inner_hidden_size
self.use_cache = use_cache
self.bos_token_id = bos_token_id
self.eos_token_id = eos_token_id
self.pad_token_id = pad_token_id
self.position_encoding_2d = position_encoding_2d
super().__init__(
pad_token_id=pad_token_id,
bos_token_id=bos_token_id,
eos_token_id=eos_token_id,
**kwargs
)

3
ice_text.model Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:99871e0c85db81ad7af1028854fd091cd5778c8414ae9d94bbbc10d02c831c21
size 2699926

1152
modeling_chatglm.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00001-of-00008.bin

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00002-of-00008.bin

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00003-of-00008.bin

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00004-of-00008.bin

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00005-of-00008.bin

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00006-of-00008.bin

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00007-of-00008.bin

View File

@ -0,0 +1 @@
/mnt/vepfs/zxdu/checkpoints/qa-glm-6b-sft-v0.8-v2-original-lr/pytorch_model-00008-of-00008.bin

View File

@ -0,0 +1,375 @@
{
"metadata": {
"total_size": 13744473856
},
"weight_map": {
"lm_head.weight": "pytorch_model-00008-of-00008.bin",
"transformer.final_layernorm.bias": "pytorch_model-00007-of-00008.bin",
"transformer.final_layernorm.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.0.attention.dense.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.attention.dense.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.attention.query_key_value.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.attention.query_key_value.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.attention.rotary_emb.inv_freq": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.input_layernorm.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.input_layernorm.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.mlp.dense_4h_to_h.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.mlp.dense_h_to_4h.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.post_attention_layernorm.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.0.post_attention_layernorm.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.attention.dense.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.attention.dense.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.attention.query_key_value.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.attention.query_key_value.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.attention.rotary_emb.inv_freq": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.input_layernorm.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.input_layernorm.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.mlp.dense_4h_to_h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.1.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.1.mlp.dense_h_to_4h.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.post_attention_layernorm.bias": "pytorch_model-00001-of-00008.bin",
"transformer.layers.1.post_attention_layernorm.weight": "pytorch_model-00001-of-00008.bin",
"transformer.layers.10.attention.dense.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.attention.dense.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.attention.query_key_value.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.attention.query_key_value.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.input_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.input_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.mlp.dense_4h_to_h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.post_attention_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.10.post_attention_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.11.attention.dense.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.11.attention.dense.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.11.attention.query_key_value.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.11.attention.query_key_value.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.11.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00008.bin",
"transformer.layers.11.input_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.11.input_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.11.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.11.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.11.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.11.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.11.post_attention_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.11.post_attention_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.attention.dense.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.attention.dense.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.attention.query_key_value.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.attention.query_key_value.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.input_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.input_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.post_attention_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.12.post_attention_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.attention.dense.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.attention.dense.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.attention.query_key_value.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.attention.query_key_value.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.input_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.input_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.post_attention_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.13.post_attention_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.attention.dense.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.attention.dense.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.attention.query_key_value.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.attention.query_key_value.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.input_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.input_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.post_attention_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.14.post_attention_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.attention.dense.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.attention.dense.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.attention.query_key_value.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.attention.query_key_value.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.input_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.input_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.post_attention_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.15.post_attention_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.16.attention.dense.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.attention.dense.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.attention.query_key_value.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.attention.query_key_value.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00008.bin",
"transformer.layers.16.input_layernorm.bias": "pytorch_model-00004-of-00008.bin",
"transformer.layers.16.input_layernorm.weight": "pytorch_model-00004-of-00008.bin",
"transformer.layers.16.mlp.dense_4h_to_h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.post_attention_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.16.post_attention_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.attention.dense.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.attention.dense.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.attention.query_key_value.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.attention.query_key_value.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.input_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.input_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.mlp.dense_4h_to_h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.post_attention_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.17.post_attention_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.attention.dense.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.attention.dense.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.attention.query_key_value.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.attention.query_key_value.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.input_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.input_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.mlp.dense_4h_to_h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.post_attention_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.18.post_attention_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.attention.dense.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.attention.dense.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.attention.query_key_value.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.attention.query_key_value.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.input_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.input_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.mlp.dense_4h_to_h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.post_attention_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.19.post_attention_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.2.attention.dense.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.attention.dense.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.attention.query_key_value.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.attention.query_key_value.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.input_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.input_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.mlp.dense_4h_to_h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.post_attention_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.2.post_attention_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.20.attention.dense.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.attention.dense.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.attention.query_key_value.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.attention.query_key_value.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.input_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.input_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.mlp.dense_4h_to_h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.20.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.20.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.post_attention_layernorm.bias": "pytorch_model-00005-of-00008.bin",
"transformer.layers.20.post_attention_layernorm.weight": "pytorch_model-00005-of-00008.bin",
"transformer.layers.21.attention.dense.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.attention.dense.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.attention.query_key_value.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.attention.query_key_value.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.input_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.input_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.mlp.dense_4h_to_h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.post_attention_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.21.post_attention_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.attention.dense.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.attention.dense.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.attention.query_key_value.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.attention.query_key_value.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.input_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.input_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.mlp.dense_4h_to_h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.post_attention_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.22.post_attention_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.attention.dense.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.attention.dense.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.attention.query_key_value.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.attention.query_key_value.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.input_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.input_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.mlp.dense_4h_to_h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.post_attention_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.23.post_attention_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.attention.dense.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.attention.dense.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.attention.query_key_value.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.attention.query_key_value.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.input_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.input_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.mlp.dense_4h_to_h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.post_attention_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.24.post_attention_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.attention.dense.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.attention.dense.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.attention.query_key_value.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.attention.query_key_value.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.input_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.input_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.mlp.dense_4h_to_h.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.25.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.25.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.25.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.25.post_attention_layernorm.bias": "pytorch_model-00006-of-00008.bin",
"transformer.layers.25.post_attention_layernorm.weight": "pytorch_model-00006-of-00008.bin",
"transformer.layers.26.attention.dense.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.attention.dense.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.attention.query_key_value.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.attention.query_key_value.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.attention.rotary_emb.inv_freq": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.input_layernorm.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.input_layernorm.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.mlp.dense_4h_to_h.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.post_attention_layernorm.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.26.post_attention_layernorm.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.attention.dense.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.attention.dense.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.attention.query_key_value.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.attention.query_key_value.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.attention.rotary_emb.inv_freq": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.input_layernorm.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.input_layernorm.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.mlp.dense_4h_to_h.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.post_attention_layernorm.bias": "pytorch_model-00007-of-00008.bin",
"transformer.layers.27.post_attention_layernorm.weight": "pytorch_model-00007-of-00008.bin",
"transformer.layers.3.attention.dense.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.attention.dense.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.attention.query_key_value.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.attention.query_key_value.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.input_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.input_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.mlp.dense_4h_to_h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.post_attention_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.3.post_attention_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.attention.dense.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.attention.dense.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.attention.query_key_value.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.attention.query_key_value.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.input_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.input_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.mlp.dense_4h_to_h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.post_attention_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.4.post_attention_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.attention.dense.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.attention.dense.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.attention.query_key_value.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.attention.query_key_value.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.input_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.input_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.mlp.dense_4h_to_h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.post_attention_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.5.post_attention_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.attention.dense.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.attention.dense.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.attention.query_key_value.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.attention.query_key_value.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.input_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.input_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.mlp.dense_4h_to_h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.6.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.6.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.6.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.6.post_attention_layernorm.bias": "pytorch_model-00002-of-00008.bin",
"transformer.layers.6.post_attention_layernorm.weight": "pytorch_model-00002-of-00008.bin",
"transformer.layers.7.attention.dense.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.attention.dense.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.attention.query_key_value.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.attention.query_key_value.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.input_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.input_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.mlp.dense_4h_to_h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.post_attention_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.7.post_attention_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.attention.dense.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.attention.dense.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.attention.query_key_value.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.attention.query_key_value.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.input_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.input_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.mlp.dense_4h_to_h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.post_attention_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.8.post_attention_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.attention.dense.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.attention.dense.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.attention.query_key_value.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.attention.query_key_value.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.input_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.input_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.mlp.dense_4h_to_h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.post_attention_layernorm.bias": "pytorch_model-00003-of-00008.bin",
"transformer.layers.9.post_attention_layernorm.weight": "pytorch_model-00003-of-00008.bin",
"transformer.word_embeddings.weight": "pytorch_model-00001-of-00008.bin"
}
}

187
quantization.py Normal file

File diff suppressed because one or more lines are too long

347
tokenization_chatglm.py Normal file
View File

@ -0,0 +1,347 @@
"""Tokenization classes for ChatGLM."""
import sys
import unicodedata
from typing import List, Optional, Union
from functools import lru_cache
import os
import collections
import re
from transformers.tokenization_utils import PreTrainedTokenizer
from icetk.text_tokenizer import TextTokenizer
from icetk.utils import auto_create
import icetk.sentencepiece_model_pb2 as sp_model
from transformers.utils import logging
logger = logging.get_logger(__name__)
VOCAB_FILES_NAMES = {"vocab_file": "ice_text.model"}
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {
"THUDM/chatglm-6b": 2048,
}
class SPTokenizer:
def __init__(
self,
vocab_file,
max_blank_length=80,
byte_fallback=True,
):
assert vocab_file is not None
self.vocab_file = vocab_file
self.special_tokens = ["[MASK]", "[gMASK]", "[sMASK]", "<unused_0>", "<sop>", "<eop>", "<ENC>", "<dBLOCK>"]
self.max_blank_length = max_blank_length
self.byte_fallback = byte_fallback
self.text_tokenizer = self._build_text_tokenizer(encode_special_tokens=False)
self.special_text_tokenizer = self._build_text_tokenizer(encode_special_tokens=True)
@staticmethod
def _configure_tokenizer(
text_tokenizer: TextTokenizer,
special_tokens: List[str],
max_blank_length: int,
byte_fallback: bool,
encode_special_tokens=False,
):
# special token
special_token_type = 4 if encode_special_tokens else 3 # 3 - CONTROL, 4 - USER_DEFINE
for token in special_tokens:
text_tokenizer.proto.pieces.append(
sp_model.ModelProto.SentencePiece(piece=token, score=0.0, type=special_token_type)
)
# whitespaces
for token in [SPTokenizer.get_tab_token()] + [
SPTokenizer.get_blank_token(i) for i in range(2, max_blank_length + 1)
]:
text_tokenizer.proto.pieces.append(sp_model.ModelProto.SentencePiece(piece=token, score=0.0, type=4))
# byte fallback
if byte_fallback:
text_tokenizer.proto.trainer_spec.byte_fallback = True
for i in range(256):
text_tokenizer.proto.pieces.append(
sp_model.ModelProto.SentencePiece(piece="<0x{:02X}>".format(i), score=0.0, type=6)
)
text_tokenizer.refresh()
def _build_text_tokenizer(self, encode_special_tokens=False):
tokenizer = TextTokenizer(self.vocab_file)
self._configure_tokenizer(
tokenizer, self.special_tokens, self.max_blank_length, self.byte_fallback, encode_special_tokens
)
return tokenizer
def _get_text_tokenizer(self, encode_special_tokens=False):
if encode_special_tokens:
return self.special_text_tokenizer
else:
return self.text_tokenizer
@staticmethod
def get_blank_token(length: int):
assert length >= 2
return f"<|blank_{length}|>"
@staticmethod
def get_tab_token():
return f"<|tab|>"
@property
def num_image_tokens(self):
return 20000
@property
def num_text_tokens(self):
return self.text_tokenizer.num_tokens
@property
def num_tokens(self):
return self.num_image_tokens + self.num_text_tokens
@staticmethod
def _encode_whitespaces(text: str, max_len: int = 80):
text = text.replace("\t", SPTokenizer.get_tab_token())
for i in range(max_len, 1, -1):
text = text.replace(" " * i, SPTokenizer.get_blank_token(i))
return text
def _preprocess(self, text: str, linebreak=True, whitespaces=True):
if linebreak:
text = text.replace("\n", "<n>")
if whitespaces:
text = self._encode_whitespaces(text, max_len=self.max_blank_length)
return text
def encode(
self, text: str, linebreak=True, whitespaces=True, special_tokens=False, add_dummy_prefix=True
) -> List[int]:
"""
@param text: Text to encode.
@param linebreak: Whether to encode newline (\n) in text.
@param whitespaces: Whether to encode multiple whitespaces or tab in text, useful for source code encoding.
@param special_tokens: Whether to encode special token ([MASK], [gMASK], etc.) in text.
@param add_dummy_prefix: Whether to add dummy blank space in the beginning.
"""
text = self._preprocess(text, linebreak, whitespaces)
if not add_dummy_prefix:
text = "<n>" + text
tmp = self._get_text_tokenizer(encode_special_tokens=special_tokens).encode(text)
tokens = [x + self.num_image_tokens for x in tmp]
return tokens if add_dummy_prefix else tokens[2:]
def decode(self, text_ids: List[int], special_tokens=False) -> str:
ids = [int(_id) - self.num_image_tokens for _id in text_ids]
text = self._get_text_tokenizer(encode_special_tokens=special_tokens).decode(ids)
text = text.replace("<n>", "\n")
text = text.replace(SPTokenizer.get_tab_token(), "\t")
for i in range(2, self.max_blank_length + 1):
text = text.replace(self.get_blank_token(i), " " * i)
return text
def tokenize(
self, text: str, linebreak=True, whitespaces=True, special_tokens=False, add_dummy_prefix=True
) -> List[str]:
"""
@param text: Text to encode.
@param linebreak: Whether to encode newline (\n) in text.
@param whitespaces: Whether to encode multiple whitespaces or tab in text, useful for source code encoding.
@param special_tokens: Whether to encode special token ([MASK], [gMASK], etc.) in text.
@param add_dummy_prefix: Whether to add dummy blank space in the beginning.
"""
text = self._preprocess(text, linebreak, whitespaces)
if not add_dummy_prefix:
text = "<n>" + text
tokens = self._get_text_tokenizer(encode_special_tokens=special_tokens).tokenize(text)
return tokens if add_dummy_prefix else tokens[2:]
def __getitem__(self, x: Union[int, str]):
if isinstance(x, int):
if x < self.num_image_tokens:
return "<image_{}>".format(x)
else:
return self.text_tokenizer.convert_id_to_token(x - self.num_image_tokens)
elif isinstance(x, str):
if x.startswith("<image_") and x.endswith(">") and x[7:-1].isdigit():
return int(x[7:-1])
else:
return self.text_tokenizer.convert_token_to_id(x) + self.num_image_tokens
else:
raise ValueError("The key should be str or int.")
class ChatGLMTokenizer(PreTrainedTokenizer):
"""
Construct a ChatGLM tokenizer. Based on byte-level Byte-Pair-Encoding.
Args:
vocab_file (`str`):
Path to the vocabulary file.
"""
vocab_files_names = VOCAB_FILES_NAMES
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
model_input_names = ["input_ids"]
def __init__(
self,
vocab_file,
do_lower_case=False,
remove_space=False,
bos_token='sop',
eos_token='eos',
eop_token='eop',
mask_token='[MASK]',
gmask_token='[gMASK]',
padding_side="left",
**kwargs
) -> None:
super().__init__(
do_lower_case=do_lower_case,
remove_space=remove_space,
padding_side=padding_side,
**kwargs
)
self.do_lower_case = do_lower_case
self.remove_space = remove_space
self.vocab_file = vocab_file
self.bos_token = bos_token
self.eos_token = eos_token
self.eop_token = eop_token
self.mask_token = mask_token
self.gMASK_token = gmask_token
self.sp_tokenizer = SPTokenizer(vocab_file)
""" Initialisation """
@property
def eop_token_id(self) -> Optional[int]:
"""
`Optional[int]`: Id of the end of sentence token in the vocabulary. Returns `None` if the token has not been
set.
"""
if self.eop_token is None:
return None
return self.convert_tokens_to_ids(self.eop_token)
@property
def vocab_size(self):
""" Returns vocab size """
return self.sp_tokenizer.num_tokens
def get_vocab(self):
""" Returns vocab as a dict """
vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
vocab.update(self.added_tokens_encoder)
return vocab
def preprocess_text(self, inputs):
if self.remove_space:
outputs = " ".join(inputs.strip().split())
else:
outputs = inputs
if self.do_lower_case:
outputs = outputs.lower()
return outputs
def _tokenize(self, text, **kwargs):
""" Returns a tokenized string. """
text = self.preprocess_text(text)
seq = self.sp_tokenizer.tokenize(text)
return seq
def decode(
self,
token_ids: Union[List[int], List[List[int]]],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
spaces_between_special_tokens: bool = True,
**kwargs
) -> str:
if isinstance(token_ids[0], list):
tokens = []
for single_token_ids in token_ids:
if self.pad_token_id in single_token_ids: # remove pad
single_token_ids = list(filter((self.pad_token_id).__ne__, single_token_ids))
tokens.append(self.sp_tokenizer.decode(single_token_ids))
return (tokens)
else:
if self.pad_token_id in token_ids: # remove pad
token_ids = list(filter((self.pad_token_id).__ne__, token_ids))
return self.sp_tokenizer.decode(token_ids)
def _convert_token_to_id(self, token):
""" Converts a token (str) in an id using the vocab. """
return self.sp_tokenizer[token]
def _convert_id_to_token(self, index):
"""Converts an index (integer) in a token (str) using the vocab."""
return self.sp_tokenizer[index]
def save_vocabulary(self, save_directory, filename_prefix=None):
"""
Save the vocabulary and special tokens file to a directory.
Args:
save_directory (`str`):
The directory in which to save the vocabulary.
filename_prefix (`str`, *optional*):
An optional prefix to add to the named of the saved files.
Returns:
`Tuple(str)`: Paths to the files saved.
"""
if os.path.isdir(save_directory):
vocab_file = os.path.join(
save_directory, VOCAB_FILES_NAMES["vocab_file"]
)
else:
vocab_file = save_directory
with open(self.vocab_file, 'rb') as fin:
proto_str = fin.read()
with open(vocab_file, "wb") as writer:
writer.write(proto_str)
return (vocab_file,)
def build_inputs_with_special_tokens(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A BERT sequence has the following format:
- single sequence: `[CLS] X [SEP]`
- pair of sequences: `[CLS] A [SEP] B [SEP]`
Args:
token_ids_0 (`List[int]`):
List of IDs to which the special tokens will be added.
token_ids_1 (`List[int]`, *optional*):
Optional second list of IDs for sequence pairs.
Returns:
`List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
"""
if token_ids_1 is not None:
token_ids_0 += token_ids_1
mask_ids = self.sp_tokenizer[self.mask_token]
gmask_ids = self.sp_tokenizer[self.gMASK_token]
if mask_ids not in token_ids_0 and gmask_ids not in token_ids_0:
token_ids_0 += [gmask_ids]
if token_ids_0[-1] != mask_ids and token_ids_0[-1] != gmask_ids:
token_ids_0 += [self.sp_tokenizer[self.eos_token]]
token_ids_0 += [self.sp_tokenizer[self.bos_token]]
return token_ids_0

19
tokenizer_config.json Normal file
View File

@ -0,0 +1,19 @@
{
"name_or_path": "THUDM/chatglm-6b",
"bos_token": "<sop>",
"eop_token": "<eop>",
"eos_token": "</s>",
"gmask_token": "[gMASK]",
"mask_token": "[MASK]",
"pad_token": "<pad>",
"unk_token": "<unk>",
"remove_space": false,
"do_lower_case": false,
"tokenizer_class": "ChatGLMTokenizer",
"auto_map": {
"AutoTokenizer": [
"tokenization_chatglm.ChatGLMTokenizer",
null
]
}
}