Upload folder using huggingface_hub
Browse files- config.json +30 -0
- configuration_zhinao.py +119 -0
- generation_config.json +15 -0
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- model.safetensors.index.json +266 -0
- special_tokens_map.json +3 -0
- tokenization_zhinao.py +261 -0
- tokenizer_config.json +18 -0
- vocab/360.tiktoken +0 -0
config.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ZhinaoForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_zhinao.ZhinaoConfig",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_zhinao.ZhinaoForCausalLM"
|
| 9 |
+
},
|
| 10 |
+
"flah-attn_version": "2.5.5",
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 4096,
|
| 13 |
+
"initializer_range": 0.01,
|
| 14 |
+
"intermediate_size": 13056,
|
| 15 |
+
"max_position_embeddings": 32768,
|
| 16 |
+
"max_window_layers": 28,
|
| 17 |
+
"model_type": "zhinao",
|
| 18 |
+
"num_attention_heads": 32,
|
| 19 |
+
"num_hidden_layers": 32,
|
| 20 |
+
"num_key_value_heads": 8,
|
| 21 |
+
"rms_norm_eps": 1e-05,
|
| 22 |
+
"rope_theta": 1000000,
|
| 23 |
+
"sliding_window": null,
|
| 24 |
+
"tie_word_embeddings": false,
|
| 25 |
+
"torch_dtype": "bfloat16",
|
| 26 |
+
"transformers_version": "4.51.0",
|
| 27 |
+
"use_cache": true,
|
| 28 |
+
"use_sliding_window": false,
|
| 29 |
+
"vocab_size": 158464
|
| 30 |
+
}
|
configuration_zhinao.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 2 |
+
from transformers.utils import logging
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
logger = logging.get_logger(__name__)
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class ZhinaoConfig(PretrainedConfig):
|
| 9 |
+
r"""
|
| 10 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 11 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Args:
|
| 15 |
+
vocab_size (`int`, *optional*, defaults to 158464):
|
| 16 |
+
Vocabulary size of the Zhinao model. Defines the number of different tokens that can be represented by the
|
| 17 |
+
`inputs_ids` passed when calling [`ZhinaoModel`]
|
| 18 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 19 |
+
Dimension of the hidden representations.
|
| 20 |
+
intermediate_size (`int`, *optional*, defaults to 13056):
|
| 21 |
+
Dimension of the MLP representations.
|
| 22 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
| 23 |
+
Number of hidden layers in the Transformer encoder.
|
| 24 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
| 25 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 26 |
+
num_key_value_heads (`int`, *optional*, defaults to 32):
|
| 27 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 28 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 29 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 30 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 31 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
| 32 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
|
| 33 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 34 |
+
The non-linear activation function (function or string) in the decoder.
|
| 35 |
+
max_position_embeddings (`int`, *optional*, defaults to 4096):
|
| 36 |
+
The maximum sequence length that this model might ever be used with.
|
| 37 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 38 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 39 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 40 |
+
The epsilon used by the rms normalization layers.
|
| 41 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 42 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 43 |
+
relevant if `config.is_decoder=True`.
|
| 44 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 45 |
+
Whether the model's input and output word embeddings should be tied.
|
| 46 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
| 47 |
+
The base period of the RoPE embeddings.
|
| 48 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
| 49 |
+
Whether to use sliding window attention.
|
| 50 |
+
sliding_window (`int`, *optional*, defaults to 4096):
|
| 51 |
+
Sliding window attention (SWA) window size. If not specified, will default to `4096`.
|
| 52 |
+
max_window_layers (`int`, *optional*, defaults to 28):
|
| 53 |
+
The number of layers that use SWA (Sliding Window Attention). The bottom layers use SWA while the top use full attention.
|
| 54 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 55 |
+
The dropout ratio for the attention probabilities.
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
>>> from transformers import ZhinaoModel, ZhinaoConfig
|
| 59 |
+
|
| 60 |
+
>>> # Initializing a Zhinao style configuration
|
| 61 |
+
>>> configuration = ZhinaoConfig()
|
| 62 |
+
|
| 63 |
+
>>> # Initializing a model from the Zhinao-7B style configuration
|
| 64 |
+
>>> model = Zhinao2Model(configuration)
|
| 65 |
+
|
| 66 |
+
>>> # Accessing the model configuration
|
| 67 |
+
>>> configuration = model.config
|
| 68 |
+
```"""
|
| 69 |
+
|
| 70 |
+
model_type = "zhinao"
|
| 71 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 72 |
+
|
| 73 |
+
def __init__(
|
| 74 |
+
self,
|
| 75 |
+
vocab_size=158464,
|
| 76 |
+
hidden_size=4096,
|
| 77 |
+
intermediate_size=13056,
|
| 78 |
+
num_hidden_layers=32,
|
| 79 |
+
num_attention_heads=32,
|
| 80 |
+
num_key_value_heads=32,
|
| 81 |
+
hidden_act="silu",
|
| 82 |
+
max_position_embeddings=4096,
|
| 83 |
+
initializer_range=0.01,
|
| 84 |
+
rms_norm_eps=1e-5,
|
| 85 |
+
use_cache=True,
|
| 86 |
+
tie_word_embeddings=False,
|
| 87 |
+
rope_theta=10000.0,
|
| 88 |
+
use_sliding_window=False,
|
| 89 |
+
sliding_window=4096,
|
| 90 |
+
max_window_layers=28,
|
| 91 |
+
attention_dropout=0.0,
|
| 92 |
+
**kwargs,
|
| 93 |
+
):
|
| 94 |
+
self.vocab_size = vocab_size
|
| 95 |
+
self.max_position_embeddings = max_position_embeddings
|
| 96 |
+
self.hidden_size = hidden_size
|
| 97 |
+
self.intermediate_size = intermediate_size
|
| 98 |
+
self.num_hidden_layers = num_hidden_layers
|
| 99 |
+
self.num_attention_heads = num_attention_heads
|
| 100 |
+
self.use_sliding_window = use_sliding_window
|
| 101 |
+
self.sliding_window = sliding_window if use_sliding_window else None
|
| 102 |
+
self.max_window_layers = max_window_layers
|
| 103 |
+
|
| 104 |
+
# for backward compatibility
|
| 105 |
+
if num_key_value_heads is None:
|
| 106 |
+
num_key_value_heads = num_attention_heads
|
| 107 |
+
|
| 108 |
+
self.num_key_value_heads = num_key_value_heads
|
| 109 |
+
self.hidden_act = hidden_act
|
| 110 |
+
self.initializer_range = initializer_range
|
| 111 |
+
self.rms_norm_eps = rms_norm_eps
|
| 112 |
+
self.use_cache = use_cache
|
| 113 |
+
self.rope_theta = rope_theta
|
| 114 |
+
self.attention_dropout = attention_dropout
|
| 115 |
+
|
| 116 |
+
super().__init__(
|
| 117 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 118 |
+
**kwargs,
|
| 119 |
+
)
|
generation_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 158326,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
158326,
|
| 6 |
+
158332,
|
| 7 |
+
158333
|
| 8 |
+
],
|
| 9 |
+
"pad_token_id": 158326,
|
| 10 |
+
"repetition_penalty": 1.05,
|
| 11 |
+
"temperature": 0.7,
|
| 12 |
+
"top_k": 20,
|
| 13 |
+
"top_p": 0.8,
|
| 14 |
+
"transformers_version": "4.51.0"
|
| 15 |
+
}
|
model-00001-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f6e0ea009f7cea302c8afe67666e93ecd1c09c51c72eb8b68b17eaf26620d43f
|
| 3 |
+
size 4991500768
|
model-00002-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:53721c92a51c8282e6b600899012711ced0aa48ec47130126c6b6d9605b61cad
|
| 3 |
+
size 4997868656
|
model-00003-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e7c4cc4a03889e94bc8d9eaea7e507ce7f19612c631d7ba5b2ea86338a91869
|
| 3 |
+
size 4261734000
|
model-00004-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e98c2af3c2dd9e42618ef961dd3c0c041da2c0bb4af819e78e216626e4ca96fd
|
| 3 |
+
size 1298137216
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 15549210624
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"lm_head.weight": "model-00004-of-00004.safetensors",
|
| 7 |
+
"model.embed_tokens.weight": "model-00001-of-00004.safetensors",
|
| 8 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 9 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 10 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 11 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 13 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 14 |
+
"model.layers.0.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 15 |
+
"model.layers.0.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 16 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 17 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 18 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 19 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 20 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 21 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 22 |
+
"model.layers.1.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 23 |
+
"model.layers.1.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 24 |
+
"model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 25 |
+
"model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 26 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 27 |
+
"model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 28 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 29 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 30 |
+
"model.layers.10.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 31 |
+
"model.layers.10.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 32 |
+
"model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 33 |
+
"model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 34 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 35 |
+
"model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 36 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 37 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 38 |
+
"model.layers.11.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 39 |
+
"model.layers.11.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 40 |
+
"model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 41 |
+
"model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 42 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 43 |
+
"model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 44 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 45 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 46 |
+
"model.layers.12.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 47 |
+
"model.layers.12.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 48 |
+
"model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 49 |
+
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 50 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 51 |
+
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 52 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 53 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 54 |
+
"model.layers.13.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 55 |
+
"model.layers.13.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 56 |
+
"model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 57 |
+
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 58 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 59 |
+
"model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 60 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 61 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 62 |
+
"model.layers.14.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 63 |
+
"model.layers.14.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 64 |
+
"model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 65 |
+
"model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 66 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 67 |
+
"model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 68 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 69 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 70 |
+
"model.layers.15.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 71 |
+
"model.layers.15.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 72 |
+
"model.layers.16.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 73 |
+
"model.layers.16.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 74 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 75 |
+
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 76 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 77 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 78 |
+
"model.layers.16.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 79 |
+
"model.layers.16.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 80 |
+
"model.layers.17.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 81 |
+
"model.layers.17.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 82 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 83 |
+
"model.layers.17.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 84 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 85 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 86 |
+
"model.layers.17.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 87 |
+
"model.layers.17.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 88 |
+
"model.layers.18.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 89 |
+
"model.layers.18.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 90 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 91 |
+
"model.layers.18.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 92 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 93 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 94 |
+
"model.layers.18.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 95 |
+
"model.layers.18.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 96 |
+
"model.layers.19.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 97 |
+
"model.layers.19.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 98 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 99 |
+
"model.layers.19.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 100 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 101 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 102 |
+
"model.layers.19.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 103 |
+
"model.layers.19.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 104 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 105 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 106 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 107 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 108 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 109 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 110 |
+
"model.layers.2.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 111 |
+
"model.layers.2.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 112 |
+
"model.layers.20.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 113 |
+
"model.layers.20.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 114 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 115 |
+
"model.layers.20.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 116 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 117 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 118 |
+
"model.layers.20.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 119 |
+
"model.layers.20.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 120 |
+
"model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 121 |
+
"model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 122 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 123 |
+
"model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 124 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 125 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 126 |
+
"model.layers.21.self_attn.qkv_proj.bias": "model-00002-of-00004.safetensors",
|
| 127 |
+
"model.layers.21.self_attn.qkv_proj.weight": "model-00002-of-00004.safetensors",
|
| 128 |
+
"model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 129 |
+
"model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 130 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 131 |
+
"model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 132 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 133 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 134 |
+
"model.layers.22.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 135 |
+
"model.layers.22.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 136 |
+
"model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 137 |
+
"model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 138 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 139 |
+
"model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 140 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 141 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 142 |
+
"model.layers.23.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 143 |
+
"model.layers.23.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 144 |
+
"model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 145 |
+
"model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 146 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 147 |
+
"model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 148 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 149 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 150 |
+
"model.layers.24.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 151 |
+
"model.layers.24.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 152 |
+
"model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 153 |
+
"model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 154 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 155 |
+
"model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 156 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 157 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 158 |
+
"model.layers.25.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 159 |
+
"model.layers.25.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 160 |
+
"model.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 161 |
+
"model.layers.26.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 162 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 163 |
+
"model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 164 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 165 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 166 |
+
"model.layers.26.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 167 |
+
"model.layers.26.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 168 |
+
"model.layers.27.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 169 |
+
"model.layers.27.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 170 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 171 |
+
"model.layers.27.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 172 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 173 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 174 |
+
"model.layers.27.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 175 |
+
"model.layers.27.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 176 |
+
"model.layers.28.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 177 |
+
"model.layers.28.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 178 |
+
"model.layers.28.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 179 |
+
"model.layers.28.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 180 |
+
"model.layers.28.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 181 |
+
"model.layers.28.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 182 |
+
"model.layers.28.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 183 |
+
"model.layers.28.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 184 |
+
"model.layers.29.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 185 |
+
"model.layers.29.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 186 |
+
"model.layers.29.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 187 |
+
"model.layers.29.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 188 |
+
"model.layers.29.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 189 |
+
"model.layers.29.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 190 |
+
"model.layers.29.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 191 |
+
"model.layers.29.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 192 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 193 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 194 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 195 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 196 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 197 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 198 |
+
"model.layers.3.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 199 |
+
"model.layers.3.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 200 |
+
"model.layers.30.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 201 |
+
"model.layers.30.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 202 |
+
"model.layers.30.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 203 |
+
"model.layers.30.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 204 |
+
"model.layers.30.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 205 |
+
"model.layers.30.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 206 |
+
"model.layers.30.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 207 |
+
"model.layers.30.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 208 |
+
"model.layers.31.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 209 |
+
"model.layers.31.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 210 |
+
"model.layers.31.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 211 |
+
"model.layers.31.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 212 |
+
"model.layers.31.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 213 |
+
"model.layers.31.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 214 |
+
"model.layers.31.self_attn.qkv_proj.bias": "model-00003-of-00004.safetensors",
|
| 215 |
+
"model.layers.31.self_attn.qkv_proj.weight": "model-00003-of-00004.safetensors",
|
| 216 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 217 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 218 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 219 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 220 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 221 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 222 |
+
"model.layers.4.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 223 |
+
"model.layers.4.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 224 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 225 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 226 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 227 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 228 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 229 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 230 |
+
"model.layers.5.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 231 |
+
"model.layers.5.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 232 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 233 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 234 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 235 |
+
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 236 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 237 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 238 |
+
"model.layers.6.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 239 |
+
"model.layers.6.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 240 |
+
"model.layers.7.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 241 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 242 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 243 |
+
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 244 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 245 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 246 |
+
"model.layers.7.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 247 |
+
"model.layers.7.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 248 |
+
"model.layers.8.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 249 |
+
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 250 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 251 |
+
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 252 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 253 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 254 |
+
"model.layers.8.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 255 |
+
"model.layers.8.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 256 |
+
"model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 257 |
+
"model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 258 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 259 |
+
"model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 260 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 261 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 262 |
+
"model.layers.9.self_attn.qkv_proj.bias": "model-00001-of-00004.safetensors",
|
| 263 |
+
"model.layers.9.self_attn.qkv_proj.weight": "model-00001-of-00004.safetensors",
|
| 264 |
+
"model.norm.weight": "model-00003-of-00004.safetensors"
|
| 265 |
+
}
|
| 266 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"pad_token": "<pad>"
|
| 3 |
+
}
|
tokenization_zhinao.py
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import torch
|
| 3 |
+
import base64
|
| 4 |
+
import tiktoken
|
| 5 |
+
from typing import Collection, Optional, Dict, List, Set, Tuple, Union
|
| 6 |
+
from transformers import PreTrainedTokenizer
|
| 7 |
+
from transformers.utils import PaddingStrategy
|
| 8 |
+
from transformers.tokenization_utils import PreTrainedTokenizer
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
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+"""
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class SPTokenizer:
|
| 15 |
+
def __init__(self, model_path):
|
| 16 |
+
self.vocab_file = model_path
|
| 17 |
+
self.pad_token = '<pad>'
|
| 18 |
+
self.unk_token = '<unk>'
|
| 19 |
+
self.mask_token = '<mask>'
|
| 20 |
+
self.eod_token = '<eod>'
|
| 21 |
+
self.eop_token = '<eop>'
|
| 22 |
+
self.im_start_token = '<|im_start|>'
|
| 23 |
+
self.im_end_token = '<|im_end|>'
|
| 24 |
+
|
| 25 |
+
## special_tokens
|
| 26 |
+
self.SPECIAL_TOKENS = (
|
| 27 |
+
self.pad_token,
|
| 28 |
+
self.unk_token,
|
| 29 |
+
self.mask_token,
|
| 30 |
+
self.eod_token,
|
| 31 |
+
self.eop_token,
|
| 32 |
+
'[space2]', '[space3]', '[space4]', '[space8]',
|
| 33 |
+
self.im_start_token, self.im_end_token
|
| 34 |
+
)
|
| 35 |
+
self.bulid_tokenizer()
|
| 36 |
+
self.out = self.output_core_token()
|
| 37 |
+
|
| 38 |
+
self.token2strs = {
|
| 39 |
+
"[space2]": " ",
|
| 40 |
+
"[space3]": " ",
|
| 41 |
+
"[space4]": " ",
|
| 42 |
+
"[space8]": " ",
|
| 43 |
+
}
|
| 44 |
+
self.str2tokens = {v: k for k, v in self.token2strs.items()}
|
| 45 |
+
self.sorted_strs = sorted(list(self.str2tokens.keys()),
|
| 46 |
+
key=lambda x: len(x), reverse=True)
|
| 47 |
+
|
| 48 |
+
## skip_special_tokens
|
| 49 |
+
self.decode_skip_special_tokens = [
|
| 50 |
+
self.pad_token,
|
| 51 |
+
self.unk_token,
|
| 52 |
+
self.mask_token,
|
| 53 |
+
self.eod_token,
|
| 54 |
+
self.eop_token,
|
| 55 |
+
self.im_start_token,
|
| 56 |
+
self.im_end_token]
|
| 57 |
+
self.decode_skip_special_tokens_ids = [self.convert_token_to_id(token) for token in self.decode_skip_special_tokens]
|
| 58 |
+
|
| 59 |
+
def _load_tiktoken_bpe(self, tiktoken_bpe_file: str):
|
| 60 |
+
with open(tiktoken_bpe_file, "rb") as f:
|
| 61 |
+
contents = f.read()
|
| 62 |
+
return {
|
| 63 |
+
base64.b64decode(token): int(rank)
|
| 64 |
+
for token, rank in (line.split() for line in contents.splitlines() if line)
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
def bulid_tokenizer(self):
|
| 68 |
+
mergeable_ranks = self._load_tiktoken_bpe(self.vocab_file)
|
| 69 |
+
special_tokens = {
|
| 70 |
+
token: index
|
| 71 |
+
for index, token in enumerate(
|
| 72 |
+
self.SPECIAL_TOKENS, start=len(mergeable_ranks)
|
| 73 |
+
)
|
| 74 |
+
}
|
| 75 |
+
encode = tiktoken.Encoding(
|
| 76 |
+
"zhinao",
|
| 77 |
+
pat_str=PAT_STR,
|
| 78 |
+
mergeable_ranks=mergeable_ranks,
|
| 79 |
+
special_tokens=special_tokens
|
| 80 |
+
)
|
| 81 |
+
decoder = {v: k for k, v in mergeable_ranks.items()}
|
| 82 |
+
decoder.update({v: k for k, v in special_tokens.items()})
|
| 83 |
+
decoder_token2id = {v: k for k, v in decoder.items()}
|
| 84 |
+
|
| 85 |
+
self.tokenizer = encode
|
| 86 |
+
self.decoder = decoder
|
| 87 |
+
self.decoder_token2id = decoder_token2id
|
| 88 |
+
self.num_tokens = len(mergeable_ranks) + len(self.SPECIAL_TOKENS)
|
| 89 |
+
|
| 90 |
+
def output_core_token(self):
|
| 91 |
+
"""output special tokens"""
|
| 92 |
+
out = {}
|
| 93 |
+
for t in self.SPECIAL_TOKENS:
|
| 94 |
+
out[t] = self.convert_token_to_id(t)
|
| 95 |
+
return out
|
| 96 |
+
|
| 97 |
+
def tokenize(
|
| 98 |
+
self,
|
| 99 |
+
text,
|
| 100 |
+
allowed_special: Union[Set, str] = "all",
|
| 101 |
+
disallowed_special: Union[Collection, str] = ()):
|
| 102 |
+
tokens = []
|
| 103 |
+
text = self.convert(text)
|
| 104 |
+
for idx in self.tokenizer.encode(text, allowed_special=allowed_special, disallowed_special=disallowed_special):
|
| 105 |
+
tokens.append(self.decoder[idx])
|
| 106 |
+
return tokens
|
| 107 |
+
|
| 108 |
+
def encode(self, text, allowed_special="all", disallowed_special=()):
|
| 109 |
+
"""text to id"""
|
| 110 |
+
text = self.convert(text)
|
| 111 |
+
return self.tokenizer.encode(text, allowed_special=allowed_special, disallowed_special=disallowed_special)
|
| 112 |
+
|
| 113 |
+
def decode(self, ids, errors="replace"):
|
| 114 |
+
"""id to text"""
|
| 115 |
+
text = self.tokenizer.decode(ids, errors=errors)
|
| 116 |
+
return self.deconvert(text)
|
| 117 |
+
|
| 118 |
+
def decode_tokens(self, tokens: List[str]) -> str:
|
| 119 |
+
"""
|
| 120 |
+
Converts a sequence of tokens in a single string.
|
| 121 |
+
"""
|
| 122 |
+
text = ""
|
| 123 |
+
temp = b""
|
| 124 |
+
for t in tokens:
|
| 125 |
+
if isinstance(t, str):
|
| 126 |
+
if temp:
|
| 127 |
+
text += temp.decode("utf-8", errors="ignore")
|
| 128 |
+
temp = b""
|
| 129 |
+
text += t
|
| 130 |
+
elif isinstance(t, bytes):
|
| 131 |
+
temp += t
|
| 132 |
+
else:
|
| 133 |
+
raise TypeError("token should only be of type bytes or str")
|
| 134 |
+
if temp:
|
| 135 |
+
text += temp.decode("utf-8", errors="ignore")
|
| 136 |
+
return self.deconvert(text)
|
| 137 |
+
|
| 138 |
+
def convert_id_to_token(self, idx):
|
| 139 |
+
return self.decoder[idx]
|
| 140 |
+
|
| 141 |
+
def convert_token_to_id(self, token):
|
| 142 |
+
return self.decoder_token2id[token]
|
| 143 |
+
|
| 144 |
+
def convert(self, text):
|
| 145 |
+
"""将文本的特殊字符转换成特殊token"""
|
| 146 |
+
for k in ["[br]", "<br>"]:
|
| 147 |
+
text = text.replace(k, "\n")
|
| 148 |
+
for k in self.sorted_strs:
|
| 149 |
+
if k in text:
|
| 150 |
+
text = text.replace(k, self.str2tokens[k])
|
| 151 |
+
return text
|
| 152 |
+
|
| 153 |
+
def deconvert(self, text):
|
| 154 |
+
"""将解码文本恢复原始字符"""
|
| 155 |
+
for t in self.token2strs:
|
| 156 |
+
if t in text:
|
| 157 |
+
text = text.replace(t, self.token2strs[t])
|
| 158 |
+
return text
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class ZhinaoTokenizer(PreTrainedTokenizer):
|
| 162 |
+
vocab_files_names = {"vocab_file": "vocab/360.tiktoken"}
|
| 163 |
+
model_input_names = ["input_ids", "attention_mask"]
|
| 164 |
+
|
| 165 |
+
def __init__(self, vocab_file, padding_side="left", clean_up_tokenization_spaces=False, **kwargs):
|
| 166 |
+
self.name = "ZhinaoTokenizer"
|
| 167 |
+
self.vocab_file = vocab_file
|
| 168 |
+
self.tokenizer = SPTokenizer(model_path=vocab_file)
|
| 169 |
+
try:
|
| 170 |
+
kwargs.pop('eos_token')
|
| 171 |
+
kwargs.pop('pad_token')
|
| 172 |
+
kwargs.pop('unk_token')
|
| 173 |
+
except:
|
| 174 |
+
pass
|
| 175 |
+
super().__init__(padding_side=padding_side, clean_up_tokenization_spaces=clean_up_tokenization_spaces, **kwargs)
|
| 176 |
+
self.pad_token_id = self.tokenizer.convert_token_to_id(self.tokenizer.pad_token)
|
| 177 |
+
self.eod_id = self.tokenizer.convert_token_to_id(self.tokenizer.eod_token)
|
| 178 |
+
self.im_start_id = self.tokenizer.convert_token_to_id(self.tokenizer.im_start_token)
|
| 179 |
+
self.im_end_id = self.tokenizer.convert_token_to_id(self.tokenizer.im_end_token)
|
| 180 |
+
|
| 181 |
+
@property
|
| 182 |
+
def eop_token(self) -> str:
|
| 183 |
+
return self.tokenizer.eop_token
|
| 184 |
+
|
| 185 |
+
@property
|
| 186 |
+
def eop_token_id(self):
|
| 187 |
+
return self.tokenizer.convert_token_to_id(self.tokenizer.eop_token)
|
| 188 |
+
|
| 189 |
+
@property
|
| 190 |
+
def eos_token_id(self):
|
| 191 |
+
return self.tokenizer.convert_token_to_id(self.tokenizer.eod_token)
|
| 192 |
+
|
| 193 |
+
@property
|
| 194 |
+
def vocab_size(self):
|
| 195 |
+
return self.tokenizer.num_tokens
|
| 196 |
+
|
| 197 |
+
def get_vocab(self):
|
| 198 |
+
""" Returns vocab as a dict """
|
| 199 |
+
vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
|
| 200 |
+
vocab.update(self.added_tokens_encoder)
|
| 201 |
+
return vocab
|
| 202 |
+
|
| 203 |
+
def tokenize(
|
| 204 |
+
self,
|
| 205 |
+
text: str,
|
| 206 |
+
allowed_special: Union[Set, str] = "all",
|
| 207 |
+
disallowed_special: Union[Collection, str] = (),
|
| 208 |
+
split_special_tokens=False,
|
| 209 |
+
) -> List[Union[bytes, str]]:
|
| 210 |
+
tokens = []
|
| 211 |
+
for t in self.tokenizer.encode(
|
| 212 |
+
text, allowed_special=allowed_special, disallowed_special=disallowed_special
|
| 213 |
+
):
|
| 214 |
+
tokens.append(self.tokenizer.decoder[t])
|
| 215 |
+
return tokens
|
| 216 |
+
|
| 217 |
+
def _decode(
|
| 218 |
+
self,
|
| 219 |
+
token_ids: Union[int, List[int]],
|
| 220 |
+
skip_special_tokens: bool = False,
|
| 221 |
+
errors: str = "ignore",
|
| 222 |
+
**kwargs,
|
| 223 |
+
) -> str:
|
| 224 |
+
if isinstance(token_ids, int):
|
| 225 |
+
token_ids = [token_ids]
|
| 226 |
+
if skip_special_tokens:
|
| 227 |
+
token_ids = [i for i in token_ids if i not in self.tokenizer.decode_skip_special_tokens_ids]
|
| 228 |
+
return self.tokenizer.decode(token_ids, errors=errors)
|
| 229 |
+
|
| 230 |
+
def _tokenize(self, text, **kwargs):
|
| 231 |
+
raise NotImplementedError
|
| 232 |
+
|
| 233 |
+
def _convert_token_to_id(self, token):
|
| 234 |
+
""" Converts a token (str) in an id using the vocab. """
|
| 235 |
+
return self.tokenizer.convert_token_to_id(token)
|
| 236 |
+
|
| 237 |
+
def _convert_id_to_token(self, index):
|
| 238 |
+
"""Converts an index (integer) in a token (str) using the vocab. """
|
| 239 |
+
return self.tokenizer.convert_id_to_token(index)
|
| 240 |
+
|
| 241 |
+
def convert_tokens_to_string(self, tokens: List[str]) -> str:
|
| 242 |
+
"""
|
| 243 |
+
Converts a sequence of tokens in a single string.
|
| 244 |
+
"""
|
| 245 |
+
return self.tokenizer.decode_tokens(tokens)
|
| 246 |
+
|
| 247 |
+
def save_vocabulary(self, save_directory, filename_prefix=None):
|
| 248 |
+
"""Save only the vocabulary of the tokenizer (vocabulary). """
|
| 249 |
+
if os.path.isdir(save_directory):
|
| 250 |
+
vocab_file = os.path.join(save_directory, self.vocab_files_names["vocab_file"])
|
| 251 |
+
else:
|
| 252 |
+
vocab_file = save_directory
|
| 253 |
+
|
| 254 |
+
with open(self.vocab_file, 'rb') as fin:
|
| 255 |
+
proto_str = fin.read()
|
| 256 |
+
|
| 257 |
+
os.makedirs(save_directory + "/vocab", exist_ok=True)
|
| 258 |
+
with open(vocab_file, "wb") as writer:
|
| 259 |
+
writer.write(proto_str)
|
| 260 |
+
|
| 261 |
+
return (vocab_file,)
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {},
|
| 3 |
+
"auto_map": {
|
| 4 |
+
"AutoTokenizer": [
|
| 5 |
+
"tokenization_zhinao.ZhinaoTokenizer",
|
| 6 |
+
null
|
| 7 |
+
]
|
| 8 |
+
},
|
| 9 |
+
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
| 10 |
+
"clean_up_tokenization_spaces": false,
|
| 11 |
+
"do_lower_case": false,
|
| 12 |
+
"extra_special_tokens": {},
|
| 13 |
+
"model_max_length": 4096,
|
| 14 |
+
"pad_token": "<pad>",
|
| 15 |
+
"padding_side": "left",
|
| 16 |
+
"remove_space": false,
|
| 17 |
+
"tokenizer_class": "ZhinaoTokenizer"
|
| 18 |
+
}
|
vocab/360.tiktoken
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|