stgzr commited on
Commit
738f2a8
1 Parent(s): 31c2fe1

update tokenizer and model weights

Browse files
added_tokens.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|endoftext|>": 96506,
3
+ "<|end|>": 96500,
4
+ "<|message|>": 96501,
5
+ "<|pad|>": 96505,
6
+ "<|start|>": 96499,
7
+ "<|tool_end|>": 96504,
8
+ "<|tool_excute|>": 96503,
9
+ "<|tool_start|>": 96502
10
+ }
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "INFLMForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_inflm.INFLMConfig",
9
+ "AutoModelForCausalLM": "modeling_inflm.INFLMForCausalLM"
10
+ },
11
+ "bos_token_id": 1,
12
+ "eos_token_id": 2,
13
+ "hidden_act": "silu",
14
+ "hidden_size": 8192,
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 22016,
17
+ "layer_norm_eps": 1e-05,
18
+ "max_position_embeddings": 32768,
19
+ "mlp_bias": false,
20
+ "model_type": "inflm",
21
+ "num_attention_heads": 64,
22
+ "num_hidden_layers": 48,
23
+ "num_key_value_heads": 8,
24
+ "pretraining_tp": 1,
25
+ "quantization_config": {
26
+ "bits": 4,
27
+ "group_size": 128,
28
+ "modules_to_not_convert": null,
29
+ "quant_method": "awq",
30
+ "version": "gemm",
31
+ "zero_point": true
32
+ },
33
+ "rope_scaling": null,
34
+ "rope_theta": 500000,
35
+ "tie_word_embeddings": false,
36
+ "torch_dtype": "float16",
37
+ "use_cache": false,
38
+ "vocab_size": 96512
39
+ }
40
+
configuration_inflm.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """INFLM model configuration."""
21
+
22
+ from transformers.models.llama.configuration_llama import LlamaConfig
23
+
24
+
25
+ class INFLMConfig(LlamaConfig):
26
+ model_type = "inflm"
27
+
28
+ def __init__(
29
+ self,
30
+ layer_norm_eps=1e-5,
31
+ **kwargs,
32
+ ):
33
+ self.layer_norm_eps = layer_norm_eps
34
+ super().__init__(
35
+ **kwargs,
36
+ )
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "eos_token_id": 2,
3
+ "pad_token_id": 3,
4
+ "max_new_tokens": 2048,
5
+ "do_sample": true,
6
+ "top_k": 0,
7
+ "top_p": 0.8,
8
+ "transformers_version": "4.39.0"
9
+ }
model-00001-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:887fa3e6b234a03b4383c48db6c3a1a0846dac72891626393ea8b657bb23f76c
3
+ size 3911092592
model-00002-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e537b957993acc32b202b0db74782997ec1567e24c896f4e9e9d9cafa60651a5
3
+ size 3955767928
model-00003-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:943871560352585ac0e535f8739598ca92eec344c726c556a2ae87e1cf2b2bd3
3
+ size 3955768024
model-00004-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f4ed76ca7423f7a122b2b388a3a8c0b42b77074275de421a0d3239dee806aed
3
+ size 3955768024
model-00005-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4fa1c4c48005d8fc5fa2d4d434916cfa06390932ffa14683ee6900bd418786a
3
+ size 3064421992
model-00006-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a3adb4891758e76f7370ce5f7e2290f9391aeb29ff98b4c87d0aba9c95c70f5
3
+ size 1581252736
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
modeling_inflm.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """PyTorch INFLM model."""
21
+
22
+ import torch
23
+ from torch import nn
24
+ from transformers.models.llama.modeling_llama import (
25
+ LlamaDecoderLayer,
26
+ LlamaModel,
27
+ LlamaForCausalLM
28
+ )
29
+ from .configuration_inflm import INFLMConfig
30
+
31
+ _CONFIG_FOR_DOC = "INFLMConfig"
32
+
33
+
34
+ class INFLMDecoderLayer(LlamaDecoderLayer):
35
+ def __init__(self, config: INFLMConfig, layer_idx: int):
36
+ super().__init__(config, layer_idx)
37
+ self.input_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
38
+ self.post_attention_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
39
+
40
+
41
+ class INFLMModel(LlamaModel):
42
+ config_class = INFLMConfig
43
+ _no_split_modules = ["INFLMDecoderLayer"]
44
+
45
+ def __init__(self, config: INFLMConfig):
46
+ super().__init__(config)
47
+ self.padding_idx = config.pad_token_id
48
+ self.vocab_size = config.vocab_size
49
+
50
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
51
+ self.layers = nn.ModuleList([INFLMDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)])
52
+ self.norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
53
+
54
+ self.gradient_checkpointing = False
55
+ # Initialize weights and apply final processing
56
+ self.post_init()
57
+
58
+
59
+ class INFLMForCausalLM(LlamaForCausalLM):
60
+ _tied_weights_keys = ["lm_head.weight"]
61
+
62
+ def __init__(self, config: INFLMConfig):
63
+ super().__init__(config)
64
+ self.model = INFLMModel(config)
65
+ self.vocab_size = config.vocab_size
66
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
67
+
68
+ # Initialize weights and apply final processing
69
+ self.post_init()
special_tokens_map.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|start|>",
4
+ "<|end|>",
5
+ "<|message|>",
6
+ "<|tool_start|>",
7
+ "<|tool_excute|>",
8
+ "<|tool_end|>",
9
+ "<|pad|>",
10
+ "<|endoftext|>"
11
+ ],
12
+ "bos_token": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false
18
+ },
19
+ "eos_token": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "pad_token": {
27
+ "content": "<pad>",
28
+ "lstrip": false,
29
+ "normalized": false,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ },
33
+ "unk_token": {
34
+ "content": "<unk>",
35
+ "lstrip": false,
36
+ "normalized": false,
37
+ "rstrip": false,
38
+ "single_word": false
39
+ }
40
+ }
tokenization_inflm.py ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+
21
+ """Tokenization classes for INFLMTokenizer."""
22
+ import os
23
+ from shutil import copyfile
24
+ from typing import Any, Dict, List, Optional, Tuple
25
+
26
+ import sentencepiece as spm
27
+
28
+ from transformers.tokenization_utils import PreTrainedTokenizer
29
+ from transformers.utils import logging
30
+
31
+ from tokenizers import pre_tokenizers,Regex,decoders
32
+ from tokenizers.pre_tokenizers import Digits, Split, ByteLevel
33
+ import os
34
+
35
+ # same as gpt4 cl-base-100k
36
+ PATTERN = Regex("(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+\s+(\S)+")
37
+
38
+ logger = logging.get_logger(__name__)
39
+
40
+ VOCAB_FILES_NAMES = {"vocab_file": "./tokenizer.model"}
41
+
42
+ PRETRAINED_VOCAB_FILES_MAP = {}
43
+
44
+
45
+ class INFLMTokenizer(PreTrainedTokenizer):
46
+ """
47
+ Construct a INFLMTokenizer tokenizer based on sentence-piece
48
+
49
+ Args:
50
+ vocab_file (`str`):
51
+ Path to the vocabulary file.
52
+ """
53
+
54
+ vocab_files_names = VOCAB_FILES_NAMES
55
+ pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
56
+ model_input_names = ["input_ids", "attention_mask"]
57
+ _auto_class = "AutoTokenizer"
58
+
59
+ def __init__(
60
+ self,
61
+ vocab_file,
62
+ unk_token="<unk>",
63
+ bos_token="<s>",
64
+ eos_token="</s>",
65
+ pad_token="<pad>",
66
+ sp_model_kwargs: Optional[Dict[str, Any]] = None,
67
+ add_bos_token=False,
68
+ add_eos_token=False,
69
+ decode_with_prefix_space=False,
70
+ clean_up_tokenization_spaces=False,
71
+ spaces_between_special_tokens=False,
72
+ **kwargs,
73
+ ):
74
+ self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
75
+ self.vocab_file = vocab_file
76
+ self.add_bos_token = add_bos_token
77
+ self.add_eos_token = add_eos_token
78
+ self.decode_with_prefix_space = decode_with_prefix_space
79
+ self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
80
+ self.sp_model.Load(vocab_file)
81
+ self._no_prefix_space_tokens = None
82
+ self.pre_tokenizer = pre_tokenizers.Sequence([Split(pattern =PATTERN,behavior = "isolated", invert = False)])
83
+ super().__init__(
84
+ bos_token=bos_token,
85
+ eos_token=eos_token,
86
+ unk_token=unk_token,
87
+ pad_token=pad_token,
88
+ clean_up_tokenization_spaces=clean_up_tokenization_spaces,
89
+ spaces_between_special_tokens=spaces_between_special_tokens,
90
+ **kwargs,
91
+ )
92
+
93
+ """ Initialisation"""
94
+
95
+ @property
96
+ def no_prefix_space_tokens(self):
97
+ if self._no_prefix_space_tokens is None:
98
+ vocab = self.convert_ids_to_tokens(list(range(self.vocab_size)))
99
+ self._no_prefix_space_tokens = {i for i, tok in enumerate(vocab) if not tok.startswith("▁")}
100
+ return self._no_prefix_space_tokens
101
+
102
+ @property
103
+ def vocab_size(self):
104
+ """Returns vocab size"""
105
+ return self.sp_model.get_piece_size()
106
+
107
+ @property
108
+ def bos_token_id(self) -> Optional[int]:
109
+ return self.sp_model.bos_id()
110
+
111
+ @property
112
+ def eos_token_id(self) -> Optional[int]:
113
+ return self.sp_model.eos_id()
114
+
115
+ def get_vocab(self):
116
+ """Returns vocab as a dict"""
117
+ vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
118
+ vocab.update(self.added_tokens_encoder)
119
+ return vocab
120
+
121
+ def _tokenize(self, text):
122
+ """Returns a tokenized string."""
123
+
124
+ splits = self.pre_tokenizer.pre_tokenize_str(text)
125
+ texts=[]
126
+
127
+ for split in splits:
128
+ texts.extend(self.sp_model.encode(split[0], out_type=str))
129
+ return texts
130
+
131
+ def _convert_token_to_id(self, token):
132
+ """Converts a token (str) in an id using the vocab."""
133
+
134
+ return self.sp_model.piece_to_id(token)
135
+
136
+ def _convert_id_to_token(self, index):
137
+ """Converts an index (integer) in a token (str) using the vocab."""
138
+ token = self.sp_model.IdToPiece(index)
139
+ return token
140
+
141
+ def _maybe_add_prefix_space(self, tokens, decoded):
142
+ if tokens and tokens[0] not in self.no_prefix_space_tokens:
143
+ return " " + decoded
144
+ else:
145
+ return decoded
146
+
147
+ def convert_tokens_to_string(self, tokens):
148
+ """Converts a sequence of tokens (string) in a single string."""
149
+ current_sub_tokens = []
150
+ out_string = ""
151
+ prev_is_special = False
152
+ for token in tokens:
153
+ # make sure that special tokens are not decoded using sentencepiece model
154
+ if token in self.all_special_tokens:
155
+ out_string += self.sp_model.decode(current_sub_tokens) + token
156
+ prev_is_special = True
157
+ current_sub_tokens = []
158
+ else:
159
+ current_sub_tokens.append(token)
160
+ prev_is_special = False
161
+ out_string += self.sp_model.decode(current_sub_tokens)
162
+
163
+ return out_string
164
+
165
+ def save_vocabulary(self, save_directory, filename_prefix: Optional[str] = None) -> Tuple[str]:
166
+ """
167
+ Save the vocabulary and special tokens file to a directory.
168
+
169
+ Args:
170
+ save_directory (`str`):
171
+ The directory in which to save the vocabulary.
172
+
173
+ Returns:
174
+ `Tuple(str)`: Paths to the files saved.
175
+ """
176
+ if not os.path.isdir(save_directory):
177
+ logger.error(f"Vocabulary path ({save_directory}) should be a directory")
178
+ return
179
+ out_vocab_file = os.path.join(
180
+ save_directory, (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]
181
+ )
182
+
183
+ if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file) and os.path.isfile(self.vocab_file):
184
+ copyfile(self.vocab_file, out_vocab_file)
185
+ elif not os.path.isfile(self.vocab_file):
186
+ with open(out_vocab_file, "wb") as fi:
187
+ content_spiece_model = self.sp_model.serialized_model_proto()
188
+ fi.write(content_spiece_model)
189
+
190
+ return (out_vocab_file,)
191
+
192
+ def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
193
+ if self.add_bos_token:
194
+ bos_token_ids = [self.bos_token_id]
195
+ else:
196
+ bos_token_ids = []
197
+
198
+ output = bos_token_ids + token_ids_0
199
+
200
+ if token_ids_1 is not None:
201
+ output = output + token_ids_1
202
+
203
+ if self.add_eos_token:
204
+ output = output + [self.eos_token_id]
205
+
206
+ return output
207
+
208
+ def get_special_tokens_mask(
209
+ self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
210
+ ) -> List[int]:
211
+ """
212
+ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
213
+ special tokens using the tokenizer `prepare_for_model` method.
214
+
215
+ Args:
216
+ token_ids_0 (`List[int]`):
217
+ List of IDs.
218
+ token_ids_1 (`List[int]`, *optional*):
219
+ Optional second list of IDs for sequence pairs.
220
+ already_has_special_tokens (`bool`, *optional*, defaults to `False`):
221
+ Whether or not the token list is already formatted with special tokens for the model.
222
+
223
+ Returns:
224
+ `List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
225
+ """
226
+ if already_has_special_tokens:
227
+ return super().get_special_tokens_mask(
228
+ token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
229
+ )
230
+
231
+ eos_token_id = [1] if self.add_eos_token else []
232
+ if token_ids_1 is None:
233
+ return ([0] * len(token_ids_0)) + eos_token_id
234
+ return ([0] * len(token_ids_0)) + eos_token_id + ([0] * len(token_ids_1)) + eos_token_id
235
+
236
+
237
+ def create_token_type_ids_from_sequences(
238
+ self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
239
+ ) -> List[int]:
240
+ """
241
+ Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT
242
+ sequence pair mask has the following format:
243
+
244
+ ```
245
+ 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
246
+ | first sequence | second sequence |
247
+ ```
248
+
249
+ if token_ids_1 is None, only returns the first portion of the mask (0s).
250
+
251
+ Note this is only used for back compatiblity, thus list of zero is returned.
252
+
253
+ Args:
254
+ token_ids_0 (`List[int]`):
255
+ List of ids.
256
+ token_ids_1 (`List[int]`, *optional*):
257
+ Optional second list of IDs for sequence pairs.
258
+
259
+ Returns:
260
+ `List[int]`: List of zeros.
261
+ """
262
+ eos = [self.eos_token_id]
263
+
264
+ if token_ids_1 is None:
265
+ return len(token_ids_0 + eos) * [0]
266
+ return len(token_ids_0 + eos + token_ids_1 + eos) * [0]
267
+
268
+
269
+ @property
270
+ def default_chat_template(self):
271
+ return None
272
+
273
+
274
+ def decode(
275
+ self,
276
+ token_ids,
277
+ skip_special_tokens: bool = False,
278
+ clean_up_tokenization_spaces: Optional[bool] = False,
279
+ spaces_between_special_tokens: bool = False,
280
+ **kwargs,
281
+ ) -> str:
282
+ # default spaces_between_special_tokens should be false.
283
+ if spaces_between_special_tokens:
284
+ logger.warning_once('spaces_between_special_tokens is set. \
285
+ It has no effect for bos,eos,pad,unk when transformers<=4.38.')
286
+ return super().decode(
287
+ token_ids,
288
+ skip_special_tokens=skip_special_tokens,
289
+ clean_up_tokenization_spaces=clean_up_tokenization_spaces,
290
+ spaces_between_special_tokens=spaces_between_special_tokens,
291
+ **kwargs,
292
+ )
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76d43d618fc0c5a7c79dc4e72579f9f29bb803b36e4a4d709d1233626fd8fe2a
3
+ size 1535725
tokenizer_config.json ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<unk>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<pad>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "96499": {
37
+ "content": "<|start|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "96500": {
45
+ "content": "<|end|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "96501": {
53
+ "content": "<|message|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "96502": {
61
+ "content": "<|tool_start|>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "96503": {
69
+ "content": "<|tool_excute|>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "96504": {
77
+ "content": "<|tool_end|>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "96505": {
85
+ "content": "<|pad|>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "96506": {
93
+ "content": "<|endoftext|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ }
100
+ },
101
+ "additional_special_tokens": [
102
+ "<|start|>",
103
+ "<|end|>",
104
+ "<|message|>",
105
+ "<|tool_start|>",
106
+ "<|tool_excute|>",
107
+ "<|tool_end|>",
108
+ "<|pad|>",
109
+ "<|endoftext|>"
110
+ ],
111
+ "auto_map": {
112
+ "AutoTokenizer": [
113
+ "tokenization_inflm.INFLMTokenizer",
114
+ null
115
+ ]
116
+ },
117
+ "bos_token": "<s>",
118
+ "chat_template": "{% for message in messages %}{% if message['role'] == 'user' %}{% if not loop.first %}{{ '\\n' }}{% endif %}{{'<|start|>user\\n' + message['content'] + '<|end|>\\n' }}{% if (loop.last and add_generation_prompt) %}{{ '<|start|>assistant<|message|>' }}{% endif %}{% elif message['role'] == 'system' %}{{ '<|start|>system\\n' + message['content'] + '<|end|>' }}{% elif message['role'] == 'assistant' %}{{ '<|start|>assistant<|message|>' + message['content'] + '<|end|>' }}{% endif %}{% endfor %}",
119
+ "clean_up_tokenization_spaces": false,
120
+ "eos_token": "</s>",
121
+ "model_max_length": 1000000000000000019884624838656,
122
+ "pad_token": "<pad>",
123
+ "return_tensors": true,
124
+ "spaces_between_special_tokens": false,
125
+ "tokenizer_class": "INFLMTokenizer",
126
+ "unk_token": "<unk>"
127
+ }