Question Answering
Transformers
ONNX
Safetensors
English
doge
text-generation
custom_code
dewdev commited on
Commit
db19442
verified
1 Parent(s): 479d606

Upload 11 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ Doge.png filter=lfs diff=lfs merge=lfs -text
Doge.png ADDED

Git LFS Details

  • SHA256: 848a831bbe3d91b2de514552805c73ef652a3100e0fbc7f5c20cedaadabba2e7
  • Pointer size: 131 Bytes
  • Size of remote file: 169 kB
README.md CHANGED
@@ -1,3 +1,125 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ datasets:
5
+ - HuggingFaceTB/smoltalk
6
+ - HuggingFaceH4/ultrafeedback_binarized
7
+ base_model:
8
+ - SmallDoge/Doge-60M
9
+ language:
10
+ - en
11
+ pipeline_tag: question-answering
12
+ ---
13
+
14
+
15
+ # **Doge 60M Instruct**
16
+
17
+ <div align="center">
18
+ <img src="https://huggingface.co/spaces/SmallDoge/README/resolve/main/org_icon.png" width="100%" alt="SmallDoge" />
19
+ </div>
20
+ <hr>
21
+ <div align="center">
22
+ <a href="https://arxiv.org/abs/2412.11834" target="_blank" style="margin: 2px;">
23
+ <img alt="arXiv" src="https://img.shields.io/static/v1?label=arXiv&message=2412.11834&color=B31B1B&logo=arXiv" style="display: inline-block; vertical-align: middle;"/>
24
+ </a>
25
+ <a href="https://github.com/SmallDoges/small-doge" target="_blank" style="margin: 2px;">
26
+ <img alt="GitHub" src="https://img.shields.io/badge/GitHub-SmallDoge-181717?logo=github" style="display: inline-block; vertical-align: middle;"/>
27
+ </a>
28
+ <a href="https://huggingface.co/SmallDoge" target="_blank" style="margin: 2px;">
29
+ <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace-SmallDoge-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
30
+ </a>
31
+ <a href="https://github.com/SmallDoges/small-doge/blob/main/LICENSE" style="margin: 2px;">
32
+ <img alt="License" src="https://img.shields.io/badge/License-Apache--2.0-blue.svg" style="display: inline-block; vertical-align: middle;"/>
33
+ </a>
34
+ </div>
35
+
36
+ Doge uses Dynamic Mask Attention as sequence transformation and can use Multi-Layer Perceptron or Cross Domain Mixture of Experts as state transformation. Dynamic Mask Attention allows the Transformer to use self-attention during training and state space during inference, and Cross Domain Mixture of Experts can directly inherit the weights of Multi-Layer Perceptron for further training. This model is trained by [SmallDoge](https://huggingface.co/SmallDoge) community, for detailed algorithm and model architecture, please refer to [Wonderful Matrices](https://arxiv.org/abs/2412.11834), all training details and code are publicly available on the [small-doge](https://github.com/SmallDoges/small-doge) repository.
37
+
38
+
39
+ ## Uses
40
+
41
+ ```python
42
+ from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, TextStreamer
43
+
44
+ tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge-60M-Instruct")
45
+ model = AutoModelForCausalLM.from_pretrained("SmallDoge/Doge-60M-Instruct", trust_remote_code=True)
46
+
47
+ generation_config = GenerationConfig(
48
+ max_new_tokens=100,
49
+ use_cache=True,
50
+ do_sample=True,
51
+ temperature=0.8,
52
+ top_p=0.9,
53
+ repetition_penalty=1.0
54
+ )
55
+ steamer = TextStreamer(
56
+ tokenizer=tokenizer,
57
+ skip_prompt=True
58
+ )
59
+
60
+ prompt = "Hi, how are you doing today?"
61
+ conversation = [
62
+ {"role": "user", "content": prompt}
63
+ ]
64
+ inputs = tokenizer.apply_chat_template(
65
+ conversation=conversation,
66
+ tokenize=True,
67
+ return_tensors="pt",
68
+ )
69
+
70
+ outputs = model.generate(
71
+ inputs,
72
+ tokenizer=tokenizer,
73
+ generation_config=generation_config,
74
+ streamer=steamer
75
+ )
76
+ ```
77
+
78
+
79
+ ## Model Details
80
+
81
+ We build the Doge-Instruct by first SFT on [SmolTalk](https://huggingface.co/datasets/HuggingFaceTB/smoltalk) and then DPO on [UltraFeedback Binarized](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized).
82
+
83
+ > TODO: The larger model is under training and will be uploaded soon.
84
+
85
+ **SFT**:
86
+ | Model | Training Data | Epochs | Content Length | LR | Batch Size | Precision |
87
+ |---|---|---|---|---|---|---|
88
+ | [Doge-20M-Instruct-SFT](https://huggingface.co/SmallDoge/Doge-20M-Instruct-SFT) | [HuggingFaceTB/smoltalk](https://huggingface.co/datasets/HuggingFaceTB/smoltalk) | 2 | 2048 | 8e-4 | 0.25M | bfloat16 |
89
+ | [Doge-60M-Instruct-SFT](https://huggingface.co/SmallDoge/Doge-60M-Instruct-SFT) | [HuggingFaceTB/smoltalk](https://huggingface.co/datasets/HuggingFaceTB/smoltalk) | 2 | 2048 | 6e-4 | 0.25M | bfloat16 |
90
+
91
+ **DPO**:
92
+ | Model | Training Data | Epochs | Content Length | LR | Batch Size | Precision |
93
+ |---|---|---|---|---|---|---|
94
+ | [Doge-20M-Instruct](https://huggingface.co/SmallDoge/Doge-20M-Instruct) | [HuggingFaceH4/ultrafeedback_binarized](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized) | 2 | 1024 | 8e-5 | 0.125M | bfloat16 |
95
+ | [Doge-60M-Instruct](https://huggingface.co/SmallDoge/Doge-60M-Instruct) | [HuggingFaceH4/ultrafeedback_binarized](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized) | 2 | 1024 | 6e-5 | 0.125M | bfloat16 |
96
+
97
+
98
+ **Procedure**:
99
+
100
+ **SFT**:
101
+ [<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="150" height="24"/>](https://wandb.ai/loser_cheems/huggingface/runs/ckbn4b5m)
102
+
103
+ **DPO**:
104
+ [<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="150" height="24"/>](https://wandb.ai/loser_cheems/huggingface/runs/3nk7mu5a)
105
+
106
+
107
+ **Environment**:
108
+ - Image: nvcr.io/nvidia/pytorch:24.12-py3
109
+ - Hardware: 1x NVIDIA RTX 4090
110
+ - Software: Transformers, TRL
111
+
112
+
113
+ ## Citation
114
+
115
+ ```bibtex
116
+ @misc{shi2024wonderfulmatrices,
117
+ title={Wonderful Matrices: Combining for a More Efficient and Effective Foundation Model Architecture},
118
+ author={Jingze Shi and Bingheng Wu},
119
+ year={2024},
120
+ eprint={2412.11834},
121
+ archivePrefix={arXiv},
122
+ primaryClass={cs.LG},
123
+ url={https://arxiv.org/abs/2412.11834},
124
+ }
125
+ ```
config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "SmallDoge/Doge-60M-Instruct",
3
+ "architectures": [
4
+ "DogeForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_doge.DogeConfig",
9
+ "AutoModelForCausalLM": "modeling_doge.DogeForCausalLM"
10
+ },
11
+ "bos_token_id": 0,
12
+ "dynamic_mask_ratio": 0.0,
13
+ "eos_token_id": 1,
14
+ "expert_retrieval_size": 256,
15
+ "hidden_act": "silu",
16
+ "hidden_bias": false,
17
+ "hidden_dropout": 0.0,
18
+ "hidden_size": 512,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 1024,
21
+ "is_moe": false,
22
+ "max_position_embeddings": 2048,
23
+ "model_type": "doge",
24
+ "num_attention_heads": 4,
25
+ "num_cdmmoe_experts": 2048,
26
+ "num_cdmmoe_experts_per_head": 8,
27
+ "num_cdmmoe_heads": 4,
28
+ "num_cdmoe_experts": 16348,
29
+ "num_cdmoe_experts_per_head": 8,
30
+ "num_cdmoe_heads": 4,
31
+ "num_channels": 3,
32
+ "num_hidden_layers": 16,
33
+ "num_key_value_heads": 2,
34
+ "pad_token_id": 2,
35
+ "patch_size": 16,
36
+ "rms_norm_eps": 1e-06,
37
+ "rope_scaling": {
38
+ "factor": 4.0,
39
+ "original_max_position_embeddings": 2048,
40
+ "rope_type": "dynamic"
41
+ },
42
+ "rope_theta": 10000.0,
43
+ "tie_word_embeddings": true,
44
+ "torch_dtype": "float32",
45
+ "transformers_version": "4.48.2",
46
+ "use_cache": true,
47
+ "vocab_size": 32768
48
+ }
configuration_doge.py ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃
2
+ # This file was automatically generated from src/transformers/models/doge/modular_doge.py.
3
+ # Do NOT edit this file manually as any edits will be overwritten by the generation of
4
+ # the file from the modular. If any change should be done, please apply the change to the
5
+ # modular_doge.py file directly. One of our CI enforces this.
6
+ # 馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃
7
+ # coding=utf-8
8
+ # Copyright 2024 Jingze Shi and the HuggingFace Inc. team. All rights reserved.
9
+ #
10
+ # This code is based on the Wonderful Matrices paper implementation.
11
+ # The Doge family of small language models is trained by Jingze Shi.
12
+ #
13
+ # Licensed under the Apache License, Version 2.0 (the "License");
14
+ # you may not use this file except in compliance with the License.
15
+ # You may obtain a copy of the License at
16
+ #
17
+ # http://www.apache.org/licenses/LICENSE-2.0
18
+ #
19
+ # Unless required by applicable law or agreed to in writing, software
20
+ # distributed under the License is distributed on an "AS IS" BASIS,
21
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ # See the License for the specific language governing permissions and
23
+ # limitations under the License.
24
+ from transformers.configuration_utils import PretrainedConfig
25
+ from transformers.modeling_rope_utils import rope_config_validation
26
+
27
+
28
+ class DogeConfig(PretrainedConfig):
29
+ r"""
30
+ This is the configuration class to store the configuration of a [`DogeModel`]. It is used to instantiate an Doge
31
+ model according to the specified arguments, defining the model architecture like [SmallDoge/Doge-20M](https://huggingface.co/SmallDoge/Doge-20M).
32
+
33
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
34
+ documentation from [`PretrainedConfig`] for more information.
35
+
36
+ Args:
37
+ vocab_size (`int`, *optional*, defaults to 32768):
38
+ Vocabulary size of the Doge model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`DogeModel`]
39
+ hidden_size (`int`, *optional*, defaults to 1024):
40
+ Dimension of the hidden representations.
41
+ intermediate_size (`int`, *optional*, defaults to 2048):
42
+ Dimension of the MLP representations.
43
+ num_hidden_layers (`int`, *optional*, defaults to 32):
44
+ Number of hidden layers in the Transformer decoder.
45
+ hidden_bias (`bool`, *optional*, defaults to `False`):
46
+ Whether to use bias in the hidden layers.
47
+ hidden_dropout (`float`, *optional*, defaults to 0.0):
48
+ Dropout probability for each sequence transformation and state transformation module.
49
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
50
+ The non-linear activation function (function or string) in the decoder.
51
+ initializer_range (`float`, *optional*, defaults to 0.02):
52
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
53
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
54
+ The epsilon used by the rms normalization layers.
55
+ use_cache (`bool`, *optional*, defaults to `True`):
56
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
57
+ relevant if `config.is_decoder=True`.
58
+ bos_token_id (`int`, *optional*, defaults to 0):
59
+ Beginning of stream token id.
60
+ eos_token_id (`int`, *optional*, defaults to 1):
61
+ End of stream token id.
62
+ pad_token_id (`int`, *optional*, defaults to 2):
63
+ Padding token id.
64
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
65
+ Whether to tie weight embeddings
66
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
67
+ The maximum sequence length that this model might ever be used with.
68
+ rope_theta (`float`, *optional*, defaults to 10000.0):
69
+ The base period of the RoPE embeddings.
70
+ rope_scaling (`Dict`, *optional*):
71
+ Dictionary containing the scaling configuration for the RoPE embeddings.
72
+ NOTE: if you apply new rope type and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value accordingly.
73
+ Doge family of small models use `{ 'rope_type': 'dynamic', 'factor': 4.0, 'original_max_position_embeddings': 2048 }` as the default value.
74
+ Expected contents:
75
+ `rope_type` (`str`):
76
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope', 'llama3'], with 'default' being the original RoPE implementation.
77
+ `factor` (`float`, *optional*):
78
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings.
79
+ In most scaling types, a `factor` of x will enable the model to handle sequences of length x * original maximum pre-trained length.
80
+ `original_max_position_embeddings` (`int`, *optional*):
81
+ Used with 'dynamic', 'longrope' and 'llama3'.
82
+ The original max position embeddings used during pretraining.
83
+ `attention_factor` (`float`, *optional*):
84
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
85
+ computation.
86
+ If unspecified, it defaults to value recommended by the implementation, using the `factor` field to infer the suggested value.
87
+ `beta_fast` (`float`, *optional*):
88
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
89
+ ramp function. If unspecified, it defaults to 32.
90
+ `beta_slow` (`float`, *optional*):
91
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
92
+ ramp function. If unspecified, it defaults to 1.
93
+ `short_factor` (`List[float]`, *optional*):
94
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<`original_max_position_embeddings`).
95
+ Must be a list of numbers with the same length as the hidden size divided by the number of attention heads divided by 2
96
+ `long_factor` (`List[float]`, *optional*):
97
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<`original_max_position_embeddings`).
98
+ Must be a list of numbers with the same length as the hidden size divided by the number of attention heads divided by 2
99
+ `low_freq_factor` (`float`, *optional*):
100
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
101
+ `high_freq_factor` (`float`, *optional*):
102
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
103
+ num_attention_heads (`int`, *optional*, defaults to 8):
104
+ Number of attention heads for each attention layer in the Transformer decoder.
105
+ num_key_value_heads (`int`, *optional*):
106
+ This is the number of key_value heads that should be used to implement Grouped Query Attention.
107
+ If `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
108
+ `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used.
109
+ When converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed by meanpooling all the original heads within that group.
110
+ For more details checkout [this paper](https://arxiv.org/pdf/2305.13245.pdf).
111
+ If it is not specified, will default to `num_attention_heads`.
112
+ attention_dropout (`float`, *optional*, defaults to 0.0):
113
+ The dropout ratio for the attention probabilities.
114
+ dynamic_mask_ratio (`float`, *optional*, defaults to 0.0):
115
+ The ratio to control the proportion of the dynamic mask filled with the minimum value. For more details checkout [this paper](https://arxiv.org/pdf/2412.11834).
116
+ is_moe (`bool`, *optional*, defaults to `False`):
117
+ Whether to use the Cross Domain Mixture of Experts, if `True`, the MoE will inherit the MLP to initialize. For more details checkout [this paper](https://arxiv.org/pdf/2412.11834).
118
+ num_cdmoe_experts (`int`, *optional*, defaults to 16348):
119
+ Number of Experts for the Cross Domain Mixture of Experts.
120
+ num_cdmoe_heads (`int`, *optional*, defaults to 4):
121
+ Number of retrieval heads, used to mix multi-head experts.
122
+ num_cdmoe_experts_per_head (`int`, *optional*, defaults to 8):
123
+ Number of Experts per retrieval head, used to mix multi-head experts.
124
+ expert_retrieval_size (`int`, *optional*, defaults to 64):
125
+ Dimension of the Expert retrieval states for calculating the dot product of query and key to determine the expert index.
126
+
127
+ ```python
128
+ >>> from transformers import DogeConfig, DogeModel
129
+
130
+ >>> # Initializing a Doge-320M style configuration
131
+ >>> configuration = DogeConfig()
132
+
133
+ >>> # Initializing a model from the Doge-320M style configuration
134
+ >>> model = DogeModel(configuration)
135
+
136
+ >>> # Accessing the model configuration
137
+ >>> configuration = model.config
138
+ ```"""
139
+
140
+ model_type = "doge"
141
+ keys_to_ignore_at_inference = ["past_key_values"]
142
+ # Default tensor parallel plan for base model `DogeModel`
143
+ base_model_tp_plan = {
144
+ "layers.*.self_attn.q_proj": "colwise",
145
+ "layers.*.self_attn.k_proj": "colwise",
146
+ "layers.*.self_attn.v_proj": "colwise",
147
+ "layers.*.self_attn.dt_proj": "colwise",
148
+ "layers.*.self_attn.o_proj": "rowwise",
149
+ "layers.*.mlp.gate_proj": "colwise",
150
+ "layers.*.mlp.up_proj": "colwise",
151
+ "layers.*.mlp.down_proj": "rowwise",
152
+ }
153
+
154
+ def __init__(
155
+ self,
156
+ vocab_size=32768,
157
+ hidden_size=1024,
158
+ intermediate_size=2048,
159
+ num_hidden_layers=32,
160
+ hidden_bias=False,
161
+ hidden_dropout=0.0,
162
+ hidden_act="silu",
163
+ initializer_range=0.02,
164
+ rms_norm_eps=1e-06,
165
+ use_cache=True,
166
+ bos_token_id=0,
167
+ eos_token_id=1,
168
+ pad_token_id=2,
169
+ tie_word_embeddings=False,
170
+ max_position_embeddings=2048,
171
+ rope_theta=10000.0,
172
+ rope_scaling=None,
173
+ num_attention_heads=8,
174
+ num_key_value_heads=None,
175
+ attention_dropout=0.0,
176
+ dynamic_mask_ratio=0.0,
177
+ is_moe=False,
178
+ num_cdmoe_experts=16348,
179
+ num_cdmoe_heads=4,
180
+ num_cdmoe_experts_per_head=8,
181
+ expert_retrieval_size=64,
182
+ **kwargs,
183
+ ):
184
+ self.vocab_size = vocab_size
185
+ self.hidden_size = hidden_size
186
+ self.intermediate_size = intermediate_size
187
+ self.num_hidden_layers = num_hidden_layers
188
+
189
+ self.hidden_bias = hidden_bias
190
+ self.hidden_dropout = hidden_dropout
191
+ self.hidden_act = hidden_act
192
+ self.initializer_range = initializer_range
193
+ self.rms_norm_eps = rms_norm_eps
194
+ self.use_cache = use_cache
195
+
196
+ self.max_position_embeddings = max_position_embeddings
197
+ self.rope_theta = rope_theta
198
+ self.rope_scaling = rope_scaling
199
+ self.num_attention_heads = num_attention_heads
200
+ self.num_key_value_heads = num_key_value_heads
201
+ self.attention_dropout = attention_dropout
202
+ self.dynamic_mask_ratio = dynamic_mask_ratio
203
+ self.is_moe = is_moe
204
+ self.num_cdmoe_experts = num_cdmoe_experts
205
+ self.num_cdmoe_heads = num_cdmoe_heads
206
+ self.num_cdmoe_experts_per_head = num_cdmoe_experts_per_head
207
+ self.expert_retrieval_size = expert_retrieval_size
208
+
209
+ # Validate the correctness of rotary position embeddings parameters
210
+ # BC: if there is a 'type' field, copy it it to 'rope_type'.
211
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
212
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
213
+ rope_config_validation(self)
214
+
215
+ # for backward compatibility
216
+ if num_key_value_heads is None:
217
+ self.num_key_value_heads = num_attention_heads
218
+
219
+ super().__init__(
220
+ bos_token_id=bos_token_id,
221
+ eos_token_id=eos_token_id,
222
+ pad_token_id=pad_token_id,
223
+ tie_word_embeddings=tie_word_embeddings,
224
+ **kwargs,
225
+ )
226
+
227
+
228
+ __all__ = ["DogeConfig"]
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 1,
5
+ "pad_token_id": 2,
6
+ "transformers_version": "4.48.2"
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d30a2a446050f4e9c26bb833e260e5479937577b280c16d1e39f8ce4e66aba1
3
+ size 218325576
modeling_doge.py ADDED
@@ -0,0 +1,1153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃
2
+ # This file was automatically generated from src/transformers/models/doge/modular_doge.py.
3
+ # Do NOT edit this file manually as any edits will be overwritten by the generation of
4
+ # the file from the modular. If any change should be done, please apply the change to the
5
+ # modular_doge.py file directly. One of our CI enforces this.
6
+ # 馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃馃毃
7
+ # coding=utf-8
8
+ # Copyright 2024 Jingze Shi and the HuggingFace Inc. team. All rights reserved.
9
+ #
10
+ # This code is based on the Wonderful Matrices paper implementation.
11
+ # The Doge family of small language models is trained by Jingze Shi.
12
+ #
13
+ # Licensed under the Apache License, Version 2.0 (the "License");
14
+ # you may not use this file except in compliance with the License.
15
+ # You may obtain a copy of the License at
16
+ #
17
+ # http://www.apache.org/licenses/LICENSE-2.0
18
+ #
19
+ # Unless required by applicable law or agreed to in writing, software
20
+ # distributed under the License is distributed on an "AS IS" BASIS,
21
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ # See the License for the specific language governing permissions and
23
+ # limitations under the License.
24
+
25
+ import math
26
+ from typing import Callable, List, Optional, Tuple, Union
27
+
28
+ import torch
29
+ import torch.nn.functional as F
30
+ from torch import nn
31
+ from transformers.activations import ACT2FN
32
+ from transformers.cache_utils import Cache, DynamicCache, StaticCache
33
+ from transformers.generation import GenerationMixin
34
+ from transformers.modeling_outputs import (
35
+ BaseModelOutputWithPast,
36
+ CausalLMOutputWithPast,
37
+ SequenceClassifierOutputWithPast,
38
+ )
39
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS
40
+ from transformers.modeling_utils import PreTrainedModel
41
+ from transformers.processing_utils import Unpack
42
+ from transformers.utils import (
43
+ LossKwargs,
44
+ add_start_docstrings,
45
+ add_start_docstrings_to_model_forward,
46
+ is_torch_flex_attn_available,
47
+ logging,
48
+ replace_return_docstrings,
49
+ )
50
+ from transformers.utils.deprecation import deprecate_kwarg
51
+
52
+ from .configuration_doge import DogeConfig
53
+
54
+
55
+ if is_torch_flex_attn_available():
56
+ from torch.nn.attention.flex_attention import flex_attention
57
+
58
+
59
+ logger = logging.get_logger(__name__)
60
+
61
+ _CONFIG_FOR_DOC = "DogeConfig"
62
+
63
+
64
+ class RMSNorm(nn.Module):
65
+ def __init__(self, hidden_size, eps=1e-6):
66
+ """
67
+ RMSNorm is equivalent to T5LayerNorm
68
+ """
69
+ super().__init__()
70
+ self.weight = nn.Parameter(torch.ones(hidden_size))
71
+ self.variance_epsilon = eps
72
+
73
+ def forward(self, hidden_states):
74
+ input_dtype = hidden_states.dtype
75
+ hidden_states = hidden_states.to(torch.float32)
76
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
77
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
78
+ return self.weight * hidden_states.to(input_dtype)
79
+
80
+ def extra_repr(self):
81
+ return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
82
+
83
+
84
+ class Residual(nn.Module):
85
+ def __init__(self, hidden_size):
86
+ super().__init__()
87
+ self.weight = nn.Parameter(torch.ones(hidden_size))
88
+
89
+ def forward(self, residual_states, hidden_states):
90
+ return self.weight * residual_states + hidden_states
91
+
92
+ def extra_repr(self):
93
+ return f"{tuple(self.weight.shape)}"
94
+
95
+
96
+ class RotaryEmbedding(nn.Module):
97
+ def __init__(self, config: Optional[DogeConfig] = None, device=None):
98
+ super().__init__()
99
+ # BC: "rope_type" was originally "type"
100
+ if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
101
+ self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
102
+ else:
103
+ self.rope_type = "default"
104
+ self.max_seq_len_cached = config.max_position_embeddings
105
+ self.original_max_seq_len = config.max_position_embeddings
106
+
107
+ self.config = config
108
+ self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
109
+
110
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
111
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
112
+ self.original_inv_freq = self.inv_freq
113
+
114
+ def _dynamic_frequency_update(self, position_ids, device):
115
+ """
116
+ dynamic RoPE layers should recompute `inv_freq` in the following situations:
117
+ 1 - growing beyond the cached sequence length (allow scaling)
118
+ 2 - the current sequence length is in the original scale (avoid losing precision with small sequences)
119
+ """
120
+ seq_len = torch.max(position_ids) + 1
121
+ if seq_len > self.max_seq_len_cached: # growth
122
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device, seq_len=seq_len)
123
+ self.register_buffer("inv_freq", inv_freq, persistent=False) # TODO joao: may break with compilation
124
+ self.max_seq_len_cached = seq_len
125
+
126
+ if seq_len < self.original_max_seq_len and self.max_seq_len_cached > self.original_max_seq_len: # reset
127
+ # This .to() is needed if the model has been moved to a device after being initialized (because
128
+ # the buffer is automatically moved, but not the original copy)
129
+ self.original_inv_freq = self.original_inv_freq.to(device)
130
+ self.register_buffer("inv_freq", self.original_inv_freq, persistent=False)
131
+ self.max_seq_len_cached = self.original_max_seq_len
132
+
133
+ @torch.no_grad()
134
+ def forward(self, x, position_ids):
135
+ if "dynamic" in self.rope_type:
136
+ self._dynamic_frequency_update(position_ids, device=x.device)
137
+
138
+ # Core RoPE block
139
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
140
+ position_ids_expanded = position_ids[:, None, :].float()
141
+ # Force float32 (see https://github.com/huggingface/transformers/pull/29285)
142
+ device_type = x.device.type
143
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
144
+ with torch.autocast(device_type=device_type, enabled=False):
145
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
146
+ emb = torch.cat((freqs, freqs), dim=-1)
147
+ cos = emb.cos()
148
+ sin = emb.sin()
149
+
150
+ # Advanced RoPE types (e.g. yarn) apply a post-processing scaling factor, equivalent to scaling attention
151
+ cos = cos * self.attention_scaling
152
+ sin = sin * self.attention_scaling
153
+
154
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
155
+
156
+
157
+ def rotate_half(x):
158
+ """
159
+ Rotates half the hidden dims of the input.
160
+ """
161
+ x1 = x[..., : x.shape[-1] // 2]
162
+ x2 = x[..., x.shape[-1] // 2 :]
163
+ return torch.cat((-x2, x1), dim=-1)
164
+
165
+
166
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
167
+ """Applies Rotary Position Embedding to the query and key tensors.
168
+
169
+ Args:
170
+ q (`torch.Tensor`): The query tensor.
171
+ k (`torch.Tensor`): The key tensor.
172
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
173
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
174
+ position_ids (`torch.Tensor`, *optional*):
175
+ Deprecated and unused.
176
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
177
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
178
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k.
179
+ For example, note that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim].
180
+ Then, if q and k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k.
181
+ Similarly, if q and k have the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
182
+ Returns:
183
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
184
+ """
185
+ cos = cos.unsqueeze(unsqueeze_dim)
186
+ sin = sin.unsqueeze(unsqueeze_dim)
187
+ q_embed = (q * cos) + (rotate_half(q) * sin)
188
+ k_embed = (k * cos) + (rotate_half(k) * sin)
189
+ return q_embed, k_embed
190
+
191
+
192
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
193
+ """
194
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep).
195
+ The hidden states go from (batch, num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
196
+ """
197
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
198
+ if n_rep == 1:
199
+ return hidden_states
200
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
201
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
202
+
203
+
204
+ class DogeDynamicMaskAttention(nn.Module):
205
+ """Dynamic Mask Attention from 'Wonderful Matrices' paper."""
206
+
207
+ def __init__(self, config: DogeConfig, layer_idx: Optional[int] = None):
208
+ super().__init__()
209
+ self.config = config
210
+ self.layer_idx = layer_idx
211
+ self.head_dim = config.hidden_size // config.num_attention_heads
212
+ self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
213
+ self.scaling = self.head_dim**-0.5
214
+ self.attention_dropout = config.attention_dropout
215
+ self.dynamic_mask_ratio = config.dynamic_mask_ratio
216
+
217
+ self.ALL_ATTENTION_FUNCTIONS = {
218
+ "eager": self.eager_attention_forward,
219
+ "flex_attention": self.flex_attention_forward,
220
+ "sdpa": self.sdpa_attention_forward,
221
+ }
222
+
223
+ # Q K V O projections
224
+ self.q_proj = nn.Linear(
225
+ config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.hidden_bias
226
+ )
227
+ self.k_proj = nn.Linear(
228
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.hidden_bias
229
+ )
230
+ self.v_proj = nn.Linear(
231
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.hidden_bias
232
+ )
233
+ # dynamic mask for the QK^T attention score matrix
234
+ self.A = nn.Parameter(torch.zeros(config.num_attention_heads))
235
+ self.dt_proj = nn.Linear(
236
+ config.num_key_value_heads * self.head_dim, config.num_attention_heads, bias=config.hidden_bias
237
+ )
238
+ self.o_proj = nn.Linear(
239
+ config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.hidden_bias
240
+ )
241
+
242
+ def forward(
243
+ self,
244
+ hidden_states: torch.Tensor,
245
+ position_embeddings: Tuple[torch.Tensor, torch.Tensor],
246
+ attention_mask: Optional[torch.Tensor] = None,
247
+ past_key_value: Optional[Cache] = None,
248
+ cache_position: Optional[torch.LongTensor] = None,
249
+ **kwargs,
250
+ ) -> Tuple[torch.Tensor, Optional[Cache]]:
251
+ input_shape = hidden_states.shape[:-1]
252
+ hidden_shape = (*input_shape, -1, self.head_dim)
253
+
254
+ query_states = self.q_proj(hidden_states).view(hidden_shape).transpose(1, 2)
255
+ key_states = self.k_proj(hidden_states).view(hidden_shape).transpose(1, 2)
256
+ value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
257
+
258
+ cos, sin = position_embeddings
259
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
260
+
261
+ if past_key_value is not None:
262
+ # sin and cos are specific to RoPE models; cache_position needed for the static cache
263
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
264
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
265
+
266
+ # calculate dynamic mask from value_states
267
+ dt_states = self.dt_proj(
268
+ value_states.transpose(1, 2).reshape(value_states.shape[0], value_states.shape[-2], -1)
269
+ )
270
+ dynamic_mask = torch.exp(self.A * F.softplus(dt_states)).transpose(-1, -2)
271
+ attn_mask = self.prepare_dynamic_mask(
272
+ hidden_states=hidden_states,
273
+ dynamic_mask=dynamic_mask,
274
+ dynamic_mask_ratio=self.dynamic_mask_ratio,
275
+ attention_mask=attention_mask,
276
+ )
277
+
278
+ attention_interface: Callable = self.eager_attention_forward
279
+ if self.config._attn_implementation != "eager":
280
+ attention_interface = self.ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
281
+
282
+ attn_output = attention_interface(
283
+ query_states,
284
+ key_states,
285
+ value_states,
286
+ attention_mask=attn_mask,
287
+ dropout=0.0 if not self.training else self.attention_dropout,
288
+ scaling=self.scaling,
289
+ **kwargs,
290
+ )
291
+
292
+ attn_output = attn_output.reshape(*input_shape, -1).contiguous()
293
+ attn_output = self.o_proj(attn_output)
294
+ return attn_output
295
+
296
+ def prepare_dynamic_mask(
297
+ self,
298
+ hidden_states: torch.Tensor,
299
+ dynamic_mask: torch.Tensor,
300
+ dynamic_mask_ratio: float = 0.0,
301
+ attention_mask: Optional[torch.Tensor] = None,
302
+ ):
303
+ """
304
+ Combine `dynamic_mask` with `attention_mask` to generate the final `attn_mask`.
305
+
306
+ Args:
307
+ hidden_states (`torch.Tensor`): The input hidden_states, used to determine the minimum value of the current input precision.
308
+ dynamic_mask (`torch.Tensor`): dynamic mask of shape `(batch_size, num_heads, key_sequence_length)`.
309
+ dynamic_mask_ratio (`float`, *optional*): Ratio from 0.0 to 1.0 used to control the proportion of the dynamic mask filled with the minimum value.
310
+ attention_mask (`torch.Tensor`, *optional*): attention mask of shape `(batch_size, 1, query_sequence_length, key_sequence_length)`.
311
+ """
312
+ attn_mask = None
313
+ if dynamic_mask is not None:
314
+ attn_mask = dynamic_mask[:, :, None, :]
315
+ if 0.0 < dynamic_mask_ratio < 1.0:
316
+ min_type = torch.finfo(hidden_states.dtype).min
317
+ num_dynamic_mask = int(attn_mask.shape[-1] * dynamic_mask_ratio)
318
+ if num_dynamic_mask > 0:
319
+ rate_value = torch.kthvalue(attn_mask, num_dynamic_mask, dim=-1, keepdim=True).values
320
+ attn_mask = attn_mask.masked_fill(attn_mask < rate_value, min_type)
321
+ if attention_mask is not None:
322
+ attn_mask = attn_mask + attention_mask[:, :, :, : attn_mask.shape[-1]]
323
+ else:
324
+ attn_mask = attention_mask
325
+
326
+ return attn_mask
327
+
328
+ def eager_attention_forward(
329
+ self,
330
+ query: torch.Tensor,
331
+ key: torch.Tensor,
332
+ value: torch.Tensor,
333
+ attention_mask: Optional[torch.Tensor],
334
+ scaling: float,
335
+ dropout: float = 0.0,
336
+ **kwargs,
337
+ ) -> torch.Tensor:
338
+ key_states = repeat_kv(key, self.num_key_value_groups)
339
+ value_states = repeat_kv(value, self.num_key_value_groups)
340
+
341
+ # compute attention scores matrix
342
+ attn_weights = torch.matmul(query, key_states.transpose(-1, -2)) * scaling
343
+ if attention_mask is not None:
344
+ causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
345
+ attn_weights = attn_weights + causal_mask
346
+
347
+ # upcast attention scores to fp32
348
+ attn_weights = F.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
349
+ attn_weights = F.dropout(attn_weights, p=dropout, training=self.training)
350
+
351
+ # apply attention scores to value states
352
+ attn_output = torch.matmul(attn_weights, value_states)
353
+ attn_output = attn_output.transpose(1, 2).contiguous()
354
+ return attn_output
355
+
356
+ def sdpa_attention_forward(
357
+ self,
358
+ query: torch.Tensor,
359
+ key: torch.Tensor,
360
+ value: torch.Tensor,
361
+ attention_mask: Optional[torch.Tensor],
362
+ scaling: float,
363
+ dropout: float = 0.0,
364
+ **kwargs,
365
+ ) -> torch.Tensor:
366
+ key = repeat_kv(key, self.num_key_value_groups)
367
+ value = repeat_kv(value, self.num_key_value_groups)
368
+
369
+ causal_mask = attention_mask
370
+ if attention_mask is not None:
371
+ causal_mask = causal_mask[:, :, :, : key.shape[-2]]
372
+
373
+ # SDPA with memory-efficient backend is bugged with non-contiguous inputs and custom attn_mask for some torch versions
374
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
375
+ query = query.contiguous()
376
+ key = key.contiguous()
377
+ value = value.contiguous()
378
+
379
+ # NOTE: As of pytorch 2.5.1, cuDNN's SDPA backward pass is still incorrect, so we disable cuDNN SDPA (see https://github.com/pytorch/pytorch/issues/138581)
380
+ torch.backends.cuda.enable_cudnn_sdp(False)
381
+ attn_output = F.scaled_dot_product_attention(
382
+ query,
383
+ key,
384
+ value,
385
+ attn_mask=causal_mask,
386
+ dropout_p=dropout,
387
+ scale=scaling,
388
+ )
389
+ attn_output = attn_output.transpose(1, 2).contiguous()
390
+ return attn_output
391
+
392
+ def flex_attention_forward(
393
+ self,
394
+ query: torch.Tensor,
395
+ key: torch.Tensor,
396
+ value: torch.Tensor,
397
+ attention_mask: Optional[torch.Tensor],
398
+ scaling: float,
399
+ dropout: float = 0.0,
400
+ **kwargs,
401
+ ) -> torch.Tensor:
402
+ key = repeat_kv(key, self.num_key_value_groups)
403
+ value = repeat_kv(value, self.num_key_value_groups)
404
+
405
+ causal_mask = attention_mask
406
+ if attention_mask is not None:
407
+ causal_mask = causal_mask[:, :, :, : key.shape[-2]]
408
+
409
+ # TODO: flex_attention: As of pytorch 2.5.1, captured buffers that require grad are not yet supported.
410
+ # NOTE: So we only use flex_attention in inference mode.
411
+ def causal_mod(score, batch, head, q_idx, kv_idx):
412
+ score = score + causal_mask[batch][0][q_idx][kv_idx]
413
+ return score
414
+
415
+ def dynamic_mod(score, batch, head, q_idx, kv_idx):
416
+ score = score + causal_mask[batch][head][q_idx][kv_idx]
417
+ return score
418
+
419
+ mask_mod = causal_mod if self.is_causal else dynamic_mod
420
+
421
+ attn_output = flex_attention(
422
+ query,
423
+ key,
424
+ value,
425
+ score_mod=mask_mod,
426
+ scale=scaling,
427
+ )
428
+ attn_output = attn_output.transpose(1, 2).contiguous()
429
+ return attn_output
430
+
431
+
432
+ class DogeMLP(nn.Module):
433
+ def __init__(self, config: DogeConfig):
434
+ super().__init__()
435
+ self.hidden_dim = config.hidden_size
436
+ self.intermediate_dim = config.intermediate_size
437
+ self.act_fn = ACT2FN[config.hidden_act]
438
+
439
+ self.gate_proj = nn.Linear(self.hidden_dim, self.intermediate_dim, bias=config.hidden_bias)
440
+ self.up_proj = nn.Linear(self.hidden_dim, self.intermediate_dim, bias=config.hidden_bias)
441
+ self.down_proj = nn.Linear(self.intermediate_dim, self.hidden_dim, bias=config.hidden_bias)
442
+
443
+ def forward(
444
+ self,
445
+ hidden_states: torch.Tensor,
446
+ **kwargs,
447
+ ) -> torch.Tensor:
448
+ hidden_states = self.down_proj(self.act_fn(self.gate_proj(hidden_states)) * self.up_proj(hidden_states))
449
+ return hidden_states
450
+
451
+
452
+ class DogeCDMoE(DogeMLP):
453
+ """Cross Domain Mixture of Experts from 'Wonderful Matrices' paper."""
454
+
455
+ def __init__(self, config: DogeConfig):
456
+ super().__init__(config)
457
+ self.hidden_dim = config.hidden_size
458
+ self.act_fn = ACT2FN[config.hidden_act]
459
+
460
+ self.expert_retrieval_dim = config.expert_retrieval_size
461
+ self.num_cdmoe_experts = config.num_cdmoe_experts
462
+ self.num_cdmoe_heads = config.num_cdmoe_heads
463
+ self.num_cdmoe_experts_per_head = config.num_cdmoe_experts_per_head
464
+ self.num_keys = int(math.sqrt(self.num_cdmoe_experts))
465
+
466
+ # queries and keys for retrieval experts
467
+ self.queries = nn.Linear(self.hidden_dim, self.num_cdmoe_heads * self.expert_retrieval_dim, bias=False)
468
+ self.keys = nn.Parameter(torch.zeros(self.num_cdmoe_heads, self.num_keys, 2, self.expert_retrieval_dim // 2))
469
+
470
+ # experts
471
+ self.down_embed = nn.Embedding(self.num_cdmoe_experts, self.hidden_dim)
472
+ self.up_embed = nn.Embedding(self.num_cdmoe_experts, self.hidden_dim)
473
+
474
+ def forward(
475
+ self,
476
+ hidden_states: torch.Tensor,
477
+ **kwargs,
478
+ ) -> torch.Tensor:
479
+ bsz, seq_len, _ = hidden_states.shape
480
+
481
+ # get similarity with queries and keys
482
+ queries = self.queries(hidden_states)
483
+ queries = queries.view(bsz, seq_len, 2, self.num_cdmoe_heads, -1).permute(2, 0, 1, 3, 4)
484
+ sim = torch.einsum("p b t h n, h k p n -> p b t h k", queries, self.keys)
485
+
486
+ # get experts with the highest similarity
487
+ (scores_x, scores_y), (indices_x, indices_y) = sim.topk(self.num_cdmoe_experts_per_head, dim=-1)
488
+ all_scores = scores_x.unsqueeze(-1) + scores_y.unsqueeze(-2)
489
+ all_scores = all_scores.view(*scores_x.shape[:-1], -1)
490
+ all_indices = (indices_x.unsqueeze(-1) * self.num_keys) + indices_y.unsqueeze(-2)
491
+ all_indices = all_indices.view(*indices_x.shape[:-1], -1)
492
+ scores, pk_indices = all_scores.topk(self.num_cdmoe_experts_per_head, dim=-1)
493
+ indices = all_indices.gather(-1, pk_indices)
494
+ down_embed = self.down_embed(indices)
495
+ up_embed = self.up_embed(indices)
496
+
497
+ # mix experts states with cross domain states
498
+ experts_weights = torch.einsum("b t d, b t h k d -> b t h k", hidden_states, down_embed)
499
+ experts_weights = self.act_fn(experts_weights) * scores.softmax(dim=-1)
500
+ experts_states = torch.einsum("b t h k, b t h k d -> b t d", experts_weights, up_embed)
501
+ hidden_states = self.down_proj(self.act_fn(self.gate_proj(hidden_states)) * self.up_proj(hidden_states))
502
+ hidden_states = hidden_states + experts_states
503
+ return hidden_states
504
+
505
+
506
+ class DogeDecoderLayer(nn.Module):
507
+ def __init__(self, config: DogeConfig, layer_idx: Optional[int] = None):
508
+ super().__init__()
509
+ self.hidden_dropout = config.hidden_dropout
510
+
511
+ self.pre_layernorm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
512
+ self.self_attn = DogeDynamicMaskAttention(config=config, layer_idx=layer_idx)
513
+ self.pre_residual = Residual(config.hidden_size)
514
+
515
+ self.post_layernorm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
516
+ self.feed_forward = DogeMLP(config) if not config.is_moe else DogeCDMoE(config)
517
+ self.post_residual = Residual(config.hidden_size)
518
+
519
+ def forward(
520
+ self,
521
+ hidden_states: torch.Tensor,
522
+ attention_mask: Optional[torch.Tensor] = None,
523
+ position_ids: Optional[torch.LongTensor] = None,
524
+ past_key_value: Optional[Cache] = None,
525
+ output_attentions: Optional[bool] = False,
526
+ use_cache: Optional[bool] = False,
527
+ cache_position: Optional[torch.LongTensor] = None,
528
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
529
+ **kwargs,
530
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
531
+ # sequence transformation
532
+ residual = hidden_states
533
+ hidden_states = self.pre_layernorm(hidden_states)
534
+ hidden_states = self.self_attn(
535
+ hidden_states=hidden_states,
536
+ attention_mask=attention_mask,
537
+ position_ids=position_ids,
538
+ past_key_value=past_key_value,
539
+ cache_position=cache_position,
540
+ position_embeddings=position_embeddings,
541
+ **kwargs,
542
+ )
543
+ self_attn_weights = None
544
+ hidden_states = F.dropout(hidden_states, p=self.hidden_dropout, training=self.training)
545
+ hidden_states = self.pre_residual(residual, hidden_states)
546
+
547
+ # state transformation
548
+ residual = hidden_states
549
+ hidden_states = self.post_layernorm(hidden_states)
550
+ hidden_states = self.feed_forward(hidden_states)
551
+ hidden_states = F.dropout(hidden_states, p=self.hidden_dropout, training=self.training)
552
+ hidden_states = self.post_residual(residual, hidden_states)
553
+
554
+ outputs = (hidden_states,)
555
+ if output_attentions:
556
+ outputs += (self_attn_weights,)
557
+
558
+ return outputs
559
+
560
+
561
+ DOGE_START_DOCSTRING = r"""
562
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
563
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
564
+ etc.)
565
+
566
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
567
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
568
+ and behavior.
569
+
570
+ Parameters:
571
+ config ([`DogeConfig`]):
572
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
573
+ load the weights associated with the model, only the configuration. Check out the
574
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
575
+ """
576
+
577
+
578
+ @add_start_docstrings(
579
+ "The bare Doge Model outputting raw hidden-states without any specific head on top.",
580
+ DOGE_START_DOCSTRING,
581
+ )
582
+ class DogePreTrainedModel(PreTrainedModel):
583
+ config_class = DogeConfig
584
+ base_model_prefix = "model"
585
+ supports_gradient_checkpointing = True
586
+ _no_split_modules = ["DogeDecoderLayer"]
587
+ _skip_keys_device_placement = ["past_key_values"]
588
+ _supports_sdpa = True
589
+ _supports_flex_attn = True
590
+ _supports_cache_class = True
591
+ _supports_quantized_cache = True
592
+ _supports_static_cache = True
593
+
594
+ def _init_weights(self, module):
595
+ std = self.config.initializer_range
596
+ if isinstance(module, (nn.Linear)):
597
+ module.weight.data.normal_(mean=0.0, std=std)
598
+ if module.bias is not None:
599
+ module.bias.data.zero_()
600
+ elif isinstance(module, nn.Embedding):
601
+ module.weight.data.normal_(mean=0.0, std=std)
602
+ if module.padding_idx is not None:
603
+ module.weight.data[module.padding_idx].zero_()
604
+
605
+
606
+ DOGE_INPUTS_DOCSTRING = r"""
607
+ Args:
608
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
609
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
610
+ it.
611
+
612
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
613
+ [`PreTrainedTokenizer.__call__`] for details.
614
+
615
+ [What are input IDs?](../glossary#input-ids)
616
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
617
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
618
+
619
+ - 1 for tokens that are **not masked**,
620
+ - 0 for tokens that are **masked**.
621
+
622
+ [What are attention masks?](../glossary#attention-mask)
623
+
624
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
625
+ [`PreTrainedTokenizer.__call__`] for details.
626
+
627
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
628
+ `past_key_values`).
629
+
630
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
631
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
632
+ information on the default strategy.
633
+
634
+ - 1 indicates the head is **not masked**,
635
+ - 0 indicates the head is **masked**.
636
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
637
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
638
+ config.n_positions - 1]`.
639
+
640
+ [What are position IDs?](../glossary#position-ids)
641
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
642
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
643
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
644
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
645
+
646
+ Two formats are allowed:
647
+ - a [`~cache_utils.Cache`] instance, see our
648
+ [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache);
649
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
650
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
651
+ cache format.
652
+
653
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
654
+ legacy cache format will be returned.
655
+
656
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
657
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
658
+ of shape `(batch_size, sequence_length)`.
659
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
660
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
661
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
662
+ model's internal embedding lookup matrix.
663
+ use_cache (`bool`, *optional*):
664
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
665
+ `past_key_values`).
666
+ output_attentions (`bool`, *optional*):
667
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
668
+ tensors for more detail.
669
+ output_hidden_states (`bool`, *optional*):
670
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
671
+ more detail.
672
+ return_dict (`bool`, *optional*):
673
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
674
+ cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
675
+ Indices depicting the position of the input sequence tokens in the sequence. Contrarily to `position_ids`,
676
+ this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
677
+ the complete sequence length.
678
+ """
679
+
680
+
681
+ @add_start_docstrings(
682
+ "The bare Doge Model outputting raw hidden-states without any specific head on top.",
683
+ DOGE_START_DOCSTRING,
684
+ )
685
+ class DogeModel(DogePreTrainedModel):
686
+ """
687
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`DogeDecoderLayer`]
688
+
689
+ Args:
690
+ config: DogeConfig
691
+ """
692
+
693
+ def __init__(self, config: DogeConfig):
694
+ super().__init__(config)
695
+ self.config = config
696
+ self.padding_idx = config.pad_token_id
697
+ self.vocab_size = config.vocab_size
698
+
699
+ self.word_embed = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id)
700
+ self.rotary_emb = RotaryEmbedding(config)
701
+ self.layers = nn.ModuleList(
702
+ [DogeDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
703
+ )
704
+ self.final_layernorm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
705
+ self.gradient_checkpointing = False
706
+
707
+ # Initialize weights and apply final processing
708
+ self.post_init()
709
+
710
+ def get_input_embeddings(self):
711
+ return self.word_embed
712
+
713
+ def set_input_embeddings(self, value):
714
+ self.word_embed = value
715
+
716
+ @add_start_docstrings_to_model_forward(DOGE_INPUTS_DOCSTRING)
717
+ def forward(
718
+ self,
719
+ input_ids: torch.LongTensor = None,
720
+ attention_mask: Optional[torch.Tensor] = None,
721
+ position_ids: Optional[torch.LongTensor] = None,
722
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
723
+ inputs_embeds: Optional[torch.FloatTensor] = None,
724
+ use_cache: Optional[bool] = None,
725
+ output_attentions: Optional[bool] = None,
726
+ output_hidden_states: Optional[bool] = None,
727
+ return_dict: Optional[bool] = None,
728
+ cache_position: Optional[torch.LongTensor] = None,
729
+ **kwargs,
730
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
731
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
732
+ output_hidden_states = (
733
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
734
+ )
735
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
736
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
737
+
738
+ if (input_ids is None) ^ (inputs_embeds is not None):
739
+ raise ValueError("You cannot specify both input_ids and inputs_embeds")
740
+
741
+ if self.gradient_checkpointing and self.training and use_cache:
742
+ logger.warning_once(
743
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
744
+ )
745
+ use_cache = False
746
+
747
+ if inputs_embeds is None:
748
+ inputs_embeds = self.word_embed(input_ids)
749
+
750
+ if use_cache and past_key_values is None:
751
+ past_key_values = DynamicCache()
752
+
753
+ if cache_position is None:
754
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
755
+ cache_position = torch.arange(
756
+ past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
757
+ )
758
+
759
+ if position_ids is None:
760
+ position_ids = cache_position.unsqueeze(0)
761
+
762
+ causal_mask = self._update_causal_mask(
763
+ attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions
764
+ )
765
+
766
+ hidden_states = inputs_embeds
767
+
768
+ # create position embeddings to be shared across the decoder layers
769
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
770
+
771
+ # decoder layers
772
+ all_hidden_states = () if output_hidden_states else None
773
+ all_self_attns = () if output_attentions else None
774
+
775
+ for decoder_layer in self.layers[: self.config.num_hidden_layers]:
776
+ if output_hidden_states:
777
+ all_hidden_states += (hidden_states,)
778
+
779
+ if self.gradient_checkpointing and self.training:
780
+ layer_outputs = self._gradient_checkpointing_func(
781
+ decoder_layer.__call__,
782
+ hidden_states,
783
+ causal_mask,
784
+ position_ids,
785
+ past_key_values,
786
+ output_attentions,
787
+ use_cache,
788
+ cache_position,
789
+ position_embeddings,
790
+ )
791
+ else:
792
+ layer_outputs = decoder_layer(
793
+ hidden_states,
794
+ attention_mask=causal_mask,
795
+ position_ids=position_ids,
796
+ past_key_value=past_key_values,
797
+ output_attentions=output_attentions,
798
+ use_cache=use_cache,
799
+ cache_position=cache_position,
800
+ position_embeddings=position_embeddings,
801
+ **kwargs,
802
+ )
803
+
804
+ hidden_states = layer_outputs[0]
805
+
806
+ if output_attentions:
807
+ all_self_attns += (layer_outputs[1],)
808
+
809
+ hidden_states = self.final_layernorm(hidden_states)
810
+
811
+ # add hidden states from the last decoder layer
812
+ if output_hidden_states:
813
+ all_hidden_states += (hidden_states,)
814
+
815
+ output = BaseModelOutputWithPast(
816
+ last_hidden_state=hidden_states,
817
+ past_key_values=past_key_values if use_cache else None,
818
+ hidden_states=all_hidden_states,
819
+ attentions=all_self_attns,
820
+ )
821
+ return output if return_dict else output.to_tuple()
822
+
823
+ def _update_causal_mask(
824
+ self,
825
+ attention_mask: torch.Tensor,
826
+ input_tensor: torch.Tensor,
827
+ cache_position: torch.Tensor,
828
+ past_key_values: Cache,
829
+ output_attentions: bool,
830
+ ):
831
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
832
+ using_static_cache = isinstance(past_key_values, StaticCache)
833
+
834
+ dtype, device = input_tensor.dtype, input_tensor.device
835
+ sequence_length = input_tensor.shape[1]
836
+ if using_static_cache:
837
+ target_length = past_key_values.get_max_cache_shape()
838
+ else:
839
+ target_length = (
840
+ attention_mask.shape[-1]
841
+ if isinstance(attention_mask, torch.Tensor)
842
+ else past_seen_tokens + sequence_length + 1
843
+ )
844
+
845
+ # in case the provided `attention` mask is 2D, we generate a causal mask here (4D).
846
+ causal_mask = self._prepare_4d_causal_attention_mask_with_cache_position(
847
+ attention_mask=attention_mask,
848
+ sequence_length=sequence_length,
849
+ target_length=target_length,
850
+ dtype=dtype,
851
+ device=device,
852
+ cache_position=cache_position,
853
+ batch_size=input_tensor.shape[0],
854
+ )
855
+
856
+ return causal_mask
857
+
858
+ @staticmethod
859
+ def _prepare_4d_causal_attention_mask_with_cache_position(
860
+ attention_mask: torch.Tensor = None,
861
+ sequence_length: int = None,
862
+ target_length: int = None,
863
+ dtype: torch.dtype = None,
864
+ device: torch.device = None,
865
+ cache_position: torch.Tensor = None,
866
+ batch_size: int = None,
867
+ **kwargs,
868
+ ):
869
+ """
870
+ Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
871
+ `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.
872
+
873
+ Args:
874
+ attention_mask (`torch.Tensor`):
875
+ A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape
876
+ `(batch_size, 1, query_length, key_value_length)`.
877
+ sequence_length (`int`):
878
+ The sequence length being processed.
879
+ target_length (`int`):
880
+ The target length: when generating with static cache, the mask should be as long as the static cache,
881
+ to account for the 0 padding, the part of the cache that is not filled yet.
882
+ dtype (`torch.dtype`):
883
+ The dtype to use for the 4D attention mask.
884
+ device (`torch.device`):
885
+ The device to plcae the 4D attention mask on.
886
+ cache_position (`torch.Tensor`):
887
+ Indices depicting the position of the input sequence tokens in the sequence.
888
+ batch_size (`torch.Tensor`):
889
+ Batch size.
890
+ """
891
+ if attention_mask is not None and attention_mask.dim() == 4:
892
+ # In this case we assume that the mask comes already in inverted form and requires no inversion or slicing.
893
+ causal_mask = attention_mask
894
+ else:
895
+ min_dtype = torch.finfo(dtype).min
896
+ causal_mask = torch.full(
897
+ (sequence_length, target_length),
898
+ fill_value=min_dtype,
899
+ dtype=dtype,
900
+ device=device,
901
+ )
902
+ if sequence_length != 1:
903
+ causal_mask = torch.triu(causal_mask, diagonal=1)
904
+ causal_mask *= torch.arange(target_length, device=device) > cache_position.reshape(-1, 1)
905
+ causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
906
+ if attention_mask is not None:
907
+ causal_mask = causal_mask.clone() # copy to contiguous memory for in-place edit
908
+ mask_length = attention_mask.shape[-1]
909
+ padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :]
910
+ padding_mask = padding_mask == 0
911
+ causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
912
+ padding_mask, min_dtype
913
+ )
914
+
915
+ return causal_mask
916
+
917
+
918
+ class KwargsForCausalLM(LossKwargs): ...
919
+
920
+
921
+ class DogeForCausalLM(DogePreTrainedModel, GenerationMixin):
922
+ _tied_weights_keys = ["lm_head.weight"]
923
+ _tp_plan = {"lm_head": "colwise_rep"}
924
+
925
+ def __init__(self, config: DogeConfig):
926
+ super().__init__(config)
927
+ self.config = config
928
+ self.model = DogeModel(config)
929
+ self.vocab_size = config.vocab_size
930
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
931
+
932
+ # Initialize weights and apply final processing
933
+ self.post_init()
934
+
935
+ def get_input_embeddings(self):
936
+ return self.model.word_embed
937
+
938
+ def set_input_embeddings(self, value):
939
+ self.model.word_embed = value
940
+
941
+ def get_output_embeddings(self):
942
+ return self.lm_head
943
+
944
+ def set_output_embeddings(self, new_embeddings):
945
+ self.lm_head = new_embeddings
946
+
947
+ def get_decoder(self):
948
+ return self.model
949
+
950
+ def set_decoder(self, decoder):
951
+ self.model = decoder
952
+
953
+ @deprecate_kwarg("num_logits_to_keep", version="4.50", new_name="logits_to_keep")
954
+ @add_start_docstrings_to_model_forward(DOGE_INPUTS_DOCSTRING)
955
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
956
+ def forward(
957
+ self,
958
+ input_ids: torch.LongTensor = None,
959
+ attention_mask: Optional[torch.Tensor] = None,
960
+ position_ids: Optional[torch.LongTensor] = None,
961
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
962
+ inputs_embeds: Optional[torch.FloatTensor] = None,
963
+ labels: Optional[torch.LongTensor] = None,
964
+ use_cache: Optional[bool] = None,
965
+ output_attentions: Optional[bool] = None,
966
+ output_hidden_states: Optional[bool] = None,
967
+ return_dict: Optional[bool] = None,
968
+ cache_position: Optional[torch.LongTensor] = None,
969
+ logits_to_keep: int = 0,
970
+ **kwargs: Unpack[KwargsForCausalLM],
971
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
972
+ r"""
973
+ Args:
974
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
975
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
976
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
977
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
978
+
979
+ logits_to_keep (`int`, *optional*):
980
+ If an `int`, compute logits for the last `logits_to_keep` tokens. If `0`, calculate logits for all
981
+ `input_ids` (special case). Only last token logits are needed for generation, and calculating them only for that
982
+ token can save memory, which becomes pretty significant for long sequences or large vocabulary size.
983
+ If a `torch.Tensor`, must be 1D corresponding to the indices to keep in the sequence length dimension.
984
+ This is useful when using packed tensor format (single dimension for batch and sequence length).
985
+
986
+ Returns:
987
+
988
+ Example:
989
+
990
+ ```python
991
+ >>> from transformers import AutoTokenizer, AutoModelForCausalLM
992
+
993
+ >>> model = AutoModelForCausalLM.from_pretrained("SmallDoge/Doge-20M")
994
+ >>> tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge-20M")
995
+
996
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
997
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
998
+
999
+ >>> # Generate
1000
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1001
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1002
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
1003
+ ```"""
1004
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1005
+ output_hidden_states = (
1006
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1007
+ )
1008
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1009
+
1010
+ # decoder output consists of (dec_features, layer_state, dec_hidden, dec_attn)
1011
+ outputs = self.model(
1012
+ input_ids=input_ids,
1013
+ attention_mask=attention_mask,
1014
+ position_ids=position_ids,
1015
+ past_key_values=past_key_values,
1016
+ inputs_embeds=inputs_embeds,
1017
+ use_cache=use_cache,
1018
+ output_attentions=output_attentions,
1019
+ output_hidden_states=output_hidden_states,
1020
+ return_dict=return_dict,
1021
+ cache_position=cache_position,
1022
+ **kwargs,
1023
+ )
1024
+
1025
+ hidden_states = outputs[0]
1026
+ # only compute necessary logits, and do not upcast them to float if we are not computing the loss
1027
+ slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
1028
+ logits = self.lm_head(hidden_states[:, slice_indices, :])
1029
+
1030
+ loss = None
1031
+ if labels is not None:
1032
+ loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.vocab_size, **kwargs)
1033
+
1034
+ if not return_dict:
1035
+ output = (logits,) + outputs[1:]
1036
+ return (loss,) + output if loss is not None else output
1037
+
1038
+ return CausalLMOutputWithPast(
1039
+ loss=loss,
1040
+ logits=logits,
1041
+ past_key_values=outputs.past_key_values,
1042
+ hidden_states=outputs.hidden_states,
1043
+ attentions=outputs.attentions,
1044
+ )
1045
+
1046
+
1047
+ @add_start_docstrings(
1048
+ """
1049
+ The Doge Model transformer with a sequence classification head on top (linear layer).
1050
+
1051
+ [`DogeForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1052
+ (e.g. GPT-2) do.
1053
+
1054
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1055
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1056
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1057
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1058
+ each row of the batch).
1059
+ """,
1060
+ DOGE_START_DOCSTRING,
1061
+ )
1062
+ class DogeForSequenceClassification(DogePreTrainedModel):
1063
+ def __init__(self, config: DogeConfig):
1064
+ super().__init__(config)
1065
+ self.num_labels = config.num_labels
1066
+
1067
+ self.model = DogeModel(config)
1068
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1069
+ self.config = config
1070
+
1071
+ # Initialize weights and apply final processing
1072
+ self.post_init()
1073
+
1074
+ def get_input_embeddings(self):
1075
+ return self.model.word_embed
1076
+
1077
+ def set_input_embeddings(self, value):
1078
+ self.model.word_embed = value
1079
+
1080
+ @add_start_docstrings_to_model_forward(DOGE_INPUTS_DOCSTRING)
1081
+ def forward(
1082
+ self,
1083
+ input_ids: Optional[torch.LongTensor] = None,
1084
+ attention_mask: Optional[torch.Tensor] = None,
1085
+ position_ids: Optional[torch.LongTensor] = None,
1086
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
1087
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1088
+ labels: Optional[torch.LongTensor] = None,
1089
+ use_cache: Optional[bool] = None,
1090
+ output_attentions: Optional[bool] = None,
1091
+ output_hidden_states: Optional[bool] = None,
1092
+ return_dict: Optional[bool] = None,
1093
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1094
+ r"""
1095
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1096
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1097
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1098
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1099
+ """
1100
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1101
+
1102
+ transformer_outputs = self.model(
1103
+ input_ids,
1104
+ attention_mask=attention_mask,
1105
+ position_ids=position_ids,
1106
+ past_key_values=past_key_values,
1107
+ inputs_embeds=inputs_embeds,
1108
+ use_cache=use_cache,
1109
+ output_attentions=output_attentions,
1110
+ output_hidden_states=output_hidden_states,
1111
+ return_dict=return_dict,
1112
+ )
1113
+ hidden_states = transformer_outputs[0]
1114
+ logits = self.score(hidden_states)
1115
+
1116
+ if input_ids is not None:
1117
+ batch_size = input_ids.shape[0]
1118
+ else:
1119
+ batch_size = inputs_embeds.shape[0]
1120
+
1121
+ if self.config.pad_token_id is None and batch_size != 1:
1122
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1123
+ if self.config.pad_token_id is None:
1124
+ sequence_lengths = -1
1125
+ else:
1126
+ if input_ids is not None:
1127
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1128
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1129
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1130
+ sequence_lengths = sequence_lengths.to(logits.device)
1131
+ else:
1132
+ sequence_lengths = -1
1133
+
1134
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1135
+
1136
+ loss = None
1137
+ if labels is not None:
1138
+ loss = self.loss_function(logits=logits, labels=labels, pooled_logits=pooled_logits, config=self.config)
1139
+
1140
+ if not return_dict:
1141
+ output = (pooled_logits,) + transformer_outputs[1:]
1142
+ return ((loss,) + output) if loss is not None else output
1143
+
1144
+ return SequenceClassifierOutputWithPast(
1145
+ loss=loss,
1146
+ logits=pooled_logits,
1147
+ past_key_values=transformer_outputs.past_key_values,
1148
+ hidden_states=transformer_outputs.hidden_states,
1149
+ attentions=transformer_outputs.attentions,
1150
+ )
1151
+
1152
+
1153
+ __all__ = ["DogeForCausalLM", "DogeModel", "DogePreTrainedModel", "DogeForSequenceClassification"]
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|begin_of_text|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|end_of_text|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|finetune_right_pad_id|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
to_onnx.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+ import onnx
4
+ from onnxruntime.quantization import quantize_dynamic, QuantType
5
+ import os
6
+ import logging
7
+ from typing import Optional, Dict, Any
8
+
9
+ class ONNXModelConverter:
10
+ def __init__(self, model_name: str, output_dir: str):
11
+ self.model_name = model_name
12
+ self.output_dir = output_dir
13
+ self.setup_logging()
14
+
15
+ # Create output directory
16
+ os.makedirs(output_dir, exist_ok=True)
17
+
18
+ # Load model and tokenizer
19
+ self.logger.info(f"Loading model {model_name}...")
20
+ self.tokenizer = AutoTokenizer.from_pretrained(
21
+ model_name,
22
+ trust_remote_code=True
23
+ )
24
+
25
+ # Load model with specific dtype
26
+ self.model = AutoModelForCausalLM.from_pretrained(
27
+ model_name,
28
+ trust_remote_code=True,
29
+ torch_dtype=torch.float32
30
+ )
31
+ self.model.eval()
32
+
33
+ def setup_logging(self):
34
+ """Set up logging configuration"""
35
+ self.logger = logging.getLogger(__name__)
36
+ self.logger.setLevel(logging.INFO)
37
+ handler = logging.StreamHandler()
38
+ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
39
+ handler.setFormatter(formatter)
40
+ self.logger.addHandler(handler)
41
+
42
+ def prepare_dummy_inputs(self):
43
+ """Prepare dummy inputs for ONNX export"""
44
+ # Create a simple input for testing
45
+ dummy_input = self.tokenizer(
46
+ "Hello, how are you?",
47
+ return_tensors="pt",
48
+ padding=True,
49
+ truncation=True,
50
+ max_length=128
51
+ )
52
+
53
+ return {
54
+ 'input_ids': dummy_input['input_ids'],
55
+ 'attention_mask': dummy_input['attention_mask']
56
+ }
57
+
58
+ def export_to_onnx(self):
59
+ """Export model to ONNX format"""
60
+ output_path = os.path.join(self.output_dir, "model.onnx")
61
+
62
+ # Get dummy inputs
63
+ inputs = self.prepare_dummy_inputs()
64
+
65
+ # Define dynamic axes for variable length inputs
66
+ dynamic_axes = {
67
+ 'input_ids': {0: 'batch_size', 1: 'sequence_length'},
68
+ 'attention_mask': {0: 'batch_size', 1: 'sequence_length'},
69
+ 'logits': {0: 'batch_size', 1: 'sequence_length'}
70
+ }
71
+
72
+ class ModelWrapper(torch.nn.Module):
73
+ def __init__(self, model):
74
+ super().__init__()
75
+ self.model = model
76
+
77
+ def forward(self, input_ids, attention_mask):
78
+ outputs = self.model(input_ids=input_ids, attention_mask=attention_mask)
79
+ return outputs.logits
80
+
81
+ # Wrap the model
82
+ wrapped_model = ModelWrapper(self.model)
83
+
84
+ try:
85
+ # Export to ONNX
86
+ torch.onnx.export(
87
+ wrapped_model,
88
+ (inputs['input_ids'], inputs['attention_mask']),
89
+ output_path,
90
+ export_params=True,
91
+ opset_version=14,
92
+ do_constant_folding=True,
93
+ input_names=['input_ids', 'attention_mask'],
94
+ output_names=['logits'],
95
+ dynamic_axes=dynamic_axes,
96
+ verbose=False
97
+ )
98
+
99
+ self.logger.info(f"Model exported to {output_path}")
100
+ return output_path
101
+
102
+ except Exception as e:
103
+ self.logger.error(f"ONNX export failed: {str(e)}")
104
+ raise
105
+
106
+ def verify_model(self, model_path: str):
107
+ """Verify the exported ONNX model"""
108
+ try:
109
+ onnx_model = onnx.load(model_path)
110
+ onnx.checker.check_model(onnx_model)
111
+ self.logger.info("ONNX model verification successful")
112
+ return True
113
+ except Exception as e:
114
+ self.logger.error(f"Model verification failed: {str(e)}")
115
+ return False
116
+
117
+ def quantize_model(self, model_path: str):
118
+ """Quantize the ONNX model"""
119
+ weight_types = {'int4':QuantType.QInt4, 'int8':QuantType.QInt8, 'uint4':QuantType.QUInt4, 'uint8':QuantType.QUInt8, 'uint16':QuantType.QUInt16, 'int16':QuantType.QInt16}
120
+ all_quantized_paths = []
121
+ for weight_type in weight_types.keys():
122
+ quantized_path = os.path.join(self.output_dir, "model_" + weight_type + ".onnx")
123
+
124
+ try:
125
+ quantize_dynamic(
126
+ model_path,
127
+ quantized_path,
128
+ weight_type=weight_types[weight_type]
129
+ )
130
+ self.logger.info(f"Model quantized and saved to {quantized_path}")
131
+ all_quantized_paths.append(quantized_path)
132
+ except Exception as e:
133
+ self.logger.error(f"Quantization failed: {str(e)}")
134
+ raise
135
+
136
+ return all_quantized_paths
137
+
138
+ def convert(self):
139
+ """Complete conversion process"""
140
+ try:
141
+ # Export to ONNX
142
+ onnx_path = self.export_to_onnx()
143
+
144
+ # Verify the exported model
145
+ if self.verify_model(onnx_path):
146
+ # Quantize if verification successful
147
+ quantized_path = self.quantize_model(onnx_path)
148
+
149
+ # Save the tokenizer
150
+ tokenizer_path = os.path.join(self.output_dir, "tokenizer")
151
+ self.tokenizer.save_pretrained(tokenizer_path)
152
+ self.logger.info(f"Tokenizer saved to {tokenizer_path}")
153
+
154
+ return {
155
+ 'onnx_model': onnx_path,
156
+ 'quantized_model': quantized_path,
157
+ 'tokenizer': tokenizer_path
158
+ }
159
+ else:
160
+ raise Exception("Model verification failed")
161
+
162
+ except Exception as e:
163
+ self.logger.error(f"Conversion process failed: {str(e)}")
164
+ raise
165
+
166
+ if __name__ == "__main__":
167
+ MODEL_NAME = "SmallDoge/Doge-60M-Instruct"
168
+ OUTPUT_DIR = "onnx"
169
+
170
+ try:
171
+ converter = ONNXModelConverter(MODEL_NAME, OUTPUT_DIR)
172
+ results = converter.convert()
173
+
174
+ print("\nConversion completed successfully!")
175
+ print(f"ONNX model path: {results['onnx_model']}")
176
+ print(f"Quantized model path: {results['quantized_model']}")
177
+ print(f"Tokenizer path: {results['tokenizer']}")
178
+
179
+ except Exception as e:
180
+ print(f"Conversion failed: {str(e)}")
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,2066 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<|begin_of_text|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<|end_of_text|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "<|finetune_right_pad_id|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<|start_header_id|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "<|end_header_id|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "5": {
44
+ "content": "<|eom_id|>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "6": {
52
+ "content": "<|eot_id|>",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ },
59
+ "7": {
60
+ "content": "<|python_tag|>",
61
+ "lstrip": false,
62
+ "normalized": false,
63
+ "rstrip": false,
64
+ "single_word": false,
65
+ "special": true
66
+ },
67
+ "8": {
68
+ "content": "<|reserved_special_token_0|>",
69
+ "lstrip": false,
70
+ "normalized": false,
71
+ "rstrip": false,
72
+ "single_word": false,
73
+ "special": true
74
+ },
75
+ "9": {
76
+ "content": "<|reserved_special_token_1|>",
77
+ "lstrip": false,
78
+ "normalized": false,
79
+ "rstrip": false,
80
+ "single_word": false,
81
+ "special": true
82
+ },
83
+ "10": {
84
+ "content": "<|reserved_special_token_2|>",
85
+ "lstrip": false,
86
+ "normalized": false,
87
+ "rstrip": false,
88
+ "single_word": false,
89
+ "special": true
90
+ },
91
+ "11": {
92
+ "content": "<|reserved_special_token_3|>",
93
+ "lstrip": false,
94
+ "normalized": false,
95
+ "rstrip": false,
96
+ "single_word": false,
97
+ "special": true
98
+ },
99
+ "12": {
100
+ "content": "<|reserved_special_token_4|>",
101
+ "lstrip": false,
102
+ "normalized": false,
103
+ "rstrip": false,
104
+ "single_word": false,
105
+ "special": true
106
+ },
107
+ "13": {
108
+ "content": "<|reserved_special_token_5|>",
109
+ "lstrip": false,
110
+ "normalized": false,
111
+ "rstrip": false,
112
+ "single_word": false,
113
+ "special": true
114
+ },
115
+ "14": {
116
+ "content": "<|reserved_special_token_6|>",
117
+ "lstrip": false,
118
+ "normalized": false,
119
+ "rstrip": false,
120
+ "single_word": false,
121
+ "special": true
122
+ },
123
+ "15": {
124
+ "content": "<|reserved_special_token_7|>",
125
+ "lstrip": false,
126
+ "normalized": false,
127
+ "rstrip": false,
128
+ "single_word": false,
129
+ "special": true
130
+ },
131
+ "16": {
132
+ "content": "<|reserved_special_token_8|>",
133
+ "lstrip": false,
134
+ "normalized": false,
135
+ "rstrip": false,
136
+ "single_word": false,
137
+ "special": true
138
+ },
139
+ "17": {
140
+ "content": "<|reserved_special_token_9|>",
141
+ "lstrip": false,
142
+ "normalized": false,
143
+ "rstrip": false,
144
+ "single_word": false,
145
+ "special": true
146
+ },
147
+ "18": {
148
+ "content": "<|reserved_special_token_10|>",
149
+ "lstrip": false,
150
+ "normalized": false,
151
+ "rstrip": false,
152
+ "single_word": false,
153
+ "special": true
154
+ },
155
+ "19": {
156
+ "content": "<|reserved_special_token_11|>",
157
+ "lstrip": false,
158
+ "normalized": false,
159
+ "rstrip": false,
160
+ "single_word": false,
161
+ "special": true
162
+ },
163
+ "20": {
164
+ "content": "<|reserved_special_token_12|>",
165
+ "lstrip": false,
166
+ "normalized": false,
167
+ "rstrip": false,
168
+ "single_word": false,
169
+ "special": true
170
+ },
171
+ "21": {
172
+ "content": "<|reserved_special_token_13|>",
173
+ "lstrip": false,
174
+ "normalized": false,
175
+ "rstrip": false,
176
+ "single_word": false,
177
+ "special": true
178
+ },
179
+ "22": {
180
+ "content": "<|reserved_special_token_14|>",
181
+ "lstrip": false,
182
+ "normalized": false,
183
+ "rstrip": false,
184
+ "single_word": false,
185
+ "special": true
186
+ },
187
+ "23": {
188
+ "content": "<|reserved_special_token_15|>",
189
+ "lstrip": false,
190
+ "normalized": false,
191
+ "rstrip": false,
192
+ "single_word": false,
193
+ "special": true
194
+ },
195
+ "24": {
196
+ "content": "<|reserved_special_token_16|>",
197
+ "lstrip": false,
198
+ "normalized": false,
199
+ "rstrip": false,
200
+ "single_word": false,
201
+ "special": true
202
+ },
203
+ "25": {
204
+ "content": "<|reserved_special_token_17|>",
205
+ "lstrip": false,
206
+ "normalized": false,
207
+ "rstrip": false,
208
+ "single_word": false,
209
+ "special": true
210
+ },
211
+ "26": {
212
+ "content": "<|reserved_special_token_18|>",
213
+ "lstrip": false,
214
+ "normalized": false,
215
+ "rstrip": false,
216
+ "single_word": false,
217
+ "special": true
218
+ },
219
+ "27": {
220
+ "content": "<|reserved_special_token_19|>",
221
+ "lstrip": false,
222
+ "normalized": false,
223
+ "rstrip": false,
224
+ "single_word": false,
225
+ "special": true
226
+ },
227
+ "28": {
228
+ "content": "<|reserved_special_token_20|>",
229
+ "lstrip": false,
230
+ "normalized": false,
231
+ "rstrip": false,
232
+ "single_word": false,
233
+ "special": true
234
+ },
235
+ "29": {
236
+ "content": "<|reserved_special_token_21|>",
237
+ "lstrip": false,
238
+ "normalized": false,
239
+ "rstrip": false,
240
+ "single_word": false,
241
+ "special": true
242
+ },
243
+ "30": {
244
+ "content": "<|reserved_special_token_22|>",
245
+ "lstrip": false,
246
+ "normalized": false,
247
+ "rstrip": false,
248
+ "single_word": false,
249
+ "special": true
250
+ },
251
+ "31": {
252
+ "content": "<|reserved_special_token_23|>",
253
+ "lstrip": false,
254
+ "normalized": false,
255
+ "rstrip": false,
256
+ "single_word": false,
257
+ "special": true
258
+ },
259
+ "32": {
260
+ "content": "<|reserved_special_token_24|>",
261
+ "lstrip": false,
262
+ "normalized": false,
263
+ "rstrip": false,
264
+ "single_word": false,
265
+ "special": true
266
+ },
267
+ "33": {
268
+ "content": "<|reserved_special_token_25|>",
269
+ "lstrip": false,
270
+ "normalized": false,
271
+ "rstrip": false,
272
+ "single_word": false,
273
+ "special": true
274
+ },
275
+ "34": {
276
+ "content": "<|reserved_special_token_26|>",
277
+ "lstrip": false,
278
+ "normalized": false,
279
+ "rstrip": false,
280
+ "single_word": false,
281
+ "special": true
282
+ },
283
+ "35": {
284
+ "content": "<|reserved_special_token_27|>",
285
+ "lstrip": false,
286
+ "normalized": false,
287
+ "rstrip": false,
288
+ "single_word": false,
289
+ "special": true
290
+ },
291
+ "36": {
292
+ "content": "<|reserved_special_token_28|>",
293
+ "lstrip": false,
294
+ "normalized": false,
295
+ "rstrip": false,
296
+ "single_word": false,
297
+ "special": true
298
+ },
299
+ "37": {
300
+ "content": "<|reserved_special_token_29|>",
301
+ "lstrip": false,
302
+ "normalized": false,
303
+ "rstrip": false,
304
+ "single_word": false,
305
+ "special": true
306
+ },
307
+ "38": {
308
+ "content": "<|reserved_special_token_30|>",
309
+ "lstrip": false,
310
+ "normalized": false,
311
+ "rstrip": false,
312
+ "single_word": false,
313
+ "special": true
314
+ },
315
+ "39": {
316
+ "content": "<|reserved_special_token_31|>",
317
+ "lstrip": false,
318
+ "normalized": false,
319
+ "rstrip": false,
320
+ "single_word": false,
321
+ "special": true
322
+ },
323
+ "40": {
324
+ "content": "<|reserved_special_token_32|>",
325
+ "lstrip": false,
326
+ "normalized": false,
327
+ "rstrip": false,
328
+ "single_word": false,
329
+ "special": true
330
+ },
331
+ "41": {
332
+ "content": "<|reserved_special_token_33|>",
333
+ "lstrip": false,
334
+ "normalized": false,
335
+ "rstrip": false,
336
+ "single_word": false,
337
+ "special": true
338
+ },
339
+ "42": {
340
+ "content": "<|reserved_special_token_34|>",
341
+ "lstrip": false,
342
+ "normalized": false,
343
+ "rstrip": false,
344
+ "single_word": false,
345
+ "special": true
346
+ },
347
+ "43": {
348
+ "content": "<|reserved_special_token_35|>",
349
+ "lstrip": false,
350
+ "normalized": false,
351
+ "rstrip": false,
352
+ "single_word": false,
353
+ "special": true
354
+ },
355
+ "44": {
356
+ "content": "<|reserved_special_token_36|>",
357
+ "lstrip": false,
358
+ "normalized": false,
359
+ "rstrip": false,
360
+ "single_word": false,
361
+ "special": true
362
+ },
363
+ "45": {
364
+ "content": "<|reserved_special_token_37|>",
365
+ "lstrip": false,
366
+ "normalized": false,
367
+ "rstrip": false,
368
+ "single_word": false,
369
+ "special": true
370
+ },
371
+ "46": {
372
+ "content": "<|reserved_special_token_38|>",
373
+ "lstrip": false,
374
+ "normalized": false,
375
+ "rstrip": false,
376
+ "single_word": false,
377
+ "special": true
378
+ },
379
+ "47": {
380
+ "content": "<|reserved_special_token_39|>",
381
+ "lstrip": false,
382
+ "normalized": false,
383
+ "rstrip": false,
384
+ "single_word": false,
385
+ "special": true
386
+ },
387
+ "48": {
388
+ "content": "<|reserved_special_token_40|>",
389
+ "lstrip": false,
390
+ "normalized": false,
391
+ "rstrip": false,
392
+ "single_word": false,
393
+ "special": true
394
+ },
395
+ "49": {
396
+ "content": "<|reserved_special_token_41|>",
397
+ "lstrip": false,
398
+ "normalized": false,
399
+ "rstrip": false,
400
+ "single_word": false,
401
+ "special": true
402
+ },
403
+ "50": {
404
+ "content": "<|reserved_special_token_42|>",
405
+ "lstrip": false,
406
+ "normalized": false,
407
+ "rstrip": false,
408
+ "single_word": false,
409
+ "special": true
410
+ },
411
+ "51": {
412
+ "content": "<|reserved_special_token_43|>",
413
+ "lstrip": false,
414
+ "normalized": false,
415
+ "rstrip": false,
416
+ "single_word": false,
417
+ "special": true
418
+ },
419
+ "52": {
420
+ "content": "<|reserved_special_token_44|>",
421
+ "lstrip": false,
422
+ "normalized": false,
423
+ "rstrip": false,
424
+ "single_word": false,
425
+ "special": true
426
+ },
427
+ "53": {
428
+ "content": "<|reserved_special_token_45|>",
429
+ "lstrip": false,
430
+ "normalized": false,
431
+ "rstrip": false,
432
+ "single_word": false,
433
+ "special": true
434
+ },
435
+ "54": {
436
+ "content": "<|reserved_special_token_46|>",
437
+ "lstrip": false,
438
+ "normalized": false,
439
+ "rstrip": false,
440
+ "single_word": false,
441
+ "special": true
442
+ },
443
+ "55": {
444
+ "content": "<|reserved_special_token_47|>",
445
+ "lstrip": false,
446
+ "normalized": false,
447
+ "rstrip": false,
448
+ "single_word": false,
449
+ "special": true
450
+ },
451
+ "56": {
452
+ "content": "<|reserved_special_token_48|>",
453
+ "lstrip": false,
454
+ "normalized": false,
455
+ "rstrip": false,
456
+ "single_word": false,
457
+ "special": true
458
+ },
459
+ "57": {
460
+ "content": "<|reserved_special_token_49|>",
461
+ "lstrip": false,
462
+ "normalized": false,
463
+ "rstrip": false,
464
+ "single_word": false,
465
+ "special": true
466
+ },
467
+ "58": {
468
+ "content": "<|reserved_special_token_50|>",
469
+ "lstrip": false,
470
+ "normalized": false,
471
+ "rstrip": false,
472
+ "single_word": false,
473
+ "special": true
474
+ },
475
+ "59": {
476
+ "content": "<|reserved_special_token_51|>",
477
+ "lstrip": false,
478
+ "normalized": false,
479
+ "rstrip": false,
480
+ "single_word": false,
481
+ "special": true
482
+ },
483
+ "60": {
484
+ "content": "<|reserved_special_token_52|>",
485
+ "lstrip": false,
486
+ "normalized": false,
487
+ "rstrip": false,
488
+ "single_word": false,
489
+ "special": true
490
+ },
491
+ "61": {
492
+ "content": "<|reserved_special_token_53|>",
493
+ "lstrip": false,
494
+ "normalized": false,
495
+ "rstrip": false,
496
+ "single_word": false,
497
+ "special": true
498
+ },
499
+ "62": {
500
+ "content": "<|reserved_special_token_54|>",
501
+ "lstrip": false,
502
+ "normalized": false,
503
+ "rstrip": false,
504
+ "single_word": false,
505
+ "special": true
506
+ },
507
+ "63": {
508
+ "content": "<|reserved_special_token_55|>",
509
+ "lstrip": false,
510
+ "normalized": false,
511
+ "rstrip": false,
512
+ "single_word": false,
513
+ "special": true
514
+ },
515
+ "64": {
516
+ "content": "<|reserved_special_token_56|>",
517
+ "lstrip": false,
518
+ "normalized": false,
519
+ "rstrip": false,
520
+ "single_word": false,
521
+ "special": true
522
+ },
523
+ "65": {
524
+ "content": "<|reserved_special_token_57|>",
525
+ "lstrip": false,
526
+ "normalized": false,
527
+ "rstrip": false,
528
+ "single_word": false,
529
+ "special": true
530
+ },
531
+ "66": {
532
+ "content": "<|reserved_special_token_58|>",
533
+ "lstrip": false,
534
+ "normalized": false,
535
+ "rstrip": false,
536
+ "single_word": false,
537
+ "special": true
538
+ },
539
+ "67": {
540
+ "content": "<|reserved_special_token_59|>",
541
+ "lstrip": false,
542
+ "normalized": false,
543
+ "rstrip": false,
544
+ "single_word": false,
545
+ "special": true
546
+ },
547
+ "68": {
548
+ "content": "<|reserved_special_token_60|>",
549
+ "lstrip": false,
550
+ "normalized": false,
551
+ "rstrip": false,
552
+ "single_word": false,
553
+ "special": true
554
+ },
555
+ "69": {
556
+ "content": "<|reserved_special_token_61|>",
557
+ "lstrip": false,
558
+ "normalized": false,
559
+ "rstrip": false,
560
+ "single_word": false,
561
+ "special": true
562
+ },
563
+ "70": {
564
+ "content": "<|reserved_special_token_62|>",
565
+ "lstrip": false,
566
+ "normalized": false,
567
+ "rstrip": false,
568
+ "single_word": false,
569
+ "special": true
570
+ },
571
+ "71": {
572
+ "content": "<|reserved_special_token_63|>",
573
+ "lstrip": false,
574
+ "normalized": false,
575
+ "rstrip": false,
576
+ "single_word": false,
577
+ "special": true
578
+ },
579
+ "72": {
580
+ "content": "<|reserved_special_token_64|>",
581
+ "lstrip": false,
582
+ "normalized": false,
583
+ "rstrip": false,
584
+ "single_word": false,
585
+ "special": true
586
+ },
587
+ "73": {
588
+ "content": "<|reserved_special_token_65|>",
589
+ "lstrip": false,
590
+ "normalized": false,
591
+ "rstrip": false,
592
+ "single_word": false,
593
+ "special": true
594
+ },
595
+ "74": {
596
+ "content": "<|reserved_special_token_66|>",
597
+ "lstrip": false,
598
+ "normalized": false,
599
+ "rstrip": false,
600
+ "single_word": false,
601
+ "special": true
602
+ },
603
+ "75": {
604
+ "content": "<|reserved_special_token_67|>",
605
+ "lstrip": false,
606
+ "normalized": false,
607
+ "rstrip": false,
608
+ "single_word": false,
609
+ "special": true
610
+ },
611
+ "76": {
612
+ "content": "<|reserved_special_token_68|>",
613
+ "lstrip": false,
614
+ "normalized": false,
615
+ "rstrip": false,
616
+ "single_word": false,
617
+ "special": true
618
+ },
619
+ "77": {
620
+ "content": "<|reserved_special_token_69|>",
621
+ "lstrip": false,
622
+ "normalized": false,
623
+ "rstrip": false,
624
+ "single_word": false,
625
+ "special": true
626
+ },
627
+ "78": {
628
+ "content": "<|reserved_special_token_70|>",
629
+ "lstrip": false,
630
+ "normalized": false,
631
+ "rstrip": false,
632
+ "single_word": false,
633
+ "special": true
634
+ },
635
+ "79": {
636
+ "content": "<|reserved_special_token_71|>",
637
+ "lstrip": false,
638
+ "normalized": false,
639
+ "rstrip": false,
640
+ "single_word": false,
641
+ "special": true
642
+ },
643
+ "80": {
644
+ "content": "<|reserved_special_token_72|>",
645
+ "lstrip": false,
646
+ "normalized": false,
647
+ "rstrip": false,
648
+ "single_word": false,
649
+ "special": true
650
+ },
651
+ "81": {
652
+ "content": "<|reserved_special_token_73|>",
653
+ "lstrip": false,
654
+ "normalized": false,
655
+ "rstrip": false,
656
+ "single_word": false,
657
+ "special": true
658
+ },
659
+ "82": {
660
+ "content": "<|reserved_special_token_74|>",
661
+ "lstrip": false,
662
+ "normalized": false,
663
+ "rstrip": false,
664
+ "single_word": false,
665
+ "special": true
666
+ },
667
+ "83": {
668
+ "content": "<|reserved_special_token_75|>",
669
+ "lstrip": false,
670
+ "normalized": false,
671
+ "rstrip": false,
672
+ "single_word": false,
673
+ "special": true
674
+ },
675
+ "84": {
676
+ "content": "<|reserved_special_token_76|>",
677
+ "lstrip": false,
678
+ "normalized": false,
679
+ "rstrip": false,
680
+ "single_word": false,
681
+ "special": true
682
+ },
683
+ "85": {
684
+ "content": "<|reserved_special_token_77|>",
685
+ "lstrip": false,
686
+ "normalized": false,
687
+ "rstrip": false,
688
+ "single_word": false,
689
+ "special": true
690
+ },
691
+ "86": {
692
+ "content": "<|reserved_special_token_78|>",
693
+ "lstrip": false,
694
+ "normalized": false,
695
+ "rstrip": false,
696
+ "single_word": false,
697
+ "special": true
698
+ },
699
+ "87": {
700
+ "content": "<|reserved_special_token_79|>",
701
+ "lstrip": false,
702
+ "normalized": false,
703
+ "rstrip": false,
704
+ "single_word": false,
705
+ "special": true
706
+ },
707
+ "88": {
708
+ "content": "<|reserved_special_token_80|>",
709
+ "lstrip": false,
710
+ "normalized": false,
711
+ "rstrip": false,
712
+ "single_word": false,
713
+ "special": true
714
+ },
715
+ "89": {
716
+ "content": "<|reserved_special_token_81|>",
717
+ "lstrip": false,
718
+ "normalized": false,
719
+ "rstrip": false,
720
+ "single_word": false,
721
+ "special": true
722
+ },
723
+ "90": {
724
+ "content": "<|reserved_special_token_82|>",
725
+ "lstrip": false,
726
+ "normalized": false,
727
+ "rstrip": false,
728
+ "single_word": false,
729
+ "special": true
730
+ },
731
+ "91": {
732
+ "content": "<|reserved_special_token_83|>",
733
+ "lstrip": false,
734
+ "normalized": false,
735
+ "rstrip": false,
736
+ "single_word": false,
737
+ "special": true
738
+ },
739
+ "92": {
740
+ "content": "<|reserved_special_token_84|>",
741
+ "lstrip": false,
742
+ "normalized": false,
743
+ "rstrip": false,
744
+ "single_word": false,
745
+ "special": true
746
+ },
747
+ "93": {
748
+ "content": "<|reserved_special_token_85|>",
749
+ "lstrip": false,
750
+ "normalized": false,
751
+ "rstrip": false,
752
+ "single_word": false,
753
+ "special": true
754
+ },
755
+ "94": {
756
+ "content": "<|reserved_special_token_86|>",
757
+ "lstrip": false,
758
+ "normalized": false,
759
+ "rstrip": false,
760
+ "single_word": false,
761
+ "special": true
762
+ },
763
+ "95": {
764
+ "content": "<|reserved_special_token_87|>",
765
+ "lstrip": false,
766
+ "normalized": false,
767
+ "rstrip": false,
768
+ "single_word": false,
769
+ "special": true
770
+ },
771
+ "96": {
772
+ "content": "<|reserved_special_token_88|>",
773
+ "lstrip": false,
774
+ "normalized": false,
775
+ "rstrip": false,
776
+ "single_word": false,
777
+ "special": true
778
+ },
779
+ "97": {
780
+ "content": "<|reserved_special_token_89|>",
781
+ "lstrip": false,
782
+ "normalized": false,
783
+ "rstrip": false,
784
+ "single_word": false,
785
+ "special": true
786
+ },
787
+ "98": {
788
+ "content": "<|reserved_special_token_90|>",
789
+ "lstrip": false,
790
+ "normalized": false,
791
+ "rstrip": false,
792
+ "single_word": false,
793
+ "special": true
794
+ },
795
+ "99": {
796
+ "content": "<|reserved_special_token_91|>",
797
+ "lstrip": false,
798
+ "normalized": false,
799
+ "rstrip": false,
800
+ "single_word": false,
801
+ "special": true
802
+ },
803
+ "100": {
804
+ "content": "<|reserved_special_token_92|>",
805
+ "lstrip": false,
806
+ "normalized": false,
807
+ "rstrip": false,
808
+ "single_word": false,
809
+ "special": true
810
+ },
811
+ "101": {
812
+ "content": "<|reserved_special_token_93|>",
813
+ "lstrip": false,
814
+ "normalized": false,
815
+ "rstrip": false,
816
+ "single_word": false,
817
+ "special": true
818
+ },
819
+ "102": {
820
+ "content": "<|reserved_special_token_94|>",
821
+ "lstrip": false,
822
+ "normalized": false,
823
+ "rstrip": false,
824
+ "single_word": false,
825
+ "special": true
826
+ },
827
+ "103": {
828
+ "content": "<|reserved_special_token_95|>",
829
+ "lstrip": false,
830
+ "normalized": false,
831
+ "rstrip": false,
832
+ "single_word": false,
833
+ "special": true
834
+ },
835
+ "104": {
836
+ "content": "<|reserved_special_token_96|>",
837
+ "lstrip": false,
838
+ "normalized": false,
839
+ "rstrip": false,
840
+ "single_word": false,
841
+ "special": true
842
+ },
843
+ "105": {
844
+ "content": "<|reserved_special_token_97|>",
845
+ "lstrip": false,
846
+ "normalized": false,
847
+ "rstrip": false,
848
+ "single_word": false,
849
+ "special": true
850
+ },
851
+ "106": {
852
+ "content": "<|reserved_special_token_98|>",
853
+ "lstrip": false,
854
+ "normalized": false,
855
+ "rstrip": false,
856
+ "single_word": false,
857
+ "special": true
858
+ },
859
+ "107": {
860
+ "content": "<|reserved_special_token_99|>",
861
+ "lstrip": false,
862
+ "normalized": false,
863
+ "rstrip": false,
864
+ "single_word": false,
865
+ "special": true
866
+ },
867
+ "108": {
868
+ "content": "<|reserved_special_token_100|>",
869
+ "lstrip": false,
870
+ "normalized": false,
871
+ "rstrip": false,
872
+ "single_word": false,
873
+ "special": true
874
+ },
875
+ "109": {
876
+ "content": "<|reserved_special_token_101|>",
877
+ "lstrip": false,
878
+ "normalized": false,
879
+ "rstrip": false,
880
+ "single_word": false,
881
+ "special": true
882
+ },
883
+ "110": {
884
+ "content": "<|reserved_special_token_102|>",
885
+ "lstrip": false,
886
+ "normalized": false,
887
+ "rstrip": false,
888
+ "single_word": false,
889
+ "special": true
890
+ },
891
+ "111": {
892
+ "content": "<|reserved_special_token_103|>",
893
+ "lstrip": false,
894
+ "normalized": false,
895
+ "rstrip": false,
896
+ "single_word": false,
897
+ "special": true
898
+ },
899
+ "112": {
900
+ "content": "<|reserved_special_token_104|>",
901
+ "lstrip": false,
902
+ "normalized": false,
903
+ "rstrip": false,
904
+ "single_word": false,
905
+ "special": true
906
+ },
907
+ "113": {
908
+ "content": "<|reserved_special_token_105|>",
909
+ "lstrip": false,
910
+ "normalized": false,
911
+ "rstrip": false,
912
+ "single_word": false,
913
+ "special": true
914
+ },
915
+ "114": {
916
+ "content": "<|reserved_special_token_106|>",
917
+ "lstrip": false,
918
+ "normalized": false,
919
+ "rstrip": false,
920
+ "single_word": false,
921
+ "special": true
922
+ },
923
+ "115": {
924
+ "content": "<|reserved_special_token_107|>",
925
+ "lstrip": false,
926
+ "normalized": false,
927
+ "rstrip": false,
928
+ "single_word": false,
929
+ "special": true
930
+ },
931
+ "116": {
932
+ "content": "<|reserved_special_token_108|>",
933
+ "lstrip": false,
934
+ "normalized": false,
935
+ "rstrip": false,
936
+ "single_word": false,
937
+ "special": true
938
+ },
939
+ "117": {
940
+ "content": "<|reserved_special_token_109|>",
941
+ "lstrip": false,
942
+ "normalized": false,
943
+ "rstrip": false,
944
+ "single_word": false,
945
+ "special": true
946
+ },
947
+ "118": {
948
+ "content": "<|reserved_special_token_110|>",
949
+ "lstrip": false,
950
+ "normalized": false,
951
+ "rstrip": false,
952
+ "single_word": false,
953
+ "special": true
954
+ },
955
+ "119": {
956
+ "content": "<|reserved_special_token_111|>",
957
+ "lstrip": false,
958
+ "normalized": false,
959
+ "rstrip": false,
960
+ "single_word": false,
961
+ "special": true
962
+ },
963
+ "120": {
964
+ "content": "<|reserved_special_token_112|>",
965
+ "lstrip": false,
966
+ "normalized": false,
967
+ "rstrip": false,
968
+ "single_word": false,
969
+ "special": true
970
+ },
971
+ "121": {
972
+ "content": "<|reserved_special_token_113|>",
973
+ "lstrip": false,
974
+ "normalized": false,
975
+ "rstrip": false,
976
+ "single_word": false,
977
+ "special": true
978
+ },
979
+ "122": {
980
+ "content": "<|reserved_special_token_114|>",
981
+ "lstrip": false,
982
+ "normalized": false,
983
+ "rstrip": false,
984
+ "single_word": false,
985
+ "special": true
986
+ },
987
+ "123": {
988
+ "content": "<|reserved_special_token_115|>",
989
+ "lstrip": false,
990
+ "normalized": false,
991
+ "rstrip": false,
992
+ "single_word": false,
993
+ "special": true
994
+ },
995
+ "124": {
996
+ "content": "<|reserved_special_token_116|>",
997
+ "lstrip": false,
998
+ "normalized": false,
999
+ "rstrip": false,
1000
+ "single_word": false,
1001
+ "special": true
1002
+ },
1003
+ "125": {
1004
+ "content": "<|reserved_special_token_117|>",
1005
+ "lstrip": false,
1006
+ "normalized": false,
1007
+ "rstrip": false,
1008
+ "single_word": false,
1009
+ "special": true
1010
+ },
1011
+ "126": {
1012
+ "content": "<|reserved_special_token_118|>",
1013
+ "lstrip": false,
1014
+ "normalized": false,
1015
+ "rstrip": false,
1016
+ "single_word": false,
1017
+ "special": true
1018
+ },
1019
+ "127": {
1020
+ "content": "<|reserved_special_token_119|>",
1021
+ "lstrip": false,
1022
+ "normalized": false,
1023
+ "rstrip": false,
1024
+ "single_word": false,
1025
+ "special": true
1026
+ },
1027
+ "128": {
1028
+ "content": "<|reserved_special_token_120|>",
1029
+ "lstrip": false,
1030
+ "normalized": false,
1031
+ "rstrip": false,
1032
+ "single_word": false,
1033
+ "special": true
1034
+ },
1035
+ "129": {
1036
+ "content": "<|reserved_special_token_121|>",
1037
+ "lstrip": false,
1038
+ "normalized": false,
1039
+ "rstrip": false,
1040
+ "single_word": false,
1041
+ "special": true
1042
+ },
1043
+ "130": {
1044
+ "content": "<|reserved_special_token_122|>",
1045
+ "lstrip": false,
1046
+ "normalized": false,
1047
+ "rstrip": false,
1048
+ "single_word": false,
1049
+ "special": true
1050
+ },
1051
+ "131": {
1052
+ "content": "<|reserved_special_token_123|>",
1053
+ "lstrip": false,
1054
+ "normalized": false,
1055
+ "rstrip": false,
1056
+ "single_word": false,
1057
+ "special": true
1058
+ },
1059
+ "132": {
1060
+ "content": "<|reserved_special_token_124|>",
1061
+ "lstrip": false,
1062
+ "normalized": false,
1063
+ "rstrip": false,
1064
+ "single_word": false,
1065
+ "special": true
1066
+ },
1067
+ "133": {
1068
+ "content": "<|reserved_special_token_125|>",
1069
+ "lstrip": false,
1070
+ "normalized": false,
1071
+ "rstrip": false,
1072
+ "single_word": false,
1073
+ "special": true
1074
+ },
1075
+ "134": {
1076
+ "content": "<|reserved_special_token_126|>",
1077
+ "lstrip": false,
1078
+ "normalized": false,
1079
+ "rstrip": false,
1080
+ "single_word": false,
1081
+ "special": true
1082
+ },
1083
+ "135": {
1084
+ "content": "<|reserved_special_token_127|>",
1085
+ "lstrip": false,
1086
+ "normalized": false,
1087
+ "rstrip": false,
1088
+ "single_word": false,
1089
+ "special": true
1090
+ },
1091
+ "136": {
1092
+ "content": "<|reserved_special_token_128|>",
1093
+ "lstrip": false,
1094
+ "normalized": false,
1095
+ "rstrip": false,
1096
+ "single_word": false,
1097
+ "special": true
1098
+ },
1099
+ "137": {
1100
+ "content": "<|reserved_special_token_129|>",
1101
+ "lstrip": false,
1102
+ "normalized": false,
1103
+ "rstrip": false,
1104
+ "single_word": false,
1105
+ "special": true
1106
+ },
1107
+ "138": {
1108
+ "content": "<|reserved_special_token_130|>",
1109
+ "lstrip": false,
1110
+ "normalized": false,
1111
+ "rstrip": false,
1112
+ "single_word": false,
1113
+ "special": true
1114
+ },
1115
+ "139": {
1116
+ "content": "<|reserved_special_token_131|>",
1117
+ "lstrip": false,
1118
+ "normalized": false,
1119
+ "rstrip": false,
1120
+ "single_word": false,
1121
+ "special": true
1122
+ },
1123
+ "140": {
1124
+ "content": "<|reserved_special_token_132|>",
1125
+ "lstrip": false,
1126
+ "normalized": false,
1127
+ "rstrip": false,
1128
+ "single_word": false,
1129
+ "special": true
1130
+ },
1131
+ "141": {
1132
+ "content": "<|reserved_special_token_133|>",
1133
+ "lstrip": false,
1134
+ "normalized": false,
1135
+ "rstrip": false,
1136
+ "single_word": false,
1137
+ "special": true
1138
+ },
1139
+ "142": {
1140
+ "content": "<|reserved_special_token_134|>",
1141
+ "lstrip": false,
1142
+ "normalized": false,
1143
+ "rstrip": false,
1144
+ "single_word": false,
1145
+ "special": true
1146
+ },
1147
+ "143": {
1148
+ "content": "<|reserved_special_token_135|>",
1149
+ "lstrip": false,
1150
+ "normalized": false,
1151
+ "rstrip": false,
1152
+ "single_word": false,
1153
+ "special": true
1154
+ },
1155
+ "144": {
1156
+ "content": "<|reserved_special_token_136|>",
1157
+ "lstrip": false,
1158
+ "normalized": false,
1159
+ "rstrip": false,
1160
+ "single_word": false,
1161
+ "special": true
1162
+ },
1163
+ "145": {
1164
+ "content": "<|reserved_special_token_137|>",
1165
+ "lstrip": false,
1166
+ "normalized": false,
1167
+ "rstrip": false,
1168
+ "single_word": false,
1169
+ "special": true
1170
+ },
1171
+ "146": {
1172
+ "content": "<|reserved_special_token_138|>",
1173
+ "lstrip": false,
1174
+ "normalized": false,
1175
+ "rstrip": false,
1176
+ "single_word": false,
1177
+ "special": true
1178
+ },
1179
+ "147": {
1180
+ "content": "<|reserved_special_token_139|>",
1181
+ "lstrip": false,
1182
+ "normalized": false,
1183
+ "rstrip": false,
1184
+ "single_word": false,
1185
+ "special": true
1186
+ },
1187
+ "148": {
1188
+ "content": "<|reserved_special_token_140|>",
1189
+ "lstrip": false,
1190
+ "normalized": false,
1191
+ "rstrip": false,
1192
+ "single_word": false,
1193
+ "special": true
1194
+ },
1195
+ "149": {
1196
+ "content": "<|reserved_special_token_141|>",
1197
+ "lstrip": false,
1198
+ "normalized": false,
1199
+ "rstrip": false,
1200
+ "single_word": false,
1201
+ "special": true
1202
+ },
1203
+ "150": {
1204
+ "content": "<|reserved_special_token_142|>",
1205
+ "lstrip": false,
1206
+ "normalized": false,
1207
+ "rstrip": false,
1208
+ "single_word": false,
1209
+ "special": true
1210
+ },
1211
+ "151": {
1212
+ "content": "<|reserved_special_token_143|>",
1213
+ "lstrip": false,
1214
+ "normalized": false,
1215
+ "rstrip": false,
1216
+ "single_word": false,
1217
+ "special": true
1218
+ },
1219
+ "152": {
1220
+ "content": "<|reserved_special_token_144|>",
1221
+ "lstrip": false,
1222
+ "normalized": false,
1223
+ "rstrip": false,
1224
+ "single_word": false,
1225
+ "special": true
1226
+ },
1227
+ "153": {
1228
+ "content": "<|reserved_special_token_145|>",
1229
+ "lstrip": false,
1230
+ "normalized": false,
1231
+ "rstrip": false,
1232
+ "single_word": false,
1233
+ "special": true
1234
+ },
1235
+ "154": {
1236
+ "content": "<|reserved_special_token_146|>",
1237
+ "lstrip": false,
1238
+ "normalized": false,
1239
+ "rstrip": false,
1240
+ "single_word": false,
1241
+ "special": true
1242
+ },
1243
+ "155": {
1244
+ "content": "<|reserved_special_token_147|>",
1245
+ "lstrip": false,
1246
+ "normalized": false,
1247
+ "rstrip": false,
1248
+ "single_word": false,
1249
+ "special": true
1250
+ },
1251
+ "156": {
1252
+ "content": "<|reserved_special_token_148|>",
1253
+ "lstrip": false,
1254
+ "normalized": false,
1255
+ "rstrip": false,
1256
+ "single_word": false,
1257
+ "special": true
1258
+ },
1259
+ "157": {
1260
+ "content": "<|reserved_special_token_149|>",
1261
+ "lstrip": false,
1262
+ "normalized": false,
1263
+ "rstrip": false,
1264
+ "single_word": false,
1265
+ "special": true
1266
+ },
1267
+ "158": {
1268
+ "content": "<|reserved_special_token_150|>",
1269
+ "lstrip": false,
1270
+ "normalized": false,
1271
+ "rstrip": false,
1272
+ "single_word": false,
1273
+ "special": true
1274
+ },
1275
+ "159": {
1276
+ "content": "<|reserved_special_token_151|>",
1277
+ "lstrip": false,
1278
+ "normalized": false,
1279
+ "rstrip": false,
1280
+ "single_word": false,
1281
+ "special": true
1282
+ },
1283
+ "160": {
1284
+ "content": "<|reserved_special_token_152|>",
1285
+ "lstrip": false,
1286
+ "normalized": false,
1287
+ "rstrip": false,
1288
+ "single_word": false,
1289
+ "special": true
1290
+ },
1291
+ "161": {
1292
+ "content": "<|reserved_special_token_153|>",
1293
+ "lstrip": false,
1294
+ "normalized": false,
1295
+ "rstrip": false,
1296
+ "single_word": false,
1297
+ "special": true
1298
+ },
1299
+ "162": {
1300
+ "content": "<|reserved_special_token_154|>",
1301
+ "lstrip": false,
1302
+ "normalized": false,
1303
+ "rstrip": false,
1304
+ "single_word": false,
1305
+ "special": true
1306
+ },
1307
+ "163": {
1308
+ "content": "<|reserved_special_token_155|>",
1309
+ "lstrip": false,
1310
+ "normalized": false,
1311
+ "rstrip": false,
1312
+ "single_word": false,
1313
+ "special": true
1314
+ },
1315
+ "164": {
1316
+ "content": "<|reserved_special_token_156|>",
1317
+ "lstrip": false,
1318
+ "normalized": false,
1319
+ "rstrip": false,
1320
+ "single_word": false,
1321
+ "special": true
1322
+ },
1323
+ "165": {
1324
+ "content": "<|reserved_special_token_157|>",
1325
+ "lstrip": false,
1326
+ "normalized": false,
1327
+ "rstrip": false,
1328
+ "single_word": false,
1329
+ "special": true
1330
+ },
1331
+ "166": {
1332
+ "content": "<|reserved_special_token_158|>",
1333
+ "lstrip": false,
1334
+ "normalized": false,
1335
+ "rstrip": false,
1336
+ "single_word": false,
1337
+ "special": true
1338
+ },
1339
+ "167": {
1340
+ "content": "<|reserved_special_token_159|>",
1341
+ "lstrip": false,
1342
+ "normalized": false,
1343
+ "rstrip": false,
1344
+ "single_word": false,
1345
+ "special": true
1346
+ },
1347
+ "168": {
1348
+ "content": "<|reserved_special_token_160|>",
1349
+ "lstrip": false,
1350
+ "normalized": false,
1351
+ "rstrip": false,
1352
+ "single_word": false,
1353
+ "special": true
1354
+ },
1355
+ "169": {
1356
+ "content": "<|reserved_special_token_161|>",
1357
+ "lstrip": false,
1358
+ "normalized": false,
1359
+ "rstrip": false,
1360
+ "single_word": false,
1361
+ "special": true
1362
+ },
1363
+ "170": {
1364
+ "content": "<|reserved_special_token_162|>",
1365
+ "lstrip": false,
1366
+ "normalized": false,
1367
+ "rstrip": false,
1368
+ "single_word": false,
1369
+ "special": true
1370
+ },
1371
+ "171": {
1372
+ "content": "<|reserved_special_token_163|>",
1373
+ "lstrip": false,
1374
+ "normalized": false,
1375
+ "rstrip": false,
1376
+ "single_word": false,
1377
+ "special": true
1378
+ },
1379
+ "172": {
1380
+ "content": "<|reserved_special_token_164|>",
1381
+ "lstrip": false,
1382
+ "normalized": false,
1383
+ "rstrip": false,
1384
+ "single_word": false,
1385
+ "special": true
1386
+ },
1387
+ "173": {
1388
+ "content": "<|reserved_special_token_165|>",
1389
+ "lstrip": false,
1390
+ "normalized": false,
1391
+ "rstrip": false,
1392
+ "single_word": false,
1393
+ "special": true
1394
+ },
1395
+ "174": {
1396
+ "content": "<|reserved_special_token_166|>",
1397
+ "lstrip": false,
1398
+ "normalized": false,
1399
+ "rstrip": false,
1400
+ "single_word": false,
1401
+ "special": true
1402
+ },
1403
+ "175": {
1404
+ "content": "<|reserved_special_token_167|>",
1405
+ "lstrip": false,
1406
+ "normalized": false,
1407
+ "rstrip": false,
1408
+ "single_word": false,
1409
+ "special": true
1410
+ },
1411
+ "176": {
1412
+ "content": "<|reserved_special_token_168|>",
1413
+ "lstrip": false,
1414
+ "normalized": false,
1415
+ "rstrip": false,
1416
+ "single_word": false,
1417
+ "special": true
1418
+ },
1419
+ "177": {
1420
+ "content": "<|reserved_special_token_169|>",
1421
+ "lstrip": false,
1422
+ "normalized": false,
1423
+ "rstrip": false,
1424
+ "single_word": false,
1425
+ "special": true
1426
+ },
1427
+ "178": {
1428
+ "content": "<|reserved_special_token_170|>",
1429
+ "lstrip": false,
1430
+ "normalized": false,
1431
+ "rstrip": false,
1432
+ "single_word": false,
1433
+ "special": true
1434
+ },
1435
+ "179": {
1436
+ "content": "<|reserved_special_token_171|>",
1437
+ "lstrip": false,
1438
+ "normalized": false,
1439
+ "rstrip": false,
1440
+ "single_word": false,
1441
+ "special": true
1442
+ },
1443
+ "180": {
1444
+ "content": "<|reserved_special_token_172|>",
1445
+ "lstrip": false,
1446
+ "normalized": false,
1447
+ "rstrip": false,
1448
+ "single_word": false,
1449
+ "special": true
1450
+ },
1451
+ "181": {
1452
+ "content": "<|reserved_special_token_173|>",
1453
+ "lstrip": false,
1454
+ "normalized": false,
1455
+ "rstrip": false,
1456
+ "single_word": false,
1457
+ "special": true
1458
+ },
1459
+ "182": {
1460
+ "content": "<|reserved_special_token_174|>",
1461
+ "lstrip": false,
1462
+ "normalized": false,
1463
+ "rstrip": false,
1464
+ "single_word": false,
1465
+ "special": true
1466
+ },
1467
+ "183": {
1468
+ "content": "<|reserved_special_token_175|>",
1469
+ "lstrip": false,
1470
+ "normalized": false,
1471
+ "rstrip": false,
1472
+ "single_word": false,
1473
+ "special": true
1474
+ },
1475
+ "184": {
1476
+ "content": "<|reserved_special_token_176|>",
1477
+ "lstrip": false,
1478
+ "normalized": false,
1479
+ "rstrip": false,
1480
+ "single_word": false,
1481
+ "special": true
1482
+ },
1483
+ "185": {
1484
+ "content": "<|reserved_special_token_177|>",
1485
+ "lstrip": false,
1486
+ "normalized": false,
1487
+ "rstrip": false,
1488
+ "single_word": false,
1489
+ "special": true
1490
+ },
1491
+ "186": {
1492
+ "content": "<|reserved_special_token_178|>",
1493
+ "lstrip": false,
1494
+ "normalized": false,
1495
+ "rstrip": false,
1496
+ "single_word": false,
1497
+ "special": true
1498
+ },
1499
+ "187": {
1500
+ "content": "<|reserved_special_token_179|>",
1501
+ "lstrip": false,
1502
+ "normalized": false,
1503
+ "rstrip": false,
1504
+ "single_word": false,
1505
+ "special": true
1506
+ },
1507
+ "188": {
1508
+ "content": "<|reserved_special_token_180|>",
1509
+ "lstrip": false,
1510
+ "normalized": false,
1511
+ "rstrip": false,
1512
+ "single_word": false,
1513
+ "special": true
1514
+ },
1515
+ "189": {
1516
+ "content": "<|reserved_special_token_181|>",
1517
+ "lstrip": false,
1518
+ "normalized": false,
1519
+ "rstrip": false,
1520
+ "single_word": false,
1521
+ "special": true
1522
+ },
1523
+ "190": {
1524
+ "content": "<|reserved_special_token_182|>",
1525
+ "lstrip": false,
1526
+ "normalized": false,
1527
+ "rstrip": false,
1528
+ "single_word": false,
1529
+ "special": true
1530
+ },
1531
+ "191": {
1532
+ "content": "<|reserved_special_token_183|>",
1533
+ "lstrip": false,
1534
+ "normalized": false,
1535
+ "rstrip": false,
1536
+ "single_word": false,
1537
+ "special": true
1538
+ },
1539
+ "192": {
1540
+ "content": "<|reserved_special_token_184|>",
1541
+ "lstrip": false,
1542
+ "normalized": false,
1543
+ "rstrip": false,
1544
+ "single_word": false,
1545
+ "special": true
1546
+ },
1547
+ "193": {
1548
+ "content": "<|reserved_special_token_185|>",
1549
+ "lstrip": false,
1550
+ "normalized": false,
1551
+ "rstrip": false,
1552
+ "single_word": false,
1553
+ "special": true
1554
+ },
1555
+ "194": {
1556
+ "content": "<|reserved_special_token_186|>",
1557
+ "lstrip": false,
1558
+ "normalized": false,
1559
+ "rstrip": false,
1560
+ "single_word": false,
1561
+ "special": true
1562
+ },
1563
+ "195": {
1564
+ "content": "<|reserved_special_token_187|>",
1565
+ "lstrip": false,
1566
+ "normalized": false,
1567
+ "rstrip": false,
1568
+ "single_word": false,
1569
+ "special": true
1570
+ },
1571
+ "196": {
1572
+ "content": "<|reserved_special_token_188|>",
1573
+ "lstrip": false,
1574
+ "normalized": false,
1575
+ "rstrip": false,
1576
+ "single_word": false,
1577
+ "special": true
1578
+ },
1579
+ "197": {
1580
+ "content": "<|reserved_special_token_189|>",
1581
+ "lstrip": false,
1582
+ "normalized": false,
1583
+ "rstrip": false,
1584
+ "single_word": false,
1585
+ "special": true
1586
+ },
1587
+ "198": {
1588
+ "content": "<|reserved_special_token_190|>",
1589
+ "lstrip": false,
1590
+ "normalized": false,
1591
+ "rstrip": false,
1592
+ "single_word": false,
1593
+ "special": true
1594
+ },
1595
+ "199": {
1596
+ "content": "<|reserved_special_token_191|>",
1597
+ "lstrip": false,
1598
+ "normalized": false,
1599
+ "rstrip": false,
1600
+ "single_word": false,
1601
+ "special": true
1602
+ },
1603
+ "200": {
1604
+ "content": "<|reserved_special_token_192|>",
1605
+ "lstrip": false,
1606
+ "normalized": false,
1607
+ "rstrip": false,
1608
+ "single_word": false,
1609
+ "special": true
1610
+ },
1611
+ "201": {
1612
+ "content": "<|reserved_special_token_193|>",
1613
+ "lstrip": false,
1614
+ "normalized": false,
1615
+ "rstrip": false,
1616
+ "single_word": false,
1617
+ "special": true
1618
+ },
1619
+ "202": {
1620
+ "content": "<|reserved_special_token_194|>",
1621
+ "lstrip": false,
1622
+ "normalized": false,
1623
+ "rstrip": false,
1624
+ "single_word": false,
1625
+ "special": true
1626
+ },
1627
+ "203": {
1628
+ "content": "<|reserved_special_token_195|>",
1629
+ "lstrip": false,
1630
+ "normalized": false,
1631
+ "rstrip": false,
1632
+ "single_word": false,
1633
+ "special": true
1634
+ },
1635
+ "204": {
1636
+ "content": "<|reserved_special_token_196|>",
1637
+ "lstrip": false,
1638
+ "normalized": false,
1639
+ "rstrip": false,
1640
+ "single_word": false,
1641
+ "special": true
1642
+ },
1643
+ "205": {
1644
+ "content": "<|reserved_special_token_197|>",
1645
+ "lstrip": false,
1646
+ "normalized": false,
1647
+ "rstrip": false,
1648
+ "single_word": false,
1649
+ "special": true
1650
+ },
1651
+ "206": {
1652
+ "content": "<|reserved_special_token_198|>",
1653
+ "lstrip": false,
1654
+ "normalized": false,
1655
+ "rstrip": false,
1656
+ "single_word": false,
1657
+ "special": true
1658
+ },
1659
+ "207": {
1660
+ "content": "<|reserved_special_token_199|>",
1661
+ "lstrip": false,
1662
+ "normalized": false,
1663
+ "rstrip": false,
1664
+ "single_word": false,
1665
+ "special": true
1666
+ },
1667
+ "208": {
1668
+ "content": "<|reserved_special_token_200|>",
1669
+ "lstrip": false,
1670
+ "normalized": false,
1671
+ "rstrip": false,
1672
+ "single_word": false,
1673
+ "special": true
1674
+ },
1675
+ "209": {
1676
+ "content": "<|reserved_special_token_201|>",
1677
+ "lstrip": false,
1678
+ "normalized": false,
1679
+ "rstrip": false,
1680
+ "single_word": false,
1681
+ "special": true
1682
+ },
1683
+ "210": {
1684
+ "content": "<|reserved_special_token_202|>",
1685
+ "lstrip": false,
1686
+ "normalized": false,
1687
+ "rstrip": false,
1688
+ "single_word": false,
1689
+ "special": true
1690
+ },
1691
+ "211": {
1692
+ "content": "<|reserved_special_token_203|>",
1693
+ "lstrip": false,
1694
+ "normalized": false,
1695
+ "rstrip": false,
1696
+ "single_word": false,
1697
+ "special": true
1698
+ },
1699
+ "212": {
1700
+ "content": "<|reserved_special_token_204|>",
1701
+ "lstrip": false,
1702
+ "normalized": false,
1703
+ "rstrip": false,
1704
+ "single_word": false,
1705
+ "special": true
1706
+ },
1707
+ "213": {
1708
+ "content": "<|reserved_special_token_205|>",
1709
+ "lstrip": false,
1710
+ "normalized": false,
1711
+ "rstrip": false,
1712
+ "single_word": false,
1713
+ "special": true
1714
+ },
1715
+ "214": {
1716
+ "content": "<|reserved_special_token_206|>",
1717
+ "lstrip": false,
1718
+ "normalized": false,
1719
+ "rstrip": false,
1720
+ "single_word": false,
1721
+ "special": true
1722
+ },
1723
+ "215": {
1724
+ "content": "<|reserved_special_token_207|>",
1725
+ "lstrip": false,
1726
+ "normalized": false,
1727
+ "rstrip": false,
1728
+ "single_word": false,
1729
+ "special": true
1730
+ },
1731
+ "216": {
1732
+ "content": "<|reserved_special_token_208|>",
1733
+ "lstrip": false,
1734
+ "normalized": false,
1735
+ "rstrip": false,
1736
+ "single_word": false,
1737
+ "special": true
1738
+ },
1739
+ "217": {
1740
+ "content": "<|reserved_special_token_209|>",
1741
+ "lstrip": false,
1742
+ "normalized": false,
1743
+ "rstrip": false,
1744
+ "single_word": false,
1745
+ "special": true
1746
+ },
1747
+ "218": {
1748
+ "content": "<|reserved_special_token_210|>",
1749
+ "lstrip": false,
1750
+ "normalized": false,
1751
+ "rstrip": false,
1752
+ "single_word": false,
1753
+ "special": true
1754
+ },
1755
+ "219": {
1756
+ "content": "<|reserved_special_token_211|>",
1757
+ "lstrip": false,
1758
+ "normalized": false,
1759
+ "rstrip": false,
1760
+ "single_word": false,
1761
+ "special": true
1762
+ },
1763
+ "220": {
1764
+ "content": "<|reserved_special_token_212|>",
1765
+ "lstrip": false,
1766
+ "normalized": false,
1767
+ "rstrip": false,
1768
+ "single_word": false,
1769
+ "special": true
1770
+ },
1771
+ "221": {
1772
+ "content": "<|reserved_special_token_213|>",
1773
+ "lstrip": false,
1774
+ "normalized": false,
1775
+ "rstrip": false,
1776
+ "single_word": false,
1777
+ "special": true
1778
+ },
1779
+ "222": {
1780
+ "content": "<|reserved_special_token_214|>",
1781
+ "lstrip": false,
1782
+ "normalized": false,
1783
+ "rstrip": false,
1784
+ "single_word": false,
1785
+ "special": true
1786
+ },
1787
+ "223": {
1788
+ "content": "<|reserved_special_token_215|>",
1789
+ "lstrip": false,
1790
+ "normalized": false,
1791
+ "rstrip": false,
1792
+ "single_word": false,
1793
+ "special": true
1794
+ },
1795
+ "224": {
1796
+ "content": "<|reserved_special_token_216|>",
1797
+ "lstrip": false,
1798
+ "normalized": false,
1799
+ "rstrip": false,
1800
+ "single_word": false,
1801
+ "special": true
1802
+ },
1803
+ "225": {
1804
+ "content": "<|reserved_special_token_217|>",
1805
+ "lstrip": false,
1806
+ "normalized": false,
1807
+ "rstrip": false,
1808
+ "single_word": false,
1809
+ "special": true
1810
+ },
1811
+ "226": {
1812
+ "content": "<|reserved_special_token_218|>",
1813
+ "lstrip": false,
1814
+ "normalized": false,
1815
+ "rstrip": false,
1816
+ "single_word": false,
1817
+ "special": true
1818
+ },
1819
+ "227": {
1820
+ "content": "<|reserved_special_token_219|>",
1821
+ "lstrip": false,
1822
+ "normalized": false,
1823
+ "rstrip": false,
1824
+ "single_word": false,
1825
+ "special": true
1826
+ },
1827
+ "228": {
1828
+ "content": "<|reserved_special_token_220|>",
1829
+ "lstrip": false,
1830
+ "normalized": false,
1831
+ "rstrip": false,
1832
+ "single_word": false,
1833
+ "special": true
1834
+ },
1835
+ "229": {
1836
+ "content": "<|reserved_special_token_221|>",
1837
+ "lstrip": false,
1838
+ "normalized": false,
1839
+ "rstrip": false,
1840
+ "single_word": false,
1841
+ "special": true
1842
+ },
1843
+ "230": {
1844
+ "content": "<|reserved_special_token_222|>",
1845
+ "lstrip": false,
1846
+ "normalized": false,
1847
+ "rstrip": false,
1848
+ "single_word": false,
1849
+ "special": true
1850
+ },
1851
+ "231": {
1852
+ "content": "<|reserved_special_token_223|>",
1853
+ "lstrip": false,
1854
+ "normalized": false,
1855
+ "rstrip": false,
1856
+ "single_word": false,
1857
+ "special": true
1858
+ },
1859
+ "232": {
1860
+ "content": "<|reserved_special_token_224|>",
1861
+ "lstrip": false,
1862
+ "normalized": false,
1863
+ "rstrip": false,
1864
+ "single_word": false,
1865
+ "special": true
1866
+ },
1867
+ "233": {
1868
+ "content": "<|reserved_special_token_225|>",
1869
+ "lstrip": false,
1870
+ "normalized": false,
1871
+ "rstrip": false,
1872
+ "single_word": false,
1873
+ "special": true
1874
+ },
1875
+ "234": {
1876
+ "content": "<|reserved_special_token_226|>",
1877
+ "lstrip": false,
1878
+ "normalized": false,
1879
+ "rstrip": false,
1880
+ "single_word": false,
1881
+ "special": true
1882
+ },
1883
+ "235": {
1884
+ "content": "<|reserved_special_token_227|>",
1885
+ "lstrip": false,
1886
+ "normalized": false,
1887
+ "rstrip": false,
1888
+ "single_word": false,
1889
+ "special": true
1890
+ },
1891
+ "236": {
1892
+ "content": "<|reserved_special_token_228|>",
1893
+ "lstrip": false,
1894
+ "normalized": false,
1895
+ "rstrip": false,
1896
+ "single_word": false,
1897
+ "special": true
1898
+ },
1899
+ "237": {
1900
+ "content": "<|reserved_special_token_229|>",
1901
+ "lstrip": false,
1902
+ "normalized": false,
1903
+ "rstrip": false,
1904
+ "single_word": false,
1905
+ "special": true
1906
+ },
1907
+ "238": {
1908
+ "content": "<|reserved_special_token_230|>",
1909
+ "lstrip": false,
1910
+ "normalized": false,
1911
+ "rstrip": false,
1912
+ "single_word": false,
1913
+ "special": true
1914
+ },
1915
+ "239": {
1916
+ "content": "<|reserved_special_token_231|>",
1917
+ "lstrip": false,
1918
+ "normalized": false,
1919
+ "rstrip": false,
1920
+ "single_word": false,
1921
+ "special": true
1922
+ },
1923
+ "240": {
1924
+ "content": "<|reserved_special_token_232|>",
1925
+ "lstrip": false,
1926
+ "normalized": false,
1927
+ "rstrip": false,
1928
+ "single_word": false,
1929
+ "special": true
1930
+ },
1931
+ "241": {
1932
+ "content": "<|reserved_special_token_233|>",
1933
+ "lstrip": false,
1934
+ "normalized": false,
1935
+ "rstrip": false,
1936
+ "single_word": false,
1937
+ "special": true
1938
+ },
1939
+ "242": {
1940
+ "content": "<|reserved_special_token_234|>",
1941
+ "lstrip": false,
1942
+ "normalized": false,
1943
+ "rstrip": false,
1944
+ "single_word": false,
1945
+ "special": true
1946
+ },
1947
+ "243": {
1948
+ "content": "<|reserved_special_token_235|>",
1949
+ "lstrip": false,
1950
+ "normalized": false,
1951
+ "rstrip": false,
1952
+ "single_word": false,
1953
+ "special": true
1954
+ },
1955
+ "244": {
1956
+ "content": "<|reserved_special_token_236|>",
1957
+ "lstrip": false,
1958
+ "normalized": false,
1959
+ "rstrip": false,
1960
+ "single_word": false,
1961
+ "special": true
1962
+ },
1963
+ "245": {
1964
+ "content": "<|reserved_special_token_237|>",
1965
+ "lstrip": false,
1966
+ "normalized": false,
1967
+ "rstrip": false,
1968
+ "single_word": false,
1969
+ "special": true
1970
+ },
1971
+ "246": {
1972
+ "content": "<|reserved_special_token_238|>",
1973
+ "lstrip": false,
1974
+ "normalized": false,
1975
+ "rstrip": false,
1976
+ "single_word": false,
1977
+ "special": true
1978
+ },
1979
+ "247": {
1980
+ "content": "<|reserved_special_token_239|>",
1981
+ "lstrip": false,
1982
+ "normalized": false,
1983
+ "rstrip": false,
1984
+ "single_word": false,
1985
+ "special": true
1986
+ },
1987
+ "248": {
1988
+ "content": "<|reserved_special_token_240|>",
1989
+ "lstrip": false,
1990
+ "normalized": false,
1991
+ "rstrip": false,
1992
+ "single_word": false,
1993
+ "special": true
1994
+ },
1995
+ "249": {
1996
+ "content": "<|reserved_special_token_241|>",
1997
+ "lstrip": false,
1998
+ "normalized": false,
1999
+ "rstrip": false,
2000
+ "single_word": false,
2001
+ "special": true
2002
+ },
2003
+ "250": {
2004
+ "content": "<|reserved_special_token_242|>",
2005
+ "lstrip": false,
2006
+ "normalized": false,
2007
+ "rstrip": false,
2008
+ "single_word": false,
2009
+ "special": true
2010
+ },
2011
+ "251": {
2012
+ "content": "<|reserved_special_token_243|>",
2013
+ "lstrip": false,
2014
+ "normalized": false,
2015
+ "rstrip": false,
2016
+ "single_word": false,
2017
+ "special": true
2018
+ },
2019
+ "32768": {
2020
+ "content": "<think>",
2021
+ "lstrip": false,
2022
+ "normalized": false,
2023
+ "rstrip": false,
2024
+ "single_word": false,
2025
+ "special": true
2026
+ },
2027
+ "32769": {
2028
+ "content": "</think>",
2029
+ "lstrip": false,
2030
+ "normalized": false,
2031
+ "rstrip": false,
2032
+ "single_word": false,
2033
+ "special": true
2034
+ },
2035
+ "32770": {
2036
+ "content": "<answer>",
2037
+ "lstrip": false,
2038
+ "normalized": false,
2039
+ "rstrip": false,
2040
+ "single_word": false,
2041
+ "special": true
2042
+ },
2043
+ "32771": {
2044
+ "content": "</answer>",
2045
+ "lstrip": false,
2046
+ "normalized": false,
2047
+ "rstrip": false,
2048
+ "single_word": false,
2049
+ "special": true
2050
+ }
2051
+ },
2052
+ "bos_token": "<|begin_of_text|>",
2053
+ "chat_template": "{{- bos_token }}\n{%- if custom_tools is defined %}\n {%- set tools = custom_tools %}\n{%- endif %}\n{%- if not tools_in_user_message is defined %}\n {%- set tools_in_user_message = true %}\n{%- endif %}\n{%- if not date_string is defined %}\n {%- set date_string = \"December 2024\" %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n\n{#- This block extracts the system message, so we can slot it into the right place. #}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = \"\" %}\n{%- endif %}\n\n{#- System message + builtin tools #}\n{{- \"<|start_header_id|>system<|end_header_id|>\\n\" }}\n{%- if builtin_tools is defined or tools is not none %}\n {{- \"Environment: ipython\\n\" }}\n{%- endif %}\n{%- if builtin_tools is defined %}\n {{- \"Tools: \" + builtin_tools | reject('equalto', 'code_interpreter') | join(\", \") + \"\\n\\n\"}}\n{%- endif %}\n{{- \"Cutting Knowledge Date: December 2024\\n\" }}\n{{- \"Today Date: \" + date_string + \"\\n\" }}\n{%- if tools is not none and not tools_in_user_message %}\n {{- \"You have access to the following functions. To call a function, please respond with JSON for a function call.\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n{%- endif %}\n{{- system_message }}\n{{- \"<|end_of_text|>\\n\\n\" }}\n\n{#- Custom tools are passed in a user message with some extra guidance #}\n{%- if tools_in_user_message and not tools is none %}\n {#- Extract the first user message so we can plug it in here #}\n {%- if messages | length != 0 %}\n {%- set first_user_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n {%- else %}\n {{- raise_exception(\"Cannot put tools in the first user message when there's no first user message!\") }}\n{%- endif %}\n {{- '<|start_header_id|>user<|end_header_id|>\\n' -}}\n {{- \"Given the following functions, please respond with a JSON for a function call \" }}\n {{- \"with its proper arguments that best answers the given prompt.\\n\\n\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n {{- first_user_message + \"<|end_of_text|>\\n\\n\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\\n'+ message['content'] | trim + '<|end_of_text|>\\n\\n' }}\n {%- elif 'tool_calls' in message %}\n {%- if not message.tool_calls|length == 1 %}\n {{- raise_exception(\"This model only supports single tool-calls at once!\") }}\n {%- endif %}\n {%- set tool_call = message.tool_calls[0].function %}\n {%- if builtin_tools is defined and tool_call.name in builtin_tools %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n' -}}\n {{- \"<|python_tag|>\" + tool_call.name + \".call(\" }}\n {%- for arg_name, arg_val in tool_call.arguments | items %}\n {{- arg_name + '=\"' + arg_val + '\"' }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- endif %}\n {%- endfor %}\n {{- \")\" }}\n {%- else %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n' -}}\n {{- '{\"name\": \"' + tool_call.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- \"}\" }}\n {%- endif %}\n {%- if builtin_tools is defined %}\n {#- This means we're in ipython mode #}\n {{- \"<|end_of_text|>\\n\\n\" }}\n {%- else %}\n {{- \"<|end_of_text|>\\n\\n\" }}\n {%- endif %}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|start_header_id|>ipython<|end_header_id|>\\n\" }}\n {%- if message.content is mapping or message.content is iterable %}\n {{- message.content | tojson }}\n {%- else %}\n {{- message.content }}\n {%- endif %}\n {{- \"<|end_of_text|>\\n\\n\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n' }}\n{%- endif %}\n",
2054
+ "clean_up_tokenization_spaces": true,
2055
+ "eos_token": "<|end_of_text|>",
2056
+ "extra_special_tokens": {},
2057
+ "model_input_names": [
2058
+ "input_ids",
2059
+ "attention_mask"
2060
+ ],
2061
+ "model_max_length": 131072,
2062
+ "pad_token": "<|finetune_right_pad_id|>",
2063
+ "padding_side": "left",
2064
+ "tokenizer_class": "PreTrainedTokenizerFast",
2065
+ "unk_token": null
2066
+ }