AriesChen commited on
Commit
895fd24
1 Parent(s): 74f4c3f

sedimentology

Browse files
.gitattributes CHANGED
@@ -1,35 +1,6 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz 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
 
1
+ optimizer.pt filter=lfs diff=lfs merge=lfs -text
2
+ pytorch_model.bin filter=lfs diff=lfs merge=lfs -text
3
+ ice_text.model filter=lfs diff=lfs merge=lfs -text
4
+ rng_state.pth filter=lfs diff=lfs merge=lfs -text
5
+ scheduler.pt filter=lfs diff=lfs merge=lfs -text
6
+ training_args.bin filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,3 +1,55 @@
 
 
 
 
 
1
  ---
2
- license: gpl-3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GeoLLM
2
+ **Large Language Model for Geology**
3
+
4
+ Large language models are used to organize geology-related knowledge (geology, geophysics, geophysical logging, etc.). This version uses the [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B) base model and fine-tunes it using P-tuning.
5
+
6
  ---
7
+
8
+ ### Sedimentology
9
+
10
+ Sedimentology, the study of sedimentary rocks and the processes by which they are formed, includes and is related to a large number of phenomena. Sedimentology includes the five fundamental processes defined by the term sediaentation --weathering, erosion, transportation, deposition and diagenesis.
11
+
12
+ **Datasets:**《沉积岩石学(第四版)》 朱筱敏
13
+
14
+ **Model:** ChatGLM-6B
15
+
16
+ **Fine-tuning:** P-Tuning v2
17
+
18
+ **Before fine-tuning**
19
+
20
+ ```
21
+ response, history = model.chat(tokenizer, "什么是沉积岩石学?", history=[])
22
+ response
23
+
24
+ 沉积岩石学是一门研究沉积岩的形成、结构和成分的学科,主要关注地球表面上不同条件下的沉积过程和岩石形成机制,包括岩浆沉积、冰川沉积、洪水沉积、海洋沉积等。沉积岩石学在地质学、地球物理学、地球化学、材料科学等领域都有广泛应用,因为沉积岩是许多自然和人工地质工程的基础,如地质勘探、矿产资源开发、土木工程、环境科学等。沉积岩石学的研究对象包括沉积岩的地质特征、成分和构造特征,以及沉积岩与地壳、岩浆和变质岩的关系。研究方法包括沉积岩分析、岩相学分析、岩浆动力学分析等。
25
+ ```
26
+
27
+ **After fine-tuning**
28
+
29
+ ```
30
+ response, history = model.chat(tokenizer, "什么是沉积岩石学?", history=[])
31
+ response
32
+
33
+ 沉积岩石学是研究沉积岩的物质成分、结构构造、岩石类型、沉积物沉积作用和沉积物质形成环境以及沉积岩分布规律的一门科学。
34
+ ```
35
+
36
+ **Error Analysis:** We meticulously refined the model by approximately 500 entries from academic textbooks, subsequently applying P-Tuning v2 for optimization. Detailed control of parameters was not conducted for the time being. Given the scarcity of the training data and the fine-tuning parameters, the outcomes might exhibit some irregularities.
37
+
38
+ **Results Analysis:** It is evident that the fine-tuned model shows enhanced reliability(more precise and concise) when providing answers within specialized knowledge domains. Moving forward, we will persist in enriching our training data and optimizing our fine-tuning methodologies in order to yield superior results.
39
+
40
  ---
41
+
42
+ ### TODO
43
+
44
+ 1. Geophysical Exploration
45
+
46
+ 2. Geophysical logging
47
+
48
+ 3. Petroleum Geology
49
+
50
+ etc...
51
+
52
+ ---
53
+
54
+ ### Related Resources
55
+ 1. [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B): ChatGLM-6B is an open bilingual language model based on General Language Model (GLM) framework, with 6.2 billion parameters.
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/content/drive/MyDrive/ChatGLM/chatglm-6b-slim",
3
+ "architectures": [
4
+ "ChatGLMForConditionalGeneration"
5
+ ],
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_chatglm.ChatGLMConfig",
8
+ "AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
9
+ "AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
10
+ },
11
+ "bos_token_id": 130004,
12
+ "eos_token_id": 130005,
13
+ "hidden_size": 4096,
14
+ "inner_hidden_size": 16384,
15
+ "layernorm_epsilon": 1e-05,
16
+ "max_sequence_length": 2048,
17
+ "model_type": "chatglm",
18
+ "num_attention_heads": 32,
19
+ "num_layers": 28,
20
+ "pad_token_id": 3,
21
+ "position_encoding_2d": true,
22
+ "pre_seq_len": 128,
23
+ "prefix_projection": false,
24
+ "quantization_bit": 4,
25
+ "torch_dtype": "float16",
26
+ "transformers_version": "4.27.1",
27
+ "use_cache": true,
28
+ "vocab_size": 130528
29
+ }
configuration_chatglm.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ ChatGLM model configuration """
2
+
3
+ from transformers.configuration_utils import PretrainedConfig
4
+ from transformers.utils import logging
5
+
6
+ logger = logging.get_logger(__name__)
7
+
8
+
9
+ class ChatGLMConfig(PretrainedConfig):
10
+ r"""
11
+ This is the configuration class to store the configuration of a [`~ChatGLMModel`].
12
+ It is used to instantiate an ChatGLM model according to the specified arguments, defining the model
13
+ architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of
14
+ the ChatGLM-6B [THUDM/ChatGLM-6B](https://huggingface.co/THUDM/chatglm-6b) architecture.
15
+ We remove 20K image tokens on top of ChatGLM-6B to save memories.
16
+
17
+ Configuration objects inherit from [`PretrainedConfig`] and can be used
18
+ to control the model outputs. Read the documentation from [`PretrainedConfig`]
19
+ for more information.
20
+
21
+
22
+ Args:
23
+ vocab_size (`int`, *optional*, defaults to 150528):
24
+ Vocabulary size of the ChatGLM-6B model. Defines the number of different tokens that can be represented by the
25
+ `inputs_ids` passed when calling [`~ChatGLMModel`] or
26
+ [`~TFChatGLMModel`].
27
+ hidden_size (`int`, *optional*, defaults to 4096):
28
+ Dimension of the encoder layers and the pooler layer.
29
+ num_hidden_layers (`int`, *optional*, defaults to 28):
30
+ Number of hidden layers in the Transformer encoder.
31
+ num_attention_heads (`int`, *optional*, defaults to 32):
32
+ Number of attention heads for each attention layer in the Transformer encoder.
33
+ inner_hidden_size (`int`, *optional*, defaults to 16384):
34
+ Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
35
+ max_sequence_length (`int`, *optional*, defaults to 512):
36
+ The maximum sequence length that this model might ever be used with.
37
+ Typically set this to something large just in case (e.g., 512 or 1024 or 2048).
38
+ layernorm_epsilon (`float`, *optional*, defaults to 1e-5):
39
+ The epsilon used by the layer normalization layers.
40
+ use_cache (`bool`, *optional*, defaults to `True`):
41
+ Whether the model should return the last key/values attentions (not used by all models).
42
+ Example:
43
+
44
+ ```python
45
+ >>> from configuration_chatglm import ChatGLMConfig
46
+ >>> from modeling_chatglm import ChatGLMModel
47
+
48
+ >>> # Initializing a ChatGLM-6B THUDM/ChatGLM-6B style configuration
49
+ >>> configuration = ChatGLMConfig()
50
+
51
+ >>> # Initializing a model from the THUDM/ChatGLM-6B style configuration
52
+ >>> model = ChatGLMModel(configuration)
53
+
54
+ >>> # Accessing the model configuration
55
+ >>> configuration = model.config
56
+ ```
57
+ """
58
+ model_type = "chatglm"
59
+
60
+ def __init__(
61
+ self,
62
+ vocab_size=130528,
63
+ hidden_size=4096,
64
+ num_layers=28,
65
+ num_attention_heads=32,
66
+ layernorm_epsilon=1e-5,
67
+ use_cache=False,
68
+ bos_token_id=130004,
69
+ eos_token_id=130005,
70
+ pad_token_id=0,
71
+ max_sequence_length=2048,
72
+ inner_hidden_size=16384,
73
+ position_encoding_2d=True,
74
+ quantization_bit=0,
75
+ pre_seq_len=None,
76
+ prefix_projection=False,
77
+ **kwargs
78
+ ):
79
+ self.num_layers = num_layers
80
+ self.vocab_size = vocab_size
81
+ self.hidden_size = hidden_size
82
+ self.num_attention_heads = num_attention_heads
83
+ self.max_sequence_length = max_sequence_length
84
+ self.layernorm_epsilon = layernorm_epsilon
85
+ self.inner_hidden_size = inner_hidden_size
86
+ self.use_cache = use_cache
87
+ self.bos_token_id = bos_token_id
88
+ self.eos_token_id = eos_token_id
89
+ self.pad_token_id = pad_token_id
90
+ self.position_encoding_2d = position_encoding_2d
91
+ self.quantization_bit = quantization_bit
92
+ self.pre_seq_len = pre_seq_len
93
+ self.prefix_projection = prefix_projection
94
+
95
+ super().__init__(
96
+ pad_token_id=pad_token_id,
97
+ bos_token_id=bos_token_id,
98
+ eos_token_id=eos_token_id,
99
+ **kwargs
100
+ )
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 130004,
4
+ "eos_token_id": 130005,
5
+ "pad_token_id": 3,
6
+ "transformers_version": "4.27.1"
7
+ }
ice_text.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99871e0c85db81ad7af1028854fd091cd5778c8414ae9d94bbbc10d02c831c21
3
+ size 2699926
modeling_chatglm.py ADDED
@@ -0,0 +1,1406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ PyTorch ChatGLM model. """
2
+
3
+ import math
4
+ import copy
5
+ import os
6
+ import warnings
7
+ import re
8
+ import sys
9
+
10
+ import torch
11
+ import torch.utils.checkpoint
12
+ import torch.nn.functional as F
13
+ from torch import nn
14
+ from torch.nn import CrossEntropyLoss, LayerNorm
15
+ from torch.nn.utils import skip_init
16
+ from typing import Optional, Tuple, Union, List, Callable, Dict, Any
17
+
18
+ from transformers.utils import (
19
+ add_code_sample_docstrings,
20
+ add_start_docstrings,
21
+ add_start_docstrings_to_model_forward,
22
+ )
23
+ from transformers.modeling_outputs import (
24
+ BaseModelOutputWithPast,
25
+ CausalLMOutputWithPast,
26
+ BaseModelOutputWithPastAndCrossAttentions,
27
+ )
28
+ from transformers.modeling_utils import PreTrainedModel
29
+ from transformers.utils import logging
30
+ from transformers.generation.logits_process import LogitsProcessor
31
+ from transformers.generation.utils import LogitsProcessorList, StoppingCriteriaList, GenerationConfig, ModelOutput
32
+
33
+ from .configuration_chatglm import ChatGLMConfig
34
+
35
+ # flags required to enable jit fusion kernels
36
+
37
+ if sys.platform != 'darwin':
38
+ torch._C._jit_set_profiling_mode(False)
39
+ torch._C._jit_set_profiling_executor(False)
40
+ torch._C._jit_override_can_fuse_on_cpu(True)
41
+ torch._C._jit_override_can_fuse_on_gpu(True)
42
+
43
+ logger = logging.get_logger(__name__)
44
+
45
+ _CHECKPOINT_FOR_DOC = "silver/ChatGLM-6B"
46
+ _CONFIG_FOR_DOC = "ChatGLM6BConfig"
47
+
48
+ CHATGLM_6B_PRETRAINED_MODEL_ARCHIVE_LIST = [
49
+ "silver/chatglm-6b-slim",
50
+ # See all ChatGLM-6B models at https://huggingface.co/models?filter=chatglm
51
+ # See the slim model at https://huggingface.co/silver/chatglm-6b-slim
52
+ ]
53
+
54
+
55
+ class InvalidScoreLogitsProcessor(LogitsProcessor):
56
+ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
57
+ if torch.isnan(scores).any() or torch.isinf(scores).any():
58
+ scores.zero_()
59
+ scores[..., 5] = 5e4
60
+ return scores
61
+
62
+
63
+ def load_tf_weights_in_chatglm_6b(model, config, tf_checkpoint_path):
64
+ """Load tf checkpoints in a pytorch model."""
65
+ try:
66
+ import re
67
+
68
+ import numpy as np
69
+ import tensorflow as tf
70
+ except ImportError:
71
+ logger.error(
72
+ "Loading a TensorFlow model in PyTorch, requires TensorFlow to be installed. Please see "
73
+ "https://www.tensorflow.org/install/ for installation instructions."
74
+ )
75
+ raise
76
+ tf_path = os.path.abspath(tf_checkpoint_path)
77
+ logger.info(f"Converting TensorFlow checkpoint from {tf_path}")
78
+ # Load weights from TF model
79
+ init_vars = tf.train.list_variables(tf_path)
80
+ names = []
81
+ arrays = []
82
+ for name, shape in init_vars:
83
+ logger.info(f"Loading TF weight {name} with shape {shape}")
84
+ array = tf.train.load_variable(tf_path, name)
85
+ names.append(name)
86
+ arrays.append(array)
87
+
88
+ for name, array in zip(names, arrays):
89
+ name = name.split("/")
90
+ # adam_v and adam_m are variables used in AdamWeightDecayOptimizer to calculated m and v
91
+ # which are not required for using pretrained model
92
+ if any(
93
+ n in ["adam_v", "adam_m", "AdamWeightDecayOptimizer", "AdamWeightDecayOptimizer_1", "global_step"]
94
+ for n in name
95
+ ):
96
+ logger.info(f"Skipping {'/'.join(name)}")
97
+ continue
98
+ pointer = model
99
+ for m_name in name:
100
+ if re.fullmatch(r"[A-Za-z]+_\d+", m_name):
101
+ scope_names = re.split(r"_(\d+)", m_name)
102
+ else:
103
+ scope_names = [m_name]
104
+ if scope_names[0] == "kernel" or scope_names[0] == "gamma":
105
+ pointer = getattr(pointer, "weight")
106
+ elif scope_names[0] == "output_bias" or scope_names[0] == "beta":
107
+ pointer = getattr(pointer, "bias")
108
+ elif scope_names[0] == "output_weights":
109
+ pointer = getattr(pointer, "weight")
110
+ elif scope_names[0] == "squad":
111
+ pointer = getattr(pointer, "classifier")
112
+ else:
113
+ try:
114
+ pointer = getattr(pointer, scope_names[0])
115
+ except AttributeError:
116
+ logger.info(f"Skipping {'/'.join(name)}")
117
+ continue
118
+ if len(scope_names) >= 2:
119
+ num = int(scope_names[1])
120
+ pointer = pointer[num]
121
+ if m_name[-11:] == "_embeddings":
122
+ pointer = getattr(pointer, "weight")
123
+ elif m_name == "kernel":
124
+ array = np.transpose(array)
125
+ try:
126
+ assert (
127
+ pointer.shape == array.shape
128
+ ), f"Pointer shape {pointer.shape} and array shape {array.shape} mismatched"
129
+ except AssertionError as e:
130
+ e.args += (pointer.shape, array.shape)
131
+ raise
132
+ logger.info(f"Initialize PyTorch weight {name}")
133
+ pointer.data = torch.from_numpy(array)
134
+ return model
135
+
136
+
137
+ class PrefixEncoder(torch.nn.Module):
138
+ """
139
+ The torch.nn model to encode the prefix
140
+ Input shape: (batch-size, prefix-length)
141
+ Output shape: (batch-size, prefix-length, 2*layers*hidden)
142
+ """
143
+
144
+ def __init__(self, config):
145
+ super().__init__()
146
+ self.prefix_projection = config.prefix_projection
147
+ if self.prefix_projection:
148
+ # Use a two-layer MLP to encode the prefix
149
+ self.embedding = torch.nn.Embedding(config.pre_seq_len, config.hidden_size)
150
+ self.trans = torch.nn.Sequential(
151
+ torch.nn.Linear(config.hidden_size, config.hidden_size),
152
+ torch.nn.Tanh(),
153
+ torch.nn.Linear(config.hidden_size, config.num_layers * config.hidden_size * 2)
154
+ )
155
+ else:
156
+ self.embedding = torch.nn.Embedding(config.pre_seq_len, config.num_layers * config.hidden_size * 2)
157
+
158
+ def forward(self, prefix: torch.Tensor):
159
+ if self.prefix_projection:
160
+ prefix_tokens = self.embedding(prefix)
161
+ past_key_values = self.trans(prefix_tokens)
162
+ else:
163
+ past_key_values = self.embedding(prefix)
164
+ return past_key_values
165
+
166
+
167
+ @torch.jit.script
168
+ def gelu_impl(x):
169
+ """OpenAI's gelu implementation."""
170
+ return 0.5 * x * (1.0 + torch.tanh(0.7978845608028654 * x *
171
+ (1.0 + 0.044715 * x * x)))
172
+
173
+
174
+ def gelu(x):
175
+ return gelu_impl(x)
176
+
177
+
178
+ class RotaryEmbedding(torch.nn.Module):
179
+ def __init__(self, dim, base=10000, precision=torch.half, learnable=False):
180
+ super().__init__()
181
+ inv_freq = 1. / (base ** (torch.arange(0, dim, 2).float() / dim))
182
+ inv_freq = inv_freq.half()
183
+ self.learnable = learnable
184
+ if learnable:
185
+ self.inv_freq = torch.nn.Parameter(inv_freq)
186
+ self.max_seq_len_cached = None
187
+ else:
188
+ self.register_buffer('inv_freq', inv_freq)
189
+ self.max_seq_len_cached = None
190
+ self.cos_cached = None
191
+ self.sin_cached = None
192
+ self.precision = precision
193
+
194
+ def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys,
195
+ error_msgs):
196
+ pass
197
+
198
+ def forward(self, x, seq_dim=1, seq_len=None):
199
+ if seq_len is None:
200
+ seq_len = x.shape[seq_dim]
201
+ if self.max_seq_len_cached is None or (seq_len > self.max_seq_len_cached):
202
+ self.max_seq_len_cached = None if self.learnable else seq_len
203
+ t = torch.arange(seq_len, device=x.device, dtype=self.inv_freq.dtype)
204
+ freqs = torch.einsum('i,j->ij', t, self.inv_freq)
205
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
206
+ emb = torch.cat((freqs, freqs), dim=-1).to(x.device)
207
+ if self.precision == torch.bfloat16:
208
+ emb = emb.float()
209
+
210
+ # [sx, 1 (b * np), hn]
211
+ cos_cached = emb.cos()[:, None, :]
212
+ sin_cached = emb.sin()[:, None, :]
213
+ if self.precision == torch.bfloat16:
214
+ cos_cached = cos_cached.bfloat16()
215
+ sin_cached = sin_cached.bfloat16()
216
+ if self.learnable:
217
+ return cos_cached, sin_cached
218
+ self.cos_cached, self.sin_cached = cos_cached, sin_cached
219
+ return self.cos_cached[:seq_len, ...], self.sin_cached[:seq_len, ...]
220
+
221
+ def _apply(self, fn):
222
+ if self.cos_cached is not None:
223
+ self.cos_cached = fn(self.cos_cached)
224
+ if self.sin_cached is not None:
225
+ self.sin_cached = fn(self.sin_cached)
226
+ return super()._apply(fn)
227
+
228
+
229
+ def rotate_half(x):
230
+ x1, x2 = x[..., :x.shape[-1] // 2], x[..., x.shape[-1] // 2:]
231
+ return torch.cat((-x2, x1), dim=x1.ndim - 1) # dim=-1 triggers a bug in earlier torch versions
232
+
233
+
234
+ @torch.jit.script
235
+ def apply_rotary_pos_emb_index(q, k, cos, sin, position_id):
236
+ # position_id: [sq, b], q, k: [sq, b, np, hn], cos: [sq, 1, hn] -> [sq, b, 1, hn]
237
+ cos, sin = F.embedding(position_id, cos.squeeze(1)).unsqueeze(2), \
238
+ F.embedding(position_id, sin.squeeze(1)).unsqueeze(2)
239
+ q, k = (q * cos) + (rotate_half(q) * sin), (k * cos) + (rotate_half(k) * sin)
240
+ return q, k
241
+
242
+
243
+ def attention_fn(
244
+ self,
245
+ query_layer,
246
+ key_layer,
247
+ value_layer,
248
+ attention_mask,
249
+ hidden_size_per_partition,
250
+ layer_id,
251
+ layer_past=None,
252
+ scaling_attention_score=True,
253
+ use_cache=False,
254
+ ):
255
+ if layer_past is not None:
256
+ past_key, past_value = layer_past[0], layer_past[1]
257
+ key_layer = torch.cat((past_key, key_layer), dim=0)
258
+ value_layer = torch.cat((past_value, value_layer), dim=0)
259
+
260
+ # seqlen, batch, num_attention_heads, hidden_size_per_attention_head
261
+ seq_len, b, nh, hidden_size = key_layer.shape
262
+
263
+ if use_cache:
264
+ present = (key_layer, value_layer)
265
+ else:
266
+ present = None
267
+
268
+ query_key_layer_scaling_coeff = float(layer_id + 1)
269
+ if scaling_attention_score:
270
+ query_layer = query_layer / (math.sqrt(hidden_size) * query_key_layer_scaling_coeff)
271
+
272
+ # ===================================
273
+ # Raw attention scores. [b, np, s, s]
274
+ # ===================================
275
+
276
+ # [b, np, sq, sk]
277
+ output_size = (query_layer.size(1), query_layer.size(2), query_layer.size(0), key_layer.size(0))
278
+
279
+ # [sq, b, np, hn] -> [sq, b * np, hn]
280
+ query_layer = query_layer.view(output_size[2], output_size[0] * output_size[1], -1)
281
+ # [sk, b, np, hn] -> [sk, b * np, hn]
282
+ key_layer = key_layer.view(output_size[3], output_size[0] * output_size[1], -1)
283
+
284
+ matmul_result = torch.empty(
285
+ output_size[0] * output_size[1],
286
+ output_size[2],
287
+ output_size[3],
288
+ dtype=query_layer.dtype,
289
+ device=query_layer.device,
290
+ )
291
+
292
+ matmul_result = torch.baddbmm(
293
+ matmul_result,
294
+ query_layer.transpose(0, 1), # [b * np, sq, hn]
295
+ key_layer.transpose(0, 1).transpose(1, 2), # [b * np, hn, sk]
296
+ beta=0.0,
297
+ alpha=1.0,
298
+ )
299
+
300
+ # change view to [b, np, sq, sk]
301
+ attention_scores = matmul_result.view(*output_size)
302
+
303
+ if self.scale_mask_softmax:
304
+ self.scale_mask_softmax.scale = query_key_layer_scaling_coeff
305
+ attention_probs = self.scale_mask_softmax(attention_scores, attention_mask.contiguous())
306
+ else:
307
+ if not (attention_mask == 0).all():
308
+ # if auto-regressive, skip
309
+ attention_scores.masked_fill_(attention_mask, -10000.0)
310
+ dtype = attention_scores.dtype
311
+ attention_scores = attention_scores.float()
312
+ attention_scores = attention_scores * query_key_layer_scaling_coeff
313
+
314
+ attention_probs = F.softmax(attention_scores, dim=-1)
315
+
316
+ attention_probs = attention_probs.type(dtype)
317
+
318
+ # =========================
319
+ # Context layer. [sq, b, hp]
320
+ # =========================
321
+
322
+ # value_layer -> context layer.
323
+ # [sk, b, np, hn] --> [b, np, sq, hn]
324
+
325
+ # context layer shape: [b, np, sq, hn]
326
+ output_size = (value_layer.size(1), value_layer.size(2), query_layer.size(0), value_layer.size(3))
327
+
328
+ # change view [sk, b * np, hn]
329
+ value_layer = value_layer.view(value_layer.size(0), output_size[0] * output_size[1], -1)
330
+
331
+ # change view [b * np, sq, sk]
332
+ attention_probs = attention_probs.view(output_size[0] * output_size[1], output_size[2], -1)
333
+
334
+ # matmul: [b * np, sq, hn]
335
+ context_layer = torch.bmm(attention_probs, value_layer.transpose(0, 1))
336
+
337
+ # change view [b, np, sq, hn]
338
+ context_layer = context_layer.view(*output_size)
339
+
340
+ # [b, np, sq, hn] --> [sq, b, np, hn]
341
+ context_layer = context_layer.permute(2, 0, 1, 3).contiguous()
342
+
343
+ # [sq, b, np, hn] --> [sq, b, hp]
344
+ new_context_layer_shape = context_layer.size()[:-2] + (hidden_size_per_partition,)
345
+ context_layer = context_layer.view(*new_context_layer_shape)
346
+
347
+ outputs = (context_layer, present, attention_probs)
348
+
349
+ return outputs
350
+
351
+
352
+ class SelfAttention(torch.nn.Module):
353
+ def __init__(self, hidden_size, num_attention_heads,
354
+ layer_id, hidden_size_per_attention_head=None, bias=True,
355
+ params_dtype=torch.float, position_encoding_2d=True):
356
+ super(SelfAttention, self).__init__()
357
+
358
+ self.layer_id = layer_id
359
+ self.hidden_size = hidden_size
360
+ self.hidden_size_per_partition = hidden_size
361
+ self.num_attention_heads = num_attention_heads
362
+ self.num_attention_heads_per_partition = num_attention_heads
363
+ self.position_encoding_2d = position_encoding_2d
364
+ self.rotary_emb = RotaryEmbedding(
365
+ self.hidden_size // (self.num_attention_heads * 2)
366
+ if position_encoding_2d
367
+ else self.hidden_size // self.num_attention_heads,
368
+ base=10000,
369
+ precision=torch.half,
370
+ learnable=False,
371
+ )
372
+
373
+ self.scale_mask_softmax = None
374
+
375
+ if hidden_size_per_attention_head is None:
376
+ self.hidden_size_per_attention_head = hidden_size // num_attention_heads
377
+ else:
378
+ self.hidden_size_per_attention_head = hidden_size_per_attention_head
379
+
380
+ self.inner_hidden_size = num_attention_heads * self.hidden_size_per_attention_head
381
+
382
+ # Strided linear layer.
383
+ self.query_key_value = skip_init(
384
+ torch.nn.Linear,
385
+ hidden_size,
386
+ 3 * self.inner_hidden_size,
387
+ bias=bias,
388
+ dtype=params_dtype,
389
+ )
390
+
391
+ self.dense = skip_init(
392
+ torch.nn.Linear,
393
+ self.inner_hidden_size,
394
+ hidden_size,
395
+ bias=bias,
396
+ dtype=params_dtype,
397
+ )
398
+
399
+ @staticmethod
400
+ def attention_mask_func(attention_scores, attention_mask):
401
+ attention_scores.masked_fill_(attention_mask, -10000.0)
402
+ return attention_scores
403
+
404
+ def split_tensor_along_last_dim(self, tensor, num_partitions,
405
+ contiguous_split_chunks=False):
406
+ """Split a tensor along its last dimension.
407
+ Arguments:
408
+ tensor: input tensor.
409
+ num_partitions: number of partitions to split the tensor
410
+ contiguous_split_chunks: If True, make each chunk contiguous
411
+ in memory.
412
+ """
413
+ # Get the size and dimension.
414
+ last_dim = tensor.dim() - 1
415
+ last_dim_size = tensor.size()[last_dim] // num_partitions
416
+ # Split.
417
+ tensor_list = torch.split(tensor, last_dim_size, dim=last_dim)
418
+ # Note: torch.split does not create contiguous tensors by default.
419
+ if contiguous_split_chunks:
420
+ return tuple(chunk.contiguous() for chunk in tensor_list)
421
+
422
+ return tensor_list
423
+
424
+ def forward(
425
+ self,
426
+ hidden_states: torch.Tensor,
427
+ position_ids,
428
+ attention_mask: torch.Tensor,
429
+ layer_id,
430
+ layer_past: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
431
+ use_cache: bool = False,
432
+ output_attentions: bool = False,
433
+ ):
434
+ """
435
+ hidden_states: [seq_len, batch, hidden_size]
436
+ attention_mask: [(1, 1), seq_len, seq_len]
437
+ """
438
+
439
+ # [seq_len, batch, 3 * hidden_size]
440
+ mixed_raw_layer = self.query_key_value(hidden_states)
441
+
442
+ # [seq_len, batch, 3 * hidden_size] --> [seq_len, batch, num_attention_heads, 3 * hidden_size_per_attention_head]
443
+ new_tensor_shape = mixed_raw_layer.size()[:-1] + (
444
+ self.num_attention_heads_per_partition,
445
+ 3 * self.hidden_size_per_attention_head,
446
+ )
447
+ mixed_raw_layer = mixed_raw_layer.view(*new_tensor_shape)
448
+
449
+ # [seq_len, batch, num_attention_heads, hidden_size_per_attention_head]
450
+ (query_layer, key_layer, value_layer) = self.split_tensor_along_last_dim(mixed_raw_layer, 3)
451
+
452
+ if self.position_encoding_2d:
453
+ q1, q2 = query_layer.chunk(2, dim=(query_layer.ndim - 1))
454
+ k1, k2 = key_layer.chunk(2, dim=(key_layer.ndim - 1))
455
+ cos, sin = self.rotary_emb(q1, seq_len=position_ids.max() + 1)
456
+ position_ids, block_position_ids = position_ids[:, 0, :].transpose(0, 1).contiguous(), \
457
+ position_ids[:, 1, :].transpose(0, 1).contiguous()
458
+ q1, k1 = apply_rotary_pos_emb_index(q1, k1, cos, sin, position_ids)
459
+ q2, k2 = apply_rotary_pos_emb_index(q2, k2, cos, sin, block_position_ids)
460
+ query_layer = torch.concat([q1, q2], dim=(q1.ndim - 1))
461
+ key_layer = torch.concat([k1, k2], dim=(k1.ndim - 1))
462
+ else:
463
+ position_ids = position_ids.transpose(0, 1)
464
+ cos, sin = self.rotary_emb(value_layer, seq_len=position_ids.max() + 1)
465
+ # [seq_len, batch, num_attention_heads, hidden_size_per_attention_head]
466
+ query_layer, key_layer = apply_rotary_pos_emb_index(query_layer, key_layer, cos, sin, position_ids)
467
+
468
+ # [seq_len, batch, hidden_size]
469
+ context_layer, present, attention_probs = attention_fn(
470
+ self=self,
471
+ query_layer=query_layer,
472
+ key_layer=key_layer,
473
+ value_layer=value_layer,
474
+ attention_mask=attention_mask,
475
+ hidden_size_per_partition=self.hidden_size_per_partition,
476
+ layer_id=layer_id,
477
+ layer_past=layer_past,
478
+ use_cache=use_cache
479
+ )
480
+
481
+ output = self.dense(context_layer)
482
+
483
+ outputs = (output, present)
484
+
485
+ if output_attentions:
486
+ outputs += (attention_probs,)
487
+
488
+ return outputs # output, present, attention_probs
489
+
490
+
491
+ class GEGLU(torch.nn.Module):
492
+ def __init__(self):
493
+ super().__init__()
494
+ self.activation_fn = F.gelu
495
+
496
+ def forward(self, x):
497
+ # dim=-1 breaks in jit for pt<1.10
498
+ x1, x2 = x.chunk(2, dim=(x.ndim - 1))
499
+ return x1 * self.activation_fn(x2)
500
+
501
+
502
+ class GLU(torch.nn.Module):
503
+ def __init__(self, hidden_size, inner_hidden_size=None,
504
+ layer_id=None, bias=True, activation_func=gelu, params_dtype=torch.float):
505
+ super(GLU, self).__init__()
506
+ self.layer_id = layer_id
507
+ self.activation_func = activation_func
508
+
509
+ # Project to 4h.
510
+ self.hidden_size = hidden_size
511
+ if inner_hidden_size is None:
512
+ inner_hidden_size = 4 * hidden_size
513
+ self.inner_hidden_size = inner_hidden_size
514
+ self.dense_h_to_4h = skip_init(
515
+ torch.nn.Linear,
516
+ self.hidden_size,
517
+ self.inner_hidden_size,
518
+ bias=bias,
519
+ dtype=params_dtype,
520
+ )
521
+ # Project back to h.
522
+ self.dense_4h_to_h = skip_init(
523
+ torch.nn.Linear,
524
+ self.inner_hidden_size,
525
+ self.hidden_size,
526
+ bias=bias,
527
+ dtype=params_dtype,
528
+ )
529
+
530
+ def forward(self, hidden_states):
531
+ """
532
+ hidden_states: [seq_len, batch, hidden_size]
533
+ """
534
+
535
+ # [seq_len, batch, inner_hidden_size]
536
+ intermediate_parallel = self.dense_h_to_4h(hidden_states)
537
+
538
+ intermediate_parallel = self.activation_func(intermediate_parallel)
539
+
540
+ output = self.dense_4h_to_h(intermediate_parallel)
541
+
542
+ return output
543
+
544
+
545
+ class GLMBlock(torch.nn.Module):
546
+ def __init__(
547
+ self,
548
+ hidden_size,
549
+ num_attention_heads,
550
+ layernorm_epsilon,
551
+ layer_id,
552
+ inner_hidden_size=None,
553
+ hidden_size_per_attention_head=None,
554
+ layernorm=LayerNorm,
555
+ use_bias=True,
556
+ params_dtype=torch.float,
557
+ num_layers=28,
558
+ position_encoding_2d=True
559
+ ):
560
+ super(GLMBlock, self).__init__()
561
+ # Set output layer initialization if not provided.
562
+
563
+ self.layer_id = layer_id
564
+
565
+ # Layernorm on the input data.
566
+ self.input_layernorm = layernorm(hidden_size, eps=layernorm_epsilon)
567
+
568
+ self.position_encoding_2d = position_encoding_2d
569
+
570
+ # Self attention.
571
+ self.attention = SelfAttention(
572
+ hidden_size,
573
+ num_attention_heads,
574
+ layer_id,
575
+ hidden_size_per_attention_head=hidden_size_per_attention_head,
576
+ bias=use_bias,
577
+ params_dtype=params_dtype,
578
+ position_encoding_2d=self.position_encoding_2d
579
+ )
580
+
581
+ # Layernorm on the input data.
582
+ self.post_attention_layernorm = layernorm(hidden_size, eps=layernorm_epsilon)
583
+
584
+ self.num_layers = num_layers
585
+
586
+ # GLU
587
+ self.mlp = GLU(
588
+ hidden_size,
589
+ inner_hidden_size=inner_hidden_size,
590
+ bias=use_bias,
591
+ layer_id=layer_id,
592
+ params_dtype=params_dtype,
593
+ )
594
+
595
+ def forward(
596
+ self,
597
+ hidden_states: torch.Tensor,
598
+ position_ids,
599
+ attention_mask: torch.Tensor,
600
+ layer_id,
601
+ layer_past: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
602
+ use_cache: bool = False,
603
+ output_attentions: bool = False,
604
+ ):
605
+ """
606
+ hidden_states: [seq_len, batch, hidden_size]
607
+ attention_mask: [(1, 1), seq_len, seq_len]
608
+ """
609
+
610
+ # Layer norm at the begining of the transformer layer.
611
+ # [seq_len, batch, hidden_size]
612
+ attention_input = self.input_layernorm(hidden_states)
613
+
614
+ # Self attention.
615
+ attention_outputs = self.attention(
616
+ attention_input,
617
+ position_ids,
618
+ attention_mask=attention_mask,
619
+ layer_id=layer_id,
620
+ layer_past=layer_past,
621
+ use_cache=use_cache,
622
+ output_attentions=output_attentions
623
+ )
624
+
625
+ attention_output = attention_outputs[0]
626
+
627
+ outputs = attention_outputs[1:]
628
+
629
+ # Residual connection.
630
+ alpha = (2 * self.num_layers) ** 0.5
631
+ hidden_states = attention_input * alpha + attention_output
632
+
633
+ mlp_input = self.post_attention_layernorm(hidden_states)
634
+
635
+ # MLP.
636
+ mlp_output = self.mlp(mlp_input)
637
+
638
+ # Second residual connection.
639
+ output = mlp_input * alpha + mlp_output
640
+
641
+ if use_cache:
642
+ outputs = (output,) + outputs
643
+ else:
644
+ outputs = (output,) + outputs[1:]
645
+
646
+ return outputs # hidden_states, present, attentions
647
+
648
+
649
+ class ChatGLMPreTrainedModel(PreTrainedModel):
650
+ """
651
+ An abstract class to handle weights initialization and
652
+ a simple interface for downloading and loading pretrained models.
653
+ """
654
+
655
+ is_parallelizable = False
656
+ supports_gradient_checkpointing = True
657
+ config_class = ChatGLMConfig
658
+ base_model_prefix = "transformer"
659
+ _no_split_modules = ["GLMBlock"]
660
+
661
+ def __init__(self, *inputs, **kwargs):
662
+ super().__init__(*inputs, **kwargs)
663
+
664
+ def _init_weights(self, module: nn.Module):
665
+ """Initialize the weights."""
666
+ return
667
+
668
+ def get_masks(self, input_ids, device):
669
+ batch_size, seq_length = input_ids.shape
670
+ context_lengths = [seq.tolist().index(self.config.bos_token_id) for seq in input_ids]
671
+ attention_mask = torch.ones((batch_size, seq_length, seq_length), device=device)
672
+ attention_mask.tril_()
673
+ for i, context_length in enumerate(context_lengths):
674
+ attention_mask[i, :, :context_length] = 1
675
+ attention_mask.unsqueeze_(1)
676
+ attention_mask = (attention_mask < 0.5).bool()
677
+
678
+ return attention_mask
679
+
680
+ def get_position_ids(self, input_ids, mask_positions, device, gmask=False):
681
+ batch_size, seq_length = input_ids.shape
682
+ context_lengths = [seq.tolist().index(self.config.bos_token_id) for seq in input_ids]
683
+ if self.position_encoding_2d:
684
+ position_ids = torch.arange(seq_length, dtype=torch.long, device=device).unsqueeze(0).repeat(batch_size, 1)
685
+ for i, context_length in enumerate(context_lengths):
686
+ position_ids[i, context_length:] = mask_positions[i]
687
+ block_position_ids = [torch.cat((
688
+ torch.zeros(context_length, dtype=torch.long, device=device),
689
+ torch.arange(seq_length - context_length, dtype=torch.long, device=device) + 1
690
+ )) for context_length in context_lengths]
691
+ block_position_ids = torch.stack(block_position_ids, dim=0)
692
+ position_ids = torch.stack((position_ids, block_position_ids), dim=1)
693
+ else:
694
+ position_ids = torch.arange(seq_length, dtype=torch.long, device=device).unsqueeze(0).repeat(batch_size, 1)
695
+ if not gmask:
696
+ for i, context_length in enumerate(context_lengths):
697
+ position_ids[context_length:] = mask_positions[i]
698
+
699
+ return position_ids
700
+
701
+ def _set_gradient_checkpointing(self, module, value=False):
702
+ if isinstance(module, ChatGLMModel):
703
+ module.gradient_checkpointing = value
704
+
705
+
706
+ CHATGLM_6B_START_DOCSTRING = r"""
707
+ This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class.
708
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general
709
+ usage and behavior.
710
+
711
+ Parameters:
712
+ config ([`~ChatGLM6BConfig`]): Model configuration class with all the parameters of the model.
713
+ Initializing with a config file does not load the weights associated with the model, only the configuration.
714
+ Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
715
+ """
716
+
717
+ CHATGLM_6B_INPUTS_DOCSTRING = r"""
718
+ Args:
719
+ input_ids (`torch.LongTensor` of shape `({0})`):
720
+ Indices of input sequence tokens in the vocabulary.
721
+
722
+ Indices can be obtained using [`ChatGLM6BTokenizer`].
723
+ See [`PreTrainedTokenizer.encode`] and
724
+ [`PreTrainedTokenizer.__call__`] for details.
725
+
726
+ [What are input IDs?](../glossary#input-ids)
727
+ attention_mask (`torch.FloatTensor` of shape `({0})`, *optional*):
728
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
729
+
730
+ - 1 for tokens that are **not masked**,
731
+ - 0 for tokens that are **masked**.
732
+
733
+ [What are attention masks?](../glossary#attention-mask)
734
+ token_type_ids (`torch.LongTensor` of shape `({0})`, *optional*):
735
+ Segment token indices to indicate first and second portions of the inputs. Indices are selected in `[0, 1]`:
736
+
737
+ - 0 corresponds to a *sentence A* token,
738
+ - 1 corresponds to a *sentence B* token.
739
+
740
+ [What are token type IDs?](../glossary#token-type-ids)
741
+ position_ids (`torch.LongTensor` of shape `({0})`, *optional*):
742
+ Indices of positions of each input sequence tokens in the position embeddings.
743
+ Selected in the range `[0, config.max_position_embeddings - 1]`.
744
+
745
+ [What are position IDs?](../glossary#position-ids)
746
+ head_mask (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
747
+ Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:
748
+
749
+ - 1 indicates the head is **not masked**,
750
+ - 0 indicates the head is **masked**.
751
+
752
+ inputs_embeds (`torch.FloatTensor` of shape `({0}, hidden_size)`, *optional*):
753
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation.
754
+ This is useful if you want more control over how to convert *input_ids* indices into associated vectors
755
+ than the model's internal embedding lookup matrix.
756
+ output_attentions (`bool`, *optional*):
757
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
758
+ tensors for more detail.
759
+ output_hidden_states (`bool`, *optional*):
760
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
761
+ more detail.
762
+ return_dict (`bool`, *optional*):
763
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
764
+ """
765
+
766
+
767
+ @add_start_docstrings(
768
+ "The bare ChatGLM-6B Model transformer outputting raw hidden-states without any specific head on top.",
769
+ CHATGLM_6B_START_DOCSTRING,
770
+ )
771
+ class ChatGLMModel(ChatGLMPreTrainedModel):
772
+ """
773
+
774
+ The model can behave as an encoder (with only self-attention) as well
775
+ as a decoder, in which case a layer of cross-attention is added between
776
+ the self-attention layers, following the architecture described in [Attention is
777
+ all you need](https://arxiv.org/abs/1706.03762) by Ashish Vaswani,
778
+ Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.
779
+
780
+ To behave as an decoder the model needs to be initialized with the
781
+ `is_decoder` argument of the configuration set to `True`.
782
+ To be used in a Seq2Seq model, the model needs to initialized with both `is_decoder`
783
+ argument and `add_cross_attention` set to `True`; an
784
+ `encoder_hidden_states` is then expected as an input to the forward pass.
785
+ """
786
+
787
+ def __init__(self, config: ChatGLMConfig):
788
+ super().__init__(config)
789
+
790
+ # recording parameters
791
+ self.max_sequence_length = config.max_sequence_length
792
+ self.hidden_size = config.hidden_size
793
+ self.params_dtype = torch.half
794
+ self.num_attention_heads = config.num_attention_heads
795
+ self.vocab_size = config.vocab_size
796
+ self.num_layers = config.num_layers
797
+ self.layernorm_epsilon = config.layernorm_epsilon
798
+ self.inner_hidden_size = config.inner_hidden_size
799
+ self.hidden_size_per_attention_head = self.hidden_size // self.num_attention_heads
800
+ self.position_encoding_2d = config.position_encoding_2d
801
+ self.pre_seq_len = config.pre_seq_len
802
+ self.prefix_projection = config.prefix_projection
803
+
804
+ self.word_embeddings = skip_init(
805
+ torch.nn.Embedding,
806
+ num_embeddings=self.vocab_size, embedding_dim=self.hidden_size,
807
+ dtype=self.params_dtype
808
+ )
809
+ self.gradient_checkpointing = False
810
+
811
+ def get_layer(layer_id):
812
+ return GLMBlock(
813
+ self.hidden_size,
814
+ self.num_attention_heads,
815
+ self.layernorm_epsilon,
816
+ layer_id,
817
+ inner_hidden_size=self.inner_hidden_size,
818
+ hidden_size_per_attention_head=self.hidden_size_per_attention_head,
819
+ layernorm=LayerNorm,
820
+ use_bias=True,
821
+ params_dtype=self.params_dtype,
822
+ position_encoding_2d=self.position_encoding_2d,
823
+ )
824
+
825
+ self.layers = torch.nn.ModuleList(
826
+ [get_layer(layer_id) for layer_id in range(self.num_layers)]
827
+ )
828
+
829
+ # Final layer norm before output.
830
+ self.final_layernorm = LayerNorm(self.hidden_size, eps=self.layernorm_epsilon)
831
+
832
+ if self.pre_seq_len is not None:
833
+ for param in self.parameters():
834
+ param.requires_grad = False
835
+ self.prefix_tokens = torch.arange(self.pre_seq_len).long()
836
+ self.prefix_encoder = PrefixEncoder(config)
837
+ self.dropout = torch.nn.Dropout(0.1)
838
+
839
+ # total_params = sum(p.numel() for p in self.parameters())
840
+ # trainable_params = sum(p.numel() for p in self.parameters() if p.requires_grad)
841
+ # print("Using p-tuning v2: # trainable_params = {} / {}".format(trainable_params, total_params))
842
+
843
+ def get_input_embeddings(self):
844
+ return self.word_embeddings
845
+
846
+ def set_input_embeddings(self, new_embeddings: torch.Tensor):
847
+ self.word_embeddings = new_embeddings
848
+
849
+ def get_prompt(self, batch_size, device, dtype=torch.half):
850
+ prefix_tokens = self.prefix_tokens.unsqueeze(0).expand(batch_size, -1).to(device)
851
+ past_key_values = self.prefix_encoder(prefix_tokens).type(dtype)
852
+ past_key_values = past_key_values.view(
853
+ batch_size,
854
+ self.pre_seq_len,
855
+ self.num_layers * 2,
856
+ self.num_attention_heads,
857
+ self.hidden_size // self.num_attention_heads
858
+ )
859
+ # seq_len, b, nh, hidden_size
860
+ past_key_values = self.dropout(past_key_values)
861
+ past_key_values = past_key_values.permute([2, 1, 0, 3, 4]).split(2)
862
+ # past_key_values = [(v[0], v[1]) for v in past_key_values]
863
+ return past_key_values
864
+
865
+ @add_start_docstrings_to_model_forward(CHATGLM_6B_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
866
+ @add_code_sample_docstrings(
867
+ checkpoint=_CHECKPOINT_FOR_DOC,
868
+ output_type=BaseModelOutputWithPastAndCrossAttentions,
869
+ config_class=_CONFIG_FOR_DOC,
870
+ )
871
+ def forward(
872
+ self,
873
+ input_ids: Optional[torch.LongTensor] = None,
874
+ position_ids: Optional[torch.LongTensor] = None,
875
+ attention_mask: Optional[torch.Tensor] = None,
876
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
877
+ inputs_embeds: Optional[torch.LongTensor] = None,
878
+ use_cache: Optional[bool] = None,
879
+ output_attentions: Optional[bool] = None,
880
+ output_hidden_states: Optional[bool] = None,
881
+ return_dict: Optional[bool] = None,
882
+ ) -> Union[Tuple[torch.Tensor, ...], BaseModelOutputWithPast]:
883
+
884
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
885
+ output_hidden_states = (
886
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
887
+ )
888
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
889
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
890
+
891
+ if self.gradient_checkpointing and self.training:
892
+ if use_cache:
893
+ logger.warning_once(
894
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
895
+ )
896
+ use_cache = False
897
+
898
+ if input_ids is not None and inputs_embeds is not None:
899
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
900
+ elif input_ids is not None:
901
+ batch_size, seq_length = input_ids.shape[:2]
902
+ elif inputs_embeds is not None:
903
+ batch_size, seq_length, _ = inputs_embeds.shape[:2]
904
+ else:
905
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
906
+
907
+ if inputs_embeds is None:
908
+ inputs_embeds = self.word_embeddings(input_ids)
909
+
910
+ if past_key_values is None:
911
+ if self.pre_seq_len is not None:
912
+ past_key_values = self.get_prompt(batch_size=input_ids.shape[0], device=input_ids.device,
913
+ dtype=inputs_embeds.dtype)
914
+ else:
915
+ past_key_values = tuple([None] * len(self.layers))
916
+
917
+ if attention_mask is None:
918
+ attention_mask = self.get_masks(
919
+ input_ids,
920
+ device=input_ids.device
921
+ )
922
+
923
+
924
+ if position_ids is None:
925
+ MASK, gMASK = 130000, 130001
926
+ mask_token = MASK if MASK in input_ids else gMASK
927
+ use_gmask = False if MASK in input_ids else gMASK
928
+
929
+ mask_positions = [seq.tolist().index(mask_token) for seq in input_ids]
930
+ position_ids = self.get_position_ids(
931
+ input_ids,
932
+ mask_positions=mask_positions,
933
+ device=input_ids.device,
934
+ gmask=use_gmask
935
+ )
936
+
937
+ if self.pre_seq_len is not None and attention_mask is not None:
938
+ prefix_attention_mask = torch.ones(batch_size, 1, input_ids.size(-1), self.pre_seq_len).to(
939
+ attention_mask.device)
940
+ prefix_attention_mask = (prefix_attention_mask < 0.5).bool()
941
+ attention_mask = torch.cat((prefix_attention_mask, attention_mask), dim=3)
942
+
943
+ # [seq_len, batch, hidden_size]
944
+ hidden_states = inputs_embeds.transpose(0, 1)
945
+
946
+ presents = () if use_cache else None
947
+ all_self_attentions = () if output_attentions else None
948
+ all_hidden_states = () if output_hidden_states else None
949
+
950
+ if attention_mask is None:
951
+ attention_mask = torch.zeros(1, 1, device=input_ids.device).bool()
952
+
953
+ else:
954
+ attention_mask = attention_mask.to(input_ids.device)
955
+
956
+ for i, layer in enumerate(self.layers):
957
+
958
+ if output_hidden_states:
959
+ all_hidden_states = all_hidden_states + (hidden_states,)
960
+ layer_past = past_key_values[i]
961
+
962
+ if self.gradient_checkpointing and self.training:
963
+ layer_ret = torch.utils.checkpoint.checkpoint(
964
+ layer,
965
+ hidden_states,
966
+ position_ids,
967
+ attention_mask,
968
+ torch.tensor(i),
969
+ layer_past,
970
+ use_cache,
971
+ output_attentions
972
+ )
973
+ else:
974
+ layer_ret = layer(
975
+ hidden_states,
976
+ position_ids=position_ids,
977
+ attention_mask=attention_mask,
978
+ layer_id=torch.tensor(i),
979
+ layer_past=layer_past,
980
+ use_cache=use_cache,
981
+ output_attentions=output_attentions
982
+ )
983
+
984
+ hidden_states = layer_ret[0]
985
+
986
+ if use_cache:
987
+ presents = presents + (layer_ret[1],)
988
+
989
+ if output_attentions:
990
+ all_self_attentions = all_self_attentions + (layer_ret[2 if use_cache else 1],)
991
+
992
+ # Final layer norm.
993
+ hidden_states = self.final_layernorm(hidden_states)
994
+
995
+ if output_hidden_states:
996
+ all_hidden_states = all_hidden_states + (hidden_states,)
997
+
998
+ if not return_dict:
999
+ return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions] if v is not None)
1000
+
1001
+ return BaseModelOutputWithPast(
1002
+ last_hidden_state=hidden_states,
1003
+ past_key_values=presents,
1004
+ hidden_states=all_hidden_states,
1005
+ attentions=all_self_attentions,
1006
+ )
1007
+
1008
+
1009
+ class ChatGLMForConditionalGeneration(ChatGLMPreTrainedModel):
1010
+ def __init__(self, config: ChatGLMConfig):
1011
+ super().__init__(config)
1012
+
1013
+ # self.hidden_size = config.hidden_size
1014
+ # self.params_dtype = torch.half
1015
+ # self.vocab_size = config.vocab_size
1016
+ self.max_sequence_length = config.max_sequence_length
1017
+
1018
+ self.position_encoding_2d = config.position_encoding_2d
1019
+
1020
+ self.transformer = ChatGLMModel(config)
1021
+
1022
+ self.lm_head = skip_init(
1023
+ nn.Linear,
1024
+ config.hidden_size,
1025
+ config.vocab_size,
1026
+ bias=False,
1027
+ dtype=torch.half
1028
+ )
1029
+
1030
+ self.config = config
1031
+
1032
+ self.quantized = False
1033
+
1034
+ if self.config.quantization_bit:
1035
+ self.quantize(self.config.quantization_bit, empty_init=True)
1036
+
1037
+ def get_output_embeddings(self):
1038
+ return self.lm_head
1039
+
1040
+ def set_output_embeddings(self, new_embeddings):
1041
+ self.lm_head = new_embeddings
1042
+
1043
+ def _update_model_kwargs_for_generation(
1044
+ self,
1045
+ outputs: ModelOutput,
1046
+ model_kwargs: Dict[str, Any],
1047
+ is_encoder_decoder: bool = False,
1048
+ standardize_cache_format: bool = False,
1049
+ ) -> Dict[str, Any]:
1050
+ # update past_key_values
1051
+ model_kwargs["past_key_values"] = self._extract_past_from_model_output(
1052
+ outputs, standardize_cache_format=standardize_cache_format
1053
+ )
1054
+
1055
+ # update attention mask
1056
+ if "attention_mask" in model_kwargs:
1057
+ attention_mask = model_kwargs["attention_mask"]
1058
+ if attention_mask is not None and attention_mask.dtype == torch.bool:
1059
+ attention_mask = torch.cat(
1060
+ [attention_mask, attention_mask.new_ones((*attention_mask.shape[:3], 1))], dim=3)
1061
+ new_attention_mask = attention_mask[:, :, -1:].clone()
1062
+ new_attention_mask[..., -1] = False
1063
+ model_kwargs["attention_mask"] = torch.cat(
1064
+ [attention_mask, new_attention_mask], dim=2
1065
+ )
1066
+
1067
+ # update position ids
1068
+ if "position_ids" in model_kwargs:
1069
+ position_ids = model_kwargs["position_ids"]
1070
+ new_position_id = position_ids[..., -1:].clone()
1071
+ new_position_id[:, 1, :] += 1
1072
+ model_kwargs["position_ids"] = torch.cat(
1073
+ [position_ids, new_position_id], dim=-1
1074
+ )
1075
+
1076
+ return model_kwargs
1077
+
1078
+ def prepare_inputs_for_generation(
1079
+ self,
1080
+ input_ids: torch.LongTensor,
1081
+ past: Optional[torch.Tensor] = None,
1082
+ past_key_values: Optional[torch.Tensor] = None,
1083
+ attention_mask: Optional[torch.Tensor] = None,
1084
+ position_ids: Optional[torch.Tensor] = None,
1085
+ **kwargs
1086
+ ) -> dict:
1087
+ batch_size, seq_length = input_ids.shape
1088
+ MASK, gMASK = 130000, 130001
1089
+ mask_token = MASK if MASK in input_ids else gMASK
1090
+ use_gmask = False if MASK in input_ids else gMASK
1091
+ seqs = input_ids.tolist()
1092
+ mask_positions = [seq.index(mask_token) for seq in seqs]
1093
+
1094
+ # only last token for input_ids if past is not None
1095
+ if past is not None or past_key_values is not None:
1096
+ last_token = input_ids[:, -1].unsqueeze(-1)
1097
+ if attention_mask is not None and attention_mask.dtype == torch.bool:
1098
+ attention_mask = attention_mask[:, :, -1:]
1099
+ else:
1100
+ attention_mask = None
1101
+ if position_ids is not None:
1102
+ position_ids = position_ids[..., -1:]
1103
+ else:
1104
+ context_lengths = [seq.index(self.config.bos_token_id) for seq in seqs]
1105
+ if self.position_encoding_2d:
1106
+ position_ids = torch.tensor(
1107
+ [[mask_position, seq_length - context_length] for mask_position, context_length in
1108
+ zip(mask_positions, context_lengths)], dtype=torch.long, device=input_ids.device).unsqueeze(-1)
1109
+ else:
1110
+ position_ids = torch.tensor([mask_position for mask_position in mask_positions], dtype=torch.long,
1111
+ device=input_ids.device).unsqueeze(-1)
1112
+
1113
+ if past is None:
1114
+ past = past_key_values
1115
+ return {
1116
+ "input_ids": last_token,
1117
+ "past_key_values": past,
1118
+ "position_ids": position_ids,
1119
+ "attention_mask": attention_mask
1120
+ }
1121
+ else:
1122
+ if attention_mask is not None and attention_mask.dtype != torch.bool:
1123
+ logger.warning_once(f"The dtype of attention mask ({attention_mask.dtype}) is not bool")
1124
+ attention_mask = None
1125
+ if attention_mask is None:
1126
+ attention_mask = self.get_masks(
1127
+ input_ids,
1128
+ device=input_ids.device
1129
+ )
1130
+ if position_ids is None:
1131
+ position_ids = self.get_position_ids(
1132
+ input_ids,
1133
+ device=input_ids.device,
1134
+ mask_positions=mask_positions,
1135
+ gmask=use_gmask
1136
+ )
1137
+
1138
+ return {
1139
+ "input_ids": input_ids,
1140
+ "past_key_values": past,
1141
+ "position_ids": position_ids,
1142
+ "attention_mask": attention_mask
1143
+ }
1144
+
1145
+ def forward(
1146
+ self,
1147
+ input_ids: Optional[torch.Tensor] = None,
1148
+ position_ids: Optional[torch.Tensor] = None,
1149
+ attention_mask: Optional[torch.Tensor] = None,
1150
+ past_key_values: Optional[Tuple[torch.FloatTensor]] = None,
1151
+ inputs_embeds: Optional[torch.Tensor] = None,
1152
+ labels: Optional[torch.Tensor] = None,
1153
+ use_cache: Optional[bool] = None,
1154
+ output_attentions: Optional[bool] = None,
1155
+ output_hidden_states: Optional[bool] = None,
1156
+ return_dict: Optional[bool] = None,
1157
+ ):
1158
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
1159
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1160
+
1161
+ transformer_outputs = self.transformer(
1162
+ input_ids=input_ids,
1163
+ position_ids=position_ids,
1164
+ attention_mask=attention_mask,
1165
+ past_key_values=past_key_values,
1166
+ inputs_embeds=inputs_embeds,
1167
+ use_cache=use_cache,
1168
+ output_attentions=output_attentions,
1169
+ output_hidden_states=output_hidden_states,
1170
+ return_dict=return_dict,
1171
+ )
1172
+
1173
+ hidden_states = transformer_outputs[0]
1174
+
1175
+ lm_logits = self.lm_head(hidden_states).permute(1, 0, 2).contiguous()
1176
+
1177
+ loss = None
1178
+ if labels is not None:
1179
+ lm_logits = lm_logits.to(torch.float32)
1180
+
1181
+ # Shift so that tokens < n predict n
1182
+ shift_logits = lm_logits[..., :-1, :].contiguous()
1183
+ shift_labels = labels[..., 1:].contiguous()
1184
+ # Flatten the tokens
1185
+ loss_fct = CrossEntropyLoss(ignore_index=-100)
1186
+ loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
1187
+
1188
+ lm_logits = lm_logits.to(hidden_states.dtype)
1189
+ loss = loss.to(hidden_states.dtype)
1190
+
1191
+ if not return_dict:
1192
+ output = (lm_logits,) + transformer_outputs[1:]
1193
+ return ((loss,) + output) if loss is not None else output
1194
+
1195
+ return CausalLMOutputWithPast(
1196
+ loss=loss,
1197
+ logits=lm_logits,
1198
+ past_key_values=transformer_outputs.past_key_values,
1199
+ hidden_states=transformer_outputs.hidden_states,
1200
+ attentions=transformer_outputs.attentions,
1201
+ )
1202
+
1203
+ @staticmethod
1204
+ def _reorder_cache(
1205
+ past: Tuple[Tuple[torch.Tensor, torch.Tensor], ...], beam_idx: torch.LongTensor
1206
+ ) -> Tuple[Tuple[torch.Tensor, torch.Tensor], ...]:
1207
+ """
1208
+ This function is used to re-order the `past_key_values` cache if [`~PreTrainedModel.beam_search`] or
1209
+ [`~PreTrainedModel.beam_sample`] is called. This is required to match `past_key_values` with the correct
1210
+ beam_idx at every generation step.
1211
+
1212
+ Output shares the same memory storage as `past`.
1213
+ """
1214
+ return tuple(
1215
+ (
1216
+ layer_past[0].index_select(1, beam_idx.to(layer_past[0].device)),
1217
+ layer_past[1].index_select(1, beam_idx.to(layer_past[1].device)),
1218
+ )
1219
+ for layer_past in past
1220
+ )
1221
+
1222
+ def process_response(self, response):
1223
+ response = response.strip()
1224
+ response = response.replace("[[训练时间]]", "2023年")
1225
+ punkts = [
1226
+ [",", ","],
1227
+ ["!", "!"],
1228
+ [":", ":"],
1229
+ [";", ";"],
1230
+ ["\?", "?"],
1231
+ ]
1232
+ for item in punkts:
1233
+ response = re.sub(r"([\u4e00-\u9fff])%s" % item[0], r"\1%s" % item[1], response)
1234
+ response = re.sub(r"%s([\u4e00-\u9fff])" % item[0], r"%s\1" % item[1], response)
1235
+ return response
1236
+
1237
+ @torch.no_grad()
1238
+ def chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, max_length: int = 2048, num_beams=1,
1239
+ do_sample=True, top_p=0.7, temperature=0.95, logits_processor=None, **kwargs):
1240
+ if history is None:
1241
+ history = []
1242
+ if logits_processor is None:
1243
+ logits_processor = LogitsProcessorList()
1244
+ logits_processor.append(InvalidScoreLogitsProcessor())
1245
+ gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p,
1246
+ "temperature": temperature, "logits_processor": logits_processor, **kwargs}
1247
+ if not history:
1248
+ prompt = query
1249
+ else:
1250
+ prompt = ""
1251
+ for i, (old_query, response) in enumerate(history):
1252
+ prompt += "[Round {}]\n问:{}\n答:{}\n".format(i, old_query, response)
1253
+ prompt += "[Round {}]\n问:{}\n答:".format(len(history), query)
1254
+ inputs = tokenizer([prompt], return_tensors="pt")
1255
+ inputs = inputs.to(self.device)
1256
+ outputs = self.generate(**inputs, **gen_kwargs)
1257
+ outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
1258
+ response = tokenizer.decode(outputs)
1259
+ response = self.process_response(response)
1260
+ history = history + [(query, response)]
1261
+ return response, history
1262
+
1263
+ @torch.no_grad()
1264
+ def stream_chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, max_length: int = 2048,
1265
+ do_sample=True, top_p=0.7, temperature=0.95, logits_processor=None, **kwargs):
1266
+ if history is None:
1267
+ history = []
1268
+ if logits_processor is None:
1269
+ logits_processor = LogitsProcessorList()
1270
+ logits_processor.append(InvalidScoreLogitsProcessor())
1271
+ gen_kwargs = {"max_length": max_length, "do_sample": do_sample, "top_p": top_p,
1272
+ "temperature": temperature, "logits_processor": logits_processor, **kwargs}
1273
+ if not history:
1274
+ prompt = query
1275
+ else:
1276
+ prompt = ""
1277
+ for i, (old_query, response) in enumerate(history):
1278
+ prompt += "[Round {}]\n问:{}\n答:{}\n".format(i, old_query, response)
1279
+ prompt += "[Round {}]\n问:{}\n答:".format(len(history), query)
1280
+ inputs = tokenizer([prompt], return_tensors="pt")
1281
+ inputs = inputs.to(self.device)
1282
+ for outputs in self.stream_generate(**inputs, **gen_kwargs):
1283
+ outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
1284
+ response = tokenizer.decode(outputs)
1285
+ response = self.process_response(response)
1286
+ new_history = history + [(query, response)]
1287
+ yield response, new_history
1288
+
1289
+ @torch.no_grad()
1290
+ def stream_generate(
1291
+ self,
1292
+ input_ids,
1293
+ generation_config: Optional[GenerationConfig] = None,
1294
+ logits_processor: Optional[LogitsProcessorList] = None,
1295
+ stopping_criteria: Optional[StoppingCriteriaList] = None,
1296
+ prefix_allowed_tokens_fn: Optional[Callable[[int, torch.Tensor], List[int]]] = None,
1297
+ **kwargs,
1298
+ ):
1299
+ batch_size, input_ids_seq_length = input_ids.shape[0], input_ids.shape[-1]
1300
+
1301
+ if generation_config is None:
1302
+ generation_config = self.generation_config
1303
+ generation_config = copy.deepcopy(generation_config)
1304
+ model_kwargs = generation_config.update(**kwargs)
1305
+ bos_token_id, eos_token_id = generation_config.bos_token_id, generation_config.eos_token_id
1306
+
1307
+ if isinstance(eos_token_id, int):
1308
+ eos_token_id = [eos_token_id]
1309
+
1310
+ has_default_max_length = kwargs.get("max_length") is None and generation_config.max_length is not None
1311
+ if has_default_max_length and generation_config.max_new_tokens is None:
1312
+ warnings.warn(
1313
+ f"Using `max_length`'s default ({generation_config.max_length}) to control the generation length. "
1314
+ "This behaviour is deprecated and will be removed from the config in v5 of Transformers -- we"
1315
+ " recommend using `max_new_tokens` to control the maximum length of the generation.",
1316
+ UserWarning,
1317
+ )
1318
+ elif generation_config.max_new_tokens is not None:
1319
+ generation_config.max_length = generation_config.max_new_tokens + input_ids_seq_length
1320
+ if not has_default_max_length:
1321
+ logger.warn(
1322
+ f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(="
1323
+ f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "
1324
+ "Please refer to the documentation for more information. "
1325
+ "(https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)",
1326
+ UserWarning,
1327
+ )
1328
+
1329
+ if input_ids_seq_length >= generation_config.max_length:
1330
+ input_ids_string = "decoder_input_ids" if self.config.is_encoder_decoder else "input_ids"
1331
+ logger.warning(
1332
+ f"Input length of {input_ids_string} is {input_ids_seq_length}, but `max_length` is set to"
1333
+ f" {generation_config.max_length}. This can lead to unexpected behavior. You should consider"
1334
+ " increasing `max_new_tokens`."
1335
+ )
1336
+
1337
+ # 2. Set generation parameters if not already defined
1338
+ logits_processor = logits_processor if logits_processor is not None else LogitsProcessorList()
1339
+ stopping_criteria = stopping_criteria if stopping_criteria is not None else StoppingCriteriaList()
1340
+
1341
+ logits_processor = self._get_logits_processor(
1342
+ generation_config=generation_config,
1343
+ input_ids_seq_length=input_ids_seq_length,
1344
+ encoder_input_ids=input_ids,
1345
+ prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,
1346
+ logits_processor=logits_processor,
1347
+ )
1348
+
1349
+ stopping_criteria = self._get_stopping_criteria(
1350
+ generation_config=generation_config, stopping_criteria=stopping_criteria
1351
+ )
1352
+ logits_warper = self._get_logits_warper(generation_config)
1353
+
1354
+ unfinished_sequences = input_ids.new(input_ids.shape[0]).fill_(1)
1355
+ scores = None
1356
+ while True:
1357
+ model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
1358
+ # forward pass to get next token
1359
+ outputs = self(
1360
+ **model_inputs,
1361
+ return_dict=True,
1362
+ output_attentions=False,
1363
+ output_hidden_states=False,
1364
+ )
1365
+
1366
+ next_token_logits = outputs.logits[:, -1, :]
1367
+
1368
+ # pre-process distribution
1369
+ next_token_scores = logits_processor(input_ids, next_token_logits)
1370
+ next_token_scores = logits_warper(input_ids, next_token_scores)
1371
+
1372
+ # sample
1373
+ probs = nn.functional.softmax(next_token_scores, dim=-1)
1374
+ if generation_config.do_sample:
1375
+ next_tokens = torch.multinomial(probs, num_samples=1).squeeze(1)
1376
+ else:
1377
+ next_tokens = torch.argmax(probs, dim=-1)
1378
+
1379
+ # update generated ids, model inputs, and length for next step
1380
+ input_ids = torch.cat([input_ids, next_tokens[:, None]], dim=-1)
1381
+ model_kwargs = self._update_model_kwargs_for_generation(
1382
+ outputs, model_kwargs, is_encoder_decoder=self.config.is_encoder_decoder
1383
+ )
1384
+ unfinished_sequences = unfinished_sequences.mul((sum(next_tokens != i for i in eos_token_id)).long())
1385
+
1386
+ # stop when each sentence is finished, or if we exceed the maximum length
1387
+ if unfinished_sequences.max() == 0 or stopping_criteria(input_ids, scores):
1388
+ break
1389
+ yield input_ids
1390
+
1391
+ def quantize(self, bits: int, empty_init=False, **kwargs):
1392
+ if bits == 0:
1393
+ return
1394
+
1395
+ from .quantization import quantize
1396
+
1397
+ if self.quantized:
1398
+ logger.info("Already quantized.")
1399
+ return self
1400
+
1401
+ self.quantized = True
1402
+
1403
+ self.config.quantization_bit = bits
1404
+
1405
+ self.transformer = quantize(self.transformer, bits, empty_init=empty_init, **kwargs)
1406
+ return self
optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec688fe5ecf20587f9e8ad2c1af552fd19872c1f077073cf428dd49d74d6c1ad
3
+ size 134
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d043ef7609416a4b52624ca09449dc4925ad776fbe1e40db2c5ca482fb55655
3
+ size 134
quantization.py ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from torch.nn import Linear
2
+ from torch.nn.parameter import Parameter
3
+
4
+ import bz2
5
+ import torch
6
+ import base64
7
+ import ctypes
8
+ from transformers.utils import logging
9
+
10
+ from typing import List
11
+ from functools import partial
12
+
13
+ logger = logging.get_logger(__name__)
14
+
15
+ try:
16
+ from cpm_kernels.kernels.base import LazyKernelCModule, KernelFunction, round_up
17
+
18
+ class Kernel:
19
+ def __init__(self, code: bytes, function_names: List[str]):
20
+ self.code = code
21
+ self._function_names = function_names
22
+ self._cmodule = LazyKernelCModule(self.code)
23
+
24
+ for name in self._function_names:
25
+ setattr(self, name, KernelFunction(self._cmodule, name))
26
+
27
+ quantization_code = "$QlpoOTFBWSZTWU9yuJUAQHN//////////f/n/8/n///n//bt4dTidcVx8X3V9FV/92/v4B7/AD5FBQFAAAChSgKpFCFAFVSigUAAAEKhSgUUqgFBKigqVREQAABQBQIANDTTIGI00BkZBkNGE0A0BkBkGQGRkaNAaAGQNBoGgDIAAYIGTI0DQAQAaGmmQMRpoDIyDIaMJoBoDIDIMgMjI0aA0AMg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1mtRbn6M+g/kP0FwDwr7quZs7xosNGpbscyxhhd9TyJyFwbLcxlTasg75vW7TsV5K7ji44XPMMrdoj+Y3rT0Hie62nlYV/pwczzOmdLqLhYkzGMzCZWGMQzGMSsZYY6Di1t4nlJ+Em63mJxrVLxPbYxNEdgc1dU2iOKyoYYWjNrEeHTYybVk0atSa7ehuwsWMWTqn1TrnS6hYsi71d1+s+k+ic70e20fzE/VaTdxT9ZtU4GIXdeNx3X77guYYfpHeTQjaMX6brOu4OY4K7Y2d9mbHarI5ox3p4GpJ2Vd/Tst60f7j999pppjR+Q/Qf8J/VaORs3cji7FfFuN61+ui9s8hix1OCh5KGVV23BPXvZfz3CLyHpix+exi8z/KnCnosY2eunor+cxyPO/xJ0vKey9OvE9VjqaYu0x3Z3jd6o2b1T12D+F8l232lwaaacD5LE8LBxu7WTlbWraWpew8Xexjel3E+wWD4APITdNqR8F3R3T0lunCQ4GaE9R37DxeCYfcHi4xci5ovKfxVs55y2hf+65E/Xdp6jR5nrebTmi5incpkyOjs50JvrZwstbbW6kfuuQw+2mykf/EXNFzxfKTrxew929TR6bWnGL//F3JFOFCQT3K4lQ"
28
+
29
+ kernels = Kernel(
30
+ bz2.decompress(base64.b64decode(quantization_code)),
31
+ [
32
+ "int4WeightCompression",
33
+ "int4WeightExtractionFloat",
34
+ "int4WeightExtractionHalf",
35
+ "int8WeightExtractionFloat",
36
+ "int8WeightExtractionHalf",
37
+ ],
38
+ )
39
+ except Exception as exception:
40
+ kernels = None
41
+ logger.warning("Failed to load cpm_kernels:" + str(exception))
42
+
43
+
44
+ class W8A16Linear(torch.autograd.Function):
45
+ @staticmethod
46
+ def forward(ctx, inp: torch.Tensor, quant_w: torch.Tensor, scale_w: torch.Tensor, weight_bit_width):
47
+ ctx.inp_shape = inp.size()
48
+ ctx.weight_bit_width = weight_bit_width
49
+ out_features = quant_w.size(0)
50
+ inp = inp.contiguous().view(-1, inp.size(-1))
51
+ weight = extract_weight_to_half(quant_w, scale_w, weight_bit_width)
52
+ ctx.weight_shape = weight.size()
53
+ output = inp.mm(weight.t())
54
+ ctx.save_for_backward(inp, quant_w, scale_w)
55
+ return output.view(*(ctx.inp_shape[:-1] + (out_features,)))
56
+
57
+ @staticmethod
58
+ def backward(ctx, grad_output: torch.Tensor):
59
+ inp, quant_w, scale_w = ctx.saved_tensors
60
+ weight = extract_weight_to_half(quant_w, scale_w, ctx.weight_bit_width)
61
+ grad_output = grad_output.contiguous().view(-1, weight.size(0))
62
+ grad_input = grad_output.mm(weight)
63
+ grad_weight = grad_output.t().mm(inp)
64
+ return grad_input.view(ctx.inp_shape), grad_weight.view(ctx.weight_shape), None, None
65
+
66
+
67
+ def compress_int4_weight(weight: torch.Tensor): # (n, m)
68
+ with torch.cuda.device(weight.device):
69
+ n, m = weight.size(0), weight.size(1)
70
+ assert m % 2 == 0
71
+ m = m // 2
72
+ out = torch.empty(n, m, dtype=torch.int8, device="cuda")
73
+ stream = torch.cuda.current_stream()
74
+
75
+ gridDim = (n, 1, 1)
76
+ blockDim = (min(round_up(m, 32), 1024), 1, 1)
77
+
78
+ kernels.int4WeightCompression(
79
+ gridDim,
80
+ blockDim,
81
+ 0,
82
+ stream,
83
+ [ctypes.c_void_p(weight.data_ptr()), ctypes.c_void_p(out.data_ptr()), ctypes.c_int32(n), ctypes.c_int32(m)],
84
+ )
85
+ return out
86
+
87
+
88
+ def extract_weight_to_half(weight: torch.Tensor, scale_list: torch.Tensor, source_bit_width: int):
89
+ if source_bit_width == 8:
90
+ func = kernels.int8WeightExtractionHalf
91
+ elif source_bit_width == 4:
92
+ func = kernels.int4WeightExtractionHalf
93
+ else:
94
+ assert False, "Unsupported bit-width"
95
+
96
+ with torch.cuda.device(weight.device):
97
+ n, m = weight.size(0), weight.size(1)
98
+ out = torch.empty(n, m * (8 // source_bit_width), dtype=torch.half, device="cuda")
99
+ stream = torch.cuda.current_stream()
100
+
101
+ gridDim = (n, 1, 1)
102
+ blockDim = (min(round_up(m, 32), 1024), 1, 1)
103
+
104
+ func(
105
+ gridDim,
106
+ blockDim,
107
+ 0,
108
+ stream,
109
+ [
110
+ ctypes.c_void_p(weight.data_ptr()),
111
+ ctypes.c_void_p(scale_list.data_ptr()),
112
+ ctypes.c_void_p(out.data_ptr()),
113
+ ctypes.c_int32(n),
114
+ ctypes.c_int32(m),
115
+ ],
116
+ )
117
+ return out
118
+
119
+
120
+ class QuantizedLinear(Linear):
121
+ def __init__(self, weight_bit_width: int, weight_tensor=None, bias_tensor=None, empty_init=False, *args, **kwargs):
122
+ super(QuantizedLinear, self).__init__(*args, **kwargs)
123
+ self.weight_bit_width = weight_bit_width
124
+
125
+ shape = self.weight.shape
126
+ del self.weight
127
+
128
+ if weight_tensor is None or empty_init:
129
+ self.weight = torch.empty(
130
+ shape[0], shape[1] * weight_bit_width // 8, dtype=torch.int8, device=kwargs["device"]
131
+ )
132
+ self.weight_scale = torch.empty(shape[0], dtype=kwargs["dtype"], device=kwargs["device"])
133
+ else:
134
+ self.weight_scale = (weight_tensor.abs().max(dim=-1).values / ((2 ** (weight_bit_width - 1)) - 1)).half()
135
+ self.weight = torch.round(weight_tensor / self.weight_scale[:, None]).to(torch.int8)
136
+ if weight_bit_width == 4:
137
+ self.weight = compress_int4_weight(self.weight)
138
+
139
+ self.weight = Parameter(self.weight.to(kwargs["device"]), requires_grad=False)
140
+ self.weight_scale = Parameter(self.weight_scale.to(kwargs["device"]), requires_grad=False)
141
+ if bias_tensor is not None:
142
+ self.bias = Parameter(bias_tensor.to(kwargs["device"]), requires_grad=False)
143
+ else:
144
+ self.bias = None
145
+
146
+ def forward(self, input):
147
+ output = W8A16Linear.apply(input, self.weight, self.weight_scale, self.weight_bit_width)
148
+ if self.bias is not None:
149
+ output = output + self.bias
150
+ return output
151
+
152
+
153
+ def quantize(model, weight_bit_width, empty_init=False, **kwargs):
154
+ """Replace fp16 linear with quantized linear"""
155
+
156
+ for layer in model.layers:
157
+ layer.attention.query_key_value = QuantizedLinear(
158
+ weight_bit_width=weight_bit_width,
159
+ weight_tensor=layer.attention.query_key_value.weight.to(torch.cuda.current_device()),
160
+ bias_tensor=layer.attention.query_key_value.bias,
161
+ in_features=layer.attention.query_key_value.in_features,
162
+ out_features=layer.attention.query_key_value.out_features,
163
+ bias=True,
164
+ dtype=torch.half,
165
+ device=layer.attention.query_key_value.weight.device,
166
+ empty_init=empty_init
167
+ )
168
+ layer.attention.dense = QuantizedLinear(
169
+ weight_bit_width=weight_bit_width,
170
+ weight_tensor=layer.attention.dense.weight.to(torch.cuda.current_device()),
171
+ bias_tensor=layer.attention.dense.bias,
172
+ in_features=layer.attention.dense.in_features,
173
+ out_features=layer.attention.dense.out_features,
174
+ bias=True,
175
+ dtype=torch.half,
176
+ device=layer.attention.dense.weight.device,
177
+ empty_init=empty_init
178
+ )
179
+ layer.mlp.dense_h_to_4h = QuantizedLinear(
180
+ weight_bit_width=weight_bit_width,
181
+ weight_tensor=layer.mlp.dense_h_to_4h.weight.to(torch.cuda.current_device()),
182
+ bias_tensor=layer.mlp.dense_h_to_4h.bias,
183
+ in_features=layer.mlp.dense_h_to_4h.in_features,
184
+ out_features=layer.mlp.dense_h_to_4h.out_features,
185
+ bias=True,
186
+ dtype=torch.half,
187
+ device=layer.mlp.dense_h_to_4h.weight.device,
188
+ empty_init=empty_init
189
+ )
190
+ layer.mlp.dense_4h_to_h = QuantizedLinear(
191
+ weight_bit_width=weight_bit_width,
192
+ weight_tensor=layer.mlp.dense_4h_to_h.weight.to(torch.cuda.current_device()),
193
+ bias_tensor=layer.mlp.dense_4h_to_h.bias,
194
+ in_features=layer.mlp.dense_4h_to_h.in_features,
195
+ out_features=layer.mlp.dense_4h_to_h.out_features,
196
+ bias=True,
197
+ dtype=torch.half,
198
+ device=layer.mlp.dense_4h_to_h.weight.device,
199
+ empty_init=empty_init
200
+ )
201
+ return model
rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e37dc82f73d28016090cbbda0b59b3662b6e32a61e6714fbc9bf56073442baba
3
+ size 14575
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:789a1605f05260342a605be992efe3dec445d76b75c62bdef618345fc0105cc0
3
+ size 627
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<sop>",
3
+ "eos_token": "</s>",
4
+ "mask_token": "[MASK]",
5
+ "pad_token": "<pad>",
6
+ "unk_token": "<unk>"
7
+ }
tokenization_chatglm.py ADDED
@@ -0,0 +1,429 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tokenization classes for ChatGLM."""
2
+ from typing import List, Optional, Union
3
+ import os
4
+
5
+ from transformers.tokenization_utils import PreTrainedTokenizer
6
+ from icetk.text_tokenizer import TextTokenizer
7
+ import icetk.sentencepiece_model_pb2 as sp_model
8
+ from transformers.utils import logging, PaddingStrategy
9
+ from transformers.tokenization_utils_base import EncodedInput, BatchEncoding
10
+ from typing import Dict
11
+ import numpy as np
12
+
13
+ logger = logging.get_logger(__name__)
14
+
15
+ PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {
16
+ "silver/chatglm-6b-slim": 2048,
17
+ }
18
+
19
+
20
+ class SPTokenizer:
21
+ def __init__(
22
+ self,
23
+ vocab_file,
24
+ max_blank_length=80,
25
+ byte_fallback=True,
26
+ ):
27
+ assert vocab_file is not None
28
+ self.vocab_file = vocab_file
29
+ self.special_tokens = ["[MASK]", "[gMASK]", "[sMASK]", "<unused_0>", "<sop>", "<eop>", "<ENC>", "<dBLOCK>"]
30
+ self.max_blank_length = max_blank_length
31
+ self.byte_fallback = byte_fallback
32
+ self.text_tokenizer = self._build_text_tokenizer(encode_special_tokens=False)
33
+ self.special_text_tokenizer = self._build_text_tokenizer(encode_special_tokens=True)
34
+
35
+ @staticmethod
36
+ def _configure_tokenizer(
37
+ text_tokenizer: TextTokenizer,
38
+ special_tokens: List[str],
39
+ max_blank_length: int,
40
+ byte_fallback: bool,
41
+ encode_special_tokens=False,
42
+ ):
43
+ # special token
44
+ special_token_type = 4 if encode_special_tokens else 3 # 3 - CONTROL, 4 - USER_DEFINE
45
+ for token in special_tokens:
46
+ text_tokenizer.proto.pieces.append(
47
+ sp_model.ModelProto.SentencePiece(piece=token, score=0.0, type=special_token_type)
48
+ )
49
+ # whitespaces
50
+ for token in [SPTokenizer.get_tab_token()] + [
51
+ SPTokenizer.get_blank_token(i) for i in range(2, max_blank_length + 1)
52
+ ]:
53
+ text_tokenizer.proto.pieces.append(sp_model.ModelProto.SentencePiece(piece=token, score=0.0, type=4))
54
+ # byte fallback
55
+ if byte_fallback:
56
+ text_tokenizer.proto.trainer_spec.byte_fallback = True
57
+ for i in range(256):
58
+ text_tokenizer.proto.pieces.append(
59
+ sp_model.ModelProto.SentencePiece(piece="<0x{:02X}>".format(i), score=0.0, type=6)
60
+ )
61
+ text_tokenizer.refresh()
62
+
63
+ def _build_text_tokenizer(self, encode_special_tokens=False):
64
+ tokenizer = TextTokenizer(self.vocab_file)
65
+ self._configure_tokenizer(
66
+ tokenizer, self.special_tokens, self.max_blank_length, self.byte_fallback, encode_special_tokens
67
+ )
68
+ return tokenizer
69
+
70
+ def _get_text_tokenizer(self, encode_special_tokens=False):
71
+ if encode_special_tokens:
72
+ return self.special_text_tokenizer
73
+ else:
74
+ return self.text_tokenizer
75
+
76
+ @staticmethod
77
+ def get_blank_token(length: int):
78
+ assert length >= 2
79
+ return f"<|blank_{length}|>"
80
+
81
+ @staticmethod
82
+ def get_tab_token():
83
+ return f"<|tab|>"
84
+
85
+ @property
86
+ def num_text_tokens(self):
87
+ return self.text_tokenizer.num_tokens
88
+
89
+ @property
90
+ def num_tokens(self):
91
+ return self.num_text_tokens
92
+
93
+ @staticmethod
94
+ def _encode_whitespaces(text: str, max_len: int = 80):
95
+ text = text.replace("\t", SPTokenizer.get_tab_token())
96
+ for i in range(max_len, 1, -1):
97
+ text = text.replace(" " * i, SPTokenizer.get_blank_token(i))
98
+ return text
99
+
100
+ def _preprocess(self, text: str, linebreak=True, whitespaces=True):
101
+ if linebreak:
102
+ text = text.replace("\n", "<n>")
103
+ if whitespaces:
104
+ text = self._encode_whitespaces(text, max_len=self.max_blank_length)
105
+ return text
106
+
107
+ def encode(
108
+ self, text: str, linebreak=True, whitespaces=True, special_tokens=False, add_dummy_prefix=True
109
+ ) -> List[int]:
110
+ """
111
+ @param text: Text to encode.
112
+ @param linebreak: Whether to encode newline (\n) in text.
113
+ @param whitespaces: Whether to encode multiple whitespaces or tab in text, useful for source code encoding.
114
+ @param special_tokens: Whether to encode special token ([MASK], [gMASK], etc.) in text.
115
+ @param add_dummy_prefix: Whether to add dummy blank space in the beginning.
116
+ """
117
+ text = self._preprocess(text, linebreak, whitespaces)
118
+ if not add_dummy_prefix:
119
+ text = "<n>" + text
120
+ tmp = self._get_text_tokenizer(encode_special_tokens=special_tokens).encode(text)
121
+ tokens = [x for x in tmp]
122
+ return tokens if add_dummy_prefix else tokens[2:]
123
+
124
+ def decode(self, text_ids: List[int], special_tokens=False) -> str:
125
+ ids = [int(_id) for _id in text_ids]
126
+ ids = [_id for _id in ids if _id >= 0]
127
+ text = self._get_text_tokenizer(encode_special_tokens=special_tokens).decode(ids)
128
+ text = text.replace("<n>", "\n")
129
+ text = text.replace(SPTokenizer.get_tab_token(), "\t")
130
+ for i in range(2, self.max_blank_length + 1):
131
+ text = text.replace(self.get_blank_token(i), " " * i)
132
+ return text
133
+
134
+ def tokenize(
135
+ self, text: str, linebreak=True, whitespaces=True, special_tokens=False, add_dummy_prefix=True
136
+ ) -> List[str]:
137
+ """
138
+ @param text: Text to encode.
139
+ @param linebreak: Whether to encode newline (\n) in text.
140
+ @param whitespaces: Whether to encode multiple whitespaces or tab in text, useful for source code encoding.
141
+ @param special_tokens: Whether to encode special token ([MASK], [gMASK], etc.) in text.
142
+ @param add_dummy_prefix: Whether to add dummy blank space in the beginning.
143
+ """
144
+ text = self._preprocess(text, linebreak, whitespaces)
145
+ if not add_dummy_prefix:
146
+ text = "<n>" + text
147
+ tokens = self._get_text_tokenizer(encode_special_tokens=special_tokens).tokenize(text)
148
+ return tokens if add_dummy_prefix else tokens[2:]
149
+
150
+ def __getitem__(self, x: Union[int, str]):
151
+ if isinstance(x, int):
152
+ return self.text_tokenizer.convert_id_to_token(x)
153
+ elif isinstance(x, str):
154
+ return self.text_tokenizer.convert_token_to_id(x)
155
+ else:
156
+ raise ValueError("The key should be str or int.")
157
+
158
+
159
+ class ChatGLMTokenizer(PreTrainedTokenizer):
160
+ """
161
+ Construct a ChatGLM tokenizer. Based on byte-level Byte-Pair-Encoding.
162
+
163
+ Args:
164
+ vocab_file (`str`):
165
+ Path to the vocabulary file.
166
+ """
167
+
168
+ vocab_files_names = {"vocab_file": "ice_text.model"}
169
+ max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
170
+ model_input_names = ["input_ids", "attention_mask", "position_ids"]
171
+
172
+ def __init__(
173
+ self,
174
+ vocab_file,
175
+ do_lower_case=False,
176
+ remove_space=False,
177
+ bos_token='sop',
178
+ eos_token='eos',
179
+ eop_token='eop',
180
+ mask_token='[MASK]',
181
+ gmask_token='[gMASK]',
182
+ padding_side="left",
183
+ **kwargs
184
+ ) -> None:
185
+ super().__init__(
186
+ do_lower_case=do_lower_case,
187
+ remove_space=remove_space,
188
+ padding_side=padding_side,
189
+ **kwargs
190
+ )
191
+
192
+ self.do_lower_case = do_lower_case
193
+ self.remove_space = remove_space
194
+ self.vocab_file = vocab_file
195
+
196
+ self.bos_token = bos_token
197
+ self.eos_token = eos_token
198
+ self.eop_token = eop_token
199
+ self.mask_token = mask_token
200
+ self.gmask_token = gmask_token
201
+
202
+ self.sp_tokenizer = SPTokenizer(vocab_file)
203
+
204
+ """ Initialisation """
205
+
206
+ @property
207
+ def eop_token_id(self) -> Optional[int]:
208
+ """
209
+ `Optional[int]`: Id of the end of sentence token in the vocabulary. Returns `None` if the token has not been
210
+ set.
211
+ """
212
+ if self.eop_token is None:
213
+ return None
214
+ return self.convert_tokens_to_ids(self.eop_token)
215
+
216
+ @property
217
+ def vocab_size(self):
218
+ """ Returns vocab size """
219
+ return self.sp_tokenizer.num_tokens
220
+
221
+ def get_vocab(self):
222
+ """ Returns vocab as a dict """
223
+ vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
224
+ vocab.update(self.added_tokens_encoder)
225
+ return vocab
226
+
227
+ def preprocess_text(self, inputs):
228
+ if self.remove_space:
229
+ outputs = " ".join(inputs.strip().split())
230
+ else:
231
+ outputs = inputs
232
+
233
+ if self.do_lower_case:
234
+ outputs = outputs.lower()
235
+
236
+ return outputs
237
+
238
+ def _tokenize(self, text, **kwargs):
239
+ """ Returns a tokenized string. """
240
+ text = self.preprocess_text(text)
241
+
242
+ seq = self.sp_tokenizer.tokenize(text)
243
+
244
+ return seq
245
+
246
+ def decode(
247
+ self,
248
+ token_ids: Union[List[int], List[List[int]]],
249
+ skip_special_tokens: bool = False,
250
+ clean_up_tokenization_spaces: bool = True,
251
+ spaces_between_special_tokens: bool = True,
252
+ **kwargs
253
+ ) -> str:
254
+ if isinstance(token_ids[0], list):
255
+ tokens = []
256
+ for single_token_ids in token_ids:
257
+ if self.pad_token_id in single_token_ids: # remove pad
258
+ single_token_ids = list(filter((self.pad_token_id).__ne__, single_token_ids))
259
+ tokens.append(self.sp_tokenizer.decode(single_token_ids))
260
+ return (tokens)
261
+ else:
262
+ if self.pad_token_id in token_ids: # remove pad
263
+ token_ids = list(filter((self.pad_token_id).__ne__, token_ids))
264
+ return self.sp_tokenizer.decode(token_ids)
265
+
266
+ def _convert_token_to_id(self, token):
267
+ """ Converts a token (str) in an id using the vocab. """
268
+ return self.sp_tokenizer[token]
269
+
270
+ def _convert_id_to_token(self, index):
271
+ """Converts an index (integer) in a token (str) using the vocab."""
272
+ return self.sp_tokenizer[index]
273
+
274
+ def save_vocabulary(self, save_directory, filename_prefix=None):
275
+ """
276
+ Save the vocabulary and special tokens file to a directory.
277
+
278
+ Args:
279
+ save_directory (`str`):
280
+ The directory in which to save the vocabulary.
281
+ filename_prefix (`str`, *optional*):
282
+ An optional prefix to add to the named of the saved files.
283
+
284
+ Returns:
285
+ `Tuple(str)`: Paths to the files saved.
286
+ """
287
+ if os.path.isdir(save_directory):
288
+ vocab_file = os.path.join(
289
+ save_directory, self.vocab_files_names["vocab_file"]
290
+ )
291
+ else:
292
+ vocab_file = save_directory
293
+
294
+ with open(self.vocab_file, 'rb') as fin:
295
+ proto_str = fin.read()
296
+
297
+ with open(vocab_file, "wb") as writer:
298
+ writer.write(proto_str)
299
+
300
+ return (vocab_file,)
301
+
302
+ def build_inputs_with_special_tokens(
303
+ self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
304
+ ) -> List[int]:
305
+ """
306
+ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
307
+ adding special tokens. A BERT sequence has the following format:
308
+
309
+ - single sequence: `[CLS] X [SEP]`
310
+ - pair of sequences: `[CLS] A [SEP] B [SEP]`
311
+
312
+ Args:
313
+ token_ids_0 (`List[int]`):
314
+ List of IDs to which the special tokens will be added.
315
+ token_ids_1 (`List[int]`, *optional*):
316
+ Optional second list of IDs for sequence pairs.
317
+
318
+ Returns:
319
+ `List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
320
+ """
321
+ mask_ids = self.sp_tokenizer[self.mask_token]
322
+ gmask_ids = self.sp_tokenizer[self.gmask_token]
323
+ eop_id = self.sp_tokenizer[self.eop_token]
324
+ if mask_ids not in token_ids_0 and gmask_ids not in token_ids_0:
325
+ token_ids_0 += [gmask_ids]
326
+
327
+ if token_ids_0[-1] != mask_ids and token_ids_0[-1] != gmask_ids:
328
+ token_ids_0 += [self.sp_tokenizer[self.eos_token]]
329
+
330
+ token_ids_0 += [self.sp_tokenizer[self.bos_token]]
331
+
332
+ if token_ids_1 is not None:
333
+ if not token_ids_1 or token_ids_1[-1] != eop_id:
334
+ token_ids_1 += [eop_id]
335
+ token_ids_0 += token_ids_1
336
+
337
+ return token_ids_0
338
+
339
+ def _pad(
340
+ self,
341
+ encoded_inputs: Union[Dict[str, EncodedInput], BatchEncoding],
342
+ max_length: Optional[int] = None,
343
+ padding_strategy: PaddingStrategy = PaddingStrategy.DO_NOT_PAD,
344
+ pad_to_multiple_of: Optional[int] = None,
345
+ return_attention_mask: Optional[bool] = None,
346
+ ) -> dict:
347
+ """
348
+ Pad encoded inputs (on left/right and up to predefined length or max length in the batch)
349
+
350
+ Args:
351
+ encoded_inputs:
352
+ Dictionary of tokenized inputs (`List[int]`) or batch of tokenized inputs (`List[List[int]]`).
353
+ max_length: maximum length of the returned list and optionally padding length (see below).
354
+ Will truncate by taking into account the special tokens.
355
+ padding_strategy: PaddingStrategy to use for padding.
356
+
357
+ - PaddingStrategy.LONGEST Pad to the longest sequence in the batch
358
+ - PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
359
+ - PaddingStrategy.DO_NOT_PAD: Do not pad
360
+ The tokenizer padding sides are defined in self.padding_side:
361
+
362
+ - 'left': pads on the left of the sequences
363
+ - 'right': pads on the right of the sequences
364
+ pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
365
+ This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
366
+ `>= 7.5` (Volta).
367
+ return_attention_mask:
368
+ (optional) Set to False to avoid returning attention mask (default: set to model specifics)
369
+ """
370
+ # Load from model defaults
371
+ bos_token_id = self.sp_tokenizer[self.bos_token]
372
+ mask_token_id = self.sp_tokenizer[self.mask_token]
373
+ gmask_token_id = self.sp_tokenizer[self.gmask_token]
374
+ assert self.padding_side == "left"
375
+
376
+ required_input = encoded_inputs[self.model_input_names[0]]
377
+ seq_length = len(required_input)
378
+
379
+ if padding_strategy == PaddingStrategy.LONGEST:
380
+ max_length = len(required_input)
381
+
382
+ if max_length is not None and pad_to_multiple_of is not None and (max_length % pad_to_multiple_of != 0):
383
+ max_length = ((max_length // pad_to_multiple_of) + 1) * pad_to_multiple_of
384
+
385
+ needs_to_be_padded = padding_strategy != PaddingStrategy.DO_NOT_PAD and len(required_input) != max_length
386
+
387
+ # Initialize attention mask if not present.
388
+ if max_length is not None:
389
+ if "attention_mask" not in encoded_inputs:
390
+ if bos_token_id in required_input:
391
+ context_length = required_input.index(bos_token_id)
392
+ else:
393
+ context_length = seq_length
394
+ attention_mask = np.ones((1, seq_length, seq_length))
395
+ attention_mask = np.tril(attention_mask)
396
+ attention_mask[:, :, :context_length] = 1
397
+ attention_mask = np.bool_(attention_mask < 0.5)
398
+ encoded_inputs["attention_mask"] = attention_mask
399
+
400
+ if "position_ids" not in encoded_inputs:
401
+ position_ids = np.arange(seq_length, dtype=np.int64)
402
+ mask_token = mask_token_id if mask_token_id in required_input else gmask_token_id
403
+ if mask_token in required_input:
404
+ mask_position = required_input.index(mask_token)
405
+ position_ids[context_length:] = mask_position
406
+ block_position_ids = np.concatenate(
407
+ [np.zeros(context_length, dtype=np.int64),
408
+ np.arange(1, seq_length - context_length + 1, dtype=np.int64)])
409
+ encoded_inputs["position_ids"] = np.stack([position_ids, block_position_ids], axis=0)
410
+
411
+ if needs_to_be_padded:
412
+ difference = max_length - len(required_input)
413
+
414
+ if "attention_mask" in encoded_inputs:
415
+ encoded_inputs["attention_mask"] = np.pad(encoded_inputs["attention_mask"],
416
+ pad_width=[(0, 0), (difference, 0), (difference, 0)],
417
+ mode='constant', constant_values=True)
418
+ if "token_type_ids" in encoded_inputs:
419
+ encoded_inputs["token_type_ids"] = [self.pad_token_type_id] * difference + encoded_inputs[
420
+ "token_type_ids"
421
+ ]
422
+ if "special_tokens_mask" in encoded_inputs:
423
+ encoded_inputs["special_tokens_mask"] = [1] * difference + encoded_inputs["special_tokens_mask"]
424
+ if "position_ids" in encoded_inputs:
425
+ encoded_inputs["position_ids"] = np.pad(encoded_inputs["position_ids"],
426
+ pad_width=[(0, 0), (difference, 0)])
427
+ encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input
428
+
429
+ return encoded_inputs
tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "auto_map": {
3
+ "AutoTokenizer": [
4
+ "tokenization_chatglm.ChatGLMTokenizer",
5
+ null
6
+ ]
7
+ },
8
+ "do_lower_case": false,
9
+ "model_max_length": 1000000000000000019884624838656,
10
+ "pad_token": "<pad>",
11
+ "padding_side": "left",
12
+ "remove_space": false,
13
+ "special_tokens_map_file": null,
14
+ "tokenizer_class": "ChatGLMTokenizer",
15
+ "unk_token": "<unk>"
16
+ }
trainer_state.json ADDED
@@ -0,0 +1,1816 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 130.43478260869566,
5
+ "global_step": 3000,
6
+ "is_hyper_param_search": false,
7
+ "is_local_process_zero": true,
8
+ "is_world_process_zero": true,
9
+ "log_history": [
10
+ {
11
+ "epoch": 0.43,
12
+ "learning_rate": 0.019933333333333334,
13
+ "loss": 4.2601,
14
+ "step": 10
15
+ },
16
+ {
17
+ "epoch": 0.87,
18
+ "learning_rate": 0.019866666666666668,
19
+ "loss": 3.5698,
20
+ "step": 20
21
+ },
22
+ {
23
+ "epoch": 1.3,
24
+ "learning_rate": 0.0198,
25
+ "loss": 3.3843,
26
+ "step": 30
27
+ },
28
+ {
29
+ "epoch": 1.74,
30
+ "learning_rate": 0.019733333333333335,
31
+ "loss": 3.167,
32
+ "step": 40
33
+ },
34
+ {
35
+ "epoch": 2.17,
36
+ "learning_rate": 0.019666666666666666,
37
+ "loss": 3.0689,
38
+ "step": 50
39
+ },
40
+ {
41
+ "epoch": 2.61,
42
+ "learning_rate": 0.0196,
43
+ "loss": 2.814,
44
+ "step": 60
45
+ },
46
+ {
47
+ "epoch": 3.04,
48
+ "learning_rate": 0.019533333333333333,
49
+ "loss": 2.7346,
50
+ "step": 70
51
+ },
52
+ {
53
+ "epoch": 3.48,
54
+ "learning_rate": 0.019466666666666667,
55
+ "loss": 2.3168,
56
+ "step": 80
57
+ },
58
+ {
59
+ "epoch": 3.91,
60
+ "learning_rate": 0.0194,
61
+ "loss": 2.3365,
62
+ "step": 90
63
+ },
64
+ {
65
+ "epoch": 4.35,
66
+ "learning_rate": 0.019333333333333334,
67
+ "loss": 1.9153,
68
+ "step": 100
69
+ },
70
+ {
71
+ "epoch": 4.78,
72
+ "learning_rate": 0.019266666666666668,
73
+ "loss": 1.8378,
74
+ "step": 110
75
+ },
76
+ {
77
+ "epoch": 5.22,
78
+ "learning_rate": 0.0192,
79
+ "loss": 1.5231,
80
+ "step": 120
81
+ },
82
+ {
83
+ "epoch": 5.65,
84
+ "learning_rate": 0.019133333333333332,
85
+ "loss": 1.278,
86
+ "step": 130
87
+ },
88
+ {
89
+ "epoch": 6.09,
90
+ "learning_rate": 0.01906666666666667,
91
+ "loss": 1.1264,
92
+ "step": 140
93
+ },
94
+ {
95
+ "epoch": 6.52,
96
+ "learning_rate": 0.019,
97
+ "loss": 0.8317,
98
+ "step": 150
99
+ },
100
+ {
101
+ "epoch": 6.96,
102
+ "learning_rate": 0.018933333333333333,
103
+ "loss": 0.7888,
104
+ "step": 160
105
+ },
106
+ {
107
+ "epoch": 7.39,
108
+ "learning_rate": 0.018866666666666667,
109
+ "loss": 0.5529,
110
+ "step": 170
111
+ },
112
+ {
113
+ "epoch": 7.83,
114
+ "learning_rate": 0.0188,
115
+ "loss": 0.4765,
116
+ "step": 180
117
+ },
118
+ {
119
+ "epoch": 8.26,
120
+ "learning_rate": 0.018733333333333334,
121
+ "loss": 0.348,
122
+ "step": 190
123
+ },
124
+ {
125
+ "epoch": 8.7,
126
+ "learning_rate": 0.018666666666666668,
127
+ "loss": 0.2838,
128
+ "step": 200
129
+ },
130
+ {
131
+ "epoch": 9.13,
132
+ "learning_rate": 0.018600000000000002,
133
+ "loss": 0.2262,
134
+ "step": 210
135
+ },
136
+ {
137
+ "epoch": 9.57,
138
+ "learning_rate": 0.018533333333333332,
139
+ "loss": 0.1665,
140
+ "step": 220
141
+ },
142
+ {
143
+ "epoch": 10.0,
144
+ "learning_rate": 0.018466666666666666,
145
+ "loss": 0.1613,
146
+ "step": 230
147
+ },
148
+ {
149
+ "epoch": 10.43,
150
+ "learning_rate": 0.0184,
151
+ "loss": 0.1014,
152
+ "step": 240
153
+ },
154
+ {
155
+ "epoch": 10.87,
156
+ "learning_rate": 0.018333333333333333,
157
+ "loss": 0.104,
158
+ "step": 250
159
+ },
160
+ {
161
+ "epoch": 11.3,
162
+ "learning_rate": 0.018266666666666667,
163
+ "loss": 0.0812,
164
+ "step": 260
165
+ },
166
+ {
167
+ "epoch": 11.74,
168
+ "learning_rate": 0.0182,
169
+ "loss": 0.0777,
170
+ "step": 270
171
+ },
172
+ {
173
+ "epoch": 12.17,
174
+ "learning_rate": 0.01813333333333333,
175
+ "loss": 0.0651,
176
+ "step": 280
177
+ },
178
+ {
179
+ "epoch": 12.61,
180
+ "learning_rate": 0.01806666666666667,
181
+ "loss": 0.054,
182
+ "step": 290
183
+ },
184
+ {
185
+ "epoch": 13.04,
186
+ "learning_rate": 0.018000000000000002,
187
+ "loss": 0.0502,
188
+ "step": 300
189
+ },
190
+ {
191
+ "epoch": 13.48,
192
+ "learning_rate": 0.017933333333333332,
193
+ "loss": 0.0348,
194
+ "step": 310
195
+ },
196
+ {
197
+ "epoch": 13.91,
198
+ "learning_rate": 0.017866666666666666,
199
+ "loss": 0.0388,
200
+ "step": 320
201
+ },
202
+ {
203
+ "epoch": 14.35,
204
+ "learning_rate": 0.0178,
205
+ "loss": 0.0328,
206
+ "step": 330
207
+ },
208
+ {
209
+ "epoch": 14.78,
210
+ "learning_rate": 0.017733333333333334,
211
+ "loss": 0.0346,
212
+ "step": 340
213
+ },
214
+ {
215
+ "epoch": 15.22,
216
+ "learning_rate": 0.017666666666666667,
217
+ "loss": 0.029,
218
+ "step": 350
219
+ },
220
+ {
221
+ "epoch": 15.65,
222
+ "learning_rate": 0.0176,
223
+ "loss": 0.0342,
224
+ "step": 360
225
+ },
226
+ {
227
+ "epoch": 16.09,
228
+ "learning_rate": 0.017533333333333335,
229
+ "loss": 0.0317,
230
+ "step": 370
231
+ },
232
+ {
233
+ "epoch": 16.52,
234
+ "learning_rate": 0.017466666666666665,
235
+ "loss": 0.0253,
236
+ "step": 380
237
+ },
238
+ {
239
+ "epoch": 16.96,
240
+ "learning_rate": 0.0174,
241
+ "loss": 0.0237,
242
+ "step": 390
243
+ },
244
+ {
245
+ "epoch": 17.39,
246
+ "learning_rate": 0.017333333333333336,
247
+ "loss": 0.0216,
248
+ "step": 400
249
+ },
250
+ {
251
+ "epoch": 17.83,
252
+ "learning_rate": 0.017266666666666666,
253
+ "loss": 0.0238,
254
+ "step": 410
255
+ },
256
+ {
257
+ "epoch": 18.26,
258
+ "learning_rate": 0.0172,
259
+ "loss": 0.0203,
260
+ "step": 420
261
+ },
262
+ {
263
+ "epoch": 18.7,
264
+ "learning_rate": 0.017133333333333334,
265
+ "loss": 0.0254,
266
+ "step": 430
267
+ },
268
+ {
269
+ "epoch": 19.13,
270
+ "learning_rate": 0.017066666666666667,
271
+ "loss": 0.0231,
272
+ "step": 440
273
+ },
274
+ {
275
+ "epoch": 19.57,
276
+ "learning_rate": 0.017,
277
+ "loss": 0.0185,
278
+ "step": 450
279
+ },
280
+ {
281
+ "epoch": 20.0,
282
+ "learning_rate": 0.016933333333333335,
283
+ "loss": 0.0205,
284
+ "step": 460
285
+ },
286
+ {
287
+ "epoch": 20.43,
288
+ "learning_rate": 0.01686666666666667,
289
+ "loss": 0.0183,
290
+ "step": 470
291
+ },
292
+ {
293
+ "epoch": 20.87,
294
+ "learning_rate": 0.0168,
295
+ "loss": 0.0246,
296
+ "step": 480
297
+ },
298
+ {
299
+ "epoch": 21.3,
300
+ "learning_rate": 0.016733333333333333,
301
+ "loss": 0.0181,
302
+ "step": 490
303
+ },
304
+ {
305
+ "epoch": 21.74,
306
+ "learning_rate": 0.016666666666666666,
307
+ "loss": 0.0198,
308
+ "step": 500
309
+ },
310
+ {
311
+ "epoch": 22.17,
312
+ "learning_rate": 0.0166,
313
+ "loss": 0.0282,
314
+ "step": 510
315
+ },
316
+ {
317
+ "epoch": 22.61,
318
+ "learning_rate": 0.016533333333333334,
319
+ "loss": 0.0161,
320
+ "step": 520
321
+ },
322
+ {
323
+ "epoch": 23.04,
324
+ "learning_rate": 0.016466666666666668,
325
+ "loss": 0.0158,
326
+ "step": 530
327
+ },
328
+ {
329
+ "epoch": 23.48,
330
+ "learning_rate": 0.016399999999999998,
331
+ "loss": 0.0138,
332
+ "step": 540
333
+ },
334
+ {
335
+ "epoch": 23.91,
336
+ "learning_rate": 0.01633333333333333,
337
+ "loss": 0.0191,
338
+ "step": 550
339
+ },
340
+ {
341
+ "epoch": 24.35,
342
+ "learning_rate": 0.01626666666666667,
343
+ "loss": 0.0147,
344
+ "step": 560
345
+ },
346
+ {
347
+ "epoch": 24.78,
348
+ "learning_rate": 0.016200000000000003,
349
+ "loss": 0.0146,
350
+ "step": 570
351
+ },
352
+ {
353
+ "epoch": 25.22,
354
+ "learning_rate": 0.016133333333333333,
355
+ "loss": 0.0116,
356
+ "step": 580
357
+ },
358
+ {
359
+ "epoch": 25.65,
360
+ "learning_rate": 0.016066666666666667,
361
+ "loss": 0.0126,
362
+ "step": 590
363
+ },
364
+ {
365
+ "epoch": 26.09,
366
+ "learning_rate": 0.016,
367
+ "loss": 0.0166,
368
+ "step": 600
369
+ },
370
+ {
371
+ "epoch": 26.52,
372
+ "learning_rate": 0.015933333333333334,
373
+ "loss": 0.014,
374
+ "step": 610
375
+ },
376
+ {
377
+ "epoch": 26.96,
378
+ "learning_rate": 0.015866666666666668,
379
+ "loss": 0.0105,
380
+ "step": 620
381
+ },
382
+ {
383
+ "epoch": 27.39,
384
+ "learning_rate": 0.0158,
385
+ "loss": 0.0098,
386
+ "step": 630
387
+ },
388
+ {
389
+ "epoch": 27.83,
390
+ "learning_rate": 0.015733333333333332,
391
+ "loss": 0.0134,
392
+ "step": 640
393
+ },
394
+ {
395
+ "epoch": 28.26,
396
+ "learning_rate": 0.015666666666666666,
397
+ "loss": 0.0138,
398
+ "step": 650
399
+ },
400
+ {
401
+ "epoch": 28.7,
402
+ "learning_rate": 0.015600000000000001,
403
+ "loss": 0.0132,
404
+ "step": 660
405
+ },
406
+ {
407
+ "epoch": 29.13,
408
+ "learning_rate": 0.015533333333333333,
409
+ "loss": 0.0106,
410
+ "step": 670
411
+ },
412
+ {
413
+ "epoch": 29.57,
414
+ "learning_rate": 0.015466666666666667,
415
+ "loss": 0.0101,
416
+ "step": 680
417
+ },
418
+ {
419
+ "epoch": 30.0,
420
+ "learning_rate": 0.0154,
421
+ "loss": 0.0095,
422
+ "step": 690
423
+ },
424
+ {
425
+ "epoch": 30.43,
426
+ "learning_rate": 0.015333333333333334,
427
+ "loss": 0.0079,
428
+ "step": 700
429
+ },
430
+ {
431
+ "epoch": 30.87,
432
+ "learning_rate": 0.015266666666666666,
433
+ "loss": 0.0107,
434
+ "step": 710
435
+ },
436
+ {
437
+ "epoch": 31.3,
438
+ "learning_rate": 0.0152,
439
+ "loss": 0.0089,
440
+ "step": 720
441
+ },
442
+ {
443
+ "epoch": 31.74,
444
+ "learning_rate": 0.015133333333333334,
445
+ "loss": 0.0095,
446
+ "step": 730
447
+ },
448
+ {
449
+ "epoch": 32.17,
450
+ "learning_rate": 0.015066666666666666,
451
+ "loss": 0.0073,
452
+ "step": 740
453
+ },
454
+ {
455
+ "epoch": 32.61,
456
+ "learning_rate": 0.015,
457
+ "loss": 0.0085,
458
+ "step": 750
459
+ },
460
+ {
461
+ "epoch": 33.04,
462
+ "learning_rate": 0.014933333333333335,
463
+ "loss": 0.0088,
464
+ "step": 760
465
+ },
466
+ {
467
+ "epoch": 33.48,
468
+ "learning_rate": 0.014866666666666667,
469
+ "loss": 0.0077,
470
+ "step": 770
471
+ },
472
+ {
473
+ "epoch": 33.91,
474
+ "learning_rate": 0.0148,
475
+ "loss": 0.0081,
476
+ "step": 780
477
+ },
478
+ {
479
+ "epoch": 34.35,
480
+ "learning_rate": 0.014733333333333334,
481
+ "loss": 0.0063,
482
+ "step": 790
483
+ },
484
+ {
485
+ "epoch": 34.78,
486
+ "learning_rate": 0.014666666666666666,
487
+ "loss": 0.0105,
488
+ "step": 800
489
+ },
490
+ {
491
+ "epoch": 35.22,
492
+ "learning_rate": 0.0146,
493
+ "loss": 0.007,
494
+ "step": 810
495
+ },
496
+ {
497
+ "epoch": 35.65,
498
+ "learning_rate": 0.014533333333333334,
499
+ "loss": 0.0075,
500
+ "step": 820
501
+ },
502
+ {
503
+ "epoch": 36.09,
504
+ "learning_rate": 0.014466666666666668,
505
+ "loss": 0.0092,
506
+ "step": 830
507
+ },
508
+ {
509
+ "epoch": 36.52,
510
+ "learning_rate": 0.0144,
511
+ "loss": 0.0074,
512
+ "step": 840
513
+ },
514
+ {
515
+ "epoch": 36.96,
516
+ "learning_rate": 0.014333333333333333,
517
+ "loss": 0.0099,
518
+ "step": 850
519
+ },
520
+ {
521
+ "epoch": 37.39,
522
+ "learning_rate": 0.014266666666666667,
523
+ "loss": 0.0077,
524
+ "step": 860
525
+ },
526
+ {
527
+ "epoch": 37.83,
528
+ "learning_rate": 0.014199999999999999,
529
+ "loss": 0.0156,
530
+ "step": 870
531
+ },
532
+ {
533
+ "epoch": 38.26,
534
+ "learning_rate": 0.014133333333333333,
535
+ "loss": 0.0103,
536
+ "step": 880
537
+ },
538
+ {
539
+ "epoch": 38.7,
540
+ "learning_rate": 0.014066666666666668,
541
+ "loss": 0.0118,
542
+ "step": 890
543
+ },
544
+ {
545
+ "epoch": 39.13,
546
+ "learning_rate": 0.013999999999999999,
547
+ "loss": 0.0109,
548
+ "step": 900
549
+ },
550
+ {
551
+ "epoch": 39.57,
552
+ "learning_rate": 0.013933333333333334,
553
+ "loss": 0.0104,
554
+ "step": 910
555
+ },
556
+ {
557
+ "epoch": 40.0,
558
+ "learning_rate": 0.013866666666666668,
559
+ "loss": 0.0127,
560
+ "step": 920
561
+ },
562
+ {
563
+ "epoch": 40.43,
564
+ "learning_rate": 0.0138,
565
+ "loss": 0.0098,
566
+ "step": 930
567
+ },
568
+ {
569
+ "epoch": 40.87,
570
+ "learning_rate": 0.013733333333333334,
571
+ "loss": 0.0135,
572
+ "step": 940
573
+ },
574
+ {
575
+ "epoch": 41.3,
576
+ "learning_rate": 0.013666666666666667,
577
+ "loss": 0.0104,
578
+ "step": 950
579
+ },
580
+ {
581
+ "epoch": 41.74,
582
+ "learning_rate": 0.013600000000000001,
583
+ "loss": 0.0113,
584
+ "step": 960
585
+ },
586
+ {
587
+ "epoch": 42.17,
588
+ "learning_rate": 0.013533333333333333,
589
+ "loss": 0.0105,
590
+ "step": 970
591
+ },
592
+ {
593
+ "epoch": 42.61,
594
+ "learning_rate": 0.013466666666666667,
595
+ "loss": 0.0113,
596
+ "step": 980
597
+ },
598
+ {
599
+ "epoch": 43.04,
600
+ "learning_rate": 0.0134,
601
+ "loss": 0.0144,
602
+ "step": 990
603
+ },
604
+ {
605
+ "epoch": 43.48,
606
+ "learning_rate": 0.013333333333333332,
607
+ "loss": 0.0137,
608
+ "step": 1000
609
+ },
610
+ {
611
+ "epoch": 43.91,
612
+ "learning_rate": 0.013266666666666666,
613
+ "loss": 0.0181,
614
+ "step": 1010
615
+ },
616
+ {
617
+ "epoch": 44.35,
618
+ "learning_rate": 0.013200000000000002,
619
+ "loss": 0.0157,
620
+ "step": 1020
621
+ },
622
+ {
623
+ "epoch": 44.78,
624
+ "learning_rate": 0.013133333333333332,
625
+ "loss": 0.0178,
626
+ "step": 1030
627
+ },
628
+ {
629
+ "epoch": 45.22,
630
+ "learning_rate": 0.013066666666666667,
631
+ "loss": 0.0214,
632
+ "step": 1040
633
+ },
634
+ {
635
+ "epoch": 45.65,
636
+ "learning_rate": 0.013000000000000001,
637
+ "loss": 0.021,
638
+ "step": 1050
639
+ },
640
+ {
641
+ "epoch": 46.09,
642
+ "learning_rate": 0.012933333333333333,
643
+ "loss": 0.0282,
644
+ "step": 1060
645
+ },
646
+ {
647
+ "epoch": 46.52,
648
+ "learning_rate": 0.012866666666666667,
649
+ "loss": 0.023,
650
+ "step": 1070
651
+ },
652
+ {
653
+ "epoch": 46.96,
654
+ "learning_rate": 0.0128,
655
+ "loss": 0.0257,
656
+ "step": 1080
657
+ },
658
+ {
659
+ "epoch": 47.39,
660
+ "learning_rate": 0.012733333333333334,
661
+ "loss": 0.0199,
662
+ "step": 1090
663
+ },
664
+ {
665
+ "epoch": 47.83,
666
+ "learning_rate": 0.012666666666666666,
667
+ "loss": 0.0148,
668
+ "step": 1100
669
+ },
670
+ {
671
+ "epoch": 48.26,
672
+ "learning_rate": 0.0126,
673
+ "loss": 0.0167,
674
+ "step": 1110
675
+ },
676
+ {
677
+ "epoch": 48.7,
678
+ "learning_rate": 0.012533333333333334,
679
+ "loss": 0.0125,
680
+ "step": 1120
681
+ },
682
+ {
683
+ "epoch": 49.13,
684
+ "learning_rate": 0.012466666666666666,
685
+ "loss": 0.0134,
686
+ "step": 1130
687
+ },
688
+ {
689
+ "epoch": 49.57,
690
+ "learning_rate": 0.0124,
691
+ "loss": 0.0105,
692
+ "step": 1140
693
+ },
694
+ {
695
+ "epoch": 50.0,
696
+ "learning_rate": 0.012333333333333335,
697
+ "loss": 0.0125,
698
+ "step": 1150
699
+ },
700
+ {
701
+ "epoch": 50.43,
702
+ "learning_rate": 0.012266666666666665,
703
+ "loss": 0.0105,
704
+ "step": 1160
705
+ },
706
+ {
707
+ "epoch": 50.87,
708
+ "learning_rate": 0.0122,
709
+ "loss": 0.0119,
710
+ "step": 1170
711
+ },
712
+ {
713
+ "epoch": 51.3,
714
+ "learning_rate": 0.012133333333333335,
715
+ "loss": 0.0094,
716
+ "step": 1180
717
+ },
718
+ {
719
+ "epoch": 51.74,
720
+ "learning_rate": 0.012066666666666668,
721
+ "loss": 0.0089,
722
+ "step": 1190
723
+ },
724
+ {
725
+ "epoch": 52.17,
726
+ "learning_rate": 0.012,
727
+ "loss": 0.0085,
728
+ "step": 1200
729
+ },
730
+ {
731
+ "epoch": 52.61,
732
+ "learning_rate": 0.011933333333333334,
733
+ "loss": 0.007,
734
+ "step": 1210
735
+ },
736
+ {
737
+ "epoch": 53.04,
738
+ "learning_rate": 0.011866666666666668,
739
+ "loss": 0.0071,
740
+ "step": 1220
741
+ },
742
+ {
743
+ "epoch": 53.48,
744
+ "learning_rate": 0.0118,
745
+ "loss": 0.0089,
746
+ "step": 1230
747
+ },
748
+ {
749
+ "epoch": 53.91,
750
+ "learning_rate": 0.011733333333333333,
751
+ "loss": 0.0082,
752
+ "step": 1240
753
+ },
754
+ {
755
+ "epoch": 54.35,
756
+ "learning_rate": 0.011666666666666667,
757
+ "loss": 0.007,
758
+ "step": 1250
759
+ },
760
+ {
761
+ "epoch": 54.78,
762
+ "learning_rate": 0.0116,
763
+ "loss": 0.0071,
764
+ "step": 1260
765
+ },
766
+ {
767
+ "epoch": 55.22,
768
+ "learning_rate": 0.011533333333333333,
769
+ "loss": 0.0086,
770
+ "step": 1270
771
+ },
772
+ {
773
+ "epoch": 55.65,
774
+ "learning_rate": 0.011466666666666667,
775
+ "loss": 0.0114,
776
+ "step": 1280
777
+ },
778
+ {
779
+ "epoch": 56.09,
780
+ "learning_rate": 0.011399999999999999,
781
+ "loss": 0.0145,
782
+ "step": 1290
783
+ },
784
+ {
785
+ "epoch": 56.52,
786
+ "learning_rate": 0.011333333333333332,
787
+ "loss": 0.0109,
788
+ "step": 1300
789
+ },
790
+ {
791
+ "epoch": 56.96,
792
+ "learning_rate": 0.011266666666666668,
793
+ "loss": 0.0221,
794
+ "step": 1310
795
+ },
796
+ {
797
+ "epoch": 57.39,
798
+ "learning_rate": 0.011200000000000002,
799
+ "loss": 0.0102,
800
+ "step": 1320
801
+ },
802
+ {
803
+ "epoch": 57.83,
804
+ "learning_rate": 0.011133333333333334,
805
+ "loss": 0.009,
806
+ "step": 1330
807
+ },
808
+ {
809
+ "epoch": 58.26,
810
+ "learning_rate": 0.011066666666666667,
811
+ "loss": 0.0097,
812
+ "step": 1340
813
+ },
814
+ {
815
+ "epoch": 58.7,
816
+ "learning_rate": 0.011000000000000001,
817
+ "loss": 0.0094,
818
+ "step": 1350
819
+ },
820
+ {
821
+ "epoch": 59.13,
822
+ "learning_rate": 0.010933333333333333,
823
+ "loss": 0.0064,
824
+ "step": 1360
825
+ },
826
+ {
827
+ "epoch": 59.57,
828
+ "learning_rate": 0.010866666666666667,
829
+ "loss": 0.0061,
830
+ "step": 1370
831
+ },
832
+ {
833
+ "epoch": 60.0,
834
+ "learning_rate": 0.0108,
835
+ "loss": 0.0078,
836
+ "step": 1380
837
+ },
838
+ {
839
+ "epoch": 60.43,
840
+ "learning_rate": 0.010733333333333333,
841
+ "loss": 0.005,
842
+ "step": 1390
843
+ },
844
+ {
845
+ "epoch": 60.87,
846
+ "learning_rate": 0.010666666666666666,
847
+ "loss": 0.0068,
848
+ "step": 1400
849
+ },
850
+ {
851
+ "epoch": 61.3,
852
+ "learning_rate": 0.0106,
853
+ "loss": 0.0051,
854
+ "step": 1410
855
+ },
856
+ {
857
+ "epoch": 61.74,
858
+ "learning_rate": 0.010533333333333332,
859
+ "loss": 0.0053,
860
+ "step": 1420
861
+ },
862
+ {
863
+ "epoch": 62.17,
864
+ "learning_rate": 0.010466666666666666,
865
+ "loss": 0.0061,
866
+ "step": 1430
867
+ },
868
+ {
869
+ "epoch": 62.61,
870
+ "learning_rate": 0.010400000000000001,
871
+ "loss": 0.0055,
872
+ "step": 1440
873
+ },
874
+ {
875
+ "epoch": 63.04,
876
+ "learning_rate": 0.010333333333333335,
877
+ "loss": 0.0063,
878
+ "step": 1450
879
+ },
880
+ {
881
+ "epoch": 63.48,
882
+ "learning_rate": 0.010266666666666667,
883
+ "loss": 0.0049,
884
+ "step": 1460
885
+ },
886
+ {
887
+ "epoch": 63.91,
888
+ "learning_rate": 0.0102,
889
+ "loss": 0.0071,
890
+ "step": 1470
891
+ },
892
+ {
893
+ "epoch": 64.35,
894
+ "learning_rate": 0.010133333333333334,
895
+ "loss": 0.0044,
896
+ "step": 1480
897
+ },
898
+ {
899
+ "epoch": 64.78,
900
+ "learning_rate": 0.010066666666666666,
901
+ "loss": 0.0056,
902
+ "step": 1490
903
+ },
904
+ {
905
+ "epoch": 65.22,
906
+ "learning_rate": 0.01,
907
+ "loss": 0.0044,
908
+ "step": 1500
909
+ },
910
+ {
911
+ "epoch": 65.65,
912
+ "learning_rate": 0.009933333333333334,
913
+ "loss": 0.0058,
914
+ "step": 1510
915
+ },
916
+ {
917
+ "epoch": 66.09,
918
+ "learning_rate": 0.009866666666666668,
919
+ "loss": 0.0056,
920
+ "step": 1520
921
+ },
922
+ {
923
+ "epoch": 66.52,
924
+ "learning_rate": 0.0098,
925
+ "loss": 0.0051,
926
+ "step": 1530
927
+ },
928
+ {
929
+ "epoch": 66.96,
930
+ "learning_rate": 0.009733333333333333,
931
+ "loss": 0.0065,
932
+ "step": 1540
933
+ },
934
+ {
935
+ "epoch": 67.39,
936
+ "learning_rate": 0.009666666666666667,
937
+ "loss": 0.0037,
938
+ "step": 1550
939
+ },
940
+ {
941
+ "epoch": 67.83,
942
+ "learning_rate": 0.0096,
943
+ "loss": 0.0056,
944
+ "step": 1560
945
+ },
946
+ {
947
+ "epoch": 68.26,
948
+ "learning_rate": 0.009533333333333335,
949
+ "loss": 0.0045,
950
+ "step": 1570
951
+ },
952
+ {
953
+ "epoch": 68.7,
954
+ "learning_rate": 0.009466666666666667,
955
+ "loss": 0.0059,
956
+ "step": 1580
957
+ },
958
+ {
959
+ "epoch": 69.13,
960
+ "learning_rate": 0.0094,
961
+ "loss": 0.0047,
962
+ "step": 1590
963
+ },
964
+ {
965
+ "epoch": 69.57,
966
+ "learning_rate": 0.009333333333333334,
967
+ "loss": 0.0051,
968
+ "step": 1600
969
+ },
970
+ {
971
+ "epoch": 70.0,
972
+ "learning_rate": 0.009266666666666666,
973
+ "loss": 0.0052,
974
+ "step": 1610
975
+ },
976
+ {
977
+ "epoch": 70.43,
978
+ "learning_rate": 0.0092,
979
+ "loss": 0.0041,
980
+ "step": 1620
981
+ },
982
+ {
983
+ "epoch": 70.87,
984
+ "learning_rate": 0.009133333333333334,
985
+ "loss": 0.0056,
986
+ "step": 1630
987
+ },
988
+ {
989
+ "epoch": 71.3,
990
+ "learning_rate": 0.009066666666666666,
991
+ "loss": 0.005,
992
+ "step": 1640
993
+ },
994
+ {
995
+ "epoch": 71.74,
996
+ "learning_rate": 0.009000000000000001,
997
+ "loss": 0.0051,
998
+ "step": 1650
999
+ },
1000
+ {
1001
+ "epoch": 72.17,
1002
+ "learning_rate": 0.008933333333333333,
1003
+ "loss": 0.0049,
1004
+ "step": 1660
1005
+ },
1006
+ {
1007
+ "epoch": 72.61,
1008
+ "learning_rate": 0.008866666666666667,
1009
+ "loss": 0.0046,
1010
+ "step": 1670
1011
+ },
1012
+ {
1013
+ "epoch": 73.04,
1014
+ "learning_rate": 0.0088,
1015
+ "loss": 0.0056,
1016
+ "step": 1680
1017
+ },
1018
+ {
1019
+ "epoch": 73.48,
1020
+ "learning_rate": 0.008733333333333333,
1021
+ "loss": 0.004,
1022
+ "step": 1690
1023
+ },
1024
+ {
1025
+ "epoch": 73.91,
1026
+ "learning_rate": 0.008666666666666668,
1027
+ "loss": 0.0043,
1028
+ "step": 1700
1029
+ },
1030
+ {
1031
+ "epoch": 74.35,
1032
+ "learning_rate": 0.0086,
1033
+ "loss": 0.0046,
1034
+ "step": 1710
1035
+ },
1036
+ {
1037
+ "epoch": 74.78,
1038
+ "learning_rate": 0.008533333333333334,
1039
+ "loss": 0.0058,
1040
+ "step": 1720
1041
+ },
1042
+ {
1043
+ "epoch": 75.22,
1044
+ "learning_rate": 0.008466666666666667,
1045
+ "loss": 0.0046,
1046
+ "step": 1730
1047
+ },
1048
+ {
1049
+ "epoch": 75.65,
1050
+ "learning_rate": 0.0084,
1051
+ "loss": 0.0056,
1052
+ "step": 1740
1053
+ },
1054
+ {
1055
+ "epoch": 76.09,
1056
+ "learning_rate": 0.008333333333333333,
1057
+ "loss": 0.0048,
1058
+ "step": 1750
1059
+ },
1060
+ {
1061
+ "epoch": 76.52,
1062
+ "learning_rate": 0.008266666666666667,
1063
+ "loss": 0.0033,
1064
+ "step": 1760
1065
+ },
1066
+ {
1067
+ "epoch": 76.96,
1068
+ "learning_rate": 0.008199999999999999,
1069
+ "loss": 0.0043,
1070
+ "step": 1770
1071
+ },
1072
+ {
1073
+ "epoch": 77.39,
1074
+ "learning_rate": 0.008133333333333334,
1075
+ "loss": 0.0034,
1076
+ "step": 1780
1077
+ },
1078
+ {
1079
+ "epoch": 77.83,
1080
+ "learning_rate": 0.008066666666666666,
1081
+ "loss": 0.0053,
1082
+ "step": 1790
1083
+ },
1084
+ {
1085
+ "epoch": 78.26,
1086
+ "learning_rate": 0.008,
1087
+ "loss": 0.0044,
1088
+ "step": 1800
1089
+ },
1090
+ {
1091
+ "epoch": 78.7,
1092
+ "learning_rate": 0.007933333333333334,
1093
+ "loss": 0.0036,
1094
+ "step": 1810
1095
+ },
1096
+ {
1097
+ "epoch": 79.13,
1098
+ "learning_rate": 0.007866666666666666,
1099
+ "loss": 0.0046,
1100
+ "step": 1820
1101
+ },
1102
+ {
1103
+ "epoch": 79.57,
1104
+ "learning_rate": 0.0078000000000000005,
1105
+ "loss": 0.0039,
1106
+ "step": 1830
1107
+ },
1108
+ {
1109
+ "epoch": 80.0,
1110
+ "learning_rate": 0.007733333333333333,
1111
+ "loss": 0.0042,
1112
+ "step": 1840
1113
+ },
1114
+ {
1115
+ "epoch": 80.43,
1116
+ "learning_rate": 0.007666666666666667,
1117
+ "loss": 0.004,
1118
+ "step": 1850
1119
+ },
1120
+ {
1121
+ "epoch": 80.87,
1122
+ "learning_rate": 0.0076,
1123
+ "loss": 0.0045,
1124
+ "step": 1860
1125
+ },
1126
+ {
1127
+ "epoch": 81.3,
1128
+ "learning_rate": 0.007533333333333333,
1129
+ "loss": 0.0035,
1130
+ "step": 1870
1131
+ },
1132
+ {
1133
+ "epoch": 81.74,
1134
+ "learning_rate": 0.0074666666666666675,
1135
+ "loss": 0.0036,
1136
+ "step": 1880
1137
+ },
1138
+ {
1139
+ "epoch": 82.17,
1140
+ "learning_rate": 0.0074,
1141
+ "loss": 0.0045,
1142
+ "step": 1890
1143
+ },
1144
+ {
1145
+ "epoch": 82.61,
1146
+ "learning_rate": 0.007333333333333333,
1147
+ "loss": 0.0033,
1148
+ "step": 1900
1149
+ },
1150
+ {
1151
+ "epoch": 83.04,
1152
+ "learning_rate": 0.007266666666666667,
1153
+ "loss": 0.0044,
1154
+ "step": 1910
1155
+ },
1156
+ {
1157
+ "epoch": 83.48,
1158
+ "learning_rate": 0.0072,
1159
+ "loss": 0.0037,
1160
+ "step": 1920
1161
+ },
1162
+ {
1163
+ "epoch": 83.91,
1164
+ "learning_rate": 0.0071333333333333335,
1165
+ "loss": 0.004,
1166
+ "step": 1930
1167
+ },
1168
+ {
1169
+ "epoch": 84.35,
1170
+ "learning_rate": 0.007066666666666666,
1171
+ "loss": 0.0043,
1172
+ "step": 1940
1173
+ },
1174
+ {
1175
+ "epoch": 84.78,
1176
+ "learning_rate": 0.006999999999999999,
1177
+ "loss": 0.0039,
1178
+ "step": 1950
1179
+ },
1180
+ {
1181
+ "epoch": 85.22,
1182
+ "learning_rate": 0.006933333333333334,
1183
+ "loss": 0.0044,
1184
+ "step": 1960
1185
+ },
1186
+ {
1187
+ "epoch": 85.65,
1188
+ "learning_rate": 0.006866666666666667,
1189
+ "loss": 0.003,
1190
+ "step": 1970
1191
+ },
1192
+ {
1193
+ "epoch": 86.09,
1194
+ "learning_rate": 0.0068000000000000005,
1195
+ "loss": 0.0054,
1196
+ "step": 1980
1197
+ },
1198
+ {
1199
+ "epoch": 86.52,
1200
+ "learning_rate": 0.006733333333333333,
1201
+ "loss": 0.0041,
1202
+ "step": 1990
1203
+ },
1204
+ {
1205
+ "epoch": 86.96,
1206
+ "learning_rate": 0.006666666666666666,
1207
+ "loss": 0.0055,
1208
+ "step": 2000
1209
+ },
1210
+ {
1211
+ "epoch": 87.39,
1212
+ "learning_rate": 0.006600000000000001,
1213
+ "loss": 0.0028,
1214
+ "step": 2010
1215
+ },
1216
+ {
1217
+ "epoch": 87.83,
1218
+ "learning_rate": 0.006533333333333334,
1219
+ "loss": 0.0045,
1220
+ "step": 2020
1221
+ },
1222
+ {
1223
+ "epoch": 88.26,
1224
+ "learning_rate": 0.006466666666666667,
1225
+ "loss": 0.0035,
1226
+ "step": 2030
1227
+ },
1228
+ {
1229
+ "epoch": 88.7,
1230
+ "learning_rate": 0.0064,
1231
+ "loss": 0.004,
1232
+ "step": 2040
1233
+ },
1234
+ {
1235
+ "epoch": 89.13,
1236
+ "learning_rate": 0.006333333333333333,
1237
+ "loss": 0.0035,
1238
+ "step": 2050
1239
+ },
1240
+ {
1241
+ "epoch": 89.57,
1242
+ "learning_rate": 0.006266666666666667,
1243
+ "loss": 0.004,
1244
+ "step": 2060
1245
+ },
1246
+ {
1247
+ "epoch": 90.0,
1248
+ "learning_rate": 0.0062,
1249
+ "loss": 0.0039,
1250
+ "step": 2070
1251
+ },
1252
+ {
1253
+ "epoch": 90.43,
1254
+ "learning_rate": 0.006133333333333333,
1255
+ "loss": 0.0037,
1256
+ "step": 2080
1257
+ },
1258
+ {
1259
+ "epoch": 90.87,
1260
+ "learning_rate": 0.006066666666666667,
1261
+ "loss": 0.003,
1262
+ "step": 2090
1263
+ },
1264
+ {
1265
+ "epoch": 91.3,
1266
+ "learning_rate": 0.006,
1267
+ "loss": 0.0043,
1268
+ "step": 2100
1269
+ },
1270
+ {
1271
+ "epoch": 91.74,
1272
+ "learning_rate": 0.005933333333333334,
1273
+ "loss": 0.0033,
1274
+ "step": 2110
1275
+ },
1276
+ {
1277
+ "epoch": 92.17,
1278
+ "learning_rate": 0.005866666666666667,
1279
+ "loss": 0.0037,
1280
+ "step": 2120
1281
+ },
1282
+ {
1283
+ "epoch": 92.61,
1284
+ "learning_rate": 0.0058,
1285
+ "loss": 0.0043,
1286
+ "step": 2130
1287
+ },
1288
+ {
1289
+ "epoch": 93.04,
1290
+ "learning_rate": 0.005733333333333333,
1291
+ "loss": 0.0032,
1292
+ "step": 2140
1293
+ },
1294
+ {
1295
+ "epoch": 93.48,
1296
+ "learning_rate": 0.005666666666666666,
1297
+ "loss": 0.003,
1298
+ "step": 2150
1299
+ },
1300
+ {
1301
+ "epoch": 93.91,
1302
+ "learning_rate": 0.005600000000000001,
1303
+ "loss": 0.0043,
1304
+ "step": 2160
1305
+ },
1306
+ {
1307
+ "epoch": 94.35,
1308
+ "learning_rate": 0.005533333333333334,
1309
+ "loss": 0.0044,
1310
+ "step": 2170
1311
+ },
1312
+ {
1313
+ "epoch": 94.78,
1314
+ "learning_rate": 0.0054666666666666665,
1315
+ "loss": 0.0037,
1316
+ "step": 2180
1317
+ },
1318
+ {
1319
+ "epoch": 95.22,
1320
+ "learning_rate": 0.0054,
1321
+ "loss": 0.0062,
1322
+ "step": 2190
1323
+ },
1324
+ {
1325
+ "epoch": 95.65,
1326
+ "learning_rate": 0.005333333333333333,
1327
+ "loss": 0.0031,
1328
+ "step": 2200
1329
+ },
1330
+ {
1331
+ "epoch": 96.09,
1332
+ "learning_rate": 0.005266666666666666,
1333
+ "loss": 0.0046,
1334
+ "step": 2210
1335
+ },
1336
+ {
1337
+ "epoch": 96.52,
1338
+ "learning_rate": 0.005200000000000001,
1339
+ "loss": 0.0036,
1340
+ "step": 2220
1341
+ },
1342
+ {
1343
+ "epoch": 96.96,
1344
+ "learning_rate": 0.0051333333333333335,
1345
+ "loss": 0.0026,
1346
+ "step": 2230
1347
+ },
1348
+ {
1349
+ "epoch": 97.39,
1350
+ "learning_rate": 0.005066666666666667,
1351
+ "loss": 0.0039,
1352
+ "step": 2240
1353
+ },
1354
+ {
1355
+ "epoch": 97.83,
1356
+ "learning_rate": 0.005,
1357
+ "loss": 0.0045,
1358
+ "step": 2250
1359
+ },
1360
+ {
1361
+ "epoch": 98.26,
1362
+ "learning_rate": 0.004933333333333334,
1363
+ "loss": 0.004,
1364
+ "step": 2260
1365
+ },
1366
+ {
1367
+ "epoch": 98.7,
1368
+ "learning_rate": 0.004866666666666667,
1369
+ "loss": 0.0045,
1370
+ "step": 2270
1371
+ },
1372
+ {
1373
+ "epoch": 99.13,
1374
+ "learning_rate": 0.0048,
1375
+ "loss": 0.0028,
1376
+ "step": 2280
1377
+ },
1378
+ {
1379
+ "epoch": 99.57,
1380
+ "learning_rate": 0.004733333333333333,
1381
+ "loss": 0.0039,
1382
+ "step": 2290
1383
+ },
1384
+ {
1385
+ "epoch": 100.0,
1386
+ "learning_rate": 0.004666666666666667,
1387
+ "loss": 0.004,
1388
+ "step": 2300
1389
+ },
1390
+ {
1391
+ "epoch": 100.43,
1392
+ "learning_rate": 0.0046,
1393
+ "loss": 0.003,
1394
+ "step": 2310
1395
+ },
1396
+ {
1397
+ "epoch": 100.87,
1398
+ "learning_rate": 0.004533333333333333,
1399
+ "loss": 0.0043,
1400
+ "step": 2320
1401
+ },
1402
+ {
1403
+ "epoch": 101.3,
1404
+ "learning_rate": 0.0044666666666666665,
1405
+ "loss": 0.0037,
1406
+ "step": 2330
1407
+ },
1408
+ {
1409
+ "epoch": 101.74,
1410
+ "learning_rate": 0.0044,
1411
+ "loss": 0.003,
1412
+ "step": 2340
1413
+ },
1414
+ {
1415
+ "epoch": 102.17,
1416
+ "learning_rate": 0.004333333333333334,
1417
+ "loss": 0.0037,
1418
+ "step": 2350
1419
+ },
1420
+ {
1421
+ "epoch": 102.61,
1422
+ "learning_rate": 0.004266666666666667,
1423
+ "loss": 0.0032,
1424
+ "step": 2360
1425
+ },
1426
+ {
1427
+ "epoch": 103.04,
1428
+ "learning_rate": 0.0042,
1429
+ "loss": 0.0037,
1430
+ "step": 2370
1431
+ },
1432
+ {
1433
+ "epoch": 103.48,
1434
+ "learning_rate": 0.0041333333333333335,
1435
+ "loss": 0.0041,
1436
+ "step": 2380
1437
+ },
1438
+ {
1439
+ "epoch": 103.91,
1440
+ "learning_rate": 0.004066666666666667,
1441
+ "loss": 0.0038,
1442
+ "step": 2390
1443
+ },
1444
+ {
1445
+ "epoch": 104.35,
1446
+ "learning_rate": 0.004,
1447
+ "loss": 0.0022,
1448
+ "step": 2400
1449
+ },
1450
+ {
1451
+ "epoch": 104.78,
1452
+ "learning_rate": 0.003933333333333333,
1453
+ "loss": 0.0033,
1454
+ "step": 2410
1455
+ },
1456
+ {
1457
+ "epoch": 105.22,
1458
+ "learning_rate": 0.0038666666666666667,
1459
+ "loss": 0.0032,
1460
+ "step": 2420
1461
+ },
1462
+ {
1463
+ "epoch": 105.65,
1464
+ "learning_rate": 0.0038,
1465
+ "loss": 0.0039,
1466
+ "step": 2430
1467
+ },
1468
+ {
1469
+ "epoch": 106.09,
1470
+ "learning_rate": 0.0037333333333333337,
1471
+ "loss": 0.0036,
1472
+ "step": 2440
1473
+ },
1474
+ {
1475
+ "epoch": 106.52,
1476
+ "learning_rate": 0.0036666666666666666,
1477
+ "loss": 0.0031,
1478
+ "step": 2450
1479
+ },
1480
+ {
1481
+ "epoch": 106.96,
1482
+ "learning_rate": 0.0036,
1483
+ "loss": 0.0036,
1484
+ "step": 2460
1485
+ },
1486
+ {
1487
+ "epoch": 107.39,
1488
+ "learning_rate": 0.003533333333333333,
1489
+ "loss": 0.0039,
1490
+ "step": 2470
1491
+ },
1492
+ {
1493
+ "epoch": 107.83,
1494
+ "learning_rate": 0.003466666666666667,
1495
+ "loss": 0.0034,
1496
+ "step": 2480
1497
+ },
1498
+ {
1499
+ "epoch": 108.26,
1500
+ "learning_rate": 0.0034000000000000002,
1501
+ "loss": 0.0033,
1502
+ "step": 2490
1503
+ },
1504
+ {
1505
+ "epoch": 108.7,
1506
+ "learning_rate": 0.003333333333333333,
1507
+ "loss": 0.0034,
1508
+ "step": 2500
1509
+ },
1510
+ {
1511
+ "epoch": 109.13,
1512
+ "learning_rate": 0.003266666666666667,
1513
+ "loss": 0.003,
1514
+ "step": 2510
1515
+ },
1516
+ {
1517
+ "epoch": 109.57,
1518
+ "learning_rate": 0.0032,
1519
+ "loss": 0.0033,
1520
+ "step": 2520
1521
+ },
1522
+ {
1523
+ "epoch": 110.0,
1524
+ "learning_rate": 0.0031333333333333335,
1525
+ "loss": 0.0038,
1526
+ "step": 2530
1527
+ },
1528
+ {
1529
+ "epoch": 110.43,
1530
+ "learning_rate": 0.0030666666666666663,
1531
+ "loss": 0.003,
1532
+ "step": 2540
1533
+ },
1534
+ {
1535
+ "epoch": 110.87,
1536
+ "learning_rate": 0.003,
1537
+ "loss": 0.0032,
1538
+ "step": 2550
1539
+ },
1540
+ {
1541
+ "epoch": 111.3,
1542
+ "learning_rate": 0.0029333333333333334,
1543
+ "loss": 0.004,
1544
+ "step": 2560
1545
+ },
1546
+ {
1547
+ "epoch": 111.74,
1548
+ "learning_rate": 0.0028666666666666667,
1549
+ "loss": 0.0029,
1550
+ "step": 2570
1551
+ },
1552
+ {
1553
+ "epoch": 112.17,
1554
+ "learning_rate": 0.0028000000000000004,
1555
+ "loss": 0.0028,
1556
+ "step": 2580
1557
+ },
1558
+ {
1559
+ "epoch": 112.61,
1560
+ "learning_rate": 0.0027333333333333333,
1561
+ "loss": 0.0034,
1562
+ "step": 2590
1563
+ },
1564
+ {
1565
+ "epoch": 113.04,
1566
+ "learning_rate": 0.0026666666666666666,
1567
+ "loss": 0.003,
1568
+ "step": 2600
1569
+ },
1570
+ {
1571
+ "epoch": 113.48,
1572
+ "learning_rate": 0.0026000000000000003,
1573
+ "loss": 0.0027,
1574
+ "step": 2610
1575
+ },
1576
+ {
1577
+ "epoch": 113.91,
1578
+ "learning_rate": 0.0025333333333333336,
1579
+ "loss": 0.0037,
1580
+ "step": 2620
1581
+ },
1582
+ {
1583
+ "epoch": 114.35,
1584
+ "learning_rate": 0.002466666666666667,
1585
+ "loss": 0.003,
1586
+ "step": 2630
1587
+ },
1588
+ {
1589
+ "epoch": 114.78,
1590
+ "learning_rate": 0.0024,
1591
+ "loss": 0.0032,
1592
+ "step": 2640
1593
+ },
1594
+ {
1595
+ "epoch": 115.22,
1596
+ "learning_rate": 0.0023333333333333335,
1597
+ "loss": 0.0029,
1598
+ "step": 2650
1599
+ },
1600
+ {
1601
+ "epoch": 115.65,
1602
+ "learning_rate": 0.0022666666666666664,
1603
+ "loss": 0.0027,
1604
+ "step": 2660
1605
+ },
1606
+ {
1607
+ "epoch": 116.09,
1608
+ "learning_rate": 0.0022,
1609
+ "loss": 0.004,
1610
+ "step": 2670
1611
+ },
1612
+ {
1613
+ "epoch": 116.52,
1614
+ "learning_rate": 0.0021333333333333334,
1615
+ "loss": 0.0032,
1616
+ "step": 2680
1617
+ },
1618
+ {
1619
+ "epoch": 116.96,
1620
+ "learning_rate": 0.0020666666666666667,
1621
+ "loss": 0.0032,
1622
+ "step": 2690
1623
+ },
1624
+ {
1625
+ "epoch": 117.39,
1626
+ "learning_rate": 0.002,
1627
+ "loss": 0.0032,
1628
+ "step": 2700
1629
+ },
1630
+ {
1631
+ "epoch": 117.83,
1632
+ "learning_rate": 0.0019333333333333333,
1633
+ "loss": 0.0034,
1634
+ "step": 2710
1635
+ },
1636
+ {
1637
+ "epoch": 118.26,
1638
+ "learning_rate": 0.0018666666666666669,
1639
+ "loss": 0.0038,
1640
+ "step": 2720
1641
+ },
1642
+ {
1643
+ "epoch": 118.7,
1644
+ "learning_rate": 0.0018,
1645
+ "loss": 0.0028,
1646
+ "step": 2730
1647
+ },
1648
+ {
1649
+ "epoch": 119.13,
1650
+ "learning_rate": 0.0017333333333333335,
1651
+ "loss": 0.0027,
1652
+ "step": 2740
1653
+ },
1654
+ {
1655
+ "epoch": 119.57,
1656
+ "learning_rate": 0.0016666666666666666,
1657
+ "loss": 0.0032,
1658
+ "step": 2750
1659
+ },
1660
+ {
1661
+ "epoch": 120.0,
1662
+ "learning_rate": 0.0016,
1663
+ "loss": 0.0029,
1664
+ "step": 2760
1665
+ },
1666
+ {
1667
+ "epoch": 120.43,
1668
+ "learning_rate": 0.0015333333333333332,
1669
+ "loss": 0.0033,
1670
+ "step": 2770
1671
+ },
1672
+ {
1673
+ "epoch": 120.87,
1674
+ "learning_rate": 0.0014666666666666667,
1675
+ "loss": 0.0036,
1676
+ "step": 2780
1677
+ },
1678
+ {
1679
+ "epoch": 121.3,
1680
+ "learning_rate": 0.0014000000000000002,
1681
+ "loss": 0.0026,
1682
+ "step": 2790
1683
+ },
1684
+ {
1685
+ "epoch": 121.74,
1686
+ "learning_rate": 0.0013333333333333333,
1687
+ "loss": 0.0028,
1688
+ "step": 2800
1689
+ },
1690
+ {
1691
+ "epoch": 122.17,
1692
+ "learning_rate": 0.0012666666666666668,
1693
+ "loss": 0.0026,
1694
+ "step": 2810
1695
+ },
1696
+ {
1697
+ "epoch": 122.61,
1698
+ "learning_rate": 0.0012,
1699
+ "loss": 0.0029,
1700
+ "step": 2820
1701
+ },
1702
+ {
1703
+ "epoch": 123.04,
1704
+ "learning_rate": 0.0011333333333333332,
1705
+ "loss": 0.0036,
1706
+ "step": 2830
1707
+ },
1708
+ {
1709
+ "epoch": 123.48,
1710
+ "learning_rate": 0.0010666666666666667,
1711
+ "loss": 0.0032,
1712
+ "step": 2840
1713
+ },
1714
+ {
1715
+ "epoch": 123.91,
1716
+ "learning_rate": 0.001,
1717
+ "loss": 0.0032,
1718
+ "step": 2850
1719
+ },
1720
+ {
1721
+ "epoch": 124.35,
1722
+ "learning_rate": 0.0009333333333333334,
1723
+ "loss": 0.0027,
1724
+ "step": 2860
1725
+ },
1726
+ {
1727
+ "epoch": 124.78,
1728
+ "learning_rate": 0.0008666666666666667,
1729
+ "loss": 0.0028,
1730
+ "step": 2870
1731
+ },
1732
+ {
1733
+ "epoch": 125.22,
1734
+ "learning_rate": 0.0008,
1735
+ "loss": 0.0027,
1736
+ "step": 2880
1737
+ },
1738
+ {
1739
+ "epoch": 125.65,
1740
+ "learning_rate": 0.0007333333333333333,
1741
+ "loss": 0.0033,
1742
+ "step": 2890
1743
+ },
1744
+ {
1745
+ "epoch": 126.09,
1746
+ "learning_rate": 0.0006666666666666666,
1747
+ "loss": 0.0027,
1748
+ "step": 2900
1749
+ },
1750
+ {
1751
+ "epoch": 126.52,
1752
+ "learning_rate": 0.0006,
1753
+ "loss": 0.0029,
1754
+ "step": 2910
1755
+ },
1756
+ {
1757
+ "epoch": 126.96,
1758
+ "learning_rate": 0.0005333333333333334,
1759
+ "loss": 0.003,
1760
+ "step": 2920
1761
+ },
1762
+ {
1763
+ "epoch": 127.39,
1764
+ "learning_rate": 0.0004666666666666667,
1765
+ "loss": 0.0031,
1766
+ "step": 2930
1767
+ },
1768
+ {
1769
+ "epoch": 127.83,
1770
+ "learning_rate": 0.0004,
1771
+ "loss": 0.0027,
1772
+ "step": 2940
1773
+ },
1774
+ {
1775
+ "epoch": 128.26,
1776
+ "learning_rate": 0.0003333333333333333,
1777
+ "loss": 0.0032,
1778
+ "step": 2950
1779
+ },
1780
+ {
1781
+ "epoch": 128.7,
1782
+ "learning_rate": 0.0002666666666666667,
1783
+ "loss": 0.0027,
1784
+ "step": 2960
1785
+ },
1786
+ {
1787
+ "epoch": 129.13,
1788
+ "learning_rate": 0.0002,
1789
+ "loss": 0.0027,
1790
+ "step": 2970
1791
+ },
1792
+ {
1793
+ "epoch": 129.57,
1794
+ "learning_rate": 0.00013333333333333334,
1795
+ "loss": 0.003,
1796
+ "step": 2980
1797
+ },
1798
+ {
1799
+ "epoch": 130.0,
1800
+ "learning_rate": 6.666666666666667e-05,
1801
+ "loss": 0.0033,
1802
+ "step": 2990
1803
+ },
1804
+ {
1805
+ "epoch": 130.43,
1806
+ "learning_rate": 0.0,
1807
+ "loss": 0.0028,
1808
+ "step": 3000
1809
+ }
1810
+ ],
1811
+ "max_steps": 3000,
1812
+ "num_train_epochs": 131,
1813
+ "total_flos": 1.0315218674515968e+17,
1814
+ "trial_name": null,
1815
+ "trial_params": null
1816
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af29f237716b9a6b665fa2af1ffaca0c4e272abf51a26e1032103f104f27e507
3
+ size 3707