Normal1919
commited on
Commit
•
8f24d28
1
Parent(s):
3928f37
Upload 48 files
Browse files- all_results.json +8 -0
- checkpoint-1000/config.json +44 -0
- checkpoint-1000/configuration_chatglm.py +59 -0
- checkpoint-1000/generation_config.json +6 -0
- checkpoint-1000/modeling_chatglm.py +1285 -0
- checkpoint-1000/optimizer.pt +3 -0
- checkpoint-1000/pytorch_model.bin +3 -0
- checkpoint-1000/quantization.py +0 -0
- checkpoint-1000/rng_state.pth +3 -0
- checkpoint-1000/scheduler.pt +3 -0
- checkpoint-1000/special_tokens_map.json +1 -0
- checkpoint-1000/tokenization_chatglm.py +257 -0
- checkpoint-1000/tokenizer.model +3 -0
- checkpoint-1000/tokenizer_config.json +14 -0
- checkpoint-1000/trainer_state.json +616 -0
- checkpoint-1000/training_args.bin +3 -0
- checkpoint-2000/config.json +44 -0
- checkpoint-2000/configuration_chatglm.py +59 -0
- checkpoint-2000/generation_config.json +6 -0
- checkpoint-2000/modeling_chatglm.py +1285 -0
- checkpoint-2000/optimizer.pt +3 -0
- checkpoint-2000/pytorch_model.bin +3 -0
- checkpoint-2000/quantization.py +0 -0
- checkpoint-2000/rng_state.pth +3 -0
- checkpoint-2000/scheduler.pt +3 -0
- checkpoint-2000/special_tokens_map.json +1 -0
- checkpoint-2000/tokenization_chatglm.py +257 -0
- checkpoint-2000/tokenizer.model +3 -0
- checkpoint-2000/tokenizer_config.json +14 -0
- checkpoint-2000/trainer_state.json +1216 -0
- checkpoint-2000/training_args.bin +3 -0
- checkpoint-3000/config.json +44 -0
- checkpoint-3000/configuration_chatglm.py +59 -0
- checkpoint-3000/generation_config.json +6 -0
- checkpoint-3000/modeling_chatglm.py +1285 -0
- checkpoint-3000/optimizer.pt +3 -0
- checkpoint-3000/pytorch_model.bin +3 -0
- checkpoint-3000/quantization.py +0 -0
- checkpoint-3000/rng_state.pth +3 -0
- checkpoint-3000/scheduler.pt +3 -0
- checkpoint-3000/special_tokens_map.json +1 -0
- checkpoint-3000/tokenization_chatglm.py +257 -0
- checkpoint-3000/tokenizer.model +3 -0
- checkpoint-3000/tokenizer_config.json +14 -0
- checkpoint-3000/trainer_state.json +1816 -0
- checkpoint-3000/training_args.bin +3 -0
- train_results.json +8 -0
- trainer_state.json +1825 -0
all_results.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"epoch": 0.28,
|
3 |
+
"train_loss": 1.2429857851664226,
|
4 |
+
"train_runtime": 27386.6257,
|
5 |
+
"train_samples": 173235,
|
6 |
+
"train_samples_per_second": 1.753,
|
7 |
+
"train_steps_per_second": 0.11
|
8 |
+
}
|
checkpoint-1000/config.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "E:/PycharmProjects/dl_models/chatglm2-6b-int4",
|
3 |
+
"add_bias_linear": false,
|
4 |
+
"add_qkv_bias": true,
|
5 |
+
"apply_query_key_layer_scaling": true,
|
6 |
+
"apply_residual_connection_post_layernorm": false,
|
7 |
+
"architectures": [
|
8 |
+
"ChatGLMForConditionalGeneration"
|
9 |
+
],
|
10 |
+
"attention_dropout": 0.0,
|
11 |
+
"attention_softmax_in_fp32": true,
|
12 |
+
"auto_map": {
|
13 |
+
"AutoConfig": "configuration_chatglm.ChatGLMConfig",
|
14 |
+
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
|
15 |
+
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
|
16 |
+
},
|
17 |
+
"bias_dropout_fusion": true,
|
18 |
+
"eos_token_id": 2,
|
19 |
+
"ffn_hidden_size": 13696,
|
20 |
+
"fp32_residual_connection": false,
|
21 |
+
"hidden_dropout": 0.0,
|
22 |
+
"hidden_size": 4096,
|
23 |
+
"kv_channels": 128,
|
24 |
+
"layernorm_epsilon": 1e-05,
|
25 |
+
"model_type": "chatglm",
|
26 |
+
"multi_query_attention": true,
|
27 |
+
"multi_query_group_num": 2,
|
28 |
+
"num_attention_heads": 32,
|
29 |
+
"num_layers": 28,
|
30 |
+
"original_rope": true,
|
31 |
+
"pad_token_id": 0,
|
32 |
+
"padded_vocab_size": 65024,
|
33 |
+
"post_layer_norm": true,
|
34 |
+
"pre_seq_len": 128,
|
35 |
+
"prefix_projection": false,
|
36 |
+
"quantization_bit": 4,
|
37 |
+
"rmsnorm": true,
|
38 |
+
"seq_length": 32768,
|
39 |
+
"tie_word_embeddings": false,
|
40 |
+
"torch_dtype": "float16",
|
41 |
+
"transformers_version": "4.31.0",
|
42 |
+
"use_cache": true,
|
43 |
+
"vocab_size": 65024
|
44 |
+
}
|
checkpoint-1000/configuration_chatglm.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PretrainedConfig
|
2 |
+
|
3 |
+
|
4 |
+
class ChatGLMConfig(PretrainedConfig):
|
5 |
+
model_type = "chatglm"
|
6 |
+
def __init__(
|
7 |
+
self,
|
8 |
+
num_layers=28,
|
9 |
+
padded_vocab_size=65024,
|
10 |
+
hidden_size=4096,
|
11 |
+
ffn_hidden_size=13696,
|
12 |
+
kv_channels=128,
|
13 |
+
num_attention_heads=32,
|
14 |
+
seq_length=2048,
|
15 |
+
hidden_dropout=0.0,
|
16 |
+
attention_dropout=0.0,
|
17 |
+
layernorm_epsilon=1e-5,
|
18 |
+
rmsnorm=True,
|
19 |
+
apply_residual_connection_post_layernorm=False,
|
20 |
+
post_layer_norm=True,
|
21 |
+
add_bias_linear=False,
|
22 |
+
add_qkv_bias=False,
|
23 |
+
bias_dropout_fusion=True,
|
24 |
+
multi_query_attention=False,
|
25 |
+
multi_query_group_num=1,
|
26 |
+
apply_query_key_layer_scaling=True,
|
27 |
+
attention_softmax_in_fp32=True,
|
28 |
+
fp32_residual_connection=False,
|
29 |
+
quantization_bit=0,
|
30 |
+
pre_seq_len=None,
|
31 |
+
prefix_projection=False,
|
32 |
+
**kwargs
|
33 |
+
):
|
34 |
+
self.num_layers = num_layers
|
35 |
+
self.vocab_size = padded_vocab_size
|
36 |
+
self.padded_vocab_size = padded_vocab_size
|
37 |
+
self.hidden_size = hidden_size
|
38 |
+
self.ffn_hidden_size = ffn_hidden_size
|
39 |
+
self.kv_channels = kv_channels
|
40 |
+
self.num_attention_heads = num_attention_heads
|
41 |
+
self.seq_length = seq_length
|
42 |
+
self.hidden_dropout = hidden_dropout
|
43 |
+
self.attention_dropout = attention_dropout
|
44 |
+
self.layernorm_epsilon = layernorm_epsilon
|
45 |
+
self.rmsnorm = rmsnorm
|
46 |
+
self.apply_residual_connection_post_layernorm = apply_residual_connection_post_layernorm
|
47 |
+
self.post_layer_norm = post_layer_norm
|
48 |
+
self.add_bias_linear = add_bias_linear
|
49 |
+
self.add_qkv_bias = add_qkv_bias
|
50 |
+
self.bias_dropout_fusion = bias_dropout_fusion
|
51 |
+
self.multi_query_attention = multi_query_attention
|
52 |
+
self.multi_query_group_num = multi_query_group_num
|
53 |
+
self.apply_query_key_layer_scaling = apply_query_key_layer_scaling
|
54 |
+
self.attention_softmax_in_fp32 = attention_softmax_in_fp32
|
55 |
+
self.fp32_residual_connection = fp32_residual_connection
|
56 |
+
self.quantization_bit = quantization_bit
|
57 |
+
self.pre_seq_len = pre_seq_len
|
58 |
+
self.prefix_projection = prefix_projection
|
59 |
+
super().__init__(**kwargs)
|
checkpoint-1000/generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"eos_token_id": 2,
|
4 |
+
"pad_token_id": 0,
|
5 |
+
"transformers_version": "4.31.0"
|
6 |
+
}
|
checkpoint-1000/modeling_chatglm.py
ADDED
@@ -0,0 +1,1285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
""" PyTorch ChatGLM model. """
|
2 |
+
|
3 |
+
import math
|
4 |
+
import copy
|
5 |
+
import warnings
|
6 |
+
import re
|
7 |
+
import sys
|
8 |
+
|
9 |
+
import torch
|
10 |
+
import torch.utils.checkpoint
|
11 |
+
import torch.nn.functional as F
|
12 |
+
from torch import nn
|
13 |
+
from torch.nn import CrossEntropyLoss, LayerNorm
|
14 |
+
from torch.nn import CrossEntropyLoss, LayerNorm, MSELoss, BCEWithLogitsLoss
|
15 |
+
from torch.nn.utils import skip_init
|
16 |
+
from typing import Optional, Tuple, Union, List, Callable, Dict, Any
|
17 |
+
|
18 |
+
from transformers.modeling_outputs import (
|
19 |
+
BaseModelOutputWithPast,
|
20 |
+
CausalLMOutputWithPast,
|
21 |
+
SequenceClassifierOutputWithPast,
|
22 |
+
)
|
23 |
+
from transformers.modeling_utils import PreTrainedModel
|
24 |
+
from transformers.utils import logging
|
25 |
+
from transformers.generation.logits_process import LogitsProcessor
|
26 |
+
from transformers.generation.utils import LogitsProcessorList, StoppingCriteriaList, GenerationConfig, ModelOutput
|
27 |
+
|
28 |
+
from .configuration_chatglm import ChatGLMConfig
|
29 |
+
|
30 |
+
# flags required to enable jit fusion kernels
|
31 |
+
|
32 |
+
if sys.platform != 'darwin':
|
33 |
+
torch._C._jit_set_profiling_mode(False)
|
34 |
+
torch._C._jit_set_profiling_executor(False)
|
35 |
+
torch._C._jit_override_can_fuse_on_cpu(True)
|
36 |
+
torch._C._jit_override_can_fuse_on_gpu(True)
|
37 |
+
|
38 |
+
logger = logging.get_logger(__name__)
|
39 |
+
|
40 |
+
_CHECKPOINT_FOR_DOC = "THUDM/ChatGLM2-6B"
|
41 |
+
_CONFIG_FOR_DOC = "ChatGLM6BConfig"
|
42 |
+
|
43 |
+
CHATGLM_6B_PRETRAINED_MODEL_ARCHIVE_LIST = [
|
44 |
+
"THUDM/chatglm2-6b",
|
45 |
+
# See all ChatGLM models at https://huggingface.co/models?filter=chatglm
|
46 |
+
]
|
47 |
+
|
48 |
+
|
49 |
+
def default_init(cls, *args, **kwargs):
|
50 |
+
return cls(*args, **kwargs)
|
51 |
+
|
52 |
+
|
53 |
+
class InvalidScoreLogitsProcessor(LogitsProcessor):
|
54 |
+
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
55 |
+
if torch.isnan(scores).any() or torch.isinf(scores).any():
|
56 |
+
scores.zero_()
|
57 |
+
scores[..., 5] = 5e4
|
58 |
+
return scores
|
59 |
+
|
60 |
+
|
61 |
+
class PrefixEncoder(torch.nn.Module):
|
62 |
+
"""
|
63 |
+
The torch.nn model to encode the prefix
|
64 |
+
Input shape: (batch-size, prefix-length)
|
65 |
+
Output shape: (batch-size, prefix-length, 2*layers*hidden)
|
66 |
+
"""
|
67 |
+
|
68 |
+
def __init__(self, config: ChatGLMConfig):
|
69 |
+
super().__init__()
|
70 |
+
self.prefix_projection = config.prefix_projection
|
71 |
+
if self.prefix_projection:
|
72 |
+
# Use a two-layer MLP to encode the prefix
|
73 |
+
kv_size = config.num_layers * config.kv_channels * config.multi_query_group_num * 2
|
74 |
+
self.embedding = torch.nn.Embedding(config.pre_seq_len, kv_size)
|
75 |
+
self.trans = torch.nn.Sequential(
|
76 |
+
torch.nn.Linear(kv_size, config.hidden_size),
|
77 |
+
torch.nn.Tanh(),
|
78 |
+
torch.nn.Linear(config.hidden_size, kv_size)
|
79 |
+
)
|
80 |
+
else:
|
81 |
+
self.embedding = torch.nn.Embedding(config.pre_seq_len,
|
82 |
+
config.num_layers * config.kv_channels * config.multi_query_group_num * 2)
|
83 |
+
|
84 |
+
def forward(self, prefix: torch.Tensor):
|
85 |
+
if self.prefix_projection:
|
86 |
+
prefix_tokens = self.embedding(prefix)
|
87 |
+
past_key_values = self.trans(prefix_tokens)
|
88 |
+
else:
|
89 |
+
past_key_values = self.embedding(prefix)
|
90 |
+
return past_key_values
|
91 |
+
|
92 |
+
|
93 |
+
def split_tensor_along_last_dim(
|
94 |
+
tensor: torch.Tensor,
|
95 |
+
num_partitions: int,
|
96 |
+
contiguous_split_chunks: bool = False,
|
97 |
+
) -> List[torch.Tensor]:
|
98 |
+
"""Split a tensor along its last dimension.
|
99 |
+
|
100 |
+
Arguments:
|
101 |
+
tensor: input tensor.
|
102 |
+
num_partitions: number of partitions to split the tensor
|
103 |
+
contiguous_split_chunks: If True, make each chunk contiguous
|
104 |
+
in memory.
|
105 |
+
|
106 |
+
Returns:
|
107 |
+
A list of Tensors
|
108 |
+
"""
|
109 |
+
# Get the size and dimension.
|
110 |
+
last_dim = tensor.dim() - 1
|
111 |
+
last_dim_size = tensor.size()[last_dim] // num_partitions
|
112 |
+
# Split.
|
113 |
+
tensor_list = torch.split(tensor, last_dim_size, dim=last_dim)
|
114 |
+
# Note: torch.split does not create contiguous tensors by default.
|
115 |
+
if contiguous_split_chunks:
|
116 |
+
return tuple(chunk.contiguous() for chunk in tensor_list)
|
117 |
+
|
118 |
+
return tensor_list
|
119 |
+
|
120 |
+
|
121 |
+
class RotaryEmbedding(nn.Module):
|
122 |
+
def __init__(self, dim, original_impl=False, device=None, dtype=None):
|
123 |
+
super().__init__()
|
124 |
+
inv_freq = 1.0 / (10000 ** (torch.arange(0, dim, 2, device=device).to(dtype=dtype) / dim))
|
125 |
+
self.register_buffer("inv_freq", inv_freq)
|
126 |
+
self.dim = dim
|
127 |
+
self.original_impl = original_impl
|
128 |
+
|
129 |
+
def forward_impl(
|
130 |
+
self, seq_len: int, n_elem: int, dtype: torch.dtype, device: torch.device, base: int = 10000
|
131 |
+
):
|
132 |
+
"""Enhanced Transformer with Rotary Position Embedding.
|
133 |
+
|
134 |
+
Derived from: https://github.com/labmlai/annotated_deep_learning_paper_implementations/blob/master/labml_nn/
|
135 |
+
transformers/rope/__init__.py. MIT License:
|
136 |
+
https://github.com/labmlai/annotated_deep_learning_paper_implementations/blob/master/license.
|
137 |
+
"""
|
138 |
+
# $\Theta = {\theta_i = 10000^{\frac{2(i-1)}{d}}, i \in [1, 2, ..., \frac{d}{2}]}$
|
139 |
+
theta = 1.0 / (base ** (torch.arange(0, n_elem, 2, dtype=dtype, device=device) / n_elem))
|
140 |
+
|
141 |
+
# Create position indexes `[0, 1, ..., seq_len - 1]`
|
142 |
+
seq_idx = torch.arange(seq_len, dtype=dtype, device=device)
|
143 |
+
|
144 |
+
# Calculate the product of position index and $\theta_i$
|
145 |
+
idx_theta = torch.outer(seq_idx, theta).float()
|
146 |
+
|
147 |
+
cache = torch.stack([torch.cos(idx_theta), torch.sin(idx_theta)], dim=-1)
|
148 |
+
|
149 |
+
# this is to mimic the behaviour of complex32, else we will get different results
|
150 |
+
if dtype in (torch.float16, torch.bfloat16, torch.int8):
|
151 |
+
cache = cache.bfloat16() if dtype == torch.bfloat16 else cache.half()
|
152 |
+
return cache
|
153 |
+
|
154 |
+
def forward(self, max_seq_len, offset=0):
|
155 |
+
return self.forward_impl(
|
156 |
+
max_seq_len, self.dim, dtype=self.inv_freq.dtype, device=self.inv_freq.device
|
157 |
+
)
|
158 |
+
|
159 |
+
|
160 |
+
@torch.jit.script
|
161 |
+
def apply_rotary_pos_emb(x: torch.Tensor, rope_cache: torch.Tensor) -> torch.Tensor:
|
162 |
+
# x: [sq, b, np, hn]
|
163 |
+
sq, b, np, hn = x.size(0), x.size(1), x.size(2), x.size(3)
|
164 |
+
rot_dim = rope_cache.shape[-2] * 2
|
165 |
+
x, x_pass = x[..., :rot_dim], x[..., rot_dim:]
|
166 |
+
# truncate to support variable sizes
|
167 |
+
rope_cache = rope_cache[:sq]
|
168 |
+
xshaped = x.reshape(sq, -1, np, rot_dim // 2, 2)
|
169 |
+
rope_cache = rope_cache.view(sq, -1, 1, xshaped.size(3), 2)
|
170 |
+
x_out2 = torch.stack(
|
171 |
+
[
|
172 |
+
xshaped[..., 0] * rope_cache[..., 0] - xshaped[..., 1] * rope_cache[..., 1],
|
173 |
+
xshaped[..., 1] * rope_cache[..., 0] + xshaped[..., 0] * rope_cache[..., 1],
|
174 |
+
],
|
175 |
+
-1,
|
176 |
+
)
|
177 |
+
x_out2 = x_out2.flatten(3)
|
178 |
+
return torch.cat((x_out2, x_pass), dim=-1)
|
179 |
+
|
180 |
+
|
181 |
+
class RMSNorm(torch.nn.Module):
|
182 |
+
def __init__(self, normalized_shape, eps=1e-5, device=None, dtype=None, **kwargs):
|
183 |
+
super().__init__()
|
184 |
+
self.weight = torch.nn.Parameter(torch.empty(normalized_shape, device=device, dtype=dtype))
|
185 |
+
self.eps = eps
|
186 |
+
|
187 |
+
def forward(self, hidden_states: torch.Tensor):
|
188 |
+
input_dtype = hidden_states.dtype
|
189 |
+
variance = hidden_states.to(torch.float32).pow(2).mean(-1, keepdim=True)
|
190 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.eps)
|
191 |
+
|
192 |
+
return (self.weight * hidden_states).to(input_dtype)
|
193 |
+
|
194 |
+
|
195 |
+
class CoreAttention(torch.nn.Module):
|
196 |
+
def __init__(self, config: ChatGLMConfig, layer_number):
|
197 |
+
super(CoreAttention, self).__init__()
|
198 |
+
|
199 |
+
self.apply_query_key_layer_scaling = config.apply_query_key_layer_scaling
|
200 |
+
self.attention_softmax_in_fp32 = config.attention_softmax_in_fp32
|
201 |
+
if self.apply_query_key_layer_scaling:
|
202 |
+
self.attention_softmax_in_fp32 = True
|
203 |
+
self.layer_number = max(1, layer_number)
|
204 |
+
|
205 |
+
projection_size = config.kv_channels * config.num_attention_heads
|
206 |
+
|
207 |
+
# Per attention head and per partition values.
|
208 |
+
self.hidden_size_per_partition = projection_size
|
209 |
+
self.hidden_size_per_attention_head = projection_size // config.num_attention_heads
|
210 |
+
self.num_attention_heads_per_partition = config.num_attention_heads
|
211 |
+
|
212 |
+
coeff = None
|
213 |
+
self.norm_factor = math.sqrt(self.hidden_size_per_attention_head)
|
214 |
+
if self.apply_query_key_layer_scaling:
|
215 |
+
coeff = self.layer_number
|
216 |
+
self.norm_factor *= coeff
|
217 |
+
self.coeff = coeff
|
218 |
+
|
219 |
+
self.attention_dropout = torch.nn.Dropout(config.attention_dropout)
|
220 |
+
|
221 |
+
def forward(self, query_layer, key_layer, value_layer, attention_mask):
|
222 |
+
pytorch_major_version = int(torch.__version__.split('.')[0])
|
223 |
+
if pytorch_major_version >= 2:
|
224 |
+
query_layer, key_layer, value_layer = [k.permute(1, 2, 0, 3) for k in [query_layer, key_layer, value_layer]]
|
225 |
+
if attention_mask is None and query_layer.shape[2] == key_layer.shape[2]:
|
226 |
+
context_layer = torch.nn.functional.scaled_dot_product_attention(query_layer, key_layer, value_layer,
|
227 |
+
is_causal=True)
|
228 |
+
else:
|
229 |
+
if attention_mask is not None:
|
230 |
+
attention_mask = ~attention_mask
|
231 |
+
context_layer = torch.nn.functional.scaled_dot_product_attention(query_layer, key_layer, value_layer,
|
232 |
+
attention_mask)
|
233 |
+
context_layer = context_layer.permute(2, 0, 1, 3)
|
234 |
+
new_context_layer_shape = context_layer.size()[:-2] + (self.hidden_size_per_partition,)
|
235 |
+
context_layer = context_layer.reshape(*new_context_layer_shape)
|
236 |
+
else:
|
237 |
+
# Raw attention scores
|
238 |
+
|
239 |
+
# [b, np, sq, sk]
|
240 |
+
output_size = (query_layer.size(1), query_layer.size(2), query_layer.size(0), key_layer.size(0))
|
241 |
+
|
242 |
+
# [sq, b, np, hn] -> [sq, b * np, hn]
|
243 |
+
query_layer = query_layer.view(output_size[2], output_size[0] * output_size[1], -1)
|
244 |
+
# [sk, b, np, hn] -> [sk, b * np, hn]
|
245 |
+
key_layer = key_layer.view(output_size[3], output_size[0] * output_size[1], -1)
|
246 |
+
|
247 |
+
# preallocting input tensor: [b * np, sq, sk]
|
248 |
+
matmul_input_buffer = torch.empty(
|
249 |
+
output_size[0] * output_size[1], output_size[2], output_size[3], dtype=query_layer.dtype,
|
250 |
+
device=query_layer.device
|
251 |
+
)
|
252 |
+
|
253 |
+
# Raw attention scores. [b * np, sq, sk]
|
254 |
+
matmul_result = torch.baddbmm(
|
255 |
+
matmul_input_buffer,
|
256 |
+
query_layer.transpose(0, 1), # [b * np, sq, hn]
|
257 |
+
key_layer.transpose(0, 1).transpose(1, 2), # [b * np, hn, sk]
|
258 |
+
beta=0.0,
|
259 |
+
alpha=(1.0 / self.norm_factor),
|
260 |
+
)
|
261 |
+
|
262 |
+
# change view to [b, np, sq, sk]
|
263 |
+
attention_scores = matmul_result.view(*output_size)
|
264 |
+
|
265 |
+
# ===========================
|
266 |
+
# Attention probs and dropout
|
267 |
+
# ===========================
|
268 |
+
|
269 |
+
# attention scores and attention mask [b, np, sq, sk]
|
270 |
+
if self.attention_softmax_in_fp32:
|
271 |
+
attention_scores = attention_scores.float()
|
272 |
+
if self.coeff is not None:
|
273 |
+
attention_scores = attention_scores * self.coeff
|
274 |
+
if attention_mask is None and attention_scores.shape[2] == attention_scores.shape[3]:
|
275 |
+
attention_mask = torch.ones(output_size[0], 1, output_size[2], output_size[3],
|
276 |
+
device=attention_scores.device, dtype=torch.bool)
|
277 |
+
attention_mask.tril_()
|
278 |
+
attention_mask = ~attention_mask
|
279 |
+
if attention_mask is not None:
|
280 |
+
attention_scores = attention_scores.masked_fill(attention_mask, float("-inf"))
|
281 |
+
attention_probs = F.softmax(attention_scores, dim=-1)
|
282 |
+
attention_probs = attention_probs.type_as(value_layer)
|
283 |
+
|
284 |
+
# This is actually dropping out entire tokens to attend to, which might
|
285 |
+
# seem a bit unusual, but is taken from the original Transformer paper.
|
286 |
+
attention_probs = self.attention_dropout(attention_probs)
|
287 |
+
# =========================
|
288 |
+
# Context layer. [sq, b, hp]
|
289 |
+
# =========================
|
290 |
+
|
291 |
+
# value_layer -> context layer.
|
292 |
+
# [sk, b, np, hn] --> [b, np, sq, hn]
|
293 |
+
|
294 |
+
# context layer shape: [b, np, sq, hn]
|
295 |
+
output_size = (value_layer.size(1), value_layer.size(2), query_layer.size(0), value_layer.size(3))
|
296 |
+
# change view [sk, b * np, hn]
|
297 |
+
value_layer = value_layer.view(value_layer.size(0), output_size[0] * output_size[1], -1)
|
298 |
+
# change view [b * np, sq, sk]
|
299 |
+
attention_probs = attention_probs.view(output_size[0] * output_size[1], output_size[2], -1)
|
300 |
+
# matmul: [b * np, sq, hn]
|
301 |
+
context_layer = torch.bmm(attention_probs, value_layer.transpose(0, 1))
|
302 |
+
# change view [b, np, sq, hn]
|
303 |
+
context_layer = context_layer.view(*output_size)
|
304 |
+
# [b, np, sq, hn] --> [sq, b, np, hn]
|
305 |
+
context_layer = context_layer.permute(2, 0, 1, 3).contiguous()
|
306 |
+
# [sq, b, np, hn] --> [sq, b, hp]
|
307 |
+
new_context_layer_shape = context_layer.size()[:-2] + (self.hidden_size_per_partition,)
|
308 |
+
context_layer = context_layer.view(*new_context_layer_shape)
|
309 |
+
|
310 |
+
return context_layer
|
311 |
+
|
312 |
+
|
313 |
+
class SelfAttention(torch.nn.Module):
|
314 |
+
"""Parallel self-attention layer abstract class.
|
315 |
+
|
316 |
+
Self-attention layer takes input with size [s, b, h]
|
317 |
+
and returns output of the same size.
|
318 |
+
"""
|
319 |
+
|
320 |
+
def __init__(self, config: ChatGLMConfig, layer_number, device=None):
|
321 |
+
super(SelfAttention, self).__init__()
|
322 |
+
self.layer_number = max(1, layer_number)
|
323 |
+
|
324 |
+
self.projection_size = config.kv_channels * config.num_attention_heads
|
325 |
+
|
326 |
+
# Per attention head and per partition values.
|
327 |
+
self.hidden_size_per_attention_head = self.projection_size // config.num_attention_heads
|
328 |
+
self.num_attention_heads_per_partition = config.num_attention_heads
|
329 |
+
|
330 |
+
self.multi_query_attention = config.multi_query_attention
|
331 |
+
self.qkv_hidden_size = 3 * self.projection_size
|
332 |
+
if self.multi_query_attention:
|
333 |
+
self.num_multi_query_groups_per_partition = config.multi_query_group_num
|
334 |
+
self.qkv_hidden_size = (
|
335 |
+
self.projection_size + 2 * self.hidden_size_per_attention_head * config.multi_query_group_num
|
336 |
+
)
|
337 |
+
self.query_key_value = nn.Linear(config.hidden_size, self.qkv_hidden_size,
|
338 |
+
bias=config.add_bias_linear or config.add_qkv_bias,
|
339 |
+
device=device, **_config_to_kwargs(config)
|
340 |
+
)
|
341 |
+
|
342 |
+
self.core_attention = CoreAttention(config, self.layer_number)
|
343 |
+
|
344 |
+
# Output.
|
345 |
+
self.dense = nn.Linear(self.projection_size, config.hidden_size, bias=config.add_bias_linear,
|
346 |
+
device=device, **_config_to_kwargs(config)
|
347 |
+
)
|
348 |
+
|
349 |
+
def _allocate_memory(self, inference_max_sequence_len, batch_size, device=None, dtype=None):
|
350 |
+
if self.multi_query_attention:
|
351 |
+
num_attention_heads = self.num_multi_query_groups_per_partition
|
352 |
+
else:
|
353 |
+
num_attention_heads = self.num_attention_heads_per_partition
|
354 |
+
return torch.empty(
|
355 |
+
inference_max_sequence_len,
|
356 |
+
batch_size,
|
357 |
+
num_attention_heads,
|
358 |
+
self.hidden_size_per_attention_head,
|
359 |
+
dtype=dtype,
|
360 |
+
device=device,
|
361 |
+
)
|
362 |
+
|
363 |
+
def forward(
|
364 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_cache=None, use_cache=True
|
365 |
+
):
|
366 |
+
# hidden_states: [sq, b, h]
|
367 |
+
|
368 |
+
# =================================================
|
369 |
+
# Pre-allocate memory for key-values for inference.
|
370 |
+
# =================================================
|
371 |
+
# =====================
|
372 |
+
# Query, Key, and Value
|
373 |
+
# =====================
|
374 |
+
|
375 |
+
# Attention heads [sq, b, h] --> [sq, b, (np * 3 * hn)]
|
376 |
+
mixed_x_layer = self.query_key_value(hidden_states)
|
377 |
+
|
378 |
+
if self.multi_query_attention:
|
379 |
+
(query_layer, key_layer, value_layer) = mixed_x_layer.split(
|
380 |
+
[
|
381 |
+
self.num_attention_heads_per_partition * self.hidden_size_per_attention_head,
|
382 |
+
self.num_multi_query_groups_per_partition * self.hidden_size_per_attention_head,
|
383 |
+
self.num_multi_query_groups_per_partition * self.hidden_size_per_attention_head,
|
384 |
+
],
|
385 |
+
dim=-1,
|
386 |
+
)
|
387 |
+
query_layer = query_layer.view(
|
388 |
+
query_layer.size()[:-1] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
389 |
+
)
|
390 |
+
key_layer = key_layer.view(
|
391 |
+
key_layer.size()[:-1] + (self.num_multi_query_groups_per_partition, self.hidden_size_per_attention_head)
|
392 |
+
)
|
393 |
+
value_layer = value_layer.view(
|
394 |
+
value_layer.size()[:-1]
|
395 |
+
+ (self.num_multi_query_groups_per_partition, self.hidden_size_per_attention_head)
|
396 |
+
)
|
397 |
+
else:
|
398 |
+
new_tensor_shape = mixed_x_layer.size()[:-1] + \
|
399 |
+
(self.num_attention_heads_per_partition,
|
400 |
+
3 * self.hidden_size_per_attention_head)
|
401 |
+
mixed_x_layer = mixed_x_layer.view(*new_tensor_shape)
|
402 |
+
|
403 |
+
# [sq, b, np, 3 * hn] --> 3 [sq, b, np, hn]
|
404 |
+
(query_layer, key_layer, value_layer) = split_tensor_along_last_dim(mixed_x_layer, 3)
|
405 |
+
|
406 |
+
# apply relative positional encoding (rotary embedding)
|
407 |
+
if rotary_pos_emb is not None:
|
408 |
+
query_layer = apply_rotary_pos_emb(query_layer, rotary_pos_emb)
|
409 |
+
key_layer = apply_rotary_pos_emb(key_layer, rotary_pos_emb)
|
410 |
+
|
411 |
+
# adjust key and value for inference
|
412 |
+
if kv_cache is not None:
|
413 |
+
cache_k, cache_v = kv_cache
|
414 |
+
key_layer = torch.cat((cache_k, key_layer), dim=0)
|
415 |
+
value_layer = torch.cat((cache_v, value_layer), dim=0)
|
416 |
+
if use_cache:
|
417 |
+
kv_cache = (key_layer, value_layer)
|
418 |
+
else:
|
419 |
+
kv_cache = None
|
420 |
+
|
421 |
+
if self.multi_query_attention:
|
422 |
+
key_layer = key_layer.unsqueeze(-2)
|
423 |
+
key_layer = key_layer.expand(
|
424 |
+
-1, -1, -1, self.num_attention_heads_per_partition // self.num_multi_query_groups_per_partition, -1
|
425 |
+
)
|
426 |
+
key_layer = key_layer.contiguous().view(
|
427 |
+
key_layer.size()[:2] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
428 |
+
)
|
429 |
+
value_layer = value_layer.unsqueeze(-2)
|
430 |
+
value_layer = value_layer.expand(
|
431 |
+
-1, -1, -1, self.num_attention_heads_per_partition // self.num_multi_query_groups_per_partition, -1
|
432 |
+
)
|
433 |
+
value_layer = value_layer.contiguous().view(
|
434 |
+
value_layer.size()[:2] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
435 |
+
)
|
436 |
+
|
437 |
+
# ==================================
|
438 |
+
# core attention computation
|
439 |
+
# ==================================
|
440 |
+
|
441 |
+
context_layer = self.core_attention(query_layer, key_layer, value_layer, attention_mask)
|
442 |
+
|
443 |
+
# =================
|
444 |
+
# Output. [sq, b, h]
|
445 |
+
# =================
|
446 |
+
|
447 |
+
output = self.dense(context_layer)
|
448 |
+
|
449 |
+
return output, kv_cache
|
450 |
+
|
451 |
+
|
452 |
+
def _config_to_kwargs(args):
|
453 |
+
common_kwargs = {
|
454 |
+
"dtype": args.torch_dtype,
|
455 |
+
}
|
456 |
+
return common_kwargs
|
457 |
+
|
458 |
+
|
459 |
+
class MLP(torch.nn.Module):
|
460 |
+
"""MLP.
|
461 |
+
|
462 |
+
MLP will take the input with h hidden state, project it to 4*h
|
463 |
+
hidden dimension, perform nonlinear transformation, and project the
|
464 |
+
state back into h hidden dimension.
|
465 |
+
"""
|
466 |
+
|
467 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
468 |
+
super(MLP, self).__init__()
|
469 |
+
|
470 |
+
self.add_bias = config.add_bias_linear
|
471 |
+
|
472 |
+
# Project to 4h. If using swiglu double the output width, see https://arxiv.org/pdf/2002.05202.pdf
|
473 |
+
self.dense_h_to_4h = nn.Linear(
|
474 |
+
config.hidden_size,
|
475 |
+
config.ffn_hidden_size * 2,
|
476 |
+
bias=self.add_bias,
|
477 |
+
device=device,
|
478 |
+
**_config_to_kwargs(config)
|
479 |
+
)
|
480 |
+
|
481 |
+
def swiglu(x):
|
482 |
+
x = torch.chunk(x, 2, dim=-1)
|
483 |
+
return F.silu(x[0]) * x[1]
|
484 |
+
|
485 |
+
self.activation_func = swiglu
|
486 |
+
|
487 |
+
# Project back to h.
|
488 |
+
self.dense_4h_to_h = nn.Linear(
|
489 |
+
config.ffn_hidden_size,
|
490 |
+
config.hidden_size,
|
491 |
+
bias=self.add_bias,
|
492 |
+
device=device,
|
493 |
+
**_config_to_kwargs(config)
|
494 |
+
)
|
495 |
+
|
496 |
+
def forward(self, hidden_states):
|
497 |
+
# [s, b, 4hp]
|
498 |
+
intermediate_parallel = self.dense_h_to_4h(hidden_states)
|
499 |
+
intermediate_parallel = self.activation_func(intermediate_parallel)
|
500 |
+
# [s, b, h]
|
501 |
+
output = self.dense_4h_to_h(intermediate_parallel)
|
502 |
+
return output
|
503 |
+
|
504 |
+
|
505 |
+
class GLMBlock(torch.nn.Module):
|
506 |
+
"""A single transformer layer.
|
507 |
+
|
508 |
+
Transformer layer takes input with size [s, b, h] and returns an
|
509 |
+
output of the same size.
|
510 |
+
"""
|
511 |
+
|
512 |
+
def __init__(self, config: ChatGLMConfig, layer_number, device=None):
|
513 |
+
super(GLMBlock, self).__init__()
|
514 |
+
self.layer_number = layer_number
|
515 |
+
|
516 |
+
self.apply_residual_connection_post_layernorm = config.apply_residual_connection_post_layernorm
|
517 |
+
|
518 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
519 |
+
|
520 |
+
LayerNormFunc = RMSNorm if config.rmsnorm else LayerNorm
|
521 |
+
# Layernorm on the input data.
|
522 |
+
self.input_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
523 |
+
dtype=config.torch_dtype)
|
524 |
+
|
525 |
+
# Self attention.
|
526 |
+
self.self_attention = SelfAttention(config, layer_number, device=device)
|
527 |
+
self.hidden_dropout = config.hidden_dropout
|
528 |
+
|
529 |
+
# Layernorm on the attention output
|
530 |
+
self.post_attention_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
531 |
+
dtype=config.torch_dtype)
|
532 |
+
|
533 |
+
# MLP
|
534 |
+
self.mlp = MLP(config, device=device)
|
535 |
+
|
536 |
+
def forward(
|
537 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_cache=None, use_cache=True,
|
538 |
+
):
|
539 |
+
# hidden_states: [s, b, h]
|
540 |
+
|
541 |
+
# Layer norm at the beginning of the transformer layer.
|
542 |
+
layernorm_output = self.input_layernorm(hidden_states)
|
543 |
+
# Self attention.
|
544 |
+
attention_output, kv_cache = self.self_attention(
|
545 |
+
layernorm_output,
|
546 |
+
attention_mask,
|
547 |
+
rotary_pos_emb,
|
548 |
+
kv_cache=kv_cache,
|
549 |
+
use_cache=use_cache
|
550 |
+
)
|
551 |
+
|
552 |
+
# Residual connection.
|
553 |
+
if self.apply_residual_connection_post_layernorm:
|
554 |
+
residual = layernorm_output
|
555 |
+
else:
|
556 |
+
residual = hidden_states
|
557 |
+
|
558 |
+
layernorm_input = torch.nn.functional.dropout(attention_output, p=self.hidden_dropout, training=self.training)
|
559 |
+
layernorm_input = residual + layernorm_input
|
560 |
+
|
561 |
+
# Layer norm post the self attention.
|
562 |
+
layernorm_output = self.post_attention_layernorm(layernorm_input)
|
563 |
+
|
564 |
+
# MLP.
|
565 |
+
mlp_output = self.mlp(layernorm_output)
|
566 |
+
|
567 |
+
# Second residual connection.
|
568 |
+
if self.apply_residual_connection_post_layernorm:
|
569 |
+
residual = layernorm_output
|
570 |
+
else:
|
571 |
+
residual = layernorm_input
|
572 |
+
|
573 |
+
output = torch.nn.functional.dropout(mlp_output, p=self.hidden_dropout, training=self.training)
|
574 |
+
output = residual + output
|
575 |
+
|
576 |
+
return output, kv_cache
|
577 |
+
|
578 |
+
|
579 |
+
class GLMTransformer(torch.nn.Module):
|
580 |
+
"""Transformer class."""
|
581 |
+
|
582 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
583 |
+
super(GLMTransformer, self).__init__()
|
584 |
+
|
585 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
586 |
+
self.post_layer_norm = config.post_layer_norm
|
587 |
+
|
588 |
+
# Number of layers.
|
589 |
+
self.num_layers = config.num_layers
|
590 |
+
|
591 |
+
# Transformer layers.
|
592 |
+
def build_layer(layer_number):
|
593 |
+
return GLMBlock(config, layer_number, device=device)
|
594 |
+
|
595 |
+
self.layers = torch.nn.ModuleList([build_layer(i + 1) for i in range(self.num_layers)])
|
596 |
+
|
597 |
+
if self.post_layer_norm:
|
598 |
+
LayerNormFunc = RMSNorm if config.rmsnorm else LayerNorm
|
599 |
+
# Final layer norm before output.
|
600 |
+
self.final_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
601 |
+
dtype=config.torch_dtype)
|
602 |
+
|
603 |
+
self.gradient_checkpointing = False
|
604 |
+
|
605 |
+
def _get_layer(self, layer_number):
|
606 |
+
return self.layers[layer_number]
|
607 |
+
|
608 |
+
def forward(
|
609 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_caches=None,
|
610 |
+
use_cache: Optional[bool] = True,
|
611 |
+
output_hidden_states: Optional[bool] = False,
|
612 |
+
):
|
613 |
+
if not kv_caches:
|
614 |
+
kv_caches = [None for _ in range(self.num_layers)]
|
615 |
+
presents = () if use_cache else None
|
616 |
+
if self.gradient_checkpointing and self.training:
|
617 |
+
if use_cache:
|
618 |
+
logger.warning_once(
|
619 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
620 |
+
)
|
621 |
+
use_cache = False
|
622 |
+
|
623 |
+
all_self_attentions = None
|
624 |
+
all_hidden_states = () if output_hidden_states else None
|
625 |
+
for index in range(self.num_layers):
|
626 |
+
if output_hidden_states:
|
627 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
628 |
+
|
629 |
+
layer = self._get_layer(index)
|
630 |
+
if self.gradient_checkpointing and self.training:
|
631 |
+
layer_ret = torch.utils.checkpoint.checkpoint(
|
632 |
+
layer,
|
633 |
+
hidden_states,
|
634 |
+
attention_mask,
|
635 |
+
rotary_pos_emb,
|
636 |
+
kv_caches[index],
|
637 |
+
use_cache
|
638 |
+
)
|
639 |
+
else:
|
640 |
+
layer_ret = layer(
|
641 |
+
hidden_states,
|
642 |
+
attention_mask,
|
643 |
+
rotary_pos_emb,
|
644 |
+
kv_cache=kv_caches[index],
|
645 |
+
use_cache=use_cache
|
646 |
+
)
|
647 |
+
hidden_states, kv_cache = layer_ret
|
648 |
+
if use_cache:
|
649 |
+
presents = presents + (kv_cache,)
|
650 |
+
|
651 |
+
if output_hidden_states:
|
652 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
653 |
+
|
654 |
+
# Final layer norm.
|
655 |
+
if self.post_layer_norm:
|
656 |
+
hidden_states = self.final_layernorm(hidden_states)
|
657 |
+
|
658 |
+
return hidden_states, presents, all_hidden_states, all_self_attentions
|
659 |
+
|
660 |
+
|
661 |
+
class ChatGLMPreTrainedModel(PreTrainedModel):
|
662 |
+
"""
|
663 |
+
An abstract class to handle weights initialization and
|
664 |
+
a simple interface for downloading and loading pretrained models.
|
665 |
+
"""
|
666 |
+
|
667 |
+
is_parallelizable = False
|
668 |
+
supports_gradient_checkpointing = True
|
669 |
+
config_class = ChatGLMConfig
|
670 |
+
base_model_prefix = "transformer"
|
671 |
+
_no_split_modules = ["GLMBlock"]
|
672 |
+
|
673 |
+
def _init_weights(self, module: nn.Module):
|
674 |
+
"""Initialize the weights."""
|
675 |
+
return
|
676 |
+
|
677 |
+
def get_masks(self, input_ids, past_key_values, padding_mask=None):
|
678 |
+
batch_size, seq_length = input_ids.shape
|
679 |
+
full_attention_mask = torch.ones(batch_size, seq_length, seq_length, device=input_ids.device)
|
680 |
+
full_attention_mask.tril_()
|
681 |
+
past_length = 0
|
682 |
+
if past_key_values:
|
683 |
+
past_length = past_key_values[0][0].shape[0]
|
684 |
+
if past_length:
|
685 |
+
full_attention_mask = torch.cat((torch.ones(batch_size, seq_length, past_length,
|
686 |
+
device=input_ids.device), full_attention_mask), dim=-1)
|
687 |
+
if padding_mask is not None:
|
688 |
+
full_attention_mask = full_attention_mask * padding_mask.unsqueeze(1)
|
689 |
+
if not past_length and padding_mask is not None:
|
690 |
+
full_attention_mask -= padding_mask.unsqueeze(-1) - 1
|
691 |
+
full_attention_mask = (full_attention_mask < 0.5).bool()
|
692 |
+
full_attention_mask.unsqueeze_(1)
|
693 |
+
return full_attention_mask
|
694 |
+
|
695 |
+
def get_position_ids(self, input_ids, device):
|
696 |
+
batch_size, seq_length = input_ids.shape
|
697 |
+
position_ids = torch.arange(seq_length, dtype=torch.long, device=device).unsqueeze(0).repeat(batch_size, 1)
|
698 |
+
return position_ids
|
699 |
+
|
700 |
+
def _set_gradient_checkpointing(self, module, value=False):
|
701 |
+
if isinstance(module, GLMTransformer):
|
702 |
+
module.gradient_checkpointing = value
|
703 |
+
|
704 |
+
|
705 |
+
class Embedding(torch.nn.Module):
|
706 |
+
"""Language model embeddings."""
|
707 |
+
|
708 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
709 |
+
super(Embedding, self).__init__()
|
710 |
+
|
711 |
+
self.hidden_size = config.hidden_size
|
712 |
+
# Word embeddings (parallel).
|
713 |
+
self.word_embeddings = nn.Embedding(
|
714 |
+
config.padded_vocab_size,
|
715 |
+
self.hidden_size,
|
716 |
+
dtype=config.torch_dtype,
|
717 |
+
device=device
|
718 |
+
)
|
719 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
720 |
+
|
721 |
+
def forward(self, input_ids):
|
722 |
+
# Embeddings.
|
723 |
+
words_embeddings = self.word_embeddings(input_ids)
|
724 |
+
embeddings = words_embeddings
|
725 |
+
# Data format change to avoid explicit tranposes : [b s h] --> [s b h].
|
726 |
+
embeddings = embeddings.transpose(0, 1).contiguous()
|
727 |
+
# If the input flag for fp32 residual connection is set, convert for float.
|
728 |
+
if self.fp32_residual_connection:
|
729 |
+
embeddings = embeddings.float()
|
730 |
+
return embeddings
|
731 |
+
|
732 |
+
|
733 |
+
class ChatGLMModel(ChatGLMPreTrainedModel):
|
734 |
+
def __init__(self, config: ChatGLMConfig, device=None, empty_init=True):
|
735 |
+
super().__init__(config)
|
736 |
+
if empty_init:
|
737 |
+
init_method = skip_init
|
738 |
+
else:
|
739 |
+
init_method = default_init
|
740 |
+
init_kwargs = {}
|
741 |
+
if device is not None:
|
742 |
+
init_kwargs["device"] = device
|
743 |
+
self.embedding = init_method(Embedding, config, **init_kwargs)
|
744 |
+
self.num_layers = config.num_layers
|
745 |
+
self.multi_query_group_num = config.multi_query_group_num
|
746 |
+
self.kv_channels = config.kv_channels
|
747 |
+
|
748 |
+
# Rotary positional embeddings
|
749 |
+
self.seq_length = config.seq_length
|
750 |
+
rotary_dim = (
|
751 |
+
config.hidden_size // config.num_attention_heads if config.kv_channels is None else config.kv_channels
|
752 |
+
)
|
753 |
+
|
754 |
+
self.rotary_pos_emb = RotaryEmbedding(rotary_dim // 2, original_impl=config.original_rope, device=device,
|
755 |
+
dtype=config.torch_dtype)
|
756 |
+
self.encoder = init_method(GLMTransformer, config, **init_kwargs)
|
757 |
+
self.output_layer = init_method(nn.Linear, config.hidden_size, config.padded_vocab_size, bias=False,
|
758 |
+
dtype=config.torch_dtype, **init_kwargs)
|
759 |
+
self.pre_seq_len = config.pre_seq_len
|
760 |
+
self.prefix_projection = config.prefix_projection
|
761 |
+
if self.pre_seq_len is not None:
|
762 |
+
for param in self.parameters():
|
763 |
+
param.requires_grad = False
|
764 |
+
self.prefix_tokens = torch.arange(self.pre_seq_len).long()
|
765 |
+
self.prefix_encoder = PrefixEncoder(config)
|
766 |
+
self.dropout = torch.nn.Dropout(0.1)
|
767 |
+
|
768 |
+
def get_input_embeddings(self):
|
769 |
+
return self.embedding.word_embeddings
|
770 |
+
|
771 |
+
def get_prompt(self, batch_size, device, dtype=torch.half):
|
772 |
+
prefix_tokens = self.prefix_tokens.unsqueeze(0).expand(batch_size, -1).to(device)
|
773 |
+
past_key_values = self.prefix_encoder(prefix_tokens).type(dtype)
|
774 |
+
past_key_values = past_key_values.view(
|
775 |
+
batch_size,
|
776 |
+
self.pre_seq_len,
|
777 |
+
self.num_layers * 2,
|
778 |
+
self.multi_query_group_num,
|
779 |
+
self.kv_channels
|
780 |
+
)
|
781 |
+
# seq_len, b, nh, hidden_size
|
782 |
+
past_key_values = self.dropout(past_key_values)
|
783 |
+
past_key_values = past_key_values.permute([2, 1, 0, 3, 4]).split(2)
|
784 |
+
return past_key_values
|
785 |
+
|
786 |
+
def forward(
|
787 |
+
self,
|
788 |
+
input_ids,
|
789 |
+
position_ids: Optional[torch.Tensor] = None,
|
790 |
+
attention_mask: Optional[torch.BoolTensor] = None,
|
791 |
+
full_attention_mask: Optional[torch.BoolTensor] = None,
|
792 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
793 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
794 |
+
use_cache: Optional[bool] = None,
|
795 |
+
output_hidden_states: Optional[bool] = None,
|
796 |
+
return_dict: Optional[bool] = None,
|
797 |
+
):
|
798 |
+
output_hidden_states = (
|
799 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
800 |
+
)
|
801 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
802 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
803 |
+
|
804 |
+
batch_size, seq_length = input_ids.shape
|
805 |
+
|
806 |
+
if inputs_embeds is None:
|
807 |
+
inputs_embeds = self.embedding(input_ids)
|
808 |
+
|
809 |
+
if self.pre_seq_len is not None:
|
810 |
+
if past_key_values is None:
|
811 |
+
past_key_values = self.get_prompt(batch_size=batch_size, device=input_ids.device,
|
812 |
+
dtype=inputs_embeds.dtype)
|
813 |
+
if attention_mask is not None:
|
814 |
+
attention_mask = torch.cat([attention_mask.new_ones((batch_size, self.pre_seq_len)),
|
815 |
+
attention_mask], dim=-1)
|
816 |
+
|
817 |
+
if full_attention_mask is None:
|
818 |
+
if (attention_mask is not None and not attention_mask.all()) or (past_key_values and seq_length != 1):
|
819 |
+
full_attention_mask = self.get_masks(input_ids, past_key_values, padding_mask=attention_mask)
|
820 |
+
|
821 |
+
# Rotary positional embeddings
|
822 |
+
rotary_pos_emb = self.rotary_pos_emb(self.seq_length)
|
823 |
+
if position_ids is not None:
|
824 |
+
rotary_pos_emb = rotary_pos_emb[position_ids]
|
825 |
+
else:
|
826 |
+
rotary_pos_emb = rotary_pos_emb[None, :seq_length]
|
827 |
+
rotary_pos_emb = rotary_pos_emb.transpose(0, 1).contiguous()
|
828 |
+
|
829 |
+
# Run encoder.
|
830 |
+
hidden_states, presents, all_hidden_states, all_self_attentions = self.encoder(
|
831 |
+
inputs_embeds, full_attention_mask, rotary_pos_emb=rotary_pos_emb,
|
832 |
+
kv_caches=past_key_values, use_cache=use_cache, output_hidden_states=output_hidden_states
|
833 |
+
)
|
834 |
+
|
835 |
+
if not return_dict:
|
836 |
+
return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions] if v is not None)
|
837 |
+
|
838 |
+
return BaseModelOutputWithPast(
|
839 |
+
last_hidden_state=hidden_states,
|
840 |
+
past_key_values=presents,
|
841 |
+
hidden_states=all_hidden_states,
|
842 |
+
attentions=all_self_attentions,
|
843 |
+
)
|
844 |
+
|
845 |
+
def quantize(self, weight_bit_width: int):
|
846 |
+
from .quantization import quantize
|
847 |
+
quantize(self.encoder, weight_bit_width)
|
848 |
+
return self
|
849 |
+
|
850 |
+
|
851 |
+
class ChatGLMForConditionalGeneration(ChatGLMPreTrainedModel):
|
852 |
+
def __init__(self, config: ChatGLMConfig, empty_init=True, device=None):
|
853 |
+
super().__init__(config)
|
854 |
+
|
855 |
+
self.max_sequence_length = config.max_length
|
856 |
+
self.transformer = ChatGLMModel(config, empty_init=empty_init, device=device)
|
857 |
+
self.config = config
|
858 |
+
self.quantized = False
|
859 |
+
|
860 |
+
if self.config.quantization_bit:
|
861 |
+
self.quantize(self.config.quantization_bit, empty_init=True)
|
862 |
+
|
863 |
+
def _update_model_kwargs_for_generation(
|
864 |
+
self,
|
865 |
+
outputs: ModelOutput,
|
866 |
+
model_kwargs: Dict[str, Any],
|
867 |
+
is_encoder_decoder: bool = False,
|
868 |
+
standardize_cache_format: bool = False,
|
869 |
+
) -> Dict[str, Any]:
|
870 |
+
# update past_key_values
|
871 |
+
model_kwargs["past_key_values"] = self._extract_past_from_model_output(
|
872 |
+
outputs, standardize_cache_format=standardize_cache_format
|
873 |
+
)
|
874 |
+
|
875 |
+
# update attention mask
|
876 |
+
if "attention_mask" in model_kwargs:
|
877 |
+
attention_mask = model_kwargs["attention_mask"]
|
878 |
+
model_kwargs["attention_mask"] = torch.cat(
|
879 |
+
[attention_mask, attention_mask.new_ones((attention_mask.shape[0], 1))], dim=-1
|
880 |
+
)
|
881 |
+
|
882 |
+
# update position ids
|
883 |
+
if "position_ids" in model_kwargs:
|
884 |
+
position_ids = model_kwargs["position_ids"]
|
885 |
+
new_position_id = position_ids[..., -1:].clone()
|
886 |
+
new_position_id += 1
|
887 |
+
model_kwargs["position_ids"] = torch.cat(
|
888 |
+
[position_ids, new_position_id], dim=-1
|
889 |
+
)
|
890 |
+
|
891 |
+
model_kwargs["is_first_forward"] = False
|
892 |
+
return model_kwargs
|
893 |
+
|
894 |
+
def prepare_inputs_for_generation(
|
895 |
+
self,
|
896 |
+
input_ids: torch.LongTensor,
|
897 |
+
past_key_values: Optional[torch.Tensor] = None,
|
898 |
+
attention_mask: Optional[torch.Tensor] = None,
|
899 |
+
position_ids: Optional[torch.Tensor] = None,
|
900 |
+
use_cache: Optional[bool] = None,
|
901 |
+
is_first_forward: bool = True,
|
902 |
+
**kwargs
|
903 |
+
) -> dict:
|
904 |
+
# only last token for input_ids if past is not None
|
905 |
+
if position_ids is None:
|
906 |
+
position_ids = self.get_position_ids(input_ids, device=input_ids.device)
|
907 |
+
if not is_first_forward:
|
908 |
+
if past_key_values is not None:
|
909 |
+
position_ids = position_ids[..., -1:]
|
910 |
+
input_ids = input_ids[:, -1:]
|
911 |
+
return {
|
912 |
+
"input_ids": input_ids,
|
913 |
+
"past_key_values": past_key_values,
|
914 |
+
"position_ids": position_ids,
|
915 |
+
"attention_mask": attention_mask,
|
916 |
+
"return_last_logit": True,
|
917 |
+
"use_cache": use_cache
|
918 |
+
}
|
919 |
+
|
920 |
+
def forward(
|
921 |
+
self,
|
922 |
+
input_ids: Optional[torch.Tensor] = None,
|
923 |
+
position_ids: Optional[torch.Tensor] = None,
|
924 |
+
attention_mask: Optional[torch.Tensor] = None,
|
925 |
+
past_key_values: Optional[Tuple[torch.FloatTensor]] = None,
|
926 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
927 |
+
labels: Optional[torch.Tensor] = None,
|
928 |
+
use_cache: Optional[bool] = None,
|
929 |
+
output_attentions: Optional[bool] = None,
|
930 |
+
output_hidden_states: Optional[bool] = None,
|
931 |
+
return_dict: Optional[bool] = None,
|
932 |
+
return_last_logit: Optional[bool] = False,
|
933 |
+
):
|
934 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
935 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
936 |
+
|
937 |
+
transformer_outputs = self.transformer(
|
938 |
+
input_ids=input_ids,
|
939 |
+
position_ids=position_ids,
|
940 |
+
attention_mask=attention_mask,
|
941 |
+
past_key_values=past_key_values,
|
942 |
+
inputs_embeds=inputs_embeds,
|
943 |
+
use_cache=use_cache,
|
944 |
+
output_hidden_states=output_hidden_states,
|
945 |
+
return_dict=return_dict,
|
946 |
+
)
|
947 |
+
|
948 |
+
hidden_states = transformer_outputs[0]
|
949 |
+
if return_last_logit:
|
950 |
+
hidden_states = hidden_states[-1:]
|
951 |
+
lm_logits = self.transformer.output_layer(hidden_states)
|
952 |
+
lm_logits = lm_logits.transpose(0, 1).contiguous()
|
953 |
+
|
954 |
+
loss = None
|
955 |
+
if labels is not None:
|
956 |
+
lm_logits = lm_logits.to(torch.float32)
|
957 |
+
|
958 |
+
# Shift so that tokens < n predict n
|
959 |
+
shift_logits = lm_logits[..., :-1, :].contiguous()
|
960 |
+
shift_labels = labels[..., 1:].contiguous()
|
961 |
+
# Flatten the tokens
|
962 |
+
loss_fct = CrossEntropyLoss(ignore_index=-100)
|
963 |
+
loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
|
964 |
+
|
965 |
+
lm_logits = lm_logits.to(hidden_states.dtype)
|
966 |
+
loss = loss.to(hidden_states.dtype)
|
967 |
+
|
968 |
+
if not return_dict:
|
969 |
+
output = (lm_logits,) + transformer_outputs[1:]
|
970 |
+
return ((loss,) + output) if loss is not None else output
|
971 |
+
|
972 |
+
return CausalLMOutputWithPast(
|
973 |
+
loss=loss,
|
974 |
+
logits=lm_logits,
|
975 |
+
past_key_values=transformer_outputs.past_key_values,
|
976 |
+
hidden_states=transformer_outputs.hidden_states,
|
977 |
+
attentions=transformer_outputs.attentions,
|
978 |
+
)
|
979 |
+
|
980 |
+
@staticmethod
|
981 |
+
def _reorder_cache(
|
982 |
+
past: Tuple[Tuple[torch.Tensor, torch.Tensor], ...], beam_idx: torch.LongTensor
|
983 |
+
) -> Tuple[Tuple[torch.Tensor, torch.Tensor], ...]:
|
984 |
+
"""
|
985 |
+
This function is used to re-order the `past_key_values` cache if [`~PreTrainedModel.beam_search`] or
|
986 |
+
[`~PreTrainedModel.beam_sample`] is called. This is required to match `past_key_values` with the correct
|
987 |
+
beam_idx at every generation step.
|
988 |
+
|
989 |
+
Output shares the same memory storage as `past`.
|
990 |
+
"""
|
991 |
+
return tuple(
|
992 |
+
(
|
993 |
+
layer_past[0].index_select(1, beam_idx.to(layer_past[0].device)),
|
994 |
+
layer_past[1].index_select(1, beam_idx.to(layer_past[1].device)),
|
995 |
+
)
|
996 |
+
for layer_past in past
|
997 |
+
)
|
998 |
+
|
999 |
+
def process_response(self, response):
|
1000 |
+
response = response.strip()
|
1001 |
+
response = response.replace("[[训练时间]]", "2023年")
|
1002 |
+
return response
|
1003 |
+
|
1004 |
+
def build_inputs(self, tokenizer, query: str, history: List[Tuple[str, str]] = None):
|
1005 |
+
prompt = tokenizer.build_prompt(query, history=history)
|
1006 |
+
inputs = tokenizer([prompt], return_tensors="pt")
|
1007 |
+
inputs = inputs.to(self.device)
|
1008 |
+
return inputs
|
1009 |
+
|
1010 |
+
def build_stream_inputs(self, tokenizer, query: str, history: List[Tuple[str, str]] = None):
|
1011 |
+
if history:
|
1012 |
+
prompt = "\n\n[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
1013 |
+
input_ids = tokenizer.encode(prompt, add_special_tokens=False)
|
1014 |
+
input_ids = input_ids[1:]
|
1015 |
+
inputs = tokenizer.batch_encode_plus([(input_ids, None)], return_tensors="pt", add_special_tokens=False)
|
1016 |
+
else:
|
1017 |
+
prompt = "[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
1018 |
+
inputs = tokenizer([prompt], return_tensors="pt")
|
1019 |
+
inputs = inputs.to(self.device)
|
1020 |
+
return inputs
|
1021 |
+
|
1022 |
+
@torch.inference_mode()
|
1023 |
+
def chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, max_length: int = 8192, num_beams=1,
|
1024 |
+
do_sample=True, top_p=0.8, temperature=0.8, logits_processor=None, **kwargs):
|
1025 |
+
if history is None:
|
1026 |
+
history = []
|
1027 |
+
if logits_processor is None:
|
1028 |
+
logits_processor = LogitsProcessorList()
|
1029 |
+
logits_processor.append(InvalidScoreLogitsProcessor())
|
1030 |
+
gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p,
|
1031 |
+
"temperature": temperature, "logits_processor": logits_processor, **kwargs}
|
1032 |
+
inputs = self.build_inputs(tokenizer, query, history=history)
|
1033 |
+
outputs = self.generate(**inputs, **gen_kwargs)
|
1034 |
+
outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
|
1035 |
+
response = tokenizer.decode(outputs)
|
1036 |
+
response = self.process_response(response)
|
1037 |
+
history = history + [(query, response)]
|
1038 |
+
return response, history
|
1039 |
+
|
1040 |
+
@torch.inference_mode()
|
1041 |
+
def stream_chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, past_key_values=None,
|
1042 |
+
max_length: int = 8192, do_sample=True, top_p=0.8, temperature=0.8, logits_processor=None,
|
1043 |
+
return_past_key_values=False, **kwargs):
|
1044 |
+
if history is None:
|
1045 |
+
history = []
|
1046 |
+
if logits_processor is None:
|
1047 |
+
logits_processor = LogitsProcessorList()
|
1048 |
+
logits_processor.append(InvalidScoreLogitsProcessor())
|
1049 |
+
gen_kwargs = {"max_length": max_length, "do_sample": do_sample, "top_p": top_p,
|
1050 |
+
"temperature": temperature, "logits_processor": logits_processor, **kwargs}
|
1051 |
+
if past_key_values is None and not return_past_key_values:
|
1052 |
+
inputs = self.build_inputs(tokenizer, query, history=history)
|
1053 |
+
else:
|
1054 |
+
inputs = self.build_stream_inputs(tokenizer, query, history=history)
|
1055 |
+
if past_key_values is not None:
|
1056 |
+
past_length = past_key_values[0][0].shape[0]
|
1057 |
+
if self.transformer.pre_seq_len is not None:
|
1058 |
+
past_length -= self.transformer.pre_seq_len
|
1059 |
+
inputs.position_ids += past_length
|
1060 |
+
attention_mask = inputs.attention_mask
|
1061 |
+
attention_mask = torch.cat((attention_mask.new_ones(1, past_length), attention_mask), dim=1)
|
1062 |
+
inputs['attention_mask'] = attention_mask
|
1063 |
+
for outputs in self.stream_generate(**inputs, past_key_values=past_key_values,
|
1064 |
+
return_past_key_values=return_past_key_values, **gen_kwargs):
|
1065 |
+
if return_past_key_values:
|
1066 |
+
outputs, past_key_values = outputs
|
1067 |
+
outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
|
1068 |
+
response = tokenizer.decode(outputs)
|
1069 |
+
if response and response[-1] != "�":
|
1070 |
+
response = self.process_response(response)
|
1071 |
+
new_history = history + [(query, response)]
|
1072 |
+
if return_past_key_values:
|
1073 |
+
yield response, new_history, past_key_values
|
1074 |
+
else:
|
1075 |
+
yield response, new_history
|
1076 |
+
|
1077 |
+
@torch.inference_mode()
|
1078 |
+
def stream_generate(
|
1079 |
+
self,
|
1080 |
+
input_ids,
|
1081 |
+
generation_config: Optional[GenerationConfig] = None,
|
1082 |
+
logits_processor: Optional[LogitsProcessorList] = None,
|
1083 |
+
stopping_criteria: Optional[StoppingCriteriaList] = None,
|
1084 |
+
prefix_allowed_tokens_fn: Optional[Callable[[int, torch.Tensor], List[int]]] = None,
|
1085 |
+
return_past_key_values=False,
|
1086 |
+
**kwargs,
|
1087 |
+
):
|
1088 |
+
batch_size, input_ids_seq_length = input_ids.shape[0], input_ids.shape[-1]
|
1089 |
+
|
1090 |
+
if generation_config is None:
|
1091 |
+
generation_config = self.generation_config
|
1092 |
+
generation_config = copy.deepcopy(generation_config)
|
1093 |
+
model_kwargs = generation_config.update(**kwargs)
|
1094 |
+
model_kwargs["use_cache"] = generation_config.use_cache
|
1095 |
+
bos_token_id, eos_token_id = generation_config.bos_token_id, generation_config.eos_token_id
|
1096 |
+
|
1097 |
+
if isinstance(eos_token_id, int):
|
1098 |
+
eos_token_id = [eos_token_id]
|
1099 |
+
|
1100 |
+
has_default_max_length = kwargs.get("max_length") is None and generation_config.max_length is not None
|
1101 |
+
if has_default_max_length and generation_config.max_new_tokens is None:
|
1102 |
+
warnings.warn(
|
1103 |
+
f"Using `max_length`'s default ({generation_config.max_length}) to control the generation length. "
|
1104 |
+
"This behaviour is deprecated and will be removed from the config in v5 of Transformers -- we"
|
1105 |
+
" recommend using `max_new_tokens` to control the maximum length of the generation.",
|
1106 |
+
UserWarning,
|
1107 |
+
)
|
1108 |
+
elif generation_config.max_new_tokens is not None:
|
1109 |
+
generation_config.max_length = generation_config.max_new_tokens + input_ids_seq_length
|
1110 |
+
if not has_default_max_length:
|
1111 |
+
logger.warn(
|
1112 |
+
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(="
|
1113 |
+
f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "
|
1114 |
+
"Please refer to the documentation for more information. "
|
1115 |
+
"(https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)",
|
1116 |
+
UserWarning,
|
1117 |
+
)
|
1118 |
+
|
1119 |
+
if input_ids_seq_length >= generation_config.max_length:
|
1120 |
+
input_ids_string = "decoder_input_ids" if self.config.is_encoder_decoder else "input_ids"
|
1121 |
+
logger.warning(
|
1122 |
+
f"Input length of {input_ids_string} is {input_ids_seq_length}, but `max_length` is set to"
|
1123 |
+
f" {generation_config.max_length}. This can lead to unexpected behavior. You should consider"
|
1124 |
+
" increasing `max_new_tokens`."
|
1125 |
+
)
|
1126 |
+
|
1127 |
+
# 2. Set generation parameters if not already defined
|
1128 |
+
logits_processor = logits_processor if logits_processor is not None else LogitsProcessorList()
|
1129 |
+
stopping_criteria = stopping_criteria if stopping_criteria is not None else StoppingCriteriaList()
|
1130 |
+
|
1131 |
+
logits_processor = self._get_logits_processor(
|
1132 |
+
generation_config=generation_config,
|
1133 |
+
input_ids_seq_length=input_ids_seq_length,
|
1134 |
+
encoder_input_ids=input_ids,
|
1135 |
+
prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,
|
1136 |
+
logits_processor=logits_processor,
|
1137 |
+
)
|
1138 |
+
|
1139 |
+
stopping_criteria = self._get_stopping_criteria(
|
1140 |
+
generation_config=generation_config, stopping_criteria=stopping_criteria
|
1141 |
+
)
|
1142 |
+
logits_warper = self._get_logits_warper(generation_config)
|
1143 |
+
|
1144 |
+
unfinished_sequences = input_ids.new(input_ids.shape[0]).fill_(1)
|
1145 |
+
scores = None
|
1146 |
+
while True:
|
1147 |
+
model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
|
1148 |
+
# forward pass to get next token
|
1149 |
+
outputs = self(
|
1150 |
+
**model_inputs,
|
1151 |
+
return_dict=True,
|
1152 |
+
output_attentions=False,
|
1153 |
+
output_hidden_states=False,
|
1154 |
+
)
|
1155 |
+
|
1156 |
+
next_token_logits = outputs.logits[:, -1, :]
|
1157 |
+
|
1158 |
+
# pre-process distribution
|
1159 |
+
next_token_scores = logits_processor(input_ids, next_token_logits)
|
1160 |
+
next_token_scores = logits_warper(input_ids, next_token_scores)
|
1161 |
+
|
1162 |
+
# sample
|
1163 |
+
probs = nn.functional.softmax(next_token_scores, dim=-1)
|
1164 |
+
if generation_config.do_sample:
|
1165 |
+
next_tokens = torch.multinomial(probs, num_samples=1).squeeze(1)
|
1166 |
+
else:
|
1167 |
+
next_tokens = torch.argmax(probs, dim=-1)
|
1168 |
+
|
1169 |
+
# update generated ids, model inputs, and length for next step
|
1170 |
+
input_ids = torch.cat([input_ids, next_tokens[:, None]], dim=-1)
|
1171 |
+
model_kwargs = self._update_model_kwargs_for_generation(
|
1172 |
+
outputs, model_kwargs, is_encoder_decoder=self.config.is_encoder_decoder
|
1173 |
+
)
|
1174 |
+
unfinished_sequences = unfinished_sequences.mul((sum(next_tokens != i for i in eos_token_id)).long())
|
1175 |
+
if return_past_key_values:
|
1176 |
+
yield input_ids, outputs.past_key_values
|
1177 |
+
else:
|
1178 |
+
yield input_ids
|
1179 |
+
# stop when each sentence is finished, or if we exceed the maximum length
|
1180 |
+
if unfinished_sequences.max() == 0 or stopping_criteria(input_ids, scores):
|
1181 |
+
break
|
1182 |
+
|
1183 |
+
def quantize(self, bits: int, empty_init=False, device=None, **kwargs):
|
1184 |
+
if bits == 0:
|
1185 |
+
return
|
1186 |
+
|
1187 |
+
from .quantization import quantize
|
1188 |
+
|
1189 |
+
if self.quantized:
|
1190 |
+
logger.info("Already quantized.")
|
1191 |
+
return self
|
1192 |
+
|
1193 |
+
self.quantized = True
|
1194 |
+
|
1195 |
+
self.config.quantization_bit = bits
|
1196 |
+
|
1197 |
+
self.transformer.encoder = quantize(self.transformer.encoder, bits, empty_init=empty_init, device=device,
|
1198 |
+
**kwargs)
|
1199 |
+
return self
|
1200 |
+
|
1201 |
+
|
1202 |
+
class ChatGLMForSequenceClassification(ChatGLMPreTrainedModel):
|
1203 |
+
def __init__(self, config: ChatGLMConfig, empty_init=True, device=None):
|
1204 |
+
super().__init__(config)
|
1205 |
+
|
1206 |
+
self.num_labels = config.num_labels
|
1207 |
+
self.transformer = ChatGLMModel(config, empty_init=empty_init, device=device)
|
1208 |
+
|
1209 |
+
self.classifier_head = nn.Linear(config.hidden_size, config.num_labels, bias=True, dtype=torch.half)
|
1210 |
+
if config.classifier_dropout is not None:
|
1211 |
+
self.dropout = nn.Dropout(config.classifier_dropout)
|
1212 |
+
else:
|
1213 |
+
self.dropout = None
|
1214 |
+
self.config = config
|
1215 |
+
|
1216 |
+
if self.config.quantization_bit:
|
1217 |
+
self.quantize(self.config.quantization_bit, empty_init=True)
|
1218 |
+
|
1219 |
+
def forward(
|
1220 |
+
self,
|
1221 |
+
input_ids: Optional[torch.LongTensor] = None,
|
1222 |
+
position_ids: Optional[torch.LongTensor] = None,
|
1223 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1224 |
+
full_attention_mask: Optional[torch.Tensor] = None,
|
1225 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
1226 |
+
inputs_embeds: Optional[torch.LongTensor] = None,
|
1227 |
+
labels: Optional[torch.LongTensor] = None,
|
1228 |
+
use_cache: Optional[bool] = None,
|
1229 |
+
output_hidden_states: Optional[bool] = None,
|
1230 |
+
return_dict: Optional[bool] = None,
|
1231 |
+
) -> Union[Tuple[torch.Tensor, ...], SequenceClassifierOutputWithPast]:
|
1232 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1233 |
+
|
1234 |
+
transformer_outputs = self.transformer(
|
1235 |
+
input_ids=input_ids,
|
1236 |
+
position_ids=position_ids,
|
1237 |
+
attention_mask=attention_mask,
|
1238 |
+
full_attention_mask=full_attention_mask,
|
1239 |
+
past_key_values=past_key_values,
|
1240 |
+
inputs_embeds=inputs_embeds,
|
1241 |
+
use_cache=use_cache,
|
1242 |
+
output_hidden_states=output_hidden_states,
|
1243 |
+
return_dict=return_dict,
|
1244 |
+
)
|
1245 |
+
|
1246 |
+
hidden_states = transformer_outputs[0]
|
1247 |
+
pooled_hidden_states = hidden_states[-1]
|
1248 |
+
if self.dropout is not None:
|
1249 |
+
pooled_hidden_states = self.dropout(pooled_hidden_states)
|
1250 |
+
logits = self.classifier_head(pooled_hidden_states)
|
1251 |
+
|
1252 |
+
loss = None
|
1253 |
+
if labels is not None:
|
1254 |
+
if self.config.problem_type is None:
|
1255 |
+
if self.num_labels == 1:
|
1256 |
+
self.config.problem_type = "regression"
|
1257 |
+
elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
|
1258 |
+
self.config.problem_type = "single_label_classification"
|
1259 |
+
else:
|
1260 |
+
self.config.problem_type = "multi_label_classification"
|
1261 |
+
|
1262 |
+
if self.config.problem_type == "regression":
|
1263 |
+
loss_fct = MSELoss()
|
1264 |
+
if self.num_labels == 1:
|
1265 |
+
loss = loss_fct(logits.squeeze().float(), labels.squeeze())
|
1266 |
+
else:
|
1267 |
+
loss = loss_fct(logits.float(), labels)
|
1268 |
+
elif self.config.problem_type == "single_label_classification":
|
1269 |
+
loss_fct = CrossEntropyLoss()
|
1270 |
+
loss = loss_fct(logits.view(-1, self.num_labels).float(), labels.view(-1))
|
1271 |
+
elif self.config.problem_type == "multi_label_classification":
|
1272 |
+
loss_fct = BCEWithLogitsLoss()
|
1273 |
+
loss = loss_fct(logits.float(), labels.view(-1, self.num_labels))
|
1274 |
+
|
1275 |
+
if not return_dict:
|
1276 |
+
output = (logits,) + transformer_outputs[1:]
|
1277 |
+
return ((loss,) + output) if loss is not None else output
|
1278 |
+
|
1279 |
+
return SequenceClassifierOutputWithPast(
|
1280 |
+
loss=loss,
|
1281 |
+
logits=logits,
|
1282 |
+
past_key_values=transformer_outputs.past_key_values,
|
1283 |
+
hidden_states=transformer_outputs.hidden_states,
|
1284 |
+
attentions=transformer_outputs.attentions,
|
1285 |
+
)
|
checkpoint-1000/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:683581a470952333639ab32852612a097f78c7f0a93e0490bab027c65fea6271
|
3 |
+
size 14681455
|
checkpoint-1000/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2e9e5f0ed00486492dce195bfca9bdafe810811fbe498ad167145f41f3d1f89a
|
3 |
+
size 7340861
|
checkpoint-1000/quantization.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
checkpoint-1000/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:637499f18ba38b03c7fc48a0c3d2efcb736559501b48a1e7306e5e2b1d2a20ce
|
3 |
+
size 14575
|
checkpoint-1000/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6b8b2da7849875ff5dc7c5782252c5e9dcc13e8a73ea1fba2a34327b3fe26b3a
|
3 |
+
size 627
|
checkpoint-1000/special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{}
|
checkpoint-1000/tokenization_chatglm.py
ADDED
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
3 |
+
from typing import List, Optional, Union, Dict
|
4 |
+
from sentencepiece import SentencePieceProcessor
|
5 |
+
from transformers import PreTrainedTokenizer
|
6 |
+
from transformers.utils import logging, PaddingStrategy
|
7 |
+
from transformers.tokenization_utils_base import EncodedInput, BatchEncoding
|
8 |
+
|
9 |
+
|
10 |
+
class SPTokenizer:
|
11 |
+
def __init__(self, model_path: str):
|
12 |
+
# reload tokenizer
|
13 |
+
assert os.path.isfile(model_path), model_path
|
14 |
+
self.sp_model = SentencePieceProcessor(model_file=model_path)
|
15 |
+
|
16 |
+
# BOS / EOS token IDs
|
17 |
+
self.n_words: int = self.sp_model.vocab_size()
|
18 |
+
self.bos_id: int = self.sp_model.bos_id()
|
19 |
+
self.eos_id: int = self.sp_model.eos_id()
|
20 |
+
self.pad_id: int = self.sp_model.unk_id()
|
21 |
+
assert self.sp_model.vocab_size() == self.sp_model.get_piece_size()
|
22 |
+
|
23 |
+
special_tokens = ["[MASK]", "[gMASK]", "[sMASK]", "sop", "eop"]
|
24 |
+
self.special_tokens = {}
|
25 |
+
self.index_special_tokens = {}
|
26 |
+
for token in special_tokens:
|
27 |
+
self.special_tokens[token] = self.n_words
|
28 |
+
self.index_special_tokens[self.n_words] = token
|
29 |
+
self.n_words += 1
|
30 |
+
|
31 |
+
def tokenize(self, s: str):
|
32 |
+
return self.sp_model.EncodeAsPieces(s)
|
33 |
+
|
34 |
+
def encode(self, s: str, bos: bool = False, eos: bool = False) -> List[int]:
|
35 |
+
assert type(s) is str
|
36 |
+
t = self.sp_model.encode(s)
|
37 |
+
if bos:
|
38 |
+
t = [self.bos_id] + t
|
39 |
+
if eos:
|
40 |
+
t = t + [self.eos_id]
|
41 |
+
return t
|
42 |
+
|
43 |
+
def decode(self, t: List[int]) -> str:
|
44 |
+
return self.sp_model.decode(t)
|
45 |
+
|
46 |
+
def decode_tokens(self, tokens: List[str]) -> str:
|
47 |
+
text = self.sp_model.DecodePieces(tokens)
|
48 |
+
return text
|
49 |
+
|
50 |
+
def convert_token_to_id(self, token):
|
51 |
+
""" Converts a token (str) in an id using the vocab. """
|
52 |
+
if token in self.special_tokens:
|
53 |
+
return self.special_tokens[token]
|
54 |
+
return self.sp_model.PieceToId(token)
|
55 |
+
|
56 |
+
def convert_id_to_token(self, index):
|
57 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
58 |
+
if index in self.index_special_tokens or index in [self.eos_id, self.bos_id, self.pad_id] or index < 0:
|
59 |
+
return ""
|
60 |
+
return self.sp_model.IdToPiece(index)
|
61 |
+
|
62 |
+
|
63 |
+
class ChatGLMTokenizer(PreTrainedTokenizer):
|
64 |
+
vocab_files_names = {"vocab_file": "tokenizer.model"}
|
65 |
+
|
66 |
+
model_input_names = ["input_ids", "attention_mask", "position_ids"]
|
67 |
+
|
68 |
+
def __init__(self, vocab_file, padding_side="left", clean_up_tokenization_spaces=False, **kwargs):
|
69 |
+
self.name = "GLMTokenizer"
|
70 |
+
|
71 |
+
self.vocab_file = vocab_file
|
72 |
+
self.tokenizer = SPTokenizer(vocab_file)
|
73 |
+
self.special_tokens = {
|
74 |
+
"<bos>": self.tokenizer.bos_id,
|
75 |
+
"<eos>": self.tokenizer.eos_id,
|
76 |
+
"<pad>": self.tokenizer.pad_id
|
77 |
+
}
|
78 |
+
super().__init__(padding_side=padding_side, clean_up_tokenization_spaces=clean_up_tokenization_spaces, **kwargs)
|
79 |
+
|
80 |
+
def get_command(self, token):
|
81 |
+
if token in self.special_tokens:
|
82 |
+
return self.special_tokens[token]
|
83 |
+
assert token in self.tokenizer.special_tokens, f"{token} is not a special token for {self.name}"
|
84 |
+
return self.tokenizer.special_tokens[token]
|
85 |
+
|
86 |
+
@property
|
87 |
+
def unk_token(self) -> str:
|
88 |
+
return "<unk>"
|
89 |
+
|
90 |
+
@property
|
91 |
+
def pad_token(self) -> str:
|
92 |
+
return "<unk>"
|
93 |
+
|
94 |
+
@property
|
95 |
+
def pad_token_id(self):
|
96 |
+
return self.get_command("<pad>")
|
97 |
+
|
98 |
+
@property
|
99 |
+
def eos_token(self) -> str:
|
100 |
+
return "</s>"
|
101 |
+
|
102 |
+
@property
|
103 |
+
def eos_token_id(self):
|
104 |
+
return self.get_command("<eos>")
|
105 |
+
|
106 |
+
@property
|
107 |
+
def vocab_size(self):
|
108 |
+
return self.tokenizer.n_words
|
109 |
+
|
110 |
+
def get_vocab(self):
|
111 |
+
""" Returns vocab as a dict """
|
112 |
+
vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
|
113 |
+
vocab.update(self.added_tokens_encoder)
|
114 |
+
return vocab
|
115 |
+
|
116 |
+
def _tokenize(self, text, **kwargs):
|
117 |
+
return self.tokenizer.tokenize(text)
|
118 |
+
|
119 |
+
def _convert_token_to_id(self, token):
|
120 |
+
""" Converts a token (str) in an id using the vocab. """
|
121 |
+
return self.tokenizer.convert_token_to_id(token)
|
122 |
+
|
123 |
+
def _convert_id_to_token(self, index):
|
124 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
125 |
+
return self.tokenizer.convert_id_to_token(index)
|
126 |
+
|
127 |
+
def convert_tokens_to_string(self, tokens: List[str]) -> str:
|
128 |
+
return self.tokenizer.decode_tokens(tokens)
|
129 |
+
|
130 |
+
def save_vocabulary(self, save_directory, filename_prefix=None):
|
131 |
+
"""
|
132 |
+
Save the vocabulary and special tokens file to a directory.
|
133 |
+
|
134 |
+
Args:
|
135 |
+
save_directory (`str`):
|
136 |
+
The directory in which to save the vocabulary.
|
137 |
+
filename_prefix (`str`, *optional*):
|
138 |
+
An optional prefix to add to the named of the saved files.
|
139 |
+
|
140 |
+
Returns:
|
141 |
+
`Tuple(str)`: Paths to the files saved.
|
142 |
+
"""
|
143 |
+
if os.path.isdir(save_directory):
|
144 |
+
vocab_file = os.path.join(
|
145 |
+
save_directory, self.vocab_files_names["vocab_file"]
|
146 |
+
)
|
147 |
+
else:
|
148 |
+
vocab_file = save_directory
|
149 |
+
|
150 |
+
with open(self.vocab_file, 'rb') as fin:
|
151 |
+
proto_str = fin.read()
|
152 |
+
|
153 |
+
with open(vocab_file, "wb") as writer:
|
154 |
+
writer.write(proto_str)
|
155 |
+
|
156 |
+
return (vocab_file,)
|
157 |
+
|
158 |
+
def get_prefix_tokens(self):
|
159 |
+
prefix_tokens = [self.get_command("[gMASK]"), self.get_command("sop")]
|
160 |
+
return prefix_tokens
|
161 |
+
|
162 |
+
def build_prompt(self, query, history=None):
|
163 |
+
if history is None:
|
164 |
+
history = []
|
165 |
+
prompt = ""
|
166 |
+
for i, (old_query, response) in enumerate(history):
|
167 |
+
prompt += "[Round {}]\n\n问:{}\n\n答:{}\n\n".format(i + 1, old_query, response)
|
168 |
+
prompt += "[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
169 |
+
return prompt
|
170 |
+
|
171 |
+
def build_inputs_with_special_tokens(
|
172 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
173 |
+
) -> List[int]:
|
174 |
+
"""
|
175 |
+
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
|
176 |
+
adding special tokens. A BERT sequence has the following format:
|
177 |
+
|
178 |
+
- single sequence: `[CLS] X [SEP]`
|
179 |
+
- pair of sequences: `[CLS] A [SEP] B [SEP]`
|
180 |
+
|
181 |
+
Args:
|
182 |
+
token_ids_0 (`List[int]`):
|
183 |
+
List of IDs to which the special tokens will be added.
|
184 |
+
token_ids_1 (`List[int]`, *optional*):
|
185 |
+
Optional second list of IDs for sequence pairs.
|
186 |
+
|
187 |
+
Returns:
|
188 |
+
`List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
|
189 |
+
"""
|
190 |
+
prefix_tokens = self.get_prefix_tokens()
|
191 |
+
token_ids_0 = prefix_tokens + token_ids_0
|
192 |
+
if token_ids_1 is not None:
|
193 |
+
token_ids_0 = token_ids_0 + token_ids_1 + [self.get_command("<eos>")]
|
194 |
+
return token_ids_0
|
195 |
+
|
196 |
+
def _pad(
|
197 |
+
self,
|
198 |
+
encoded_inputs: Union[Dict[str, EncodedInput], BatchEncoding],
|
199 |
+
max_length: Optional[int] = None,
|
200 |
+
padding_strategy: PaddingStrategy = PaddingStrategy.DO_NOT_PAD,
|
201 |
+
pad_to_multiple_of: Optional[int] = None,
|
202 |
+
return_attention_mask: Optional[bool] = None,
|
203 |
+
) -> dict:
|
204 |
+
"""
|
205 |
+
Pad encoded inputs (on left/right and up to predefined length or max length in the batch)
|
206 |
+
|
207 |
+
Args:
|
208 |
+
encoded_inputs:
|
209 |
+
Dictionary of tokenized inputs (`List[int]`) or batch of tokenized inputs (`List[List[int]]`).
|
210 |
+
max_length: maximum length of the returned list and optionally padding length (see below).
|
211 |
+
Will truncate by taking into account the special tokens.
|
212 |
+
padding_strategy: PaddingStrategy to use for padding.
|
213 |
+
|
214 |
+
- PaddingStrategy.LONGEST Pad to the longest sequence in the batch
|
215 |
+
- PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
|
216 |
+
- PaddingStrategy.DO_NOT_PAD: Do not pad
|
217 |
+
The tokenizer padding sides are defined in self.padding_side:
|
218 |
+
|
219 |
+
- 'left': pads on the left of the sequences
|
220 |
+
- 'right': pads on the right of the sequences
|
221 |
+
pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
|
222 |
+
This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
|
223 |
+
`>= 7.5` (Volta).
|
224 |
+
return_attention_mask:
|
225 |
+
(optional) Set to False to avoid returning attention mask (default: set to model specifics)
|
226 |
+
"""
|
227 |
+
# Load from model defaults
|
228 |
+
assert self.padding_side == "left"
|
229 |
+
|
230 |
+
required_input = encoded_inputs[self.model_input_names[0]]
|
231 |
+
seq_length = len(required_input)
|
232 |
+
|
233 |
+
if padding_strategy == PaddingStrategy.LONGEST:
|
234 |
+
max_length = len(required_input)
|
235 |
+
|
236 |
+
if max_length is not None and pad_to_multiple_of is not None and (max_length % pad_to_multiple_of != 0):
|
237 |
+
max_length = ((max_length // pad_to_multiple_of) + 1) * pad_to_multiple_of
|
238 |
+
|
239 |
+
needs_to_be_padded = padding_strategy != PaddingStrategy.DO_NOT_PAD and len(required_input) != max_length
|
240 |
+
|
241 |
+
# Initialize attention mask if not present.
|
242 |
+
if "attention_mask" not in encoded_inputs:
|
243 |
+
encoded_inputs["attention_mask"] = [1] * seq_length
|
244 |
+
|
245 |
+
if "position_ids" not in encoded_inputs:
|
246 |
+
encoded_inputs["position_ids"] = list(range(seq_length))
|
247 |
+
|
248 |
+
if needs_to_be_padded:
|
249 |
+
difference = max_length - len(required_input)
|
250 |
+
|
251 |
+
if "attention_mask" in encoded_inputs:
|
252 |
+
encoded_inputs["attention_mask"] = [0] * difference + encoded_inputs["attention_mask"]
|
253 |
+
if "position_ids" in encoded_inputs:
|
254 |
+
encoded_inputs["position_ids"] = [0] * difference + encoded_inputs["position_ids"]
|
255 |
+
encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input
|
256 |
+
|
257 |
+
return encoded_inputs
|
checkpoint-1000/tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7dc4c393423b76e4373e5157ddc34803a0189ba96b21ddbb40269d31468a6f2
|
3 |
+
size 1018370
|
checkpoint-1000/tokenizer_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"auto_map": {
|
3 |
+
"AutoTokenizer": [
|
4 |
+
"tokenization_chatglm.ChatGLMTokenizer",
|
5 |
+
null
|
6 |
+
]
|
7 |
+
},
|
8 |
+
"clean_up_tokenization_spaces": false,
|
9 |
+
"do_lower_case": false,
|
10 |
+
"model_max_length": 1000000000000000019884624838656,
|
11 |
+
"padding_side": "left",
|
12 |
+
"remove_space": false,
|
13 |
+
"tokenizer_class": "ChatGLMTokenizer"
|
14 |
+
}
|
checkpoint-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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 0.09235955575053684,
|
5 |
+
"global_step": 1000,
|
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.0,
|
12 |
+
"learning_rate": 0.019933333333333334,
|
13 |
+
"loss": 2.6644,
|
14 |
+
"step": 10
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"epoch": 0.0,
|
18 |
+
"learning_rate": 0.019866666666666668,
|
19 |
+
"loss": 1.7151,
|
20 |
+
"step": 20
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"epoch": 0.0,
|
24 |
+
"learning_rate": 0.0198,
|
25 |
+
"loss": 1.6228,
|
26 |
+
"step": 30
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"epoch": 0.0,
|
30 |
+
"learning_rate": 0.019733333333333335,
|
31 |
+
"loss": 1.401,
|
32 |
+
"step": 40
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"epoch": 0.0,
|
36 |
+
"learning_rate": 0.019666666666666666,
|
37 |
+
"loss": 1.6172,
|
38 |
+
"step": 50
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"epoch": 0.01,
|
42 |
+
"learning_rate": 0.0196,
|
43 |
+
"loss": 1.4695,
|
44 |
+
"step": 60
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"epoch": 0.01,
|
48 |
+
"learning_rate": 0.019533333333333333,
|
49 |
+
"loss": 1.5137,
|
50 |
+
"step": 70
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"epoch": 0.01,
|
54 |
+
"learning_rate": 0.019466666666666667,
|
55 |
+
"loss": 1.5425,
|
56 |
+
"step": 80
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"epoch": 0.01,
|
60 |
+
"learning_rate": 0.0194,
|
61 |
+
"loss": 1.4272,
|
62 |
+
"step": 90
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"epoch": 0.01,
|
66 |
+
"learning_rate": 0.019333333333333334,
|
67 |
+
"loss": 1.3727,
|
68 |
+
"step": 100
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"epoch": 0.01,
|
72 |
+
"learning_rate": 0.019266666666666668,
|
73 |
+
"loss": 1.3114,
|
74 |
+
"step": 110
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"epoch": 0.01,
|
78 |
+
"learning_rate": 0.0192,
|
79 |
+
"loss": 1.4758,
|
80 |
+
"step": 120
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"epoch": 0.01,
|
84 |
+
"learning_rate": 0.019133333333333332,
|
85 |
+
"loss": 1.5219,
|
86 |
+
"step": 130
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"epoch": 0.01,
|
90 |
+
"learning_rate": 0.01906666666666667,
|
91 |
+
"loss": 1.376,
|
92 |
+
"step": 140
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"epoch": 0.01,
|
96 |
+
"learning_rate": 0.019,
|
97 |
+
"loss": 1.4257,
|
98 |
+
"step": 150
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"epoch": 0.01,
|
102 |
+
"learning_rate": 0.018933333333333333,
|
103 |
+
"loss": 1.3474,
|
104 |
+
"step": 160
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"epoch": 0.02,
|
108 |
+
"learning_rate": 0.018866666666666667,
|
109 |
+
"loss": 1.2929,
|
110 |
+
"step": 170
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"epoch": 0.02,
|
114 |
+
"learning_rate": 0.0188,
|
115 |
+
"loss": 1.3208,
|
116 |
+
"step": 180
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"epoch": 0.02,
|
120 |
+
"learning_rate": 0.018733333333333334,
|
121 |
+
"loss": 1.3381,
|
122 |
+
"step": 190
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"epoch": 0.02,
|
126 |
+
"learning_rate": 0.018666666666666668,
|
127 |
+
"loss": 1.3644,
|
128 |
+
"step": 200
|
129 |
+
},
|
130 |
+
{
|
131 |
+
"epoch": 0.02,
|
132 |
+
"learning_rate": 0.018600000000000002,
|
133 |
+
"loss": 1.2932,
|
134 |
+
"step": 210
|
135 |
+
},
|
136 |
+
{
|
137 |
+
"epoch": 0.02,
|
138 |
+
"learning_rate": 0.018533333333333332,
|
139 |
+
"loss": 1.4092,
|
140 |
+
"step": 220
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"epoch": 0.02,
|
144 |
+
"learning_rate": 0.018466666666666666,
|
145 |
+
"loss": 1.3006,
|
146 |
+
"step": 230
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"epoch": 0.02,
|
150 |
+
"learning_rate": 0.0184,
|
151 |
+
"loss": 1.4572,
|
152 |
+
"step": 240
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"epoch": 0.02,
|
156 |
+
"learning_rate": 0.018333333333333333,
|
157 |
+
"loss": 1.2789,
|
158 |
+
"step": 250
|
159 |
+
},
|
160 |
+
{
|
161 |
+
"epoch": 0.02,
|
162 |
+
"learning_rate": 0.018266666666666667,
|
163 |
+
"loss": 1.4444,
|
164 |
+
"step": 260
|
165 |
+
},
|
166 |
+
{
|
167 |
+
"epoch": 0.02,
|
168 |
+
"learning_rate": 0.0182,
|
169 |
+
"loss": 1.4511,
|
170 |
+
"step": 270
|
171 |
+
},
|
172 |
+
{
|
173 |
+
"epoch": 0.03,
|
174 |
+
"learning_rate": 0.01813333333333333,
|
175 |
+
"loss": 1.3541,
|
176 |
+
"step": 280
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"epoch": 0.03,
|
180 |
+
"learning_rate": 0.01806666666666667,
|
181 |
+
"loss": 1.3228,
|
182 |
+
"step": 290
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"epoch": 0.03,
|
186 |
+
"learning_rate": 0.018000000000000002,
|
187 |
+
"loss": 1.3185,
|
188 |
+
"step": 300
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"epoch": 0.03,
|
192 |
+
"learning_rate": 0.017933333333333332,
|
193 |
+
"loss": 1.199,
|
194 |
+
"step": 310
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"epoch": 0.03,
|
198 |
+
"learning_rate": 0.017866666666666666,
|
199 |
+
"loss": 1.3417,
|
200 |
+
"step": 320
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"epoch": 0.03,
|
204 |
+
"learning_rate": 0.0178,
|
205 |
+
"loss": 1.4251,
|
206 |
+
"step": 330
|
207 |
+
},
|
208 |
+
{
|
209 |
+
"epoch": 0.03,
|
210 |
+
"learning_rate": 0.017733333333333334,
|
211 |
+
"loss": 1.3574,
|
212 |
+
"step": 340
|
213 |
+
},
|
214 |
+
{
|
215 |
+
"epoch": 0.03,
|
216 |
+
"learning_rate": 0.017666666666666667,
|
217 |
+
"loss": 1.2547,
|
218 |
+
"step": 350
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"epoch": 0.03,
|
222 |
+
"learning_rate": 0.0176,
|
223 |
+
"loss": 1.2651,
|
224 |
+
"step": 360
|
225 |
+
},
|
226 |
+
{
|
227 |
+
"epoch": 0.03,
|
228 |
+
"learning_rate": 0.017533333333333335,
|
229 |
+
"loss": 1.3414,
|
230 |
+
"step": 370
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"epoch": 0.04,
|
234 |
+
"learning_rate": 0.017466666666666665,
|
235 |
+
"loss": 1.3322,
|
236 |
+
"step": 380
|
237 |
+
},
|
238 |
+
{
|
239 |
+
"epoch": 0.04,
|
240 |
+
"learning_rate": 0.0174,
|
241 |
+
"loss": 1.4147,
|
242 |
+
"step": 390
|
243 |
+
},
|
244 |
+
{
|
245 |
+
"epoch": 0.04,
|
246 |
+
"learning_rate": 0.017333333333333336,
|
247 |
+
"loss": 1.2813,
|
248 |
+
"step": 400
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"epoch": 0.04,
|
252 |
+
"learning_rate": 0.017266666666666666,
|
253 |
+
"loss": 1.3687,
|
254 |
+
"step": 410
|
255 |
+
},
|
256 |
+
{
|
257 |
+
"epoch": 0.04,
|
258 |
+
"learning_rate": 0.0172,
|
259 |
+
"loss": 1.5593,
|
260 |
+
"step": 420
|
261 |
+
},
|
262 |
+
{
|
263 |
+
"epoch": 0.04,
|
264 |
+
"learning_rate": 0.017133333333333334,
|
265 |
+
"loss": 1.3073,
|
266 |
+
"step": 430
|
267 |
+
},
|
268 |
+
{
|
269 |
+
"epoch": 0.04,
|
270 |
+
"learning_rate": 0.017066666666666667,
|
271 |
+
"loss": 1.2359,
|
272 |
+
"step": 440
|
273 |
+
},
|
274 |
+
{
|
275 |
+
"epoch": 0.04,
|
276 |
+
"learning_rate": 0.017,
|
277 |
+
"loss": 1.2474,
|
278 |
+
"step": 450
|
279 |
+
},
|
280 |
+
{
|
281 |
+
"epoch": 0.04,
|
282 |
+
"learning_rate": 0.016933333333333335,
|
283 |
+
"loss": 1.3874,
|
284 |
+
"step": 460
|
285 |
+
},
|
286 |
+
{
|
287 |
+
"epoch": 0.04,
|
288 |
+
"learning_rate": 0.01686666666666667,
|
289 |
+
"loss": 1.3203,
|
290 |
+
"step": 470
|
291 |
+
},
|
292 |
+
{
|
293 |
+
"epoch": 0.04,
|
294 |
+
"learning_rate": 0.0168,
|
295 |
+
"loss": 1.2875,
|
296 |
+
"step": 480
|
297 |
+
},
|
298 |
+
{
|
299 |
+
"epoch": 0.05,
|
300 |
+
"learning_rate": 0.016733333333333333,
|
301 |
+
"loss": 1.2767,
|
302 |
+
"step": 490
|
303 |
+
},
|
304 |
+
{
|
305 |
+
"epoch": 0.05,
|
306 |
+
"learning_rate": 0.016666666666666666,
|
307 |
+
"loss": 1.3017,
|
308 |
+
"step": 500
|
309 |
+
},
|
310 |
+
{
|
311 |
+
"epoch": 0.05,
|
312 |
+
"learning_rate": 0.0166,
|
313 |
+
"loss": 1.2321,
|
314 |
+
"step": 510
|
315 |
+
},
|
316 |
+
{
|
317 |
+
"epoch": 0.05,
|
318 |
+
"learning_rate": 0.016533333333333334,
|
319 |
+
"loss": 1.1719,
|
320 |
+
"step": 520
|
321 |
+
},
|
322 |
+
{
|
323 |
+
"epoch": 0.05,
|
324 |
+
"learning_rate": 0.016466666666666668,
|
325 |
+
"loss": 1.2552,
|
326 |
+
"step": 530
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"epoch": 0.05,
|
330 |
+
"learning_rate": 0.016399999999999998,
|
331 |
+
"loss": 1.3816,
|
332 |
+
"step": 540
|
333 |
+
},
|
334 |
+
{
|
335 |
+
"epoch": 0.05,
|
336 |
+
"learning_rate": 0.01633333333333333,
|
337 |
+
"loss": 1.2956,
|
338 |
+
"step": 550
|
339 |
+
},
|
340 |
+
{
|
341 |
+
"epoch": 0.05,
|
342 |
+
"learning_rate": 0.01626666666666667,
|
343 |
+
"loss": 1.2061,
|
344 |
+
"step": 560
|
345 |
+
},
|
346 |
+
{
|
347 |
+
"epoch": 0.05,
|
348 |
+
"learning_rate": 0.016200000000000003,
|
349 |
+
"loss": 1.2086,
|
350 |
+
"step": 570
|
351 |
+
},
|
352 |
+
{
|
353 |
+
"epoch": 0.05,
|
354 |
+
"learning_rate": 0.016133333333333333,
|
355 |
+
"loss": 1.1633,
|
356 |
+
"step": 580
|
357 |
+
},
|
358 |
+
{
|
359 |
+
"epoch": 0.05,
|
360 |
+
"learning_rate": 0.016066666666666667,
|
361 |
+
"loss": 1.2638,
|
362 |
+
"step": 590
|
363 |
+
},
|
364 |
+
{
|
365 |
+
"epoch": 0.06,
|
366 |
+
"learning_rate": 0.016,
|
367 |
+
"loss": 1.3441,
|
368 |
+
"step": 600
|
369 |
+
},
|
370 |
+
{
|
371 |
+
"epoch": 0.06,
|
372 |
+
"learning_rate": 0.015933333333333334,
|
373 |
+
"loss": 1.2924,
|
374 |
+
"step": 610
|
375 |
+
},
|
376 |
+
{
|
377 |
+
"epoch": 0.06,
|
378 |
+
"learning_rate": 0.015866666666666668,
|
379 |
+
"loss": 1.1818,
|
380 |
+
"step": 620
|
381 |
+
},
|
382 |
+
{
|
383 |
+
"epoch": 0.06,
|
384 |
+
"learning_rate": 0.0158,
|
385 |
+
"loss": 1.3918,
|
386 |
+
"step": 630
|
387 |
+
},
|
388 |
+
{
|
389 |
+
"epoch": 0.06,
|
390 |
+
"learning_rate": 0.015733333333333332,
|
391 |
+
"loss": 1.2232,
|
392 |
+
"step": 640
|
393 |
+
},
|
394 |
+
{
|
395 |
+
"epoch": 0.06,
|
396 |
+
"learning_rate": 0.015666666666666666,
|
397 |
+
"loss": 1.2472,
|
398 |
+
"step": 650
|
399 |
+
},
|
400 |
+
{
|
401 |
+
"epoch": 0.06,
|
402 |
+
"learning_rate": 0.015600000000000001,
|
403 |
+
"loss": 1.2398,
|
404 |
+
"step": 660
|
405 |
+
},
|
406 |
+
{
|
407 |
+
"epoch": 0.06,
|
408 |
+
"learning_rate": 0.015533333333333333,
|
409 |
+
"loss": 1.3649,
|
410 |
+
"step": 670
|
411 |
+
},
|
412 |
+
{
|
413 |
+
"epoch": 0.06,
|
414 |
+
"learning_rate": 0.015466666666666667,
|
415 |
+
"loss": 1.2302,
|
416 |
+
"step": 680
|
417 |
+
},
|
418 |
+
{
|
419 |
+
"epoch": 0.06,
|
420 |
+
"learning_rate": 0.0154,
|
421 |
+
"loss": 1.2053,
|
422 |
+
"step": 690
|
423 |
+
},
|
424 |
+
{
|
425 |
+
"epoch": 0.06,
|
426 |
+
"learning_rate": 0.015333333333333334,
|
427 |
+
"loss": 1.2974,
|
428 |
+
"step": 700
|
429 |
+
},
|
430 |
+
{
|
431 |
+
"epoch": 0.07,
|
432 |
+
"learning_rate": 0.015266666666666666,
|
433 |
+
"loss": 1.3036,
|
434 |
+
"step": 710
|
435 |
+
},
|
436 |
+
{
|
437 |
+
"epoch": 0.07,
|
438 |
+
"learning_rate": 0.0152,
|
439 |
+
"loss": 1.3162,
|
440 |
+
"step": 720
|
441 |
+
},
|
442 |
+
{
|
443 |
+
"epoch": 0.07,
|
444 |
+
"learning_rate": 0.015133333333333334,
|
445 |
+
"loss": 1.2567,
|
446 |
+
"step": 730
|
447 |
+
},
|
448 |
+
{
|
449 |
+
"epoch": 0.07,
|
450 |
+
"learning_rate": 0.015066666666666666,
|
451 |
+
"loss": 1.2578,
|
452 |
+
"step": 740
|
453 |
+
},
|
454 |
+
{
|
455 |
+
"epoch": 0.07,
|
456 |
+
"learning_rate": 0.015,
|
457 |
+
"loss": 1.2692,
|
458 |
+
"step": 750
|
459 |
+
},
|
460 |
+
{
|
461 |
+
"epoch": 0.07,
|
462 |
+
"learning_rate": 0.014933333333333335,
|
463 |
+
"loss": 1.1332,
|
464 |
+
"step": 760
|
465 |
+
},
|
466 |
+
{
|
467 |
+
"epoch": 0.07,
|
468 |
+
"learning_rate": 0.014866666666666667,
|
469 |
+
"loss": 1.2949,
|
470 |
+
"step": 770
|
471 |
+
},
|
472 |
+
{
|
473 |
+
"epoch": 0.07,
|
474 |
+
"learning_rate": 0.0148,
|
475 |
+
"loss": 1.2703,
|
476 |
+
"step": 780
|
477 |
+
},
|
478 |
+
{
|
479 |
+
"epoch": 0.07,
|
480 |
+
"learning_rate": 0.014733333333333334,
|
481 |
+
"loss": 1.3891,
|
482 |
+
"step": 790
|
483 |
+
},
|
484 |
+
{
|
485 |
+
"epoch": 0.07,
|
486 |
+
"learning_rate": 0.014666666666666666,
|
487 |
+
"loss": 1.3594,
|
488 |
+
"step": 800
|
489 |
+
},
|
490 |
+
{
|
491 |
+
"epoch": 0.07,
|
492 |
+
"learning_rate": 0.0146,
|
493 |
+
"loss": 1.166,
|
494 |
+
"step": 810
|
495 |
+
},
|
496 |
+
{
|
497 |
+
"epoch": 0.08,
|
498 |
+
"learning_rate": 0.014533333333333334,
|
499 |
+
"loss": 1.3256,
|
500 |
+
"step": 820
|
501 |
+
},
|
502 |
+
{
|
503 |
+
"epoch": 0.08,
|
504 |
+
"learning_rate": 0.014466666666666668,
|
505 |
+
"loss": 1.2669,
|
506 |
+
"step": 830
|
507 |
+
},
|
508 |
+
{
|
509 |
+
"epoch": 0.08,
|
510 |
+
"learning_rate": 0.0144,
|
511 |
+
"loss": 1.241,
|
512 |
+
"step": 840
|
513 |
+
},
|
514 |
+
{
|
515 |
+
"epoch": 0.08,
|
516 |
+
"learning_rate": 0.014333333333333333,
|
517 |
+
"loss": 1.2591,
|
518 |
+
"step": 850
|
519 |
+
},
|
520 |
+
{
|
521 |
+
"epoch": 0.08,
|
522 |
+
"learning_rate": 0.014266666666666667,
|
523 |
+
"loss": 1.238,
|
524 |
+
"step": 860
|
525 |
+
},
|
526 |
+
{
|
527 |
+
"epoch": 0.08,
|
528 |
+
"learning_rate": 0.014199999999999999,
|
529 |
+
"loss": 1.3583,
|
530 |
+
"step": 870
|
531 |
+
},
|
532 |
+
{
|
533 |
+
"epoch": 0.08,
|
534 |
+
"learning_rate": 0.014133333333333333,
|
535 |
+
"loss": 1.164,
|
536 |
+
"step": 880
|
537 |
+
},
|
538 |
+
{
|
539 |
+
"epoch": 0.08,
|
540 |
+
"learning_rate": 0.014066666666666668,
|
541 |
+
"loss": 1.2367,
|
542 |
+
"step": 890
|
543 |
+
},
|
544 |
+
{
|
545 |
+
"epoch": 0.08,
|
546 |
+
"learning_rate": 0.013999999999999999,
|
547 |
+
"loss": 1.1864,
|
548 |
+
"step": 900
|
549 |
+
},
|
550 |
+
{
|
551 |
+
"epoch": 0.08,
|
552 |
+
"learning_rate": 0.013933333333333334,
|
553 |
+
"loss": 1.2259,
|
554 |
+
"step": 910
|
555 |
+
},
|
556 |
+
{
|
557 |
+
"epoch": 0.08,
|
558 |
+
"learning_rate": 0.013866666666666668,
|
559 |
+
"loss": 1.2129,
|
560 |
+
"step": 920
|
561 |
+
},
|
562 |
+
{
|
563 |
+
"epoch": 0.09,
|
564 |
+
"learning_rate": 0.0138,
|
565 |
+
"loss": 1.2085,
|
566 |
+
"step": 930
|
567 |
+
},
|
568 |
+
{
|
569 |
+
"epoch": 0.09,
|
570 |
+
"learning_rate": 0.013733333333333334,
|
571 |
+
"loss": 1.2316,
|
572 |
+
"step": 940
|
573 |
+
},
|
574 |
+
{
|
575 |
+
"epoch": 0.09,
|
576 |
+
"learning_rate": 0.013666666666666667,
|
577 |
+
"loss": 1.2721,
|
578 |
+
"step": 950
|
579 |
+
},
|
580 |
+
{
|
581 |
+
"epoch": 0.09,
|
582 |
+
"learning_rate": 0.013600000000000001,
|
583 |
+
"loss": 1.2428,
|
584 |
+
"step": 960
|
585 |
+
},
|
586 |
+
{
|
587 |
+
"epoch": 0.09,
|
588 |
+
"learning_rate": 0.013533333333333333,
|
589 |
+
"loss": 1.2126,
|
590 |
+
"step": 970
|
591 |
+
},
|
592 |
+
{
|
593 |
+
"epoch": 0.09,
|
594 |
+
"learning_rate": 0.013466666666666667,
|
595 |
+
"loss": 1.1583,
|
596 |
+
"step": 980
|
597 |
+
},
|
598 |
+
{
|
599 |
+
"epoch": 0.09,
|
600 |
+
"learning_rate": 0.0134,
|
601 |
+
"loss": 1.2776,
|
602 |
+
"step": 990
|
603 |
+
},
|
604 |
+
{
|
605 |
+
"epoch": 0.09,
|
606 |
+
"learning_rate": 0.013333333333333332,
|
607 |
+
"loss": 1.2317,
|
608 |
+
"step": 1000
|
609 |
+
}
|
610 |
+
],
|
611 |
+
"max_steps": 3000,
|
612 |
+
"num_train_epochs": 1,
|
613 |
+
"total_flos": 5.7864771305472e+16,
|
614 |
+
"trial_name": null,
|
615 |
+
"trial_params": null
|
616 |
+
}
|
checkpoint-1000/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:70ac9eb43a2d446e07cde6bbbb21250fe0373a4093de76a8aa1f7223e3836bcd
|
3 |
+
size 4155
|
checkpoint-2000/config.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "E:/PycharmProjects/dl_models/chatglm2-6b-int4",
|
3 |
+
"add_bias_linear": false,
|
4 |
+
"add_qkv_bias": true,
|
5 |
+
"apply_query_key_layer_scaling": true,
|
6 |
+
"apply_residual_connection_post_layernorm": false,
|
7 |
+
"architectures": [
|
8 |
+
"ChatGLMForConditionalGeneration"
|
9 |
+
],
|
10 |
+
"attention_dropout": 0.0,
|
11 |
+
"attention_softmax_in_fp32": true,
|
12 |
+
"auto_map": {
|
13 |
+
"AutoConfig": "configuration_chatglm.ChatGLMConfig",
|
14 |
+
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
|
15 |
+
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
|
16 |
+
},
|
17 |
+
"bias_dropout_fusion": true,
|
18 |
+
"eos_token_id": 2,
|
19 |
+
"ffn_hidden_size": 13696,
|
20 |
+
"fp32_residual_connection": false,
|
21 |
+
"hidden_dropout": 0.0,
|
22 |
+
"hidden_size": 4096,
|
23 |
+
"kv_channels": 128,
|
24 |
+
"layernorm_epsilon": 1e-05,
|
25 |
+
"model_type": "chatglm",
|
26 |
+
"multi_query_attention": true,
|
27 |
+
"multi_query_group_num": 2,
|
28 |
+
"num_attention_heads": 32,
|
29 |
+
"num_layers": 28,
|
30 |
+
"original_rope": true,
|
31 |
+
"pad_token_id": 0,
|
32 |
+
"padded_vocab_size": 65024,
|
33 |
+
"post_layer_norm": true,
|
34 |
+
"pre_seq_len": 128,
|
35 |
+
"prefix_projection": false,
|
36 |
+
"quantization_bit": 4,
|
37 |
+
"rmsnorm": true,
|
38 |
+
"seq_length": 32768,
|
39 |
+
"tie_word_embeddings": false,
|
40 |
+
"torch_dtype": "float16",
|
41 |
+
"transformers_version": "4.31.0",
|
42 |
+
"use_cache": true,
|
43 |
+
"vocab_size": 65024
|
44 |
+
}
|
checkpoint-2000/configuration_chatglm.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PretrainedConfig
|
2 |
+
|
3 |
+
|
4 |
+
class ChatGLMConfig(PretrainedConfig):
|
5 |
+
model_type = "chatglm"
|
6 |
+
def __init__(
|
7 |
+
self,
|
8 |
+
num_layers=28,
|
9 |
+
padded_vocab_size=65024,
|
10 |
+
hidden_size=4096,
|
11 |
+
ffn_hidden_size=13696,
|
12 |
+
kv_channels=128,
|
13 |
+
num_attention_heads=32,
|
14 |
+
seq_length=2048,
|
15 |
+
hidden_dropout=0.0,
|
16 |
+
attention_dropout=0.0,
|
17 |
+
layernorm_epsilon=1e-5,
|
18 |
+
rmsnorm=True,
|
19 |
+
apply_residual_connection_post_layernorm=False,
|
20 |
+
post_layer_norm=True,
|
21 |
+
add_bias_linear=False,
|
22 |
+
add_qkv_bias=False,
|
23 |
+
bias_dropout_fusion=True,
|
24 |
+
multi_query_attention=False,
|
25 |
+
multi_query_group_num=1,
|
26 |
+
apply_query_key_layer_scaling=True,
|
27 |
+
attention_softmax_in_fp32=True,
|
28 |
+
fp32_residual_connection=False,
|
29 |
+
quantization_bit=0,
|
30 |
+
pre_seq_len=None,
|
31 |
+
prefix_projection=False,
|
32 |
+
**kwargs
|
33 |
+
):
|
34 |
+
self.num_layers = num_layers
|
35 |
+
self.vocab_size = padded_vocab_size
|
36 |
+
self.padded_vocab_size = padded_vocab_size
|
37 |
+
self.hidden_size = hidden_size
|
38 |
+
self.ffn_hidden_size = ffn_hidden_size
|
39 |
+
self.kv_channels = kv_channels
|
40 |
+
self.num_attention_heads = num_attention_heads
|
41 |
+
self.seq_length = seq_length
|
42 |
+
self.hidden_dropout = hidden_dropout
|
43 |
+
self.attention_dropout = attention_dropout
|
44 |
+
self.layernorm_epsilon = layernorm_epsilon
|
45 |
+
self.rmsnorm = rmsnorm
|
46 |
+
self.apply_residual_connection_post_layernorm = apply_residual_connection_post_layernorm
|
47 |
+
self.post_layer_norm = post_layer_norm
|
48 |
+
self.add_bias_linear = add_bias_linear
|
49 |
+
self.add_qkv_bias = add_qkv_bias
|
50 |
+
self.bias_dropout_fusion = bias_dropout_fusion
|
51 |
+
self.multi_query_attention = multi_query_attention
|
52 |
+
self.multi_query_group_num = multi_query_group_num
|
53 |
+
self.apply_query_key_layer_scaling = apply_query_key_layer_scaling
|
54 |
+
self.attention_softmax_in_fp32 = attention_softmax_in_fp32
|
55 |
+
self.fp32_residual_connection = fp32_residual_connection
|
56 |
+
self.quantization_bit = quantization_bit
|
57 |
+
self.pre_seq_len = pre_seq_len
|
58 |
+
self.prefix_projection = prefix_projection
|
59 |
+
super().__init__(**kwargs)
|
checkpoint-2000/generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"eos_token_id": 2,
|
4 |
+
"pad_token_id": 0,
|
5 |
+
"transformers_version": "4.31.0"
|
6 |
+
}
|
checkpoint-2000/modeling_chatglm.py
ADDED
@@ -0,0 +1,1285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
""" PyTorch ChatGLM model. """
|
2 |
+
|
3 |
+
import math
|
4 |
+
import copy
|
5 |
+
import warnings
|
6 |
+
import re
|
7 |
+
import sys
|
8 |
+
|
9 |
+
import torch
|
10 |
+
import torch.utils.checkpoint
|
11 |
+
import torch.nn.functional as F
|
12 |
+
from torch import nn
|
13 |
+
from torch.nn import CrossEntropyLoss, LayerNorm
|
14 |
+
from torch.nn import CrossEntropyLoss, LayerNorm, MSELoss, BCEWithLogitsLoss
|
15 |
+
from torch.nn.utils import skip_init
|
16 |
+
from typing import Optional, Tuple, Union, List, Callable, Dict, Any
|
17 |
+
|
18 |
+
from transformers.modeling_outputs import (
|
19 |
+
BaseModelOutputWithPast,
|
20 |
+
CausalLMOutputWithPast,
|
21 |
+
SequenceClassifierOutputWithPast,
|
22 |
+
)
|
23 |
+
from transformers.modeling_utils import PreTrainedModel
|
24 |
+
from transformers.utils import logging
|
25 |
+
from transformers.generation.logits_process import LogitsProcessor
|
26 |
+
from transformers.generation.utils import LogitsProcessorList, StoppingCriteriaList, GenerationConfig, ModelOutput
|
27 |
+
|
28 |
+
from .configuration_chatglm import ChatGLMConfig
|
29 |
+
|
30 |
+
# flags required to enable jit fusion kernels
|
31 |
+
|
32 |
+
if sys.platform != 'darwin':
|
33 |
+
torch._C._jit_set_profiling_mode(False)
|
34 |
+
torch._C._jit_set_profiling_executor(False)
|
35 |
+
torch._C._jit_override_can_fuse_on_cpu(True)
|
36 |
+
torch._C._jit_override_can_fuse_on_gpu(True)
|
37 |
+
|
38 |
+
logger = logging.get_logger(__name__)
|
39 |
+
|
40 |
+
_CHECKPOINT_FOR_DOC = "THUDM/ChatGLM2-6B"
|
41 |
+
_CONFIG_FOR_DOC = "ChatGLM6BConfig"
|
42 |
+
|
43 |
+
CHATGLM_6B_PRETRAINED_MODEL_ARCHIVE_LIST = [
|
44 |
+
"THUDM/chatglm2-6b",
|
45 |
+
# See all ChatGLM models at https://huggingface.co/models?filter=chatglm
|
46 |
+
]
|
47 |
+
|
48 |
+
|
49 |
+
def default_init(cls, *args, **kwargs):
|
50 |
+
return cls(*args, **kwargs)
|
51 |
+
|
52 |
+
|
53 |
+
class InvalidScoreLogitsProcessor(LogitsProcessor):
|
54 |
+
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
55 |
+
if torch.isnan(scores).any() or torch.isinf(scores).any():
|
56 |
+
scores.zero_()
|
57 |
+
scores[..., 5] = 5e4
|
58 |
+
return scores
|
59 |
+
|
60 |
+
|
61 |
+
class PrefixEncoder(torch.nn.Module):
|
62 |
+
"""
|
63 |
+
The torch.nn model to encode the prefix
|
64 |
+
Input shape: (batch-size, prefix-length)
|
65 |
+
Output shape: (batch-size, prefix-length, 2*layers*hidden)
|
66 |
+
"""
|
67 |
+
|
68 |
+
def __init__(self, config: ChatGLMConfig):
|
69 |
+
super().__init__()
|
70 |
+
self.prefix_projection = config.prefix_projection
|
71 |
+
if self.prefix_projection:
|
72 |
+
# Use a two-layer MLP to encode the prefix
|
73 |
+
kv_size = config.num_layers * config.kv_channels * config.multi_query_group_num * 2
|
74 |
+
self.embedding = torch.nn.Embedding(config.pre_seq_len, kv_size)
|
75 |
+
self.trans = torch.nn.Sequential(
|
76 |
+
torch.nn.Linear(kv_size, config.hidden_size),
|
77 |
+
torch.nn.Tanh(),
|
78 |
+
torch.nn.Linear(config.hidden_size, kv_size)
|
79 |
+
)
|
80 |
+
else:
|
81 |
+
self.embedding = torch.nn.Embedding(config.pre_seq_len,
|
82 |
+
config.num_layers * config.kv_channels * config.multi_query_group_num * 2)
|
83 |
+
|
84 |
+
def forward(self, prefix: torch.Tensor):
|
85 |
+
if self.prefix_projection:
|
86 |
+
prefix_tokens = self.embedding(prefix)
|
87 |
+
past_key_values = self.trans(prefix_tokens)
|
88 |
+
else:
|
89 |
+
past_key_values = self.embedding(prefix)
|
90 |
+
return past_key_values
|
91 |
+
|
92 |
+
|
93 |
+
def split_tensor_along_last_dim(
|
94 |
+
tensor: torch.Tensor,
|
95 |
+
num_partitions: int,
|
96 |
+
contiguous_split_chunks: bool = False,
|
97 |
+
) -> List[torch.Tensor]:
|
98 |
+
"""Split a tensor along its last dimension.
|
99 |
+
|
100 |
+
Arguments:
|
101 |
+
tensor: input tensor.
|
102 |
+
num_partitions: number of partitions to split the tensor
|
103 |
+
contiguous_split_chunks: If True, make each chunk contiguous
|
104 |
+
in memory.
|
105 |
+
|
106 |
+
Returns:
|
107 |
+
A list of Tensors
|
108 |
+
"""
|
109 |
+
# Get the size and dimension.
|
110 |
+
last_dim = tensor.dim() - 1
|
111 |
+
last_dim_size = tensor.size()[last_dim] // num_partitions
|
112 |
+
# Split.
|
113 |
+
tensor_list = torch.split(tensor, last_dim_size, dim=last_dim)
|
114 |
+
# Note: torch.split does not create contiguous tensors by default.
|
115 |
+
if contiguous_split_chunks:
|
116 |
+
return tuple(chunk.contiguous() for chunk in tensor_list)
|
117 |
+
|
118 |
+
return tensor_list
|
119 |
+
|
120 |
+
|
121 |
+
class RotaryEmbedding(nn.Module):
|
122 |
+
def __init__(self, dim, original_impl=False, device=None, dtype=None):
|
123 |
+
super().__init__()
|
124 |
+
inv_freq = 1.0 / (10000 ** (torch.arange(0, dim, 2, device=device).to(dtype=dtype) / dim))
|
125 |
+
self.register_buffer("inv_freq", inv_freq)
|
126 |
+
self.dim = dim
|
127 |
+
self.original_impl = original_impl
|
128 |
+
|
129 |
+
def forward_impl(
|
130 |
+
self, seq_len: int, n_elem: int, dtype: torch.dtype, device: torch.device, base: int = 10000
|
131 |
+
):
|
132 |
+
"""Enhanced Transformer with Rotary Position Embedding.
|
133 |
+
|
134 |
+
Derived from: https://github.com/labmlai/annotated_deep_learning_paper_implementations/blob/master/labml_nn/
|
135 |
+
transformers/rope/__init__.py. MIT License:
|
136 |
+
https://github.com/labmlai/annotated_deep_learning_paper_implementations/blob/master/license.
|
137 |
+
"""
|
138 |
+
# $\Theta = {\theta_i = 10000^{\frac{2(i-1)}{d}}, i \in [1, 2, ..., \frac{d}{2}]}$
|
139 |
+
theta = 1.0 / (base ** (torch.arange(0, n_elem, 2, dtype=dtype, device=device) / n_elem))
|
140 |
+
|
141 |
+
# Create position indexes `[0, 1, ..., seq_len - 1]`
|
142 |
+
seq_idx = torch.arange(seq_len, dtype=dtype, device=device)
|
143 |
+
|
144 |
+
# Calculate the product of position index and $\theta_i$
|
145 |
+
idx_theta = torch.outer(seq_idx, theta).float()
|
146 |
+
|
147 |
+
cache = torch.stack([torch.cos(idx_theta), torch.sin(idx_theta)], dim=-1)
|
148 |
+
|
149 |
+
# this is to mimic the behaviour of complex32, else we will get different results
|
150 |
+
if dtype in (torch.float16, torch.bfloat16, torch.int8):
|
151 |
+
cache = cache.bfloat16() if dtype == torch.bfloat16 else cache.half()
|
152 |
+
return cache
|
153 |
+
|
154 |
+
def forward(self, max_seq_len, offset=0):
|
155 |
+
return self.forward_impl(
|
156 |
+
max_seq_len, self.dim, dtype=self.inv_freq.dtype, device=self.inv_freq.device
|
157 |
+
)
|
158 |
+
|
159 |
+
|
160 |
+
@torch.jit.script
|
161 |
+
def apply_rotary_pos_emb(x: torch.Tensor, rope_cache: torch.Tensor) -> torch.Tensor:
|
162 |
+
# x: [sq, b, np, hn]
|
163 |
+
sq, b, np, hn = x.size(0), x.size(1), x.size(2), x.size(3)
|
164 |
+
rot_dim = rope_cache.shape[-2] * 2
|
165 |
+
x, x_pass = x[..., :rot_dim], x[..., rot_dim:]
|
166 |
+
# truncate to support variable sizes
|
167 |
+
rope_cache = rope_cache[:sq]
|
168 |
+
xshaped = x.reshape(sq, -1, np, rot_dim // 2, 2)
|
169 |
+
rope_cache = rope_cache.view(sq, -1, 1, xshaped.size(3), 2)
|
170 |
+
x_out2 = torch.stack(
|
171 |
+
[
|
172 |
+
xshaped[..., 0] * rope_cache[..., 0] - xshaped[..., 1] * rope_cache[..., 1],
|
173 |
+
xshaped[..., 1] * rope_cache[..., 0] + xshaped[..., 0] * rope_cache[..., 1],
|
174 |
+
],
|
175 |
+
-1,
|
176 |
+
)
|
177 |
+
x_out2 = x_out2.flatten(3)
|
178 |
+
return torch.cat((x_out2, x_pass), dim=-1)
|
179 |
+
|
180 |
+
|
181 |
+
class RMSNorm(torch.nn.Module):
|
182 |
+
def __init__(self, normalized_shape, eps=1e-5, device=None, dtype=None, **kwargs):
|
183 |
+
super().__init__()
|
184 |
+
self.weight = torch.nn.Parameter(torch.empty(normalized_shape, device=device, dtype=dtype))
|
185 |
+
self.eps = eps
|
186 |
+
|
187 |
+
def forward(self, hidden_states: torch.Tensor):
|
188 |
+
input_dtype = hidden_states.dtype
|
189 |
+
variance = hidden_states.to(torch.float32).pow(2).mean(-1, keepdim=True)
|
190 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.eps)
|
191 |
+
|
192 |
+
return (self.weight * hidden_states).to(input_dtype)
|
193 |
+
|
194 |
+
|
195 |
+
class CoreAttention(torch.nn.Module):
|
196 |
+
def __init__(self, config: ChatGLMConfig, layer_number):
|
197 |
+
super(CoreAttention, self).__init__()
|
198 |
+
|
199 |
+
self.apply_query_key_layer_scaling = config.apply_query_key_layer_scaling
|
200 |
+
self.attention_softmax_in_fp32 = config.attention_softmax_in_fp32
|
201 |
+
if self.apply_query_key_layer_scaling:
|
202 |
+
self.attention_softmax_in_fp32 = True
|
203 |
+
self.layer_number = max(1, layer_number)
|
204 |
+
|
205 |
+
projection_size = config.kv_channels * config.num_attention_heads
|
206 |
+
|
207 |
+
# Per attention head and per partition values.
|
208 |
+
self.hidden_size_per_partition = projection_size
|
209 |
+
self.hidden_size_per_attention_head = projection_size // config.num_attention_heads
|
210 |
+
self.num_attention_heads_per_partition = config.num_attention_heads
|
211 |
+
|
212 |
+
coeff = None
|
213 |
+
self.norm_factor = math.sqrt(self.hidden_size_per_attention_head)
|
214 |
+
if self.apply_query_key_layer_scaling:
|
215 |
+
coeff = self.layer_number
|
216 |
+
self.norm_factor *= coeff
|
217 |
+
self.coeff = coeff
|
218 |
+
|
219 |
+
self.attention_dropout = torch.nn.Dropout(config.attention_dropout)
|
220 |
+
|
221 |
+
def forward(self, query_layer, key_layer, value_layer, attention_mask):
|
222 |
+
pytorch_major_version = int(torch.__version__.split('.')[0])
|
223 |
+
if pytorch_major_version >= 2:
|
224 |
+
query_layer, key_layer, value_layer = [k.permute(1, 2, 0, 3) for k in [query_layer, key_layer, value_layer]]
|
225 |
+
if attention_mask is None and query_layer.shape[2] == key_layer.shape[2]:
|
226 |
+
context_layer = torch.nn.functional.scaled_dot_product_attention(query_layer, key_layer, value_layer,
|
227 |
+
is_causal=True)
|
228 |
+
else:
|
229 |
+
if attention_mask is not None:
|
230 |
+
attention_mask = ~attention_mask
|
231 |
+
context_layer = torch.nn.functional.scaled_dot_product_attention(query_layer, key_layer, value_layer,
|
232 |
+
attention_mask)
|
233 |
+
context_layer = context_layer.permute(2, 0, 1, 3)
|
234 |
+
new_context_layer_shape = context_layer.size()[:-2] + (self.hidden_size_per_partition,)
|
235 |
+
context_layer = context_layer.reshape(*new_context_layer_shape)
|
236 |
+
else:
|
237 |
+
# Raw attention scores
|
238 |
+
|
239 |
+
# [b, np, sq, sk]
|
240 |
+
output_size = (query_layer.size(1), query_layer.size(2), query_layer.size(0), key_layer.size(0))
|
241 |
+
|
242 |
+
# [sq, b, np, hn] -> [sq, b * np, hn]
|
243 |
+
query_layer = query_layer.view(output_size[2], output_size[0] * output_size[1], -1)
|
244 |
+
# [sk, b, np, hn] -> [sk, b * np, hn]
|
245 |
+
key_layer = key_layer.view(output_size[3], output_size[0] * output_size[1], -1)
|
246 |
+
|
247 |
+
# preallocting input tensor: [b * np, sq, sk]
|
248 |
+
matmul_input_buffer = torch.empty(
|
249 |
+
output_size[0] * output_size[1], output_size[2], output_size[3], dtype=query_layer.dtype,
|
250 |
+
device=query_layer.device
|
251 |
+
)
|
252 |
+
|
253 |
+
# Raw attention scores. [b * np, sq, sk]
|
254 |
+
matmul_result = torch.baddbmm(
|
255 |
+
matmul_input_buffer,
|
256 |
+
query_layer.transpose(0, 1), # [b * np, sq, hn]
|
257 |
+
key_layer.transpose(0, 1).transpose(1, 2), # [b * np, hn, sk]
|
258 |
+
beta=0.0,
|
259 |
+
alpha=(1.0 / self.norm_factor),
|
260 |
+
)
|
261 |
+
|
262 |
+
# change view to [b, np, sq, sk]
|
263 |
+
attention_scores = matmul_result.view(*output_size)
|
264 |
+
|
265 |
+
# ===========================
|
266 |
+
# Attention probs and dropout
|
267 |
+
# ===========================
|
268 |
+
|
269 |
+
# attention scores and attention mask [b, np, sq, sk]
|
270 |
+
if self.attention_softmax_in_fp32:
|
271 |
+
attention_scores = attention_scores.float()
|
272 |
+
if self.coeff is not None:
|
273 |
+
attention_scores = attention_scores * self.coeff
|
274 |
+
if attention_mask is None and attention_scores.shape[2] == attention_scores.shape[3]:
|
275 |
+
attention_mask = torch.ones(output_size[0], 1, output_size[2], output_size[3],
|
276 |
+
device=attention_scores.device, dtype=torch.bool)
|
277 |
+
attention_mask.tril_()
|
278 |
+
attention_mask = ~attention_mask
|
279 |
+
if attention_mask is not None:
|
280 |
+
attention_scores = attention_scores.masked_fill(attention_mask, float("-inf"))
|
281 |
+
attention_probs = F.softmax(attention_scores, dim=-1)
|
282 |
+
attention_probs = attention_probs.type_as(value_layer)
|
283 |
+
|
284 |
+
# This is actually dropping out entire tokens to attend to, which might
|
285 |
+
# seem a bit unusual, but is taken from the original Transformer paper.
|
286 |
+
attention_probs = self.attention_dropout(attention_probs)
|
287 |
+
# =========================
|
288 |
+
# Context layer. [sq, b, hp]
|
289 |
+
# =========================
|
290 |
+
|
291 |
+
# value_layer -> context layer.
|
292 |
+
# [sk, b, np, hn] --> [b, np, sq, hn]
|
293 |
+
|
294 |
+
# context layer shape: [b, np, sq, hn]
|
295 |
+
output_size = (value_layer.size(1), value_layer.size(2), query_layer.size(0), value_layer.size(3))
|
296 |
+
# change view [sk, b * np, hn]
|
297 |
+
value_layer = value_layer.view(value_layer.size(0), output_size[0] * output_size[1], -1)
|
298 |
+
# change view [b * np, sq, sk]
|
299 |
+
attention_probs = attention_probs.view(output_size[0] * output_size[1], output_size[2], -1)
|
300 |
+
# matmul: [b * np, sq, hn]
|
301 |
+
context_layer = torch.bmm(attention_probs, value_layer.transpose(0, 1))
|
302 |
+
# change view [b, np, sq, hn]
|
303 |
+
context_layer = context_layer.view(*output_size)
|
304 |
+
# [b, np, sq, hn] --> [sq, b, np, hn]
|
305 |
+
context_layer = context_layer.permute(2, 0, 1, 3).contiguous()
|
306 |
+
# [sq, b, np, hn] --> [sq, b, hp]
|
307 |
+
new_context_layer_shape = context_layer.size()[:-2] + (self.hidden_size_per_partition,)
|
308 |
+
context_layer = context_layer.view(*new_context_layer_shape)
|
309 |
+
|
310 |
+
return context_layer
|
311 |
+
|
312 |
+
|
313 |
+
class SelfAttention(torch.nn.Module):
|
314 |
+
"""Parallel self-attention layer abstract class.
|
315 |
+
|
316 |
+
Self-attention layer takes input with size [s, b, h]
|
317 |
+
and returns output of the same size.
|
318 |
+
"""
|
319 |
+
|
320 |
+
def __init__(self, config: ChatGLMConfig, layer_number, device=None):
|
321 |
+
super(SelfAttention, self).__init__()
|
322 |
+
self.layer_number = max(1, layer_number)
|
323 |
+
|
324 |
+
self.projection_size = config.kv_channels * config.num_attention_heads
|
325 |
+
|
326 |
+
# Per attention head and per partition values.
|
327 |
+
self.hidden_size_per_attention_head = self.projection_size // config.num_attention_heads
|
328 |
+
self.num_attention_heads_per_partition = config.num_attention_heads
|
329 |
+
|
330 |
+
self.multi_query_attention = config.multi_query_attention
|
331 |
+
self.qkv_hidden_size = 3 * self.projection_size
|
332 |
+
if self.multi_query_attention:
|
333 |
+
self.num_multi_query_groups_per_partition = config.multi_query_group_num
|
334 |
+
self.qkv_hidden_size = (
|
335 |
+
self.projection_size + 2 * self.hidden_size_per_attention_head * config.multi_query_group_num
|
336 |
+
)
|
337 |
+
self.query_key_value = nn.Linear(config.hidden_size, self.qkv_hidden_size,
|
338 |
+
bias=config.add_bias_linear or config.add_qkv_bias,
|
339 |
+
device=device, **_config_to_kwargs(config)
|
340 |
+
)
|
341 |
+
|
342 |
+
self.core_attention = CoreAttention(config, self.layer_number)
|
343 |
+
|
344 |
+
# Output.
|
345 |
+
self.dense = nn.Linear(self.projection_size, config.hidden_size, bias=config.add_bias_linear,
|
346 |
+
device=device, **_config_to_kwargs(config)
|
347 |
+
)
|
348 |
+
|
349 |
+
def _allocate_memory(self, inference_max_sequence_len, batch_size, device=None, dtype=None):
|
350 |
+
if self.multi_query_attention:
|
351 |
+
num_attention_heads = self.num_multi_query_groups_per_partition
|
352 |
+
else:
|
353 |
+
num_attention_heads = self.num_attention_heads_per_partition
|
354 |
+
return torch.empty(
|
355 |
+
inference_max_sequence_len,
|
356 |
+
batch_size,
|
357 |
+
num_attention_heads,
|
358 |
+
self.hidden_size_per_attention_head,
|
359 |
+
dtype=dtype,
|
360 |
+
device=device,
|
361 |
+
)
|
362 |
+
|
363 |
+
def forward(
|
364 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_cache=None, use_cache=True
|
365 |
+
):
|
366 |
+
# hidden_states: [sq, b, h]
|
367 |
+
|
368 |
+
# =================================================
|
369 |
+
# Pre-allocate memory for key-values for inference.
|
370 |
+
# =================================================
|
371 |
+
# =====================
|
372 |
+
# Query, Key, and Value
|
373 |
+
# =====================
|
374 |
+
|
375 |
+
# Attention heads [sq, b, h] --> [sq, b, (np * 3 * hn)]
|
376 |
+
mixed_x_layer = self.query_key_value(hidden_states)
|
377 |
+
|
378 |
+
if self.multi_query_attention:
|
379 |
+
(query_layer, key_layer, value_layer) = mixed_x_layer.split(
|
380 |
+
[
|
381 |
+
self.num_attention_heads_per_partition * self.hidden_size_per_attention_head,
|
382 |
+
self.num_multi_query_groups_per_partition * self.hidden_size_per_attention_head,
|
383 |
+
self.num_multi_query_groups_per_partition * self.hidden_size_per_attention_head,
|
384 |
+
],
|
385 |
+
dim=-1,
|
386 |
+
)
|
387 |
+
query_layer = query_layer.view(
|
388 |
+
query_layer.size()[:-1] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
389 |
+
)
|
390 |
+
key_layer = key_layer.view(
|
391 |
+
key_layer.size()[:-1] + (self.num_multi_query_groups_per_partition, self.hidden_size_per_attention_head)
|
392 |
+
)
|
393 |
+
value_layer = value_layer.view(
|
394 |
+
value_layer.size()[:-1]
|
395 |
+
+ (self.num_multi_query_groups_per_partition, self.hidden_size_per_attention_head)
|
396 |
+
)
|
397 |
+
else:
|
398 |
+
new_tensor_shape = mixed_x_layer.size()[:-1] + \
|
399 |
+
(self.num_attention_heads_per_partition,
|
400 |
+
3 * self.hidden_size_per_attention_head)
|
401 |
+
mixed_x_layer = mixed_x_layer.view(*new_tensor_shape)
|
402 |
+
|
403 |
+
# [sq, b, np, 3 * hn] --> 3 [sq, b, np, hn]
|
404 |
+
(query_layer, key_layer, value_layer) = split_tensor_along_last_dim(mixed_x_layer, 3)
|
405 |
+
|
406 |
+
# apply relative positional encoding (rotary embedding)
|
407 |
+
if rotary_pos_emb is not None:
|
408 |
+
query_layer = apply_rotary_pos_emb(query_layer, rotary_pos_emb)
|
409 |
+
key_layer = apply_rotary_pos_emb(key_layer, rotary_pos_emb)
|
410 |
+
|
411 |
+
# adjust key and value for inference
|
412 |
+
if kv_cache is not None:
|
413 |
+
cache_k, cache_v = kv_cache
|
414 |
+
key_layer = torch.cat((cache_k, key_layer), dim=0)
|
415 |
+
value_layer = torch.cat((cache_v, value_layer), dim=0)
|
416 |
+
if use_cache:
|
417 |
+
kv_cache = (key_layer, value_layer)
|
418 |
+
else:
|
419 |
+
kv_cache = None
|
420 |
+
|
421 |
+
if self.multi_query_attention:
|
422 |
+
key_layer = key_layer.unsqueeze(-2)
|
423 |
+
key_layer = key_layer.expand(
|
424 |
+
-1, -1, -1, self.num_attention_heads_per_partition // self.num_multi_query_groups_per_partition, -1
|
425 |
+
)
|
426 |
+
key_layer = key_layer.contiguous().view(
|
427 |
+
key_layer.size()[:2] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
428 |
+
)
|
429 |
+
value_layer = value_layer.unsqueeze(-2)
|
430 |
+
value_layer = value_layer.expand(
|
431 |
+
-1, -1, -1, self.num_attention_heads_per_partition // self.num_multi_query_groups_per_partition, -1
|
432 |
+
)
|
433 |
+
value_layer = value_layer.contiguous().view(
|
434 |
+
value_layer.size()[:2] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
435 |
+
)
|
436 |
+
|
437 |
+
# ==================================
|
438 |
+
# core attention computation
|
439 |
+
# ==================================
|
440 |
+
|
441 |
+
context_layer = self.core_attention(query_layer, key_layer, value_layer, attention_mask)
|
442 |
+
|
443 |
+
# =================
|
444 |
+
# Output. [sq, b, h]
|
445 |
+
# =================
|
446 |
+
|
447 |
+
output = self.dense(context_layer)
|
448 |
+
|
449 |
+
return output, kv_cache
|
450 |
+
|
451 |
+
|
452 |
+
def _config_to_kwargs(args):
|
453 |
+
common_kwargs = {
|
454 |
+
"dtype": args.torch_dtype,
|
455 |
+
}
|
456 |
+
return common_kwargs
|
457 |
+
|
458 |
+
|
459 |
+
class MLP(torch.nn.Module):
|
460 |
+
"""MLP.
|
461 |
+
|
462 |
+
MLP will take the input with h hidden state, project it to 4*h
|
463 |
+
hidden dimension, perform nonlinear transformation, and project the
|
464 |
+
state back into h hidden dimension.
|
465 |
+
"""
|
466 |
+
|
467 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
468 |
+
super(MLP, self).__init__()
|
469 |
+
|
470 |
+
self.add_bias = config.add_bias_linear
|
471 |
+
|
472 |
+
# Project to 4h. If using swiglu double the output width, see https://arxiv.org/pdf/2002.05202.pdf
|
473 |
+
self.dense_h_to_4h = nn.Linear(
|
474 |
+
config.hidden_size,
|
475 |
+
config.ffn_hidden_size * 2,
|
476 |
+
bias=self.add_bias,
|
477 |
+
device=device,
|
478 |
+
**_config_to_kwargs(config)
|
479 |
+
)
|
480 |
+
|
481 |
+
def swiglu(x):
|
482 |
+
x = torch.chunk(x, 2, dim=-1)
|
483 |
+
return F.silu(x[0]) * x[1]
|
484 |
+
|
485 |
+
self.activation_func = swiglu
|
486 |
+
|
487 |
+
# Project back to h.
|
488 |
+
self.dense_4h_to_h = nn.Linear(
|
489 |
+
config.ffn_hidden_size,
|
490 |
+
config.hidden_size,
|
491 |
+
bias=self.add_bias,
|
492 |
+
device=device,
|
493 |
+
**_config_to_kwargs(config)
|
494 |
+
)
|
495 |
+
|
496 |
+
def forward(self, hidden_states):
|
497 |
+
# [s, b, 4hp]
|
498 |
+
intermediate_parallel = self.dense_h_to_4h(hidden_states)
|
499 |
+
intermediate_parallel = self.activation_func(intermediate_parallel)
|
500 |
+
# [s, b, h]
|
501 |
+
output = self.dense_4h_to_h(intermediate_parallel)
|
502 |
+
return output
|
503 |
+
|
504 |
+
|
505 |
+
class GLMBlock(torch.nn.Module):
|
506 |
+
"""A single transformer layer.
|
507 |
+
|
508 |
+
Transformer layer takes input with size [s, b, h] and returns an
|
509 |
+
output of the same size.
|
510 |
+
"""
|
511 |
+
|
512 |
+
def __init__(self, config: ChatGLMConfig, layer_number, device=None):
|
513 |
+
super(GLMBlock, self).__init__()
|
514 |
+
self.layer_number = layer_number
|
515 |
+
|
516 |
+
self.apply_residual_connection_post_layernorm = config.apply_residual_connection_post_layernorm
|
517 |
+
|
518 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
519 |
+
|
520 |
+
LayerNormFunc = RMSNorm if config.rmsnorm else LayerNorm
|
521 |
+
# Layernorm on the input data.
|
522 |
+
self.input_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
523 |
+
dtype=config.torch_dtype)
|
524 |
+
|
525 |
+
# Self attention.
|
526 |
+
self.self_attention = SelfAttention(config, layer_number, device=device)
|
527 |
+
self.hidden_dropout = config.hidden_dropout
|
528 |
+
|
529 |
+
# Layernorm on the attention output
|
530 |
+
self.post_attention_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
531 |
+
dtype=config.torch_dtype)
|
532 |
+
|
533 |
+
# MLP
|
534 |
+
self.mlp = MLP(config, device=device)
|
535 |
+
|
536 |
+
def forward(
|
537 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_cache=None, use_cache=True,
|
538 |
+
):
|
539 |
+
# hidden_states: [s, b, h]
|
540 |
+
|
541 |
+
# Layer norm at the beginning of the transformer layer.
|
542 |
+
layernorm_output = self.input_layernorm(hidden_states)
|
543 |
+
# Self attention.
|
544 |
+
attention_output, kv_cache = self.self_attention(
|
545 |
+
layernorm_output,
|
546 |
+
attention_mask,
|
547 |
+
rotary_pos_emb,
|
548 |
+
kv_cache=kv_cache,
|
549 |
+
use_cache=use_cache
|
550 |
+
)
|
551 |
+
|
552 |
+
# Residual connection.
|
553 |
+
if self.apply_residual_connection_post_layernorm:
|
554 |
+
residual = layernorm_output
|
555 |
+
else:
|
556 |
+
residual = hidden_states
|
557 |
+
|
558 |
+
layernorm_input = torch.nn.functional.dropout(attention_output, p=self.hidden_dropout, training=self.training)
|
559 |
+
layernorm_input = residual + layernorm_input
|
560 |
+
|
561 |
+
# Layer norm post the self attention.
|
562 |
+
layernorm_output = self.post_attention_layernorm(layernorm_input)
|
563 |
+
|
564 |
+
# MLP.
|
565 |
+
mlp_output = self.mlp(layernorm_output)
|
566 |
+
|
567 |
+
# Second residual connection.
|
568 |
+
if self.apply_residual_connection_post_layernorm:
|
569 |
+
residual = layernorm_output
|
570 |
+
else:
|
571 |
+
residual = layernorm_input
|
572 |
+
|
573 |
+
output = torch.nn.functional.dropout(mlp_output, p=self.hidden_dropout, training=self.training)
|
574 |
+
output = residual + output
|
575 |
+
|
576 |
+
return output, kv_cache
|
577 |
+
|
578 |
+
|
579 |
+
class GLMTransformer(torch.nn.Module):
|
580 |
+
"""Transformer class."""
|
581 |
+
|
582 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
583 |
+
super(GLMTransformer, self).__init__()
|
584 |
+
|
585 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
586 |
+
self.post_layer_norm = config.post_layer_norm
|
587 |
+
|
588 |
+
# Number of layers.
|
589 |
+
self.num_layers = config.num_layers
|
590 |
+
|
591 |
+
# Transformer layers.
|
592 |
+
def build_layer(layer_number):
|
593 |
+
return GLMBlock(config, layer_number, device=device)
|
594 |
+
|
595 |
+
self.layers = torch.nn.ModuleList([build_layer(i + 1) for i in range(self.num_layers)])
|
596 |
+
|
597 |
+
if self.post_layer_norm:
|
598 |
+
LayerNormFunc = RMSNorm if config.rmsnorm else LayerNorm
|
599 |
+
# Final layer norm before output.
|
600 |
+
self.final_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
601 |
+
dtype=config.torch_dtype)
|
602 |
+
|
603 |
+
self.gradient_checkpointing = False
|
604 |
+
|
605 |
+
def _get_layer(self, layer_number):
|
606 |
+
return self.layers[layer_number]
|
607 |
+
|
608 |
+
def forward(
|
609 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_caches=None,
|
610 |
+
use_cache: Optional[bool] = True,
|
611 |
+
output_hidden_states: Optional[bool] = False,
|
612 |
+
):
|
613 |
+
if not kv_caches:
|
614 |
+
kv_caches = [None for _ in range(self.num_layers)]
|
615 |
+
presents = () if use_cache else None
|
616 |
+
if self.gradient_checkpointing and self.training:
|
617 |
+
if use_cache:
|
618 |
+
logger.warning_once(
|
619 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
620 |
+
)
|
621 |
+
use_cache = False
|
622 |
+
|
623 |
+
all_self_attentions = None
|
624 |
+
all_hidden_states = () if output_hidden_states else None
|
625 |
+
for index in range(self.num_layers):
|
626 |
+
if output_hidden_states:
|
627 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
628 |
+
|
629 |
+
layer = self._get_layer(index)
|
630 |
+
if self.gradient_checkpointing and self.training:
|
631 |
+
layer_ret = torch.utils.checkpoint.checkpoint(
|
632 |
+
layer,
|
633 |
+
hidden_states,
|
634 |
+
attention_mask,
|
635 |
+
rotary_pos_emb,
|
636 |
+
kv_caches[index],
|
637 |
+
use_cache
|
638 |
+
)
|
639 |
+
else:
|
640 |
+
layer_ret = layer(
|
641 |
+
hidden_states,
|
642 |
+
attention_mask,
|
643 |
+
rotary_pos_emb,
|
644 |
+
kv_cache=kv_caches[index],
|
645 |
+
use_cache=use_cache
|
646 |
+
)
|
647 |
+
hidden_states, kv_cache = layer_ret
|
648 |
+
if use_cache:
|
649 |
+
presents = presents + (kv_cache,)
|
650 |
+
|
651 |
+
if output_hidden_states:
|
652 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
653 |
+
|
654 |
+
# Final layer norm.
|
655 |
+
if self.post_layer_norm:
|
656 |
+
hidden_states = self.final_layernorm(hidden_states)
|
657 |
+
|
658 |
+
return hidden_states, presents, all_hidden_states, all_self_attentions
|
659 |
+
|
660 |
+
|
661 |
+
class ChatGLMPreTrainedModel(PreTrainedModel):
|
662 |
+
"""
|
663 |
+
An abstract class to handle weights initialization and
|
664 |
+
a simple interface for downloading and loading pretrained models.
|
665 |
+
"""
|
666 |
+
|
667 |
+
is_parallelizable = False
|
668 |
+
supports_gradient_checkpointing = True
|
669 |
+
config_class = ChatGLMConfig
|
670 |
+
base_model_prefix = "transformer"
|
671 |
+
_no_split_modules = ["GLMBlock"]
|
672 |
+
|
673 |
+
def _init_weights(self, module: nn.Module):
|
674 |
+
"""Initialize the weights."""
|
675 |
+
return
|
676 |
+
|
677 |
+
def get_masks(self, input_ids, past_key_values, padding_mask=None):
|
678 |
+
batch_size, seq_length = input_ids.shape
|
679 |
+
full_attention_mask = torch.ones(batch_size, seq_length, seq_length, device=input_ids.device)
|
680 |
+
full_attention_mask.tril_()
|
681 |
+
past_length = 0
|
682 |
+
if past_key_values:
|
683 |
+
past_length = past_key_values[0][0].shape[0]
|
684 |
+
if past_length:
|
685 |
+
full_attention_mask = torch.cat((torch.ones(batch_size, seq_length, past_length,
|
686 |
+
device=input_ids.device), full_attention_mask), dim=-1)
|
687 |
+
if padding_mask is not None:
|
688 |
+
full_attention_mask = full_attention_mask * padding_mask.unsqueeze(1)
|
689 |
+
if not past_length and padding_mask is not None:
|
690 |
+
full_attention_mask -= padding_mask.unsqueeze(-1) - 1
|
691 |
+
full_attention_mask = (full_attention_mask < 0.5).bool()
|
692 |
+
full_attention_mask.unsqueeze_(1)
|
693 |
+
return full_attention_mask
|
694 |
+
|
695 |
+
def get_position_ids(self, input_ids, device):
|
696 |
+
batch_size, seq_length = input_ids.shape
|
697 |
+
position_ids = torch.arange(seq_length, dtype=torch.long, device=device).unsqueeze(0).repeat(batch_size, 1)
|
698 |
+
return position_ids
|
699 |
+
|
700 |
+
def _set_gradient_checkpointing(self, module, value=False):
|
701 |
+
if isinstance(module, GLMTransformer):
|
702 |
+
module.gradient_checkpointing = value
|
703 |
+
|
704 |
+
|
705 |
+
class Embedding(torch.nn.Module):
|
706 |
+
"""Language model embeddings."""
|
707 |
+
|
708 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
709 |
+
super(Embedding, self).__init__()
|
710 |
+
|
711 |
+
self.hidden_size = config.hidden_size
|
712 |
+
# Word embeddings (parallel).
|
713 |
+
self.word_embeddings = nn.Embedding(
|
714 |
+
config.padded_vocab_size,
|
715 |
+
self.hidden_size,
|
716 |
+
dtype=config.torch_dtype,
|
717 |
+
device=device
|
718 |
+
)
|
719 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
720 |
+
|
721 |
+
def forward(self, input_ids):
|
722 |
+
# Embeddings.
|
723 |
+
words_embeddings = self.word_embeddings(input_ids)
|
724 |
+
embeddings = words_embeddings
|
725 |
+
# Data format change to avoid explicit tranposes : [b s h] --> [s b h].
|
726 |
+
embeddings = embeddings.transpose(0, 1).contiguous()
|
727 |
+
# If the input flag for fp32 residual connection is set, convert for float.
|
728 |
+
if self.fp32_residual_connection:
|
729 |
+
embeddings = embeddings.float()
|
730 |
+
return embeddings
|
731 |
+
|
732 |
+
|
733 |
+
class ChatGLMModel(ChatGLMPreTrainedModel):
|
734 |
+
def __init__(self, config: ChatGLMConfig, device=None, empty_init=True):
|
735 |
+
super().__init__(config)
|
736 |
+
if empty_init:
|
737 |
+
init_method = skip_init
|
738 |
+
else:
|
739 |
+
init_method = default_init
|
740 |
+
init_kwargs = {}
|
741 |
+
if device is not None:
|
742 |
+
init_kwargs["device"] = device
|
743 |
+
self.embedding = init_method(Embedding, config, **init_kwargs)
|
744 |
+
self.num_layers = config.num_layers
|
745 |
+
self.multi_query_group_num = config.multi_query_group_num
|
746 |
+
self.kv_channels = config.kv_channels
|
747 |
+
|
748 |
+
# Rotary positional embeddings
|
749 |
+
self.seq_length = config.seq_length
|
750 |
+
rotary_dim = (
|
751 |
+
config.hidden_size // config.num_attention_heads if config.kv_channels is None else config.kv_channels
|
752 |
+
)
|
753 |
+
|
754 |
+
self.rotary_pos_emb = RotaryEmbedding(rotary_dim // 2, original_impl=config.original_rope, device=device,
|
755 |
+
dtype=config.torch_dtype)
|
756 |
+
self.encoder = init_method(GLMTransformer, config, **init_kwargs)
|
757 |
+
self.output_layer = init_method(nn.Linear, config.hidden_size, config.padded_vocab_size, bias=False,
|
758 |
+
dtype=config.torch_dtype, **init_kwargs)
|
759 |
+
self.pre_seq_len = config.pre_seq_len
|
760 |
+
self.prefix_projection = config.prefix_projection
|
761 |
+
if self.pre_seq_len is not None:
|
762 |
+
for param in self.parameters():
|
763 |
+
param.requires_grad = False
|
764 |
+
self.prefix_tokens = torch.arange(self.pre_seq_len).long()
|
765 |
+
self.prefix_encoder = PrefixEncoder(config)
|
766 |
+
self.dropout = torch.nn.Dropout(0.1)
|
767 |
+
|
768 |
+
def get_input_embeddings(self):
|
769 |
+
return self.embedding.word_embeddings
|
770 |
+
|
771 |
+
def get_prompt(self, batch_size, device, dtype=torch.half):
|
772 |
+
prefix_tokens = self.prefix_tokens.unsqueeze(0).expand(batch_size, -1).to(device)
|
773 |
+
past_key_values = self.prefix_encoder(prefix_tokens).type(dtype)
|
774 |
+
past_key_values = past_key_values.view(
|
775 |
+
batch_size,
|
776 |
+
self.pre_seq_len,
|
777 |
+
self.num_layers * 2,
|
778 |
+
self.multi_query_group_num,
|
779 |
+
self.kv_channels
|
780 |
+
)
|
781 |
+
# seq_len, b, nh, hidden_size
|
782 |
+
past_key_values = self.dropout(past_key_values)
|
783 |
+
past_key_values = past_key_values.permute([2, 1, 0, 3, 4]).split(2)
|
784 |
+
return past_key_values
|
785 |
+
|
786 |
+
def forward(
|
787 |
+
self,
|
788 |
+
input_ids,
|
789 |
+
position_ids: Optional[torch.Tensor] = None,
|
790 |
+
attention_mask: Optional[torch.BoolTensor] = None,
|
791 |
+
full_attention_mask: Optional[torch.BoolTensor] = None,
|
792 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
793 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
794 |
+
use_cache: Optional[bool] = None,
|
795 |
+
output_hidden_states: Optional[bool] = None,
|
796 |
+
return_dict: Optional[bool] = None,
|
797 |
+
):
|
798 |
+
output_hidden_states = (
|
799 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
800 |
+
)
|
801 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
802 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
803 |
+
|
804 |
+
batch_size, seq_length = input_ids.shape
|
805 |
+
|
806 |
+
if inputs_embeds is None:
|
807 |
+
inputs_embeds = self.embedding(input_ids)
|
808 |
+
|
809 |
+
if self.pre_seq_len is not None:
|
810 |
+
if past_key_values is None:
|
811 |
+
past_key_values = self.get_prompt(batch_size=batch_size, device=input_ids.device,
|
812 |
+
dtype=inputs_embeds.dtype)
|
813 |
+
if attention_mask is not None:
|
814 |
+
attention_mask = torch.cat([attention_mask.new_ones((batch_size, self.pre_seq_len)),
|
815 |
+
attention_mask], dim=-1)
|
816 |
+
|
817 |
+
if full_attention_mask is None:
|
818 |
+
if (attention_mask is not None and not attention_mask.all()) or (past_key_values and seq_length != 1):
|
819 |
+
full_attention_mask = self.get_masks(input_ids, past_key_values, padding_mask=attention_mask)
|
820 |
+
|
821 |
+
# Rotary positional embeddings
|
822 |
+
rotary_pos_emb = self.rotary_pos_emb(self.seq_length)
|
823 |
+
if position_ids is not None:
|
824 |
+
rotary_pos_emb = rotary_pos_emb[position_ids]
|
825 |
+
else:
|
826 |
+
rotary_pos_emb = rotary_pos_emb[None, :seq_length]
|
827 |
+
rotary_pos_emb = rotary_pos_emb.transpose(0, 1).contiguous()
|
828 |
+
|
829 |
+
# Run encoder.
|
830 |
+
hidden_states, presents, all_hidden_states, all_self_attentions = self.encoder(
|
831 |
+
inputs_embeds, full_attention_mask, rotary_pos_emb=rotary_pos_emb,
|
832 |
+
kv_caches=past_key_values, use_cache=use_cache, output_hidden_states=output_hidden_states
|
833 |
+
)
|
834 |
+
|
835 |
+
if not return_dict:
|
836 |
+
return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions] if v is not None)
|
837 |
+
|
838 |
+
return BaseModelOutputWithPast(
|
839 |
+
last_hidden_state=hidden_states,
|
840 |
+
past_key_values=presents,
|
841 |
+
hidden_states=all_hidden_states,
|
842 |
+
attentions=all_self_attentions,
|
843 |
+
)
|
844 |
+
|
845 |
+
def quantize(self, weight_bit_width: int):
|
846 |
+
from .quantization import quantize
|
847 |
+
quantize(self.encoder, weight_bit_width)
|
848 |
+
return self
|
849 |
+
|
850 |
+
|
851 |
+
class ChatGLMForConditionalGeneration(ChatGLMPreTrainedModel):
|
852 |
+
def __init__(self, config: ChatGLMConfig, empty_init=True, device=None):
|
853 |
+
super().__init__(config)
|
854 |
+
|
855 |
+
self.max_sequence_length = config.max_length
|
856 |
+
self.transformer = ChatGLMModel(config, empty_init=empty_init, device=device)
|
857 |
+
self.config = config
|
858 |
+
self.quantized = False
|
859 |
+
|
860 |
+
if self.config.quantization_bit:
|
861 |
+
self.quantize(self.config.quantization_bit, empty_init=True)
|
862 |
+
|
863 |
+
def _update_model_kwargs_for_generation(
|
864 |
+
self,
|
865 |
+
outputs: ModelOutput,
|
866 |
+
model_kwargs: Dict[str, Any],
|
867 |
+
is_encoder_decoder: bool = False,
|
868 |
+
standardize_cache_format: bool = False,
|
869 |
+
) -> Dict[str, Any]:
|
870 |
+
# update past_key_values
|
871 |
+
model_kwargs["past_key_values"] = self._extract_past_from_model_output(
|
872 |
+
outputs, standardize_cache_format=standardize_cache_format
|
873 |
+
)
|
874 |
+
|
875 |
+
# update attention mask
|
876 |
+
if "attention_mask" in model_kwargs:
|
877 |
+
attention_mask = model_kwargs["attention_mask"]
|
878 |
+
model_kwargs["attention_mask"] = torch.cat(
|
879 |
+
[attention_mask, attention_mask.new_ones((attention_mask.shape[0], 1))], dim=-1
|
880 |
+
)
|
881 |
+
|
882 |
+
# update position ids
|
883 |
+
if "position_ids" in model_kwargs:
|
884 |
+
position_ids = model_kwargs["position_ids"]
|
885 |
+
new_position_id = position_ids[..., -1:].clone()
|
886 |
+
new_position_id += 1
|
887 |
+
model_kwargs["position_ids"] = torch.cat(
|
888 |
+
[position_ids, new_position_id], dim=-1
|
889 |
+
)
|
890 |
+
|
891 |
+
model_kwargs["is_first_forward"] = False
|
892 |
+
return model_kwargs
|
893 |
+
|
894 |
+
def prepare_inputs_for_generation(
|
895 |
+
self,
|
896 |
+
input_ids: torch.LongTensor,
|
897 |
+
past_key_values: Optional[torch.Tensor] = None,
|
898 |
+
attention_mask: Optional[torch.Tensor] = None,
|
899 |
+
position_ids: Optional[torch.Tensor] = None,
|
900 |
+
use_cache: Optional[bool] = None,
|
901 |
+
is_first_forward: bool = True,
|
902 |
+
**kwargs
|
903 |
+
) -> dict:
|
904 |
+
# only last token for input_ids if past is not None
|
905 |
+
if position_ids is None:
|
906 |
+
position_ids = self.get_position_ids(input_ids, device=input_ids.device)
|
907 |
+
if not is_first_forward:
|
908 |
+
if past_key_values is not None:
|
909 |
+
position_ids = position_ids[..., -1:]
|
910 |
+
input_ids = input_ids[:, -1:]
|
911 |
+
return {
|
912 |
+
"input_ids": input_ids,
|
913 |
+
"past_key_values": past_key_values,
|
914 |
+
"position_ids": position_ids,
|
915 |
+
"attention_mask": attention_mask,
|
916 |
+
"return_last_logit": True,
|
917 |
+
"use_cache": use_cache
|
918 |
+
}
|
919 |
+
|
920 |
+
def forward(
|
921 |
+
self,
|
922 |
+
input_ids: Optional[torch.Tensor] = None,
|
923 |
+
position_ids: Optional[torch.Tensor] = None,
|
924 |
+
attention_mask: Optional[torch.Tensor] = None,
|
925 |
+
past_key_values: Optional[Tuple[torch.FloatTensor]] = None,
|
926 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
927 |
+
labels: Optional[torch.Tensor] = None,
|
928 |
+
use_cache: Optional[bool] = None,
|
929 |
+
output_attentions: Optional[bool] = None,
|
930 |
+
output_hidden_states: Optional[bool] = None,
|
931 |
+
return_dict: Optional[bool] = None,
|
932 |
+
return_last_logit: Optional[bool] = False,
|
933 |
+
):
|
934 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
935 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
936 |
+
|
937 |
+
transformer_outputs = self.transformer(
|
938 |
+
input_ids=input_ids,
|
939 |
+
position_ids=position_ids,
|
940 |
+
attention_mask=attention_mask,
|
941 |
+
past_key_values=past_key_values,
|
942 |
+
inputs_embeds=inputs_embeds,
|
943 |
+
use_cache=use_cache,
|
944 |
+
output_hidden_states=output_hidden_states,
|
945 |
+
return_dict=return_dict,
|
946 |
+
)
|
947 |
+
|
948 |
+
hidden_states = transformer_outputs[0]
|
949 |
+
if return_last_logit:
|
950 |
+
hidden_states = hidden_states[-1:]
|
951 |
+
lm_logits = self.transformer.output_layer(hidden_states)
|
952 |
+
lm_logits = lm_logits.transpose(0, 1).contiguous()
|
953 |
+
|
954 |
+
loss = None
|
955 |
+
if labels is not None:
|
956 |
+
lm_logits = lm_logits.to(torch.float32)
|
957 |
+
|
958 |
+
# Shift so that tokens < n predict n
|
959 |
+
shift_logits = lm_logits[..., :-1, :].contiguous()
|
960 |
+
shift_labels = labels[..., 1:].contiguous()
|
961 |
+
# Flatten the tokens
|
962 |
+
loss_fct = CrossEntropyLoss(ignore_index=-100)
|
963 |
+
loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
|
964 |
+
|
965 |
+
lm_logits = lm_logits.to(hidden_states.dtype)
|
966 |
+
loss = loss.to(hidden_states.dtype)
|
967 |
+
|
968 |
+
if not return_dict:
|
969 |
+
output = (lm_logits,) + transformer_outputs[1:]
|
970 |
+
return ((loss,) + output) if loss is not None else output
|
971 |
+
|
972 |
+
return CausalLMOutputWithPast(
|
973 |
+
loss=loss,
|
974 |
+
logits=lm_logits,
|
975 |
+
past_key_values=transformer_outputs.past_key_values,
|
976 |
+
hidden_states=transformer_outputs.hidden_states,
|
977 |
+
attentions=transformer_outputs.attentions,
|
978 |
+
)
|
979 |
+
|
980 |
+
@staticmethod
|
981 |
+
def _reorder_cache(
|
982 |
+
past: Tuple[Tuple[torch.Tensor, torch.Tensor], ...], beam_idx: torch.LongTensor
|
983 |
+
) -> Tuple[Tuple[torch.Tensor, torch.Tensor], ...]:
|
984 |
+
"""
|
985 |
+
This function is used to re-order the `past_key_values` cache if [`~PreTrainedModel.beam_search`] or
|
986 |
+
[`~PreTrainedModel.beam_sample`] is called. This is required to match `past_key_values` with the correct
|
987 |
+
beam_idx at every generation step.
|
988 |
+
|
989 |
+
Output shares the same memory storage as `past`.
|
990 |
+
"""
|
991 |
+
return tuple(
|
992 |
+
(
|
993 |
+
layer_past[0].index_select(1, beam_idx.to(layer_past[0].device)),
|
994 |
+
layer_past[1].index_select(1, beam_idx.to(layer_past[1].device)),
|
995 |
+
)
|
996 |
+
for layer_past in past
|
997 |
+
)
|
998 |
+
|
999 |
+
def process_response(self, response):
|
1000 |
+
response = response.strip()
|
1001 |
+
response = response.replace("[[训练时间]]", "2023年")
|
1002 |
+
return response
|
1003 |
+
|
1004 |
+
def build_inputs(self, tokenizer, query: str, history: List[Tuple[str, str]] = None):
|
1005 |
+
prompt = tokenizer.build_prompt(query, history=history)
|
1006 |
+
inputs = tokenizer([prompt], return_tensors="pt")
|
1007 |
+
inputs = inputs.to(self.device)
|
1008 |
+
return inputs
|
1009 |
+
|
1010 |
+
def build_stream_inputs(self, tokenizer, query: str, history: List[Tuple[str, str]] = None):
|
1011 |
+
if history:
|
1012 |
+
prompt = "\n\n[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
1013 |
+
input_ids = tokenizer.encode(prompt, add_special_tokens=False)
|
1014 |
+
input_ids = input_ids[1:]
|
1015 |
+
inputs = tokenizer.batch_encode_plus([(input_ids, None)], return_tensors="pt", add_special_tokens=False)
|
1016 |
+
else:
|
1017 |
+
prompt = "[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
1018 |
+
inputs = tokenizer([prompt], return_tensors="pt")
|
1019 |
+
inputs = inputs.to(self.device)
|
1020 |
+
return inputs
|
1021 |
+
|
1022 |
+
@torch.inference_mode()
|
1023 |
+
def chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, max_length: int = 8192, num_beams=1,
|
1024 |
+
do_sample=True, top_p=0.8, temperature=0.8, logits_processor=None, **kwargs):
|
1025 |
+
if history is None:
|
1026 |
+
history = []
|
1027 |
+
if logits_processor is None:
|
1028 |
+
logits_processor = LogitsProcessorList()
|
1029 |
+
logits_processor.append(InvalidScoreLogitsProcessor())
|
1030 |
+
gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p,
|
1031 |
+
"temperature": temperature, "logits_processor": logits_processor, **kwargs}
|
1032 |
+
inputs = self.build_inputs(tokenizer, query, history=history)
|
1033 |
+
outputs = self.generate(**inputs, **gen_kwargs)
|
1034 |
+
outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
|
1035 |
+
response = tokenizer.decode(outputs)
|
1036 |
+
response = self.process_response(response)
|
1037 |
+
history = history + [(query, response)]
|
1038 |
+
return response, history
|
1039 |
+
|
1040 |
+
@torch.inference_mode()
|
1041 |
+
def stream_chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, past_key_values=None,
|
1042 |
+
max_length: int = 8192, do_sample=True, top_p=0.8, temperature=0.8, logits_processor=None,
|
1043 |
+
return_past_key_values=False, **kwargs):
|
1044 |
+
if history is None:
|
1045 |
+
history = []
|
1046 |
+
if logits_processor is None:
|
1047 |
+
logits_processor = LogitsProcessorList()
|
1048 |
+
logits_processor.append(InvalidScoreLogitsProcessor())
|
1049 |
+
gen_kwargs = {"max_length": max_length, "do_sample": do_sample, "top_p": top_p,
|
1050 |
+
"temperature": temperature, "logits_processor": logits_processor, **kwargs}
|
1051 |
+
if past_key_values is None and not return_past_key_values:
|
1052 |
+
inputs = self.build_inputs(tokenizer, query, history=history)
|
1053 |
+
else:
|
1054 |
+
inputs = self.build_stream_inputs(tokenizer, query, history=history)
|
1055 |
+
if past_key_values is not None:
|
1056 |
+
past_length = past_key_values[0][0].shape[0]
|
1057 |
+
if self.transformer.pre_seq_len is not None:
|
1058 |
+
past_length -= self.transformer.pre_seq_len
|
1059 |
+
inputs.position_ids += past_length
|
1060 |
+
attention_mask = inputs.attention_mask
|
1061 |
+
attention_mask = torch.cat((attention_mask.new_ones(1, past_length), attention_mask), dim=1)
|
1062 |
+
inputs['attention_mask'] = attention_mask
|
1063 |
+
for outputs in self.stream_generate(**inputs, past_key_values=past_key_values,
|
1064 |
+
return_past_key_values=return_past_key_values, **gen_kwargs):
|
1065 |
+
if return_past_key_values:
|
1066 |
+
outputs, past_key_values = outputs
|
1067 |
+
outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
|
1068 |
+
response = tokenizer.decode(outputs)
|
1069 |
+
if response and response[-1] != "�":
|
1070 |
+
response = self.process_response(response)
|
1071 |
+
new_history = history + [(query, response)]
|
1072 |
+
if return_past_key_values:
|
1073 |
+
yield response, new_history, past_key_values
|
1074 |
+
else:
|
1075 |
+
yield response, new_history
|
1076 |
+
|
1077 |
+
@torch.inference_mode()
|
1078 |
+
def stream_generate(
|
1079 |
+
self,
|
1080 |
+
input_ids,
|
1081 |
+
generation_config: Optional[GenerationConfig] = None,
|
1082 |
+
logits_processor: Optional[LogitsProcessorList] = None,
|
1083 |
+
stopping_criteria: Optional[StoppingCriteriaList] = None,
|
1084 |
+
prefix_allowed_tokens_fn: Optional[Callable[[int, torch.Tensor], List[int]]] = None,
|
1085 |
+
return_past_key_values=False,
|
1086 |
+
**kwargs,
|
1087 |
+
):
|
1088 |
+
batch_size, input_ids_seq_length = input_ids.shape[0], input_ids.shape[-1]
|
1089 |
+
|
1090 |
+
if generation_config is None:
|
1091 |
+
generation_config = self.generation_config
|
1092 |
+
generation_config = copy.deepcopy(generation_config)
|
1093 |
+
model_kwargs = generation_config.update(**kwargs)
|
1094 |
+
model_kwargs["use_cache"] = generation_config.use_cache
|
1095 |
+
bos_token_id, eos_token_id = generation_config.bos_token_id, generation_config.eos_token_id
|
1096 |
+
|
1097 |
+
if isinstance(eos_token_id, int):
|
1098 |
+
eos_token_id = [eos_token_id]
|
1099 |
+
|
1100 |
+
has_default_max_length = kwargs.get("max_length") is None and generation_config.max_length is not None
|
1101 |
+
if has_default_max_length and generation_config.max_new_tokens is None:
|
1102 |
+
warnings.warn(
|
1103 |
+
f"Using `max_length`'s default ({generation_config.max_length}) to control the generation length. "
|
1104 |
+
"This behaviour is deprecated and will be removed from the config in v5 of Transformers -- we"
|
1105 |
+
" recommend using `max_new_tokens` to control the maximum length of the generation.",
|
1106 |
+
UserWarning,
|
1107 |
+
)
|
1108 |
+
elif generation_config.max_new_tokens is not None:
|
1109 |
+
generation_config.max_length = generation_config.max_new_tokens + input_ids_seq_length
|
1110 |
+
if not has_default_max_length:
|
1111 |
+
logger.warn(
|
1112 |
+
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(="
|
1113 |
+
f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "
|
1114 |
+
"Please refer to the documentation for more information. "
|
1115 |
+
"(https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)",
|
1116 |
+
UserWarning,
|
1117 |
+
)
|
1118 |
+
|
1119 |
+
if input_ids_seq_length >= generation_config.max_length:
|
1120 |
+
input_ids_string = "decoder_input_ids" if self.config.is_encoder_decoder else "input_ids"
|
1121 |
+
logger.warning(
|
1122 |
+
f"Input length of {input_ids_string} is {input_ids_seq_length}, but `max_length` is set to"
|
1123 |
+
f" {generation_config.max_length}. This can lead to unexpected behavior. You should consider"
|
1124 |
+
" increasing `max_new_tokens`."
|
1125 |
+
)
|
1126 |
+
|
1127 |
+
# 2. Set generation parameters if not already defined
|
1128 |
+
logits_processor = logits_processor if logits_processor is not None else LogitsProcessorList()
|
1129 |
+
stopping_criteria = stopping_criteria if stopping_criteria is not None else StoppingCriteriaList()
|
1130 |
+
|
1131 |
+
logits_processor = self._get_logits_processor(
|
1132 |
+
generation_config=generation_config,
|
1133 |
+
input_ids_seq_length=input_ids_seq_length,
|
1134 |
+
encoder_input_ids=input_ids,
|
1135 |
+
prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,
|
1136 |
+
logits_processor=logits_processor,
|
1137 |
+
)
|
1138 |
+
|
1139 |
+
stopping_criteria = self._get_stopping_criteria(
|
1140 |
+
generation_config=generation_config, stopping_criteria=stopping_criteria
|
1141 |
+
)
|
1142 |
+
logits_warper = self._get_logits_warper(generation_config)
|
1143 |
+
|
1144 |
+
unfinished_sequences = input_ids.new(input_ids.shape[0]).fill_(1)
|
1145 |
+
scores = None
|
1146 |
+
while True:
|
1147 |
+
model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
|
1148 |
+
# forward pass to get next token
|
1149 |
+
outputs = self(
|
1150 |
+
**model_inputs,
|
1151 |
+
return_dict=True,
|
1152 |
+
output_attentions=False,
|
1153 |
+
output_hidden_states=False,
|
1154 |
+
)
|
1155 |
+
|
1156 |
+
next_token_logits = outputs.logits[:, -1, :]
|
1157 |
+
|
1158 |
+
# pre-process distribution
|
1159 |
+
next_token_scores = logits_processor(input_ids, next_token_logits)
|
1160 |
+
next_token_scores = logits_warper(input_ids, next_token_scores)
|
1161 |
+
|
1162 |
+
# sample
|
1163 |
+
probs = nn.functional.softmax(next_token_scores, dim=-1)
|
1164 |
+
if generation_config.do_sample:
|
1165 |
+
next_tokens = torch.multinomial(probs, num_samples=1).squeeze(1)
|
1166 |
+
else:
|
1167 |
+
next_tokens = torch.argmax(probs, dim=-1)
|
1168 |
+
|
1169 |
+
# update generated ids, model inputs, and length for next step
|
1170 |
+
input_ids = torch.cat([input_ids, next_tokens[:, None]], dim=-1)
|
1171 |
+
model_kwargs = self._update_model_kwargs_for_generation(
|
1172 |
+
outputs, model_kwargs, is_encoder_decoder=self.config.is_encoder_decoder
|
1173 |
+
)
|
1174 |
+
unfinished_sequences = unfinished_sequences.mul((sum(next_tokens != i for i in eos_token_id)).long())
|
1175 |
+
if return_past_key_values:
|
1176 |
+
yield input_ids, outputs.past_key_values
|
1177 |
+
else:
|
1178 |
+
yield input_ids
|
1179 |
+
# stop when each sentence is finished, or if we exceed the maximum length
|
1180 |
+
if unfinished_sequences.max() == 0 or stopping_criteria(input_ids, scores):
|
1181 |
+
break
|
1182 |
+
|
1183 |
+
def quantize(self, bits: int, empty_init=False, device=None, **kwargs):
|
1184 |
+
if bits == 0:
|
1185 |
+
return
|
1186 |
+
|
1187 |
+
from .quantization import quantize
|
1188 |
+
|
1189 |
+
if self.quantized:
|
1190 |
+
logger.info("Already quantized.")
|
1191 |
+
return self
|
1192 |
+
|
1193 |
+
self.quantized = True
|
1194 |
+
|
1195 |
+
self.config.quantization_bit = bits
|
1196 |
+
|
1197 |
+
self.transformer.encoder = quantize(self.transformer.encoder, bits, empty_init=empty_init, device=device,
|
1198 |
+
**kwargs)
|
1199 |
+
return self
|
1200 |
+
|
1201 |
+
|
1202 |
+
class ChatGLMForSequenceClassification(ChatGLMPreTrainedModel):
|
1203 |
+
def __init__(self, config: ChatGLMConfig, empty_init=True, device=None):
|
1204 |
+
super().__init__(config)
|
1205 |
+
|
1206 |
+
self.num_labels = config.num_labels
|
1207 |
+
self.transformer = ChatGLMModel(config, empty_init=empty_init, device=device)
|
1208 |
+
|
1209 |
+
self.classifier_head = nn.Linear(config.hidden_size, config.num_labels, bias=True, dtype=torch.half)
|
1210 |
+
if config.classifier_dropout is not None:
|
1211 |
+
self.dropout = nn.Dropout(config.classifier_dropout)
|
1212 |
+
else:
|
1213 |
+
self.dropout = None
|
1214 |
+
self.config = config
|
1215 |
+
|
1216 |
+
if self.config.quantization_bit:
|
1217 |
+
self.quantize(self.config.quantization_bit, empty_init=True)
|
1218 |
+
|
1219 |
+
def forward(
|
1220 |
+
self,
|
1221 |
+
input_ids: Optional[torch.LongTensor] = None,
|
1222 |
+
position_ids: Optional[torch.LongTensor] = None,
|
1223 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1224 |
+
full_attention_mask: Optional[torch.Tensor] = None,
|
1225 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
1226 |
+
inputs_embeds: Optional[torch.LongTensor] = None,
|
1227 |
+
labels: Optional[torch.LongTensor] = None,
|
1228 |
+
use_cache: Optional[bool] = None,
|
1229 |
+
output_hidden_states: Optional[bool] = None,
|
1230 |
+
return_dict: Optional[bool] = None,
|
1231 |
+
) -> Union[Tuple[torch.Tensor, ...], SequenceClassifierOutputWithPast]:
|
1232 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1233 |
+
|
1234 |
+
transformer_outputs = self.transformer(
|
1235 |
+
input_ids=input_ids,
|
1236 |
+
position_ids=position_ids,
|
1237 |
+
attention_mask=attention_mask,
|
1238 |
+
full_attention_mask=full_attention_mask,
|
1239 |
+
past_key_values=past_key_values,
|
1240 |
+
inputs_embeds=inputs_embeds,
|
1241 |
+
use_cache=use_cache,
|
1242 |
+
output_hidden_states=output_hidden_states,
|
1243 |
+
return_dict=return_dict,
|
1244 |
+
)
|
1245 |
+
|
1246 |
+
hidden_states = transformer_outputs[0]
|
1247 |
+
pooled_hidden_states = hidden_states[-1]
|
1248 |
+
if self.dropout is not None:
|
1249 |
+
pooled_hidden_states = self.dropout(pooled_hidden_states)
|
1250 |
+
logits = self.classifier_head(pooled_hidden_states)
|
1251 |
+
|
1252 |
+
loss = None
|
1253 |
+
if labels is not None:
|
1254 |
+
if self.config.problem_type is None:
|
1255 |
+
if self.num_labels == 1:
|
1256 |
+
self.config.problem_type = "regression"
|
1257 |
+
elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
|
1258 |
+
self.config.problem_type = "single_label_classification"
|
1259 |
+
else:
|
1260 |
+
self.config.problem_type = "multi_label_classification"
|
1261 |
+
|
1262 |
+
if self.config.problem_type == "regression":
|
1263 |
+
loss_fct = MSELoss()
|
1264 |
+
if self.num_labels == 1:
|
1265 |
+
loss = loss_fct(logits.squeeze().float(), labels.squeeze())
|
1266 |
+
else:
|
1267 |
+
loss = loss_fct(logits.float(), labels)
|
1268 |
+
elif self.config.problem_type == "single_label_classification":
|
1269 |
+
loss_fct = CrossEntropyLoss()
|
1270 |
+
loss = loss_fct(logits.view(-1, self.num_labels).float(), labels.view(-1))
|
1271 |
+
elif self.config.problem_type == "multi_label_classification":
|
1272 |
+
loss_fct = BCEWithLogitsLoss()
|
1273 |
+
loss = loss_fct(logits.float(), labels.view(-1, self.num_labels))
|
1274 |
+
|
1275 |
+
if not return_dict:
|
1276 |
+
output = (logits,) + transformer_outputs[1:]
|
1277 |
+
return ((loss,) + output) if loss is not None else output
|
1278 |
+
|
1279 |
+
return SequenceClassifierOutputWithPast(
|
1280 |
+
loss=loss,
|
1281 |
+
logits=logits,
|
1282 |
+
past_key_values=transformer_outputs.past_key_values,
|
1283 |
+
hidden_states=transformer_outputs.hidden_states,
|
1284 |
+
attentions=transformer_outputs.attentions,
|
1285 |
+
)
|
checkpoint-2000/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7141e4be1f44b2119e3e32755baacf7a756a25ff21af1f5fb79facaecbbb97a0
|
3 |
+
size 14681455
|
checkpoint-2000/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c2d64d7dc915cba98541c03f637ad8167c792d0b5b9611aff477356d7beeed9f
|
3 |
+
size 7340861
|
checkpoint-2000/quantization.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
checkpoint-2000/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e769ab142cc628982263acecebfd601643b5ad22d48163da36d4246c8d70d5b9
|
3 |
+
size 14575
|
checkpoint-2000/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b2181151705bc21abd4b28f2057fc0eb4770b8b2410347d913d2ae5fb451e29d
|
3 |
+
size 627
|
checkpoint-2000/special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{}
|
checkpoint-2000/tokenization_chatglm.py
ADDED
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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3 |
+
from typing import List, Optional, Union, Dict
|
4 |
+
from sentencepiece import SentencePieceProcessor
|
5 |
+
from transformers import PreTrainedTokenizer
|
6 |
+
from transformers.utils import logging, PaddingStrategy
|
7 |
+
from transformers.tokenization_utils_base import EncodedInput, BatchEncoding
|
8 |
+
|
9 |
+
|
10 |
+
class SPTokenizer:
|
11 |
+
def __init__(self, model_path: str):
|
12 |
+
# reload tokenizer
|
13 |
+
assert os.path.isfile(model_path), model_path
|
14 |
+
self.sp_model = SentencePieceProcessor(model_file=model_path)
|
15 |
+
|
16 |
+
# BOS / EOS token IDs
|
17 |
+
self.n_words: int = self.sp_model.vocab_size()
|
18 |
+
self.bos_id: int = self.sp_model.bos_id()
|
19 |
+
self.eos_id: int = self.sp_model.eos_id()
|
20 |
+
self.pad_id: int = self.sp_model.unk_id()
|
21 |
+
assert self.sp_model.vocab_size() == self.sp_model.get_piece_size()
|
22 |
+
|
23 |
+
special_tokens = ["[MASK]", "[gMASK]", "[sMASK]", "sop", "eop"]
|
24 |
+
self.special_tokens = {}
|
25 |
+
self.index_special_tokens = {}
|
26 |
+
for token in special_tokens:
|
27 |
+
self.special_tokens[token] = self.n_words
|
28 |
+
self.index_special_tokens[self.n_words] = token
|
29 |
+
self.n_words += 1
|
30 |
+
|
31 |
+
def tokenize(self, s: str):
|
32 |
+
return self.sp_model.EncodeAsPieces(s)
|
33 |
+
|
34 |
+
def encode(self, s: str, bos: bool = False, eos: bool = False) -> List[int]:
|
35 |
+
assert type(s) is str
|
36 |
+
t = self.sp_model.encode(s)
|
37 |
+
if bos:
|
38 |
+
t = [self.bos_id] + t
|
39 |
+
if eos:
|
40 |
+
t = t + [self.eos_id]
|
41 |
+
return t
|
42 |
+
|
43 |
+
def decode(self, t: List[int]) -> str:
|
44 |
+
return self.sp_model.decode(t)
|
45 |
+
|
46 |
+
def decode_tokens(self, tokens: List[str]) -> str:
|
47 |
+
text = self.sp_model.DecodePieces(tokens)
|
48 |
+
return text
|
49 |
+
|
50 |
+
def convert_token_to_id(self, token):
|
51 |
+
""" Converts a token (str) in an id using the vocab. """
|
52 |
+
if token in self.special_tokens:
|
53 |
+
return self.special_tokens[token]
|
54 |
+
return self.sp_model.PieceToId(token)
|
55 |
+
|
56 |
+
def convert_id_to_token(self, index):
|
57 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
58 |
+
if index in self.index_special_tokens or index in [self.eos_id, self.bos_id, self.pad_id] or index < 0:
|
59 |
+
return ""
|
60 |
+
return self.sp_model.IdToPiece(index)
|
61 |
+
|
62 |
+
|
63 |
+
class ChatGLMTokenizer(PreTrainedTokenizer):
|
64 |
+
vocab_files_names = {"vocab_file": "tokenizer.model"}
|
65 |
+
|
66 |
+
model_input_names = ["input_ids", "attention_mask", "position_ids"]
|
67 |
+
|
68 |
+
def __init__(self, vocab_file, padding_side="left", clean_up_tokenization_spaces=False, **kwargs):
|
69 |
+
self.name = "GLMTokenizer"
|
70 |
+
|
71 |
+
self.vocab_file = vocab_file
|
72 |
+
self.tokenizer = SPTokenizer(vocab_file)
|
73 |
+
self.special_tokens = {
|
74 |
+
"<bos>": self.tokenizer.bos_id,
|
75 |
+
"<eos>": self.tokenizer.eos_id,
|
76 |
+
"<pad>": self.tokenizer.pad_id
|
77 |
+
}
|
78 |
+
super().__init__(padding_side=padding_side, clean_up_tokenization_spaces=clean_up_tokenization_spaces, **kwargs)
|
79 |
+
|
80 |
+
def get_command(self, token):
|
81 |
+
if token in self.special_tokens:
|
82 |
+
return self.special_tokens[token]
|
83 |
+
assert token in self.tokenizer.special_tokens, f"{token} is not a special token for {self.name}"
|
84 |
+
return self.tokenizer.special_tokens[token]
|
85 |
+
|
86 |
+
@property
|
87 |
+
def unk_token(self) -> str:
|
88 |
+
return "<unk>"
|
89 |
+
|
90 |
+
@property
|
91 |
+
def pad_token(self) -> str:
|
92 |
+
return "<unk>"
|
93 |
+
|
94 |
+
@property
|
95 |
+
def pad_token_id(self):
|
96 |
+
return self.get_command("<pad>")
|
97 |
+
|
98 |
+
@property
|
99 |
+
def eos_token(self) -> str:
|
100 |
+
return "</s>"
|
101 |
+
|
102 |
+
@property
|
103 |
+
def eos_token_id(self):
|
104 |
+
return self.get_command("<eos>")
|
105 |
+
|
106 |
+
@property
|
107 |
+
def vocab_size(self):
|
108 |
+
return self.tokenizer.n_words
|
109 |
+
|
110 |
+
def get_vocab(self):
|
111 |
+
""" Returns vocab as a dict """
|
112 |
+
vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
|
113 |
+
vocab.update(self.added_tokens_encoder)
|
114 |
+
return vocab
|
115 |
+
|
116 |
+
def _tokenize(self, text, **kwargs):
|
117 |
+
return self.tokenizer.tokenize(text)
|
118 |
+
|
119 |
+
def _convert_token_to_id(self, token):
|
120 |
+
""" Converts a token (str) in an id using the vocab. """
|
121 |
+
return self.tokenizer.convert_token_to_id(token)
|
122 |
+
|
123 |
+
def _convert_id_to_token(self, index):
|
124 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
125 |
+
return self.tokenizer.convert_id_to_token(index)
|
126 |
+
|
127 |
+
def convert_tokens_to_string(self, tokens: List[str]) -> str:
|
128 |
+
return self.tokenizer.decode_tokens(tokens)
|
129 |
+
|
130 |
+
def save_vocabulary(self, save_directory, filename_prefix=None):
|
131 |
+
"""
|
132 |
+
Save the vocabulary and special tokens file to a directory.
|
133 |
+
|
134 |
+
Args:
|
135 |
+
save_directory (`str`):
|
136 |
+
The directory in which to save the vocabulary.
|
137 |
+
filename_prefix (`str`, *optional*):
|
138 |
+
An optional prefix to add to the named of the saved files.
|
139 |
+
|
140 |
+
Returns:
|
141 |
+
`Tuple(str)`: Paths to the files saved.
|
142 |
+
"""
|
143 |
+
if os.path.isdir(save_directory):
|
144 |
+
vocab_file = os.path.join(
|
145 |
+
save_directory, self.vocab_files_names["vocab_file"]
|
146 |
+
)
|
147 |
+
else:
|
148 |
+
vocab_file = save_directory
|
149 |
+
|
150 |
+
with open(self.vocab_file, 'rb') as fin:
|
151 |
+
proto_str = fin.read()
|
152 |
+
|
153 |
+
with open(vocab_file, "wb") as writer:
|
154 |
+
writer.write(proto_str)
|
155 |
+
|
156 |
+
return (vocab_file,)
|
157 |
+
|
158 |
+
def get_prefix_tokens(self):
|
159 |
+
prefix_tokens = [self.get_command("[gMASK]"), self.get_command("sop")]
|
160 |
+
return prefix_tokens
|
161 |
+
|
162 |
+
def build_prompt(self, query, history=None):
|
163 |
+
if history is None:
|
164 |
+
history = []
|
165 |
+
prompt = ""
|
166 |
+
for i, (old_query, response) in enumerate(history):
|
167 |
+
prompt += "[Round {}]\n\n问:{}\n\n答:{}\n\n".format(i + 1, old_query, response)
|
168 |
+
prompt += "[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
169 |
+
return prompt
|
170 |
+
|
171 |
+
def build_inputs_with_special_tokens(
|
172 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
173 |
+
) -> List[int]:
|
174 |
+
"""
|
175 |
+
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
|
176 |
+
adding special tokens. A BERT sequence has the following format:
|
177 |
+
|
178 |
+
- single sequence: `[CLS] X [SEP]`
|
179 |
+
- pair of sequences: `[CLS] A [SEP] B [SEP]`
|
180 |
+
|
181 |
+
Args:
|
182 |
+
token_ids_0 (`List[int]`):
|
183 |
+
List of IDs to which the special tokens will be added.
|
184 |
+
token_ids_1 (`List[int]`, *optional*):
|
185 |
+
Optional second list of IDs for sequence pairs.
|
186 |
+
|
187 |
+
Returns:
|
188 |
+
`List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
|
189 |
+
"""
|
190 |
+
prefix_tokens = self.get_prefix_tokens()
|
191 |
+
token_ids_0 = prefix_tokens + token_ids_0
|
192 |
+
if token_ids_1 is not None:
|
193 |
+
token_ids_0 = token_ids_0 + token_ids_1 + [self.get_command("<eos>")]
|
194 |
+
return token_ids_0
|
195 |
+
|
196 |
+
def _pad(
|
197 |
+
self,
|
198 |
+
encoded_inputs: Union[Dict[str, EncodedInput], BatchEncoding],
|
199 |
+
max_length: Optional[int] = None,
|
200 |
+
padding_strategy: PaddingStrategy = PaddingStrategy.DO_NOT_PAD,
|
201 |
+
pad_to_multiple_of: Optional[int] = None,
|
202 |
+
return_attention_mask: Optional[bool] = None,
|
203 |
+
) -> dict:
|
204 |
+
"""
|
205 |
+
Pad encoded inputs (on left/right and up to predefined length or max length in the batch)
|
206 |
+
|
207 |
+
Args:
|
208 |
+
encoded_inputs:
|
209 |
+
Dictionary of tokenized inputs (`List[int]`) or batch of tokenized inputs (`List[List[int]]`).
|
210 |
+
max_length: maximum length of the returned list and optionally padding length (see below).
|
211 |
+
Will truncate by taking into account the special tokens.
|
212 |
+
padding_strategy: PaddingStrategy to use for padding.
|
213 |
+
|
214 |
+
- PaddingStrategy.LONGEST Pad to the longest sequence in the batch
|
215 |
+
- PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
|
216 |
+
- PaddingStrategy.DO_NOT_PAD: Do not pad
|
217 |
+
The tokenizer padding sides are defined in self.padding_side:
|
218 |
+
|
219 |
+
- 'left': pads on the left of the sequences
|
220 |
+
- 'right': pads on the right of the sequences
|
221 |
+
pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
|
222 |
+
This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
|
223 |
+
`>= 7.5` (Volta).
|
224 |
+
return_attention_mask:
|
225 |
+
(optional) Set to False to avoid returning attention mask (default: set to model specifics)
|
226 |
+
"""
|
227 |
+
# Load from model defaults
|
228 |
+
assert self.padding_side == "left"
|
229 |
+
|
230 |
+
required_input = encoded_inputs[self.model_input_names[0]]
|
231 |
+
seq_length = len(required_input)
|
232 |
+
|
233 |
+
if padding_strategy == PaddingStrategy.LONGEST:
|
234 |
+
max_length = len(required_input)
|
235 |
+
|
236 |
+
if max_length is not None and pad_to_multiple_of is not None and (max_length % pad_to_multiple_of != 0):
|
237 |
+
max_length = ((max_length // pad_to_multiple_of) + 1) * pad_to_multiple_of
|
238 |
+
|
239 |
+
needs_to_be_padded = padding_strategy != PaddingStrategy.DO_NOT_PAD and len(required_input) != max_length
|
240 |
+
|
241 |
+
# Initialize attention mask if not present.
|
242 |
+
if "attention_mask" not in encoded_inputs:
|
243 |
+
encoded_inputs["attention_mask"] = [1] * seq_length
|
244 |
+
|
245 |
+
if "position_ids" not in encoded_inputs:
|
246 |
+
encoded_inputs["position_ids"] = list(range(seq_length))
|
247 |
+
|
248 |
+
if needs_to_be_padded:
|
249 |
+
difference = max_length - len(required_input)
|
250 |
+
|
251 |
+
if "attention_mask" in encoded_inputs:
|
252 |
+
encoded_inputs["attention_mask"] = [0] * difference + encoded_inputs["attention_mask"]
|
253 |
+
if "position_ids" in encoded_inputs:
|
254 |
+
encoded_inputs["position_ids"] = [0] * difference + encoded_inputs["position_ids"]
|
255 |
+
encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input
|
256 |
+
|
257 |
+
return encoded_inputs
|
checkpoint-2000/tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7dc4c393423b76e4373e5157ddc34803a0189ba96b21ddbb40269d31468a6f2
|
3 |
+
size 1018370
|
checkpoint-2000/tokenizer_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"auto_map": {
|
3 |
+
"AutoTokenizer": [
|
4 |
+
"tokenization_chatglm.ChatGLMTokenizer",
|
5 |
+
null
|
6 |
+
]
|
7 |
+
},
|
8 |
+
"clean_up_tokenization_spaces": false,
|
9 |
+
"do_lower_case": false,
|
10 |
+
"model_max_length": 1000000000000000019884624838656,
|
11 |
+
"padding_side": "left",
|
12 |
+
"remove_space": false,
|
13 |
+
"tokenizer_class": "ChatGLMTokenizer"
|
14 |
+
}
|
checkpoint-2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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 0.18471911150107367,
|
5 |
+
"global_step": 2000,
|
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.0,
|
12 |
+
"learning_rate": 0.019933333333333334,
|
13 |
+
"loss": 2.6644,
|
14 |
+
"step": 10
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"epoch": 0.0,
|
18 |
+
"learning_rate": 0.019866666666666668,
|
19 |
+
"loss": 1.7151,
|
20 |
+
"step": 20
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"epoch": 0.0,
|
24 |
+
"learning_rate": 0.0198,
|
25 |
+
"loss": 1.6228,
|
26 |
+
"step": 30
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"epoch": 0.0,
|
30 |
+
"learning_rate": 0.019733333333333335,
|
31 |
+
"loss": 1.401,
|
32 |
+
"step": 40
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"epoch": 0.0,
|
36 |
+
"learning_rate": 0.019666666666666666,
|
37 |
+
"loss": 1.6172,
|
38 |
+
"step": 50
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"epoch": 0.01,
|
42 |
+
"learning_rate": 0.0196,
|
43 |
+
"loss": 1.4695,
|
44 |
+
"step": 60
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"epoch": 0.01,
|
48 |
+
"learning_rate": 0.019533333333333333,
|
49 |
+
"loss": 1.5137,
|
50 |
+
"step": 70
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"epoch": 0.01,
|
54 |
+
"learning_rate": 0.019466666666666667,
|
55 |
+
"loss": 1.5425,
|
56 |
+
"step": 80
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"epoch": 0.01,
|
60 |
+
"learning_rate": 0.0194,
|
61 |
+
"loss": 1.4272,
|
62 |
+
"step": 90
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"epoch": 0.01,
|
66 |
+
"learning_rate": 0.019333333333333334,
|
67 |
+
"loss": 1.3727,
|
68 |
+
"step": 100
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"epoch": 0.01,
|
72 |
+
"learning_rate": 0.019266666666666668,
|
73 |
+
"loss": 1.3114,
|
74 |
+
"step": 110
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"epoch": 0.01,
|
78 |
+
"learning_rate": 0.0192,
|
79 |
+
"loss": 1.4758,
|
80 |
+
"step": 120
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"epoch": 0.01,
|
84 |
+
"learning_rate": 0.019133333333333332,
|
85 |
+
"loss": 1.5219,
|
86 |
+
"step": 130
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"epoch": 0.01,
|
90 |
+
"learning_rate": 0.01906666666666667,
|
91 |
+
"loss": 1.376,
|
92 |
+
"step": 140
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"epoch": 0.01,
|
96 |
+
"learning_rate": 0.019,
|
97 |
+
"loss": 1.4257,
|
98 |
+
"step": 150
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"epoch": 0.01,
|
102 |
+
"learning_rate": 0.018933333333333333,
|
103 |
+
"loss": 1.3474,
|
104 |
+
"step": 160
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"epoch": 0.02,
|
108 |
+
"learning_rate": 0.018866666666666667,
|
109 |
+
"loss": 1.2929,
|
110 |
+
"step": 170
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"epoch": 0.02,
|
114 |
+
"learning_rate": 0.0188,
|
115 |
+
"loss": 1.3208,
|
116 |
+
"step": 180
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"epoch": 0.02,
|
120 |
+
"learning_rate": 0.018733333333333334,
|
121 |
+
"loss": 1.3381,
|
122 |
+
"step": 190
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"epoch": 0.02,
|
126 |
+
"learning_rate": 0.018666666666666668,
|
127 |
+
"loss": 1.3644,
|
128 |
+
"step": 200
|
129 |
+
},
|
130 |
+
{
|
131 |
+
"epoch": 0.02,
|
132 |
+
"learning_rate": 0.018600000000000002,
|
133 |
+
"loss": 1.2932,
|
134 |
+
"step": 210
|
135 |
+
},
|
136 |
+
{
|
137 |
+
"epoch": 0.02,
|
138 |
+
"learning_rate": 0.018533333333333332,
|
139 |
+
"loss": 1.4092,
|
140 |
+
"step": 220
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"epoch": 0.02,
|
144 |
+
"learning_rate": 0.018466666666666666,
|
145 |
+
"loss": 1.3006,
|
146 |
+
"step": 230
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"epoch": 0.02,
|
150 |
+
"learning_rate": 0.0184,
|
151 |
+
"loss": 1.4572,
|
152 |
+
"step": 240
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"epoch": 0.02,
|
156 |
+
"learning_rate": 0.018333333333333333,
|
157 |
+
"loss": 1.2789,
|
158 |
+
"step": 250
|
159 |
+
},
|
160 |
+
{
|
161 |
+
"epoch": 0.02,
|
162 |
+
"learning_rate": 0.018266666666666667,
|
163 |
+
"loss": 1.4444,
|
164 |
+
"step": 260
|
165 |
+
},
|
166 |
+
{
|
167 |
+
"epoch": 0.02,
|
168 |
+
"learning_rate": 0.0182,
|
169 |
+
"loss": 1.4511,
|
170 |
+
"step": 270
|
171 |
+
},
|
172 |
+
{
|
173 |
+
"epoch": 0.03,
|
174 |
+
"learning_rate": 0.01813333333333333,
|
175 |
+
"loss": 1.3541,
|
176 |
+
"step": 280
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"epoch": 0.03,
|
180 |
+
"learning_rate": 0.01806666666666667,
|
181 |
+
"loss": 1.3228,
|
182 |
+
"step": 290
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"epoch": 0.03,
|
186 |
+
"learning_rate": 0.018000000000000002,
|
187 |
+
"loss": 1.3185,
|
188 |
+
"step": 300
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"epoch": 0.03,
|
192 |
+
"learning_rate": 0.017933333333333332,
|
193 |
+
"loss": 1.199,
|
194 |
+
"step": 310
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"epoch": 0.03,
|
198 |
+
"learning_rate": 0.017866666666666666,
|
199 |
+
"loss": 1.3417,
|
200 |
+
"step": 320
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"epoch": 0.03,
|
204 |
+
"learning_rate": 0.0178,
|
205 |
+
"loss": 1.4251,
|
206 |
+
"step": 330
|
207 |
+
},
|
208 |
+
{
|
209 |
+
"epoch": 0.03,
|
210 |
+
"learning_rate": 0.017733333333333334,
|
211 |
+
"loss": 1.3574,
|
212 |
+
"step": 340
|
213 |
+
},
|
214 |
+
{
|
215 |
+
"epoch": 0.03,
|
216 |
+
"learning_rate": 0.017666666666666667,
|
217 |
+
"loss": 1.2547,
|
218 |
+
"step": 350
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"epoch": 0.03,
|
222 |
+
"learning_rate": 0.0176,
|
223 |
+
"loss": 1.2651,
|
224 |
+
"step": 360
|
225 |
+
},
|
226 |
+
{
|
227 |
+
"epoch": 0.03,
|
228 |
+
"learning_rate": 0.017533333333333335,
|
229 |
+
"loss": 1.3414,
|
230 |
+
"step": 370
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"epoch": 0.04,
|
234 |
+
"learning_rate": 0.017466666666666665,
|
235 |
+
"loss": 1.3322,
|
236 |
+
"step": 380
|
237 |
+
},
|
238 |
+
{
|
239 |
+
"epoch": 0.04,
|
240 |
+
"learning_rate": 0.0174,
|
241 |
+
"loss": 1.4147,
|
242 |
+
"step": 390
|
243 |
+
},
|
244 |
+
{
|
245 |
+
"epoch": 0.04,
|
246 |
+
"learning_rate": 0.017333333333333336,
|
247 |
+
"loss": 1.2813,
|
248 |
+
"step": 400
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"epoch": 0.04,
|
252 |
+
"learning_rate": 0.017266666666666666,
|
253 |
+
"loss": 1.3687,
|
254 |
+
"step": 410
|
255 |
+
},
|
256 |
+
{
|
257 |
+
"epoch": 0.04,
|
258 |
+
"learning_rate": 0.0172,
|
259 |
+
"loss": 1.5593,
|
260 |
+
"step": 420
|
261 |
+
},
|
262 |
+
{
|
263 |
+
"epoch": 0.04,
|
264 |
+
"learning_rate": 0.017133333333333334,
|
265 |
+
"loss": 1.3073,
|
266 |
+
"step": 430
|
267 |
+
},
|
268 |
+
{
|
269 |
+
"epoch": 0.04,
|
270 |
+
"learning_rate": 0.017066666666666667,
|
271 |
+
"loss": 1.2359,
|
272 |
+
"step": 440
|
273 |
+
},
|
274 |
+
{
|
275 |
+
"epoch": 0.04,
|
276 |
+
"learning_rate": 0.017,
|
277 |
+
"loss": 1.2474,
|
278 |
+
"step": 450
|
279 |
+
},
|
280 |
+
{
|
281 |
+
"epoch": 0.04,
|
282 |
+
"learning_rate": 0.016933333333333335,
|
283 |
+
"loss": 1.3874,
|
284 |
+
"step": 460
|
285 |
+
},
|
286 |
+
{
|
287 |
+
"epoch": 0.04,
|
288 |
+
"learning_rate": 0.01686666666666667,
|
289 |
+
"loss": 1.3203,
|
290 |
+
"step": 470
|
291 |
+
},
|
292 |
+
{
|
293 |
+
"epoch": 0.04,
|
294 |
+
"learning_rate": 0.0168,
|
295 |
+
"loss": 1.2875,
|
296 |
+
"step": 480
|
297 |
+
},
|
298 |
+
{
|
299 |
+
"epoch": 0.05,
|
300 |
+
"learning_rate": 0.016733333333333333,
|
301 |
+
"loss": 1.2767,
|
302 |
+
"step": 490
|
303 |
+
},
|
304 |
+
{
|
305 |
+
"epoch": 0.05,
|
306 |
+
"learning_rate": 0.016666666666666666,
|
307 |
+
"loss": 1.3017,
|
308 |
+
"step": 500
|
309 |
+
},
|
310 |
+
{
|
311 |
+
"epoch": 0.05,
|
312 |
+
"learning_rate": 0.0166,
|
313 |
+
"loss": 1.2321,
|
314 |
+
"step": 510
|
315 |
+
},
|
316 |
+
{
|
317 |
+
"epoch": 0.05,
|
318 |
+
"learning_rate": 0.016533333333333334,
|
319 |
+
"loss": 1.1719,
|
320 |
+
"step": 520
|
321 |
+
},
|
322 |
+
{
|
323 |
+
"epoch": 0.05,
|
324 |
+
"learning_rate": 0.016466666666666668,
|
325 |
+
"loss": 1.2552,
|
326 |
+
"step": 530
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"epoch": 0.05,
|
330 |
+
"learning_rate": 0.016399999999999998,
|
331 |
+
"loss": 1.3816,
|
332 |
+
"step": 540
|
333 |
+
},
|
334 |
+
{
|
335 |
+
"epoch": 0.05,
|
336 |
+
"learning_rate": 0.01633333333333333,
|
337 |
+
"loss": 1.2956,
|
338 |
+
"step": 550
|
339 |
+
},
|
340 |
+
{
|
341 |
+
"epoch": 0.05,
|
342 |
+
"learning_rate": 0.01626666666666667,
|
343 |
+
"loss": 1.2061,
|
344 |
+
"step": 560
|
345 |
+
},
|
346 |
+
{
|
347 |
+
"epoch": 0.05,
|
348 |
+
"learning_rate": 0.016200000000000003,
|
349 |
+
"loss": 1.2086,
|
350 |
+
"step": 570
|
351 |
+
},
|
352 |
+
{
|
353 |
+
"epoch": 0.05,
|
354 |
+
"learning_rate": 0.016133333333333333,
|
355 |
+
"loss": 1.1633,
|
356 |
+
"step": 580
|
357 |
+
},
|
358 |
+
{
|
359 |
+
"epoch": 0.05,
|
360 |
+
"learning_rate": 0.016066666666666667,
|
361 |
+
"loss": 1.2638,
|
362 |
+
"step": 590
|
363 |
+
},
|
364 |
+
{
|
365 |
+
"epoch": 0.06,
|
366 |
+
"learning_rate": 0.016,
|
367 |
+
"loss": 1.3441,
|
368 |
+
"step": 600
|
369 |
+
},
|
370 |
+
{
|
371 |
+
"epoch": 0.06,
|
372 |
+
"learning_rate": 0.015933333333333334,
|
373 |
+
"loss": 1.2924,
|
374 |
+
"step": 610
|
375 |
+
},
|
376 |
+
{
|
377 |
+
"epoch": 0.06,
|
378 |
+
"learning_rate": 0.015866666666666668,
|
379 |
+
"loss": 1.1818,
|
380 |
+
"step": 620
|
381 |
+
},
|
382 |
+
{
|
383 |
+
"epoch": 0.06,
|
384 |
+
"learning_rate": 0.0158,
|
385 |
+
"loss": 1.3918,
|
386 |
+
"step": 630
|
387 |
+
},
|
388 |
+
{
|
389 |
+
"epoch": 0.06,
|
390 |
+
"learning_rate": 0.015733333333333332,
|
391 |
+
"loss": 1.2232,
|
392 |
+
"step": 640
|
393 |
+
},
|
394 |
+
{
|
395 |
+
"epoch": 0.06,
|
396 |
+
"learning_rate": 0.015666666666666666,
|
397 |
+
"loss": 1.2472,
|
398 |
+
"step": 650
|
399 |
+
},
|
400 |
+
{
|
401 |
+
"epoch": 0.06,
|
402 |
+
"learning_rate": 0.015600000000000001,
|
403 |
+
"loss": 1.2398,
|
404 |
+
"step": 660
|
405 |
+
},
|
406 |
+
{
|
407 |
+
"epoch": 0.06,
|
408 |
+
"learning_rate": 0.015533333333333333,
|
409 |
+
"loss": 1.3649,
|
410 |
+
"step": 670
|
411 |
+
},
|
412 |
+
{
|
413 |
+
"epoch": 0.06,
|
414 |
+
"learning_rate": 0.015466666666666667,
|
415 |
+
"loss": 1.2302,
|
416 |
+
"step": 680
|
417 |
+
},
|
418 |
+
{
|
419 |
+
"epoch": 0.06,
|
420 |
+
"learning_rate": 0.0154,
|
421 |
+
"loss": 1.2053,
|
422 |
+
"step": 690
|
423 |
+
},
|
424 |
+
{
|
425 |
+
"epoch": 0.06,
|
426 |
+
"learning_rate": 0.015333333333333334,
|
427 |
+
"loss": 1.2974,
|
428 |
+
"step": 700
|
429 |
+
},
|
430 |
+
{
|
431 |
+
"epoch": 0.07,
|
432 |
+
"learning_rate": 0.015266666666666666,
|
433 |
+
"loss": 1.3036,
|
434 |
+
"step": 710
|
435 |
+
},
|
436 |
+
{
|
437 |
+
"epoch": 0.07,
|
438 |
+
"learning_rate": 0.0152,
|
439 |
+
"loss": 1.3162,
|
440 |
+
"step": 720
|
441 |
+
},
|
442 |
+
{
|
443 |
+
"epoch": 0.07,
|
444 |
+
"learning_rate": 0.015133333333333334,
|
445 |
+
"loss": 1.2567,
|
446 |
+
"step": 730
|
447 |
+
},
|
448 |
+
{
|
449 |
+
"epoch": 0.07,
|
450 |
+
"learning_rate": 0.015066666666666666,
|
451 |
+
"loss": 1.2578,
|
452 |
+
"step": 740
|
453 |
+
},
|
454 |
+
{
|
455 |
+
"epoch": 0.07,
|
456 |
+
"learning_rate": 0.015,
|
457 |
+
"loss": 1.2692,
|
458 |
+
"step": 750
|
459 |
+
},
|
460 |
+
{
|
461 |
+
"epoch": 0.07,
|
462 |
+
"learning_rate": 0.014933333333333335,
|
463 |
+
"loss": 1.1332,
|
464 |
+
"step": 760
|
465 |
+
},
|
466 |
+
{
|
467 |
+
"epoch": 0.07,
|
468 |
+
"learning_rate": 0.014866666666666667,
|
469 |
+
"loss": 1.2949,
|
470 |
+
"step": 770
|
471 |
+
},
|
472 |
+
{
|
473 |
+
"epoch": 0.07,
|
474 |
+
"learning_rate": 0.0148,
|
475 |
+
"loss": 1.2703,
|
476 |
+
"step": 780
|
477 |
+
},
|
478 |
+
{
|
479 |
+
"epoch": 0.07,
|
480 |
+
"learning_rate": 0.014733333333333334,
|
481 |
+
"loss": 1.3891,
|
482 |
+
"step": 790
|
483 |
+
},
|
484 |
+
{
|
485 |
+
"epoch": 0.07,
|
486 |
+
"learning_rate": 0.014666666666666666,
|
487 |
+
"loss": 1.3594,
|
488 |
+
"step": 800
|
489 |
+
},
|
490 |
+
{
|
491 |
+
"epoch": 0.07,
|
492 |
+
"learning_rate": 0.0146,
|
493 |
+
"loss": 1.166,
|
494 |
+
"step": 810
|
495 |
+
},
|
496 |
+
{
|
497 |
+
"epoch": 0.08,
|
498 |
+
"learning_rate": 0.014533333333333334,
|
499 |
+
"loss": 1.3256,
|
500 |
+
"step": 820
|
501 |
+
},
|
502 |
+
{
|
503 |
+
"epoch": 0.08,
|
504 |
+
"learning_rate": 0.014466666666666668,
|
505 |
+
"loss": 1.2669,
|
506 |
+
"step": 830
|
507 |
+
},
|
508 |
+
{
|
509 |
+
"epoch": 0.08,
|
510 |
+
"learning_rate": 0.0144,
|
511 |
+
"loss": 1.241,
|
512 |
+
"step": 840
|
513 |
+
},
|
514 |
+
{
|
515 |
+
"epoch": 0.08,
|
516 |
+
"learning_rate": 0.014333333333333333,
|
517 |
+
"loss": 1.2591,
|
518 |
+
"step": 850
|
519 |
+
},
|
520 |
+
{
|
521 |
+
"epoch": 0.08,
|
522 |
+
"learning_rate": 0.014266666666666667,
|
523 |
+
"loss": 1.238,
|
524 |
+
"step": 860
|
525 |
+
},
|
526 |
+
{
|
527 |
+
"epoch": 0.08,
|
528 |
+
"learning_rate": 0.014199999999999999,
|
529 |
+
"loss": 1.3583,
|
530 |
+
"step": 870
|
531 |
+
},
|
532 |
+
{
|
533 |
+
"epoch": 0.08,
|
534 |
+
"learning_rate": 0.014133333333333333,
|
535 |
+
"loss": 1.164,
|
536 |
+
"step": 880
|
537 |
+
},
|
538 |
+
{
|
539 |
+
"epoch": 0.08,
|
540 |
+
"learning_rate": 0.014066666666666668,
|
541 |
+
"loss": 1.2367,
|
542 |
+
"step": 890
|
543 |
+
},
|
544 |
+
{
|
545 |
+
"epoch": 0.08,
|
546 |
+
"learning_rate": 0.013999999999999999,
|
547 |
+
"loss": 1.1864,
|
548 |
+
"step": 900
|
549 |
+
},
|
550 |
+
{
|
551 |
+
"epoch": 0.08,
|
552 |
+
"learning_rate": 0.013933333333333334,
|
553 |
+
"loss": 1.2259,
|
554 |
+
"step": 910
|
555 |
+
},
|
556 |
+
{
|
557 |
+
"epoch": 0.08,
|
558 |
+
"learning_rate": 0.013866666666666668,
|
559 |
+
"loss": 1.2129,
|
560 |
+
"step": 920
|
561 |
+
},
|
562 |
+
{
|
563 |
+
"epoch": 0.09,
|
564 |
+
"learning_rate": 0.0138,
|
565 |
+
"loss": 1.2085,
|
566 |
+
"step": 930
|
567 |
+
},
|
568 |
+
{
|
569 |
+
"epoch": 0.09,
|
570 |
+
"learning_rate": 0.013733333333333334,
|
571 |
+
"loss": 1.2316,
|
572 |
+
"step": 940
|
573 |
+
},
|
574 |
+
{
|
575 |
+
"epoch": 0.09,
|
576 |
+
"learning_rate": 0.013666666666666667,
|
577 |
+
"loss": 1.2721,
|
578 |
+
"step": 950
|
579 |
+
},
|
580 |
+
{
|
581 |
+
"epoch": 0.09,
|
582 |
+
"learning_rate": 0.013600000000000001,
|
583 |
+
"loss": 1.2428,
|
584 |
+
"step": 960
|
585 |
+
},
|
586 |
+
{
|
587 |
+
"epoch": 0.09,
|
588 |
+
"learning_rate": 0.013533333333333333,
|
589 |
+
"loss": 1.2126,
|
590 |
+
"step": 970
|
591 |
+
},
|
592 |
+
{
|
593 |
+
"epoch": 0.09,
|
594 |
+
"learning_rate": 0.013466666666666667,
|
595 |
+
"loss": 1.1583,
|
596 |
+
"step": 980
|
597 |
+
},
|
598 |
+
{
|
599 |
+
"epoch": 0.09,
|
600 |
+
"learning_rate": 0.0134,
|
601 |
+
"loss": 1.2776,
|
602 |
+
"step": 990
|
603 |
+
},
|
604 |
+
{
|
605 |
+
"epoch": 0.09,
|
606 |
+
"learning_rate": 0.013333333333333332,
|
607 |
+
"loss": 1.2317,
|
608 |
+
"step": 1000
|
609 |
+
},
|
610 |
+
{
|
611 |
+
"epoch": 0.09,
|
612 |
+
"learning_rate": 0.013266666666666666,
|
613 |
+
"loss": 1.2047,
|
614 |
+
"step": 1010
|
615 |
+
},
|
616 |
+
{
|
617 |
+
"epoch": 0.09,
|
618 |
+
"learning_rate": 0.013200000000000002,
|
619 |
+
"loss": 1.202,
|
620 |
+
"step": 1020
|
621 |
+
},
|
622 |
+
{
|
623 |
+
"epoch": 0.1,
|
624 |
+
"learning_rate": 0.013133333333333332,
|
625 |
+
"loss": 1.1877,
|
626 |
+
"step": 1030
|
627 |
+
},
|
628 |
+
{
|
629 |
+
"epoch": 0.1,
|
630 |
+
"learning_rate": 0.013066666666666667,
|
631 |
+
"loss": 1.3071,
|
632 |
+
"step": 1040
|
633 |
+
},
|
634 |
+
{
|
635 |
+
"epoch": 0.1,
|
636 |
+
"learning_rate": 0.013000000000000001,
|
637 |
+
"loss": 1.2976,
|
638 |
+
"step": 1050
|
639 |
+
},
|
640 |
+
{
|
641 |
+
"epoch": 0.1,
|
642 |
+
"learning_rate": 0.012933333333333333,
|
643 |
+
"loss": 1.4156,
|
644 |
+
"step": 1060
|
645 |
+
},
|
646 |
+
{
|
647 |
+
"epoch": 0.1,
|
648 |
+
"learning_rate": 0.012866666666666667,
|
649 |
+
"loss": 1.173,
|
650 |
+
"step": 1070
|
651 |
+
},
|
652 |
+
{
|
653 |
+
"epoch": 0.1,
|
654 |
+
"learning_rate": 0.0128,
|
655 |
+
"loss": 1.2263,
|
656 |
+
"step": 1080
|
657 |
+
},
|
658 |
+
{
|
659 |
+
"epoch": 0.1,
|
660 |
+
"learning_rate": 0.012733333333333334,
|
661 |
+
"loss": 1.3235,
|
662 |
+
"step": 1090
|
663 |
+
},
|
664 |
+
{
|
665 |
+
"epoch": 0.1,
|
666 |
+
"learning_rate": 0.012666666666666666,
|
667 |
+
"loss": 1.1923,
|
668 |
+
"step": 1100
|
669 |
+
},
|
670 |
+
{
|
671 |
+
"epoch": 0.1,
|
672 |
+
"learning_rate": 0.0126,
|
673 |
+
"loss": 1.2879,
|
674 |
+
"step": 1110
|
675 |
+
},
|
676 |
+
{
|
677 |
+
"epoch": 0.1,
|
678 |
+
"learning_rate": 0.012533333333333334,
|
679 |
+
"loss": 1.196,
|
680 |
+
"step": 1120
|
681 |
+
},
|
682 |
+
{
|
683 |
+
"epoch": 0.1,
|
684 |
+
"learning_rate": 0.012466666666666666,
|
685 |
+
"loss": 1.2605,
|
686 |
+
"step": 1130
|
687 |
+
},
|
688 |
+
{
|
689 |
+
"epoch": 0.11,
|
690 |
+
"learning_rate": 0.0124,
|
691 |
+
"loss": 1.2303,
|
692 |
+
"step": 1140
|
693 |
+
},
|
694 |
+
{
|
695 |
+
"epoch": 0.11,
|
696 |
+
"learning_rate": 0.012333333333333335,
|
697 |
+
"loss": 1.2381,
|
698 |
+
"step": 1150
|
699 |
+
},
|
700 |
+
{
|
701 |
+
"epoch": 0.11,
|
702 |
+
"learning_rate": 0.012266666666666665,
|
703 |
+
"loss": 1.2709,
|
704 |
+
"step": 1160
|
705 |
+
},
|
706 |
+
{
|
707 |
+
"epoch": 0.11,
|
708 |
+
"learning_rate": 0.0122,
|
709 |
+
"loss": 1.2121,
|
710 |
+
"step": 1170
|
711 |
+
},
|
712 |
+
{
|
713 |
+
"epoch": 0.11,
|
714 |
+
"learning_rate": 0.012133333333333335,
|
715 |
+
"loss": 1.3713,
|
716 |
+
"step": 1180
|
717 |
+
},
|
718 |
+
{
|
719 |
+
"epoch": 0.11,
|
720 |
+
"learning_rate": 0.012066666666666668,
|
721 |
+
"loss": 1.2923,
|
722 |
+
"step": 1190
|
723 |
+
},
|
724 |
+
{
|
725 |
+
"epoch": 0.11,
|
726 |
+
"learning_rate": 0.012,
|
727 |
+
"loss": 1.2947,
|
728 |
+
"step": 1200
|
729 |
+
},
|
730 |
+
{
|
731 |
+
"epoch": 0.11,
|
732 |
+
"learning_rate": 0.011933333333333334,
|
733 |
+
"loss": 1.1538,
|
734 |
+
"step": 1210
|
735 |
+
},
|
736 |
+
{
|
737 |
+
"epoch": 0.11,
|
738 |
+
"learning_rate": 0.011866666666666668,
|
739 |
+
"loss": 1.1312,
|
740 |
+
"step": 1220
|
741 |
+
},
|
742 |
+
{
|
743 |
+
"epoch": 0.11,
|
744 |
+
"learning_rate": 0.0118,
|
745 |
+
"loss": 1.1807,
|
746 |
+
"step": 1230
|
747 |
+
},
|
748 |
+
{
|
749 |
+
"epoch": 0.11,
|
750 |
+
"learning_rate": 0.011733333333333333,
|
751 |
+
"loss": 1.2729,
|
752 |
+
"step": 1240
|
753 |
+
},
|
754 |
+
{
|
755 |
+
"epoch": 0.12,
|
756 |
+
"learning_rate": 0.011666666666666667,
|
757 |
+
"loss": 1.21,
|
758 |
+
"step": 1250
|
759 |
+
},
|
760 |
+
{
|
761 |
+
"epoch": 0.12,
|
762 |
+
"learning_rate": 0.0116,
|
763 |
+
"loss": 1.1986,
|
764 |
+
"step": 1260
|
765 |
+
},
|
766 |
+
{
|
767 |
+
"epoch": 0.12,
|
768 |
+
"learning_rate": 0.011533333333333333,
|
769 |
+
"loss": 1.2003,
|
770 |
+
"step": 1270
|
771 |
+
},
|
772 |
+
{
|
773 |
+
"epoch": 0.12,
|
774 |
+
"learning_rate": 0.011466666666666667,
|
775 |
+
"loss": 1.1773,
|
776 |
+
"step": 1280
|
777 |
+
},
|
778 |
+
{
|
779 |
+
"epoch": 0.12,
|
780 |
+
"learning_rate": 0.011399999999999999,
|
781 |
+
"loss": 1.3241,
|
782 |
+
"step": 1290
|
783 |
+
},
|
784 |
+
{
|
785 |
+
"epoch": 0.12,
|
786 |
+
"learning_rate": 0.011333333333333332,
|
787 |
+
"loss": 1.2157,
|
788 |
+
"step": 1300
|
789 |
+
},
|
790 |
+
{
|
791 |
+
"epoch": 0.12,
|
792 |
+
"learning_rate": 0.011266666666666668,
|
793 |
+
"loss": 1.2549,
|
794 |
+
"step": 1310
|
795 |
+
},
|
796 |
+
{
|
797 |
+
"epoch": 0.12,
|
798 |
+
"learning_rate": 0.011200000000000002,
|
799 |
+
"loss": 1.3245,
|
800 |
+
"step": 1320
|
801 |
+
},
|
802 |
+
{
|
803 |
+
"epoch": 0.12,
|
804 |
+
"learning_rate": 0.011133333333333334,
|
805 |
+
"loss": 1.2109,
|
806 |
+
"step": 1330
|
807 |
+
},
|
808 |
+
{
|
809 |
+
"epoch": 0.12,
|
810 |
+
"learning_rate": 0.011066666666666667,
|
811 |
+
"loss": 1.1979,
|
812 |
+
"step": 1340
|
813 |
+
},
|
814 |
+
{
|
815 |
+
"epoch": 0.12,
|
816 |
+
"learning_rate": 0.011000000000000001,
|
817 |
+
"loss": 1.2804,
|
818 |
+
"step": 1350
|
819 |
+
},
|
820 |
+
{
|
821 |
+
"epoch": 0.13,
|
822 |
+
"learning_rate": 0.010933333333333333,
|
823 |
+
"loss": 1.2655,
|
824 |
+
"step": 1360
|
825 |
+
},
|
826 |
+
{
|
827 |
+
"epoch": 0.13,
|
828 |
+
"learning_rate": 0.010866666666666667,
|
829 |
+
"loss": 1.1264,
|
830 |
+
"step": 1370
|
831 |
+
},
|
832 |
+
{
|
833 |
+
"epoch": 0.13,
|
834 |
+
"learning_rate": 0.0108,
|
835 |
+
"loss": 1.2949,
|
836 |
+
"step": 1380
|
837 |
+
},
|
838 |
+
{
|
839 |
+
"epoch": 0.13,
|
840 |
+
"learning_rate": 0.010733333333333333,
|
841 |
+
"loss": 1.2038,
|
842 |
+
"step": 1390
|
843 |
+
},
|
844 |
+
{
|
845 |
+
"epoch": 0.13,
|
846 |
+
"learning_rate": 0.010666666666666666,
|
847 |
+
"loss": 1.2514,
|
848 |
+
"step": 1400
|
849 |
+
},
|
850 |
+
{
|
851 |
+
"epoch": 0.13,
|
852 |
+
"learning_rate": 0.0106,
|
853 |
+
"loss": 1.1692,
|
854 |
+
"step": 1410
|
855 |
+
},
|
856 |
+
{
|
857 |
+
"epoch": 0.13,
|
858 |
+
"learning_rate": 0.010533333333333332,
|
859 |
+
"loss": 1.1947,
|
860 |
+
"step": 1420
|
861 |
+
},
|
862 |
+
{
|
863 |
+
"epoch": 0.13,
|
864 |
+
"learning_rate": 0.010466666666666666,
|
865 |
+
"loss": 1.3294,
|
866 |
+
"step": 1430
|
867 |
+
},
|
868 |
+
{
|
869 |
+
"epoch": 0.13,
|
870 |
+
"learning_rate": 0.010400000000000001,
|
871 |
+
"loss": 1.2169,
|
872 |
+
"step": 1440
|
873 |
+
},
|
874 |
+
{
|
875 |
+
"epoch": 0.13,
|
876 |
+
"learning_rate": 0.010333333333333335,
|
877 |
+
"loss": 1.3113,
|
878 |
+
"step": 1450
|
879 |
+
},
|
880 |
+
{
|
881 |
+
"epoch": 0.13,
|
882 |
+
"learning_rate": 0.010266666666666667,
|
883 |
+
"loss": 1.1322,
|
884 |
+
"step": 1460
|
885 |
+
},
|
886 |
+
{
|
887 |
+
"epoch": 0.14,
|
888 |
+
"learning_rate": 0.0102,
|
889 |
+
"loss": 1.4228,
|
890 |
+
"step": 1470
|
891 |
+
},
|
892 |
+
{
|
893 |
+
"epoch": 0.14,
|
894 |
+
"learning_rate": 0.010133333333333334,
|
895 |
+
"loss": 1.2384,
|
896 |
+
"step": 1480
|
897 |
+
},
|
898 |
+
{
|
899 |
+
"epoch": 0.14,
|
900 |
+
"learning_rate": 0.010066666666666666,
|
901 |
+
"loss": 1.2107,
|
902 |
+
"step": 1490
|
903 |
+
},
|
904 |
+
{
|
905 |
+
"epoch": 0.14,
|
906 |
+
"learning_rate": 0.01,
|
907 |
+
"loss": 1.2655,
|
908 |
+
"step": 1500
|
909 |
+
},
|
910 |
+
{
|
911 |
+
"epoch": 0.14,
|
912 |
+
"learning_rate": 0.009933333333333334,
|
913 |
+
"loss": 1.2991,
|
914 |
+
"step": 1510
|
915 |
+
},
|
916 |
+
{
|
917 |
+
"epoch": 0.14,
|
918 |
+
"learning_rate": 0.009866666666666668,
|
919 |
+
"loss": 1.324,
|
920 |
+
"step": 1520
|
921 |
+
},
|
922 |
+
{
|
923 |
+
"epoch": 0.14,
|
924 |
+
"learning_rate": 0.0098,
|
925 |
+
"loss": 1.3443,
|
926 |
+
"step": 1530
|
927 |
+
},
|
928 |
+
{
|
929 |
+
"epoch": 0.14,
|
930 |
+
"learning_rate": 0.009733333333333333,
|
931 |
+
"loss": 1.1389,
|
932 |
+
"step": 1540
|
933 |
+
},
|
934 |
+
{
|
935 |
+
"epoch": 0.14,
|
936 |
+
"learning_rate": 0.009666666666666667,
|
937 |
+
"loss": 1.2308,
|
938 |
+
"step": 1550
|
939 |
+
},
|
940 |
+
{
|
941 |
+
"epoch": 0.14,
|
942 |
+
"learning_rate": 0.0096,
|
943 |
+
"loss": 1.1847,
|
944 |
+
"step": 1560
|
945 |
+
},
|
946 |
+
{
|
947 |
+
"epoch": 0.15,
|
948 |
+
"learning_rate": 0.009533333333333335,
|
949 |
+
"loss": 1.3154,
|
950 |
+
"step": 1570
|
951 |
+
},
|
952 |
+
{
|
953 |
+
"epoch": 0.15,
|
954 |
+
"learning_rate": 0.009466666666666667,
|
955 |
+
"loss": 1.233,
|
956 |
+
"step": 1580
|
957 |
+
},
|
958 |
+
{
|
959 |
+
"epoch": 0.15,
|
960 |
+
"learning_rate": 0.0094,
|
961 |
+
"loss": 1.147,
|
962 |
+
"step": 1590
|
963 |
+
},
|
964 |
+
{
|
965 |
+
"epoch": 0.15,
|
966 |
+
"learning_rate": 0.009333333333333334,
|
967 |
+
"loss": 1.1824,
|
968 |
+
"step": 1600
|
969 |
+
},
|
970 |
+
{
|
971 |
+
"epoch": 0.15,
|
972 |
+
"learning_rate": 0.009266666666666666,
|
973 |
+
"loss": 1.2093,
|
974 |
+
"step": 1610
|
975 |
+
},
|
976 |
+
{
|
977 |
+
"epoch": 0.15,
|
978 |
+
"learning_rate": 0.0092,
|
979 |
+
"loss": 1.2111,
|
980 |
+
"step": 1620
|
981 |
+
},
|
982 |
+
{
|
983 |
+
"epoch": 0.15,
|
984 |
+
"learning_rate": 0.009133333333333334,
|
985 |
+
"loss": 1.0596,
|
986 |
+
"step": 1630
|
987 |
+
},
|
988 |
+
{
|
989 |
+
"epoch": 0.15,
|
990 |
+
"learning_rate": 0.009066666666666666,
|
991 |
+
"loss": 1.3025,
|
992 |
+
"step": 1640
|
993 |
+
},
|
994 |
+
{
|
995 |
+
"epoch": 0.15,
|
996 |
+
"learning_rate": 0.009000000000000001,
|
997 |
+
"loss": 1.1726,
|
998 |
+
"step": 1650
|
999 |
+
},
|
1000 |
+
{
|
1001 |
+
"epoch": 0.15,
|
1002 |
+
"learning_rate": 0.008933333333333333,
|
1003 |
+
"loss": 1.2078,
|
1004 |
+
"step": 1660
|
1005 |
+
},
|
1006 |
+
{
|
1007 |
+
"epoch": 0.15,
|
1008 |
+
"learning_rate": 0.008866666666666667,
|
1009 |
+
"loss": 1.2652,
|
1010 |
+
"step": 1670
|
1011 |
+
},
|
1012 |
+
{
|
1013 |
+
"epoch": 0.16,
|
1014 |
+
"learning_rate": 0.0088,
|
1015 |
+
"loss": 1.2033,
|
1016 |
+
"step": 1680
|
1017 |
+
},
|
1018 |
+
{
|
1019 |
+
"epoch": 0.16,
|
1020 |
+
"learning_rate": 0.008733333333333333,
|
1021 |
+
"loss": 1.1598,
|
1022 |
+
"step": 1690
|
1023 |
+
},
|
1024 |
+
{
|
1025 |
+
"epoch": 0.16,
|
1026 |
+
"learning_rate": 0.008666666666666668,
|
1027 |
+
"loss": 1.1904,
|
1028 |
+
"step": 1700
|
1029 |
+
},
|
1030 |
+
{
|
1031 |
+
"epoch": 0.16,
|
1032 |
+
"learning_rate": 0.0086,
|
1033 |
+
"loss": 1.242,
|
1034 |
+
"step": 1710
|
1035 |
+
},
|
1036 |
+
{
|
1037 |
+
"epoch": 0.16,
|
1038 |
+
"learning_rate": 0.008533333333333334,
|
1039 |
+
"loss": 1.3042,
|
1040 |
+
"step": 1720
|
1041 |
+
},
|
1042 |
+
{
|
1043 |
+
"epoch": 0.16,
|
1044 |
+
"learning_rate": 0.008466666666666667,
|
1045 |
+
"loss": 1.3653,
|
1046 |
+
"step": 1730
|
1047 |
+
},
|
1048 |
+
{
|
1049 |
+
"epoch": 0.16,
|
1050 |
+
"learning_rate": 0.0084,
|
1051 |
+
"loss": 1.1784,
|
1052 |
+
"step": 1740
|
1053 |
+
},
|
1054 |
+
{
|
1055 |
+
"epoch": 0.16,
|
1056 |
+
"learning_rate": 0.008333333333333333,
|
1057 |
+
"loss": 1.2306,
|
1058 |
+
"step": 1750
|
1059 |
+
},
|
1060 |
+
{
|
1061 |
+
"epoch": 0.16,
|
1062 |
+
"learning_rate": 0.008266666666666667,
|
1063 |
+
"loss": 1.2139,
|
1064 |
+
"step": 1760
|
1065 |
+
},
|
1066 |
+
{
|
1067 |
+
"epoch": 0.16,
|
1068 |
+
"learning_rate": 0.008199999999999999,
|
1069 |
+
"loss": 1.1891,
|
1070 |
+
"step": 1770
|
1071 |
+
},
|
1072 |
+
{
|
1073 |
+
"epoch": 0.16,
|
1074 |
+
"learning_rate": 0.008133333333333334,
|
1075 |
+
"loss": 1.2619,
|
1076 |
+
"step": 1780
|
1077 |
+
},
|
1078 |
+
{
|
1079 |
+
"epoch": 0.17,
|
1080 |
+
"learning_rate": 0.008066666666666666,
|
1081 |
+
"loss": 1.0873,
|
1082 |
+
"step": 1790
|
1083 |
+
},
|
1084 |
+
{
|
1085 |
+
"epoch": 0.17,
|
1086 |
+
"learning_rate": 0.008,
|
1087 |
+
"loss": 1.2537,
|
1088 |
+
"step": 1800
|
1089 |
+
},
|
1090 |
+
{
|
1091 |
+
"epoch": 0.17,
|
1092 |
+
"learning_rate": 0.007933333333333334,
|
1093 |
+
"loss": 1.2575,
|
1094 |
+
"step": 1810
|
1095 |
+
},
|
1096 |
+
{
|
1097 |
+
"epoch": 0.17,
|
1098 |
+
"learning_rate": 0.007866666666666666,
|
1099 |
+
"loss": 1.1043,
|
1100 |
+
"step": 1820
|
1101 |
+
},
|
1102 |
+
{
|
1103 |
+
"epoch": 0.17,
|
1104 |
+
"learning_rate": 0.0078000000000000005,
|
1105 |
+
"loss": 1.2063,
|
1106 |
+
"step": 1830
|
1107 |
+
},
|
1108 |
+
{
|
1109 |
+
"epoch": 0.17,
|
1110 |
+
"learning_rate": 0.007733333333333333,
|
1111 |
+
"loss": 1.1602,
|
1112 |
+
"step": 1840
|
1113 |
+
},
|
1114 |
+
{
|
1115 |
+
"epoch": 0.17,
|
1116 |
+
"learning_rate": 0.007666666666666667,
|
1117 |
+
"loss": 1.1474,
|
1118 |
+
"step": 1850
|
1119 |
+
},
|
1120 |
+
{
|
1121 |
+
"epoch": 0.17,
|
1122 |
+
"learning_rate": 0.0076,
|
1123 |
+
"loss": 1.1482,
|
1124 |
+
"step": 1860
|
1125 |
+
},
|
1126 |
+
{
|
1127 |
+
"epoch": 0.17,
|
1128 |
+
"learning_rate": 0.007533333333333333,
|
1129 |
+
"loss": 1.2124,
|
1130 |
+
"step": 1870
|
1131 |
+
},
|
1132 |
+
{
|
1133 |
+
"epoch": 0.17,
|
1134 |
+
"learning_rate": 0.0074666666666666675,
|
1135 |
+
"loss": 1.195,
|
1136 |
+
"step": 1880
|
1137 |
+
},
|
1138 |
+
{
|
1139 |
+
"epoch": 0.17,
|
1140 |
+
"learning_rate": 0.0074,
|
1141 |
+
"loss": 1.1426,
|
1142 |
+
"step": 1890
|
1143 |
+
},
|
1144 |
+
{
|
1145 |
+
"epoch": 0.18,
|
1146 |
+
"learning_rate": 0.007333333333333333,
|
1147 |
+
"loss": 1.2067,
|
1148 |
+
"step": 1900
|
1149 |
+
},
|
1150 |
+
{
|
1151 |
+
"epoch": 0.18,
|
1152 |
+
"learning_rate": 0.007266666666666667,
|
1153 |
+
"loss": 1.1649,
|
1154 |
+
"step": 1910
|
1155 |
+
},
|
1156 |
+
{
|
1157 |
+
"epoch": 0.18,
|
1158 |
+
"learning_rate": 0.0072,
|
1159 |
+
"loss": 1.0978,
|
1160 |
+
"step": 1920
|
1161 |
+
},
|
1162 |
+
{
|
1163 |
+
"epoch": 0.18,
|
1164 |
+
"learning_rate": 0.0071333333333333335,
|
1165 |
+
"loss": 1.2298,
|
1166 |
+
"step": 1930
|
1167 |
+
},
|
1168 |
+
{
|
1169 |
+
"epoch": 0.18,
|
1170 |
+
"learning_rate": 0.007066666666666666,
|
1171 |
+
"loss": 1.195,
|
1172 |
+
"step": 1940
|
1173 |
+
},
|
1174 |
+
{
|
1175 |
+
"epoch": 0.18,
|
1176 |
+
"learning_rate": 0.006999999999999999,
|
1177 |
+
"loss": 1.2032,
|
1178 |
+
"step": 1950
|
1179 |
+
},
|
1180 |
+
{
|
1181 |
+
"epoch": 0.18,
|
1182 |
+
"learning_rate": 0.006933333333333334,
|
1183 |
+
"loss": 1.1134,
|
1184 |
+
"step": 1960
|
1185 |
+
},
|
1186 |
+
{
|
1187 |
+
"epoch": 0.18,
|
1188 |
+
"learning_rate": 0.006866666666666667,
|
1189 |
+
"loss": 1.2925,
|
1190 |
+
"step": 1970
|
1191 |
+
},
|
1192 |
+
{
|
1193 |
+
"epoch": 0.18,
|
1194 |
+
"learning_rate": 0.0068000000000000005,
|
1195 |
+
"loss": 1.1389,
|
1196 |
+
"step": 1980
|
1197 |
+
},
|
1198 |
+
{
|
1199 |
+
"epoch": 0.18,
|
1200 |
+
"learning_rate": 0.006733333333333333,
|
1201 |
+
"loss": 1.1952,
|
1202 |
+
"step": 1990
|
1203 |
+
},
|
1204 |
+
{
|
1205 |
+
"epoch": 0.18,
|
1206 |
+
"learning_rate": 0.006666666666666666,
|
1207 |
+
"loss": 1.0672,
|
1208 |
+
"step": 2000
|
1209 |
+
}
|
1210 |
+
],
|
1211 |
+
"max_steps": 3000,
|
1212 |
+
"num_train_epochs": 1,
|
1213 |
+
"total_flos": 1.15729542610944e+17,
|
1214 |
+
"trial_name": null,
|
1215 |
+
"trial_params": null
|
1216 |
+
}
|
checkpoint-2000/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:70ac9eb43a2d446e07cde6bbbb21250fe0373a4093de76a8aa1f7223e3836bcd
|
3 |
+
size 4155
|
checkpoint-3000/config.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "E:/PycharmProjects/dl_models/chatglm2-6b-int4",
|
3 |
+
"add_bias_linear": false,
|
4 |
+
"add_qkv_bias": true,
|
5 |
+
"apply_query_key_layer_scaling": true,
|
6 |
+
"apply_residual_connection_post_layernorm": false,
|
7 |
+
"architectures": [
|
8 |
+
"ChatGLMForConditionalGeneration"
|
9 |
+
],
|
10 |
+
"attention_dropout": 0.0,
|
11 |
+
"attention_softmax_in_fp32": true,
|
12 |
+
"auto_map": {
|
13 |
+
"AutoConfig": "configuration_chatglm.ChatGLMConfig",
|
14 |
+
"AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
|
15 |
+
"AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
|
16 |
+
},
|
17 |
+
"bias_dropout_fusion": true,
|
18 |
+
"eos_token_id": 2,
|
19 |
+
"ffn_hidden_size": 13696,
|
20 |
+
"fp32_residual_connection": false,
|
21 |
+
"hidden_dropout": 0.0,
|
22 |
+
"hidden_size": 4096,
|
23 |
+
"kv_channels": 128,
|
24 |
+
"layernorm_epsilon": 1e-05,
|
25 |
+
"model_type": "chatglm",
|
26 |
+
"multi_query_attention": true,
|
27 |
+
"multi_query_group_num": 2,
|
28 |
+
"num_attention_heads": 32,
|
29 |
+
"num_layers": 28,
|
30 |
+
"original_rope": true,
|
31 |
+
"pad_token_id": 0,
|
32 |
+
"padded_vocab_size": 65024,
|
33 |
+
"post_layer_norm": true,
|
34 |
+
"pre_seq_len": 128,
|
35 |
+
"prefix_projection": false,
|
36 |
+
"quantization_bit": 4,
|
37 |
+
"rmsnorm": true,
|
38 |
+
"seq_length": 32768,
|
39 |
+
"tie_word_embeddings": false,
|
40 |
+
"torch_dtype": "float16",
|
41 |
+
"transformers_version": "4.31.0",
|
42 |
+
"use_cache": true,
|
43 |
+
"vocab_size": 65024
|
44 |
+
}
|
checkpoint-3000/configuration_chatglm.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PretrainedConfig
|
2 |
+
|
3 |
+
|
4 |
+
class ChatGLMConfig(PretrainedConfig):
|
5 |
+
model_type = "chatglm"
|
6 |
+
def __init__(
|
7 |
+
self,
|
8 |
+
num_layers=28,
|
9 |
+
padded_vocab_size=65024,
|
10 |
+
hidden_size=4096,
|
11 |
+
ffn_hidden_size=13696,
|
12 |
+
kv_channels=128,
|
13 |
+
num_attention_heads=32,
|
14 |
+
seq_length=2048,
|
15 |
+
hidden_dropout=0.0,
|
16 |
+
attention_dropout=0.0,
|
17 |
+
layernorm_epsilon=1e-5,
|
18 |
+
rmsnorm=True,
|
19 |
+
apply_residual_connection_post_layernorm=False,
|
20 |
+
post_layer_norm=True,
|
21 |
+
add_bias_linear=False,
|
22 |
+
add_qkv_bias=False,
|
23 |
+
bias_dropout_fusion=True,
|
24 |
+
multi_query_attention=False,
|
25 |
+
multi_query_group_num=1,
|
26 |
+
apply_query_key_layer_scaling=True,
|
27 |
+
attention_softmax_in_fp32=True,
|
28 |
+
fp32_residual_connection=False,
|
29 |
+
quantization_bit=0,
|
30 |
+
pre_seq_len=None,
|
31 |
+
prefix_projection=False,
|
32 |
+
**kwargs
|
33 |
+
):
|
34 |
+
self.num_layers = num_layers
|
35 |
+
self.vocab_size = padded_vocab_size
|
36 |
+
self.padded_vocab_size = padded_vocab_size
|
37 |
+
self.hidden_size = hidden_size
|
38 |
+
self.ffn_hidden_size = ffn_hidden_size
|
39 |
+
self.kv_channels = kv_channels
|
40 |
+
self.num_attention_heads = num_attention_heads
|
41 |
+
self.seq_length = seq_length
|
42 |
+
self.hidden_dropout = hidden_dropout
|
43 |
+
self.attention_dropout = attention_dropout
|
44 |
+
self.layernorm_epsilon = layernorm_epsilon
|
45 |
+
self.rmsnorm = rmsnorm
|
46 |
+
self.apply_residual_connection_post_layernorm = apply_residual_connection_post_layernorm
|
47 |
+
self.post_layer_norm = post_layer_norm
|
48 |
+
self.add_bias_linear = add_bias_linear
|
49 |
+
self.add_qkv_bias = add_qkv_bias
|
50 |
+
self.bias_dropout_fusion = bias_dropout_fusion
|
51 |
+
self.multi_query_attention = multi_query_attention
|
52 |
+
self.multi_query_group_num = multi_query_group_num
|
53 |
+
self.apply_query_key_layer_scaling = apply_query_key_layer_scaling
|
54 |
+
self.attention_softmax_in_fp32 = attention_softmax_in_fp32
|
55 |
+
self.fp32_residual_connection = fp32_residual_connection
|
56 |
+
self.quantization_bit = quantization_bit
|
57 |
+
self.pre_seq_len = pre_seq_len
|
58 |
+
self.prefix_projection = prefix_projection
|
59 |
+
super().__init__(**kwargs)
|
checkpoint-3000/generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"eos_token_id": 2,
|
4 |
+
"pad_token_id": 0,
|
5 |
+
"transformers_version": "4.31.0"
|
6 |
+
}
|
checkpoint-3000/modeling_chatglm.py
ADDED
@@ -0,0 +1,1285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
""" PyTorch ChatGLM model. """
|
2 |
+
|
3 |
+
import math
|
4 |
+
import copy
|
5 |
+
import warnings
|
6 |
+
import re
|
7 |
+
import sys
|
8 |
+
|
9 |
+
import torch
|
10 |
+
import torch.utils.checkpoint
|
11 |
+
import torch.nn.functional as F
|
12 |
+
from torch import nn
|
13 |
+
from torch.nn import CrossEntropyLoss, LayerNorm
|
14 |
+
from torch.nn import CrossEntropyLoss, LayerNorm, MSELoss, BCEWithLogitsLoss
|
15 |
+
from torch.nn.utils import skip_init
|
16 |
+
from typing import Optional, Tuple, Union, List, Callable, Dict, Any
|
17 |
+
|
18 |
+
from transformers.modeling_outputs import (
|
19 |
+
BaseModelOutputWithPast,
|
20 |
+
CausalLMOutputWithPast,
|
21 |
+
SequenceClassifierOutputWithPast,
|
22 |
+
)
|
23 |
+
from transformers.modeling_utils import PreTrainedModel
|
24 |
+
from transformers.utils import logging
|
25 |
+
from transformers.generation.logits_process import LogitsProcessor
|
26 |
+
from transformers.generation.utils import LogitsProcessorList, StoppingCriteriaList, GenerationConfig, ModelOutput
|
27 |
+
|
28 |
+
from .configuration_chatglm import ChatGLMConfig
|
29 |
+
|
30 |
+
# flags required to enable jit fusion kernels
|
31 |
+
|
32 |
+
if sys.platform != 'darwin':
|
33 |
+
torch._C._jit_set_profiling_mode(False)
|
34 |
+
torch._C._jit_set_profiling_executor(False)
|
35 |
+
torch._C._jit_override_can_fuse_on_cpu(True)
|
36 |
+
torch._C._jit_override_can_fuse_on_gpu(True)
|
37 |
+
|
38 |
+
logger = logging.get_logger(__name__)
|
39 |
+
|
40 |
+
_CHECKPOINT_FOR_DOC = "THUDM/ChatGLM2-6B"
|
41 |
+
_CONFIG_FOR_DOC = "ChatGLM6BConfig"
|
42 |
+
|
43 |
+
CHATGLM_6B_PRETRAINED_MODEL_ARCHIVE_LIST = [
|
44 |
+
"THUDM/chatglm2-6b",
|
45 |
+
# See all ChatGLM models at https://huggingface.co/models?filter=chatglm
|
46 |
+
]
|
47 |
+
|
48 |
+
|
49 |
+
def default_init(cls, *args, **kwargs):
|
50 |
+
return cls(*args, **kwargs)
|
51 |
+
|
52 |
+
|
53 |
+
class InvalidScoreLogitsProcessor(LogitsProcessor):
|
54 |
+
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
55 |
+
if torch.isnan(scores).any() or torch.isinf(scores).any():
|
56 |
+
scores.zero_()
|
57 |
+
scores[..., 5] = 5e4
|
58 |
+
return scores
|
59 |
+
|
60 |
+
|
61 |
+
class PrefixEncoder(torch.nn.Module):
|
62 |
+
"""
|
63 |
+
The torch.nn model to encode the prefix
|
64 |
+
Input shape: (batch-size, prefix-length)
|
65 |
+
Output shape: (batch-size, prefix-length, 2*layers*hidden)
|
66 |
+
"""
|
67 |
+
|
68 |
+
def __init__(self, config: ChatGLMConfig):
|
69 |
+
super().__init__()
|
70 |
+
self.prefix_projection = config.prefix_projection
|
71 |
+
if self.prefix_projection:
|
72 |
+
# Use a two-layer MLP to encode the prefix
|
73 |
+
kv_size = config.num_layers * config.kv_channels * config.multi_query_group_num * 2
|
74 |
+
self.embedding = torch.nn.Embedding(config.pre_seq_len, kv_size)
|
75 |
+
self.trans = torch.nn.Sequential(
|
76 |
+
torch.nn.Linear(kv_size, config.hidden_size),
|
77 |
+
torch.nn.Tanh(),
|
78 |
+
torch.nn.Linear(config.hidden_size, kv_size)
|
79 |
+
)
|
80 |
+
else:
|
81 |
+
self.embedding = torch.nn.Embedding(config.pre_seq_len,
|
82 |
+
config.num_layers * config.kv_channels * config.multi_query_group_num * 2)
|
83 |
+
|
84 |
+
def forward(self, prefix: torch.Tensor):
|
85 |
+
if self.prefix_projection:
|
86 |
+
prefix_tokens = self.embedding(prefix)
|
87 |
+
past_key_values = self.trans(prefix_tokens)
|
88 |
+
else:
|
89 |
+
past_key_values = self.embedding(prefix)
|
90 |
+
return past_key_values
|
91 |
+
|
92 |
+
|
93 |
+
def split_tensor_along_last_dim(
|
94 |
+
tensor: torch.Tensor,
|
95 |
+
num_partitions: int,
|
96 |
+
contiguous_split_chunks: bool = False,
|
97 |
+
) -> List[torch.Tensor]:
|
98 |
+
"""Split a tensor along its last dimension.
|
99 |
+
|
100 |
+
Arguments:
|
101 |
+
tensor: input tensor.
|
102 |
+
num_partitions: number of partitions to split the tensor
|
103 |
+
contiguous_split_chunks: If True, make each chunk contiguous
|
104 |
+
in memory.
|
105 |
+
|
106 |
+
Returns:
|
107 |
+
A list of Tensors
|
108 |
+
"""
|
109 |
+
# Get the size and dimension.
|
110 |
+
last_dim = tensor.dim() - 1
|
111 |
+
last_dim_size = tensor.size()[last_dim] // num_partitions
|
112 |
+
# Split.
|
113 |
+
tensor_list = torch.split(tensor, last_dim_size, dim=last_dim)
|
114 |
+
# Note: torch.split does not create contiguous tensors by default.
|
115 |
+
if contiguous_split_chunks:
|
116 |
+
return tuple(chunk.contiguous() for chunk in tensor_list)
|
117 |
+
|
118 |
+
return tensor_list
|
119 |
+
|
120 |
+
|
121 |
+
class RotaryEmbedding(nn.Module):
|
122 |
+
def __init__(self, dim, original_impl=False, device=None, dtype=None):
|
123 |
+
super().__init__()
|
124 |
+
inv_freq = 1.0 / (10000 ** (torch.arange(0, dim, 2, device=device).to(dtype=dtype) / dim))
|
125 |
+
self.register_buffer("inv_freq", inv_freq)
|
126 |
+
self.dim = dim
|
127 |
+
self.original_impl = original_impl
|
128 |
+
|
129 |
+
def forward_impl(
|
130 |
+
self, seq_len: int, n_elem: int, dtype: torch.dtype, device: torch.device, base: int = 10000
|
131 |
+
):
|
132 |
+
"""Enhanced Transformer with Rotary Position Embedding.
|
133 |
+
|
134 |
+
Derived from: https://github.com/labmlai/annotated_deep_learning_paper_implementations/blob/master/labml_nn/
|
135 |
+
transformers/rope/__init__.py. MIT License:
|
136 |
+
https://github.com/labmlai/annotated_deep_learning_paper_implementations/blob/master/license.
|
137 |
+
"""
|
138 |
+
# $\Theta = {\theta_i = 10000^{\frac{2(i-1)}{d}}, i \in [1, 2, ..., \frac{d}{2}]}$
|
139 |
+
theta = 1.0 / (base ** (torch.arange(0, n_elem, 2, dtype=dtype, device=device) / n_elem))
|
140 |
+
|
141 |
+
# Create position indexes `[0, 1, ..., seq_len - 1]`
|
142 |
+
seq_idx = torch.arange(seq_len, dtype=dtype, device=device)
|
143 |
+
|
144 |
+
# Calculate the product of position index and $\theta_i$
|
145 |
+
idx_theta = torch.outer(seq_idx, theta).float()
|
146 |
+
|
147 |
+
cache = torch.stack([torch.cos(idx_theta), torch.sin(idx_theta)], dim=-1)
|
148 |
+
|
149 |
+
# this is to mimic the behaviour of complex32, else we will get different results
|
150 |
+
if dtype in (torch.float16, torch.bfloat16, torch.int8):
|
151 |
+
cache = cache.bfloat16() if dtype == torch.bfloat16 else cache.half()
|
152 |
+
return cache
|
153 |
+
|
154 |
+
def forward(self, max_seq_len, offset=0):
|
155 |
+
return self.forward_impl(
|
156 |
+
max_seq_len, self.dim, dtype=self.inv_freq.dtype, device=self.inv_freq.device
|
157 |
+
)
|
158 |
+
|
159 |
+
|
160 |
+
@torch.jit.script
|
161 |
+
def apply_rotary_pos_emb(x: torch.Tensor, rope_cache: torch.Tensor) -> torch.Tensor:
|
162 |
+
# x: [sq, b, np, hn]
|
163 |
+
sq, b, np, hn = x.size(0), x.size(1), x.size(2), x.size(3)
|
164 |
+
rot_dim = rope_cache.shape[-2] * 2
|
165 |
+
x, x_pass = x[..., :rot_dim], x[..., rot_dim:]
|
166 |
+
# truncate to support variable sizes
|
167 |
+
rope_cache = rope_cache[:sq]
|
168 |
+
xshaped = x.reshape(sq, -1, np, rot_dim // 2, 2)
|
169 |
+
rope_cache = rope_cache.view(sq, -1, 1, xshaped.size(3), 2)
|
170 |
+
x_out2 = torch.stack(
|
171 |
+
[
|
172 |
+
xshaped[..., 0] * rope_cache[..., 0] - xshaped[..., 1] * rope_cache[..., 1],
|
173 |
+
xshaped[..., 1] * rope_cache[..., 0] + xshaped[..., 0] * rope_cache[..., 1],
|
174 |
+
],
|
175 |
+
-1,
|
176 |
+
)
|
177 |
+
x_out2 = x_out2.flatten(3)
|
178 |
+
return torch.cat((x_out2, x_pass), dim=-1)
|
179 |
+
|
180 |
+
|
181 |
+
class RMSNorm(torch.nn.Module):
|
182 |
+
def __init__(self, normalized_shape, eps=1e-5, device=None, dtype=None, **kwargs):
|
183 |
+
super().__init__()
|
184 |
+
self.weight = torch.nn.Parameter(torch.empty(normalized_shape, device=device, dtype=dtype))
|
185 |
+
self.eps = eps
|
186 |
+
|
187 |
+
def forward(self, hidden_states: torch.Tensor):
|
188 |
+
input_dtype = hidden_states.dtype
|
189 |
+
variance = hidden_states.to(torch.float32).pow(2).mean(-1, keepdim=True)
|
190 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.eps)
|
191 |
+
|
192 |
+
return (self.weight * hidden_states).to(input_dtype)
|
193 |
+
|
194 |
+
|
195 |
+
class CoreAttention(torch.nn.Module):
|
196 |
+
def __init__(self, config: ChatGLMConfig, layer_number):
|
197 |
+
super(CoreAttention, self).__init__()
|
198 |
+
|
199 |
+
self.apply_query_key_layer_scaling = config.apply_query_key_layer_scaling
|
200 |
+
self.attention_softmax_in_fp32 = config.attention_softmax_in_fp32
|
201 |
+
if self.apply_query_key_layer_scaling:
|
202 |
+
self.attention_softmax_in_fp32 = True
|
203 |
+
self.layer_number = max(1, layer_number)
|
204 |
+
|
205 |
+
projection_size = config.kv_channels * config.num_attention_heads
|
206 |
+
|
207 |
+
# Per attention head and per partition values.
|
208 |
+
self.hidden_size_per_partition = projection_size
|
209 |
+
self.hidden_size_per_attention_head = projection_size // config.num_attention_heads
|
210 |
+
self.num_attention_heads_per_partition = config.num_attention_heads
|
211 |
+
|
212 |
+
coeff = None
|
213 |
+
self.norm_factor = math.sqrt(self.hidden_size_per_attention_head)
|
214 |
+
if self.apply_query_key_layer_scaling:
|
215 |
+
coeff = self.layer_number
|
216 |
+
self.norm_factor *= coeff
|
217 |
+
self.coeff = coeff
|
218 |
+
|
219 |
+
self.attention_dropout = torch.nn.Dropout(config.attention_dropout)
|
220 |
+
|
221 |
+
def forward(self, query_layer, key_layer, value_layer, attention_mask):
|
222 |
+
pytorch_major_version = int(torch.__version__.split('.')[0])
|
223 |
+
if pytorch_major_version >= 2:
|
224 |
+
query_layer, key_layer, value_layer = [k.permute(1, 2, 0, 3) for k in [query_layer, key_layer, value_layer]]
|
225 |
+
if attention_mask is None and query_layer.shape[2] == key_layer.shape[2]:
|
226 |
+
context_layer = torch.nn.functional.scaled_dot_product_attention(query_layer, key_layer, value_layer,
|
227 |
+
is_causal=True)
|
228 |
+
else:
|
229 |
+
if attention_mask is not None:
|
230 |
+
attention_mask = ~attention_mask
|
231 |
+
context_layer = torch.nn.functional.scaled_dot_product_attention(query_layer, key_layer, value_layer,
|
232 |
+
attention_mask)
|
233 |
+
context_layer = context_layer.permute(2, 0, 1, 3)
|
234 |
+
new_context_layer_shape = context_layer.size()[:-2] + (self.hidden_size_per_partition,)
|
235 |
+
context_layer = context_layer.reshape(*new_context_layer_shape)
|
236 |
+
else:
|
237 |
+
# Raw attention scores
|
238 |
+
|
239 |
+
# [b, np, sq, sk]
|
240 |
+
output_size = (query_layer.size(1), query_layer.size(2), query_layer.size(0), key_layer.size(0))
|
241 |
+
|
242 |
+
# [sq, b, np, hn] -> [sq, b * np, hn]
|
243 |
+
query_layer = query_layer.view(output_size[2], output_size[0] * output_size[1], -1)
|
244 |
+
# [sk, b, np, hn] -> [sk, b * np, hn]
|
245 |
+
key_layer = key_layer.view(output_size[3], output_size[0] * output_size[1], -1)
|
246 |
+
|
247 |
+
# preallocting input tensor: [b * np, sq, sk]
|
248 |
+
matmul_input_buffer = torch.empty(
|
249 |
+
output_size[0] * output_size[1], output_size[2], output_size[3], dtype=query_layer.dtype,
|
250 |
+
device=query_layer.device
|
251 |
+
)
|
252 |
+
|
253 |
+
# Raw attention scores. [b * np, sq, sk]
|
254 |
+
matmul_result = torch.baddbmm(
|
255 |
+
matmul_input_buffer,
|
256 |
+
query_layer.transpose(0, 1), # [b * np, sq, hn]
|
257 |
+
key_layer.transpose(0, 1).transpose(1, 2), # [b * np, hn, sk]
|
258 |
+
beta=0.0,
|
259 |
+
alpha=(1.0 / self.norm_factor),
|
260 |
+
)
|
261 |
+
|
262 |
+
# change view to [b, np, sq, sk]
|
263 |
+
attention_scores = matmul_result.view(*output_size)
|
264 |
+
|
265 |
+
# ===========================
|
266 |
+
# Attention probs and dropout
|
267 |
+
# ===========================
|
268 |
+
|
269 |
+
# attention scores and attention mask [b, np, sq, sk]
|
270 |
+
if self.attention_softmax_in_fp32:
|
271 |
+
attention_scores = attention_scores.float()
|
272 |
+
if self.coeff is not None:
|
273 |
+
attention_scores = attention_scores * self.coeff
|
274 |
+
if attention_mask is None and attention_scores.shape[2] == attention_scores.shape[3]:
|
275 |
+
attention_mask = torch.ones(output_size[0], 1, output_size[2], output_size[3],
|
276 |
+
device=attention_scores.device, dtype=torch.bool)
|
277 |
+
attention_mask.tril_()
|
278 |
+
attention_mask = ~attention_mask
|
279 |
+
if attention_mask is not None:
|
280 |
+
attention_scores = attention_scores.masked_fill(attention_mask, float("-inf"))
|
281 |
+
attention_probs = F.softmax(attention_scores, dim=-1)
|
282 |
+
attention_probs = attention_probs.type_as(value_layer)
|
283 |
+
|
284 |
+
# This is actually dropping out entire tokens to attend to, which might
|
285 |
+
# seem a bit unusual, but is taken from the original Transformer paper.
|
286 |
+
attention_probs = self.attention_dropout(attention_probs)
|
287 |
+
# =========================
|
288 |
+
# Context layer. [sq, b, hp]
|
289 |
+
# =========================
|
290 |
+
|
291 |
+
# value_layer -> context layer.
|
292 |
+
# [sk, b, np, hn] --> [b, np, sq, hn]
|
293 |
+
|
294 |
+
# context layer shape: [b, np, sq, hn]
|
295 |
+
output_size = (value_layer.size(1), value_layer.size(2), query_layer.size(0), value_layer.size(3))
|
296 |
+
# change view [sk, b * np, hn]
|
297 |
+
value_layer = value_layer.view(value_layer.size(0), output_size[0] * output_size[1], -1)
|
298 |
+
# change view [b * np, sq, sk]
|
299 |
+
attention_probs = attention_probs.view(output_size[0] * output_size[1], output_size[2], -1)
|
300 |
+
# matmul: [b * np, sq, hn]
|
301 |
+
context_layer = torch.bmm(attention_probs, value_layer.transpose(0, 1))
|
302 |
+
# change view [b, np, sq, hn]
|
303 |
+
context_layer = context_layer.view(*output_size)
|
304 |
+
# [b, np, sq, hn] --> [sq, b, np, hn]
|
305 |
+
context_layer = context_layer.permute(2, 0, 1, 3).contiguous()
|
306 |
+
# [sq, b, np, hn] --> [sq, b, hp]
|
307 |
+
new_context_layer_shape = context_layer.size()[:-2] + (self.hidden_size_per_partition,)
|
308 |
+
context_layer = context_layer.view(*new_context_layer_shape)
|
309 |
+
|
310 |
+
return context_layer
|
311 |
+
|
312 |
+
|
313 |
+
class SelfAttention(torch.nn.Module):
|
314 |
+
"""Parallel self-attention layer abstract class.
|
315 |
+
|
316 |
+
Self-attention layer takes input with size [s, b, h]
|
317 |
+
and returns output of the same size.
|
318 |
+
"""
|
319 |
+
|
320 |
+
def __init__(self, config: ChatGLMConfig, layer_number, device=None):
|
321 |
+
super(SelfAttention, self).__init__()
|
322 |
+
self.layer_number = max(1, layer_number)
|
323 |
+
|
324 |
+
self.projection_size = config.kv_channels * config.num_attention_heads
|
325 |
+
|
326 |
+
# Per attention head and per partition values.
|
327 |
+
self.hidden_size_per_attention_head = self.projection_size // config.num_attention_heads
|
328 |
+
self.num_attention_heads_per_partition = config.num_attention_heads
|
329 |
+
|
330 |
+
self.multi_query_attention = config.multi_query_attention
|
331 |
+
self.qkv_hidden_size = 3 * self.projection_size
|
332 |
+
if self.multi_query_attention:
|
333 |
+
self.num_multi_query_groups_per_partition = config.multi_query_group_num
|
334 |
+
self.qkv_hidden_size = (
|
335 |
+
self.projection_size + 2 * self.hidden_size_per_attention_head * config.multi_query_group_num
|
336 |
+
)
|
337 |
+
self.query_key_value = nn.Linear(config.hidden_size, self.qkv_hidden_size,
|
338 |
+
bias=config.add_bias_linear or config.add_qkv_bias,
|
339 |
+
device=device, **_config_to_kwargs(config)
|
340 |
+
)
|
341 |
+
|
342 |
+
self.core_attention = CoreAttention(config, self.layer_number)
|
343 |
+
|
344 |
+
# Output.
|
345 |
+
self.dense = nn.Linear(self.projection_size, config.hidden_size, bias=config.add_bias_linear,
|
346 |
+
device=device, **_config_to_kwargs(config)
|
347 |
+
)
|
348 |
+
|
349 |
+
def _allocate_memory(self, inference_max_sequence_len, batch_size, device=None, dtype=None):
|
350 |
+
if self.multi_query_attention:
|
351 |
+
num_attention_heads = self.num_multi_query_groups_per_partition
|
352 |
+
else:
|
353 |
+
num_attention_heads = self.num_attention_heads_per_partition
|
354 |
+
return torch.empty(
|
355 |
+
inference_max_sequence_len,
|
356 |
+
batch_size,
|
357 |
+
num_attention_heads,
|
358 |
+
self.hidden_size_per_attention_head,
|
359 |
+
dtype=dtype,
|
360 |
+
device=device,
|
361 |
+
)
|
362 |
+
|
363 |
+
def forward(
|
364 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_cache=None, use_cache=True
|
365 |
+
):
|
366 |
+
# hidden_states: [sq, b, h]
|
367 |
+
|
368 |
+
# =================================================
|
369 |
+
# Pre-allocate memory for key-values for inference.
|
370 |
+
# =================================================
|
371 |
+
# =====================
|
372 |
+
# Query, Key, and Value
|
373 |
+
# =====================
|
374 |
+
|
375 |
+
# Attention heads [sq, b, h] --> [sq, b, (np * 3 * hn)]
|
376 |
+
mixed_x_layer = self.query_key_value(hidden_states)
|
377 |
+
|
378 |
+
if self.multi_query_attention:
|
379 |
+
(query_layer, key_layer, value_layer) = mixed_x_layer.split(
|
380 |
+
[
|
381 |
+
self.num_attention_heads_per_partition * self.hidden_size_per_attention_head,
|
382 |
+
self.num_multi_query_groups_per_partition * self.hidden_size_per_attention_head,
|
383 |
+
self.num_multi_query_groups_per_partition * self.hidden_size_per_attention_head,
|
384 |
+
],
|
385 |
+
dim=-1,
|
386 |
+
)
|
387 |
+
query_layer = query_layer.view(
|
388 |
+
query_layer.size()[:-1] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
389 |
+
)
|
390 |
+
key_layer = key_layer.view(
|
391 |
+
key_layer.size()[:-1] + (self.num_multi_query_groups_per_partition, self.hidden_size_per_attention_head)
|
392 |
+
)
|
393 |
+
value_layer = value_layer.view(
|
394 |
+
value_layer.size()[:-1]
|
395 |
+
+ (self.num_multi_query_groups_per_partition, self.hidden_size_per_attention_head)
|
396 |
+
)
|
397 |
+
else:
|
398 |
+
new_tensor_shape = mixed_x_layer.size()[:-1] + \
|
399 |
+
(self.num_attention_heads_per_partition,
|
400 |
+
3 * self.hidden_size_per_attention_head)
|
401 |
+
mixed_x_layer = mixed_x_layer.view(*new_tensor_shape)
|
402 |
+
|
403 |
+
# [sq, b, np, 3 * hn] --> 3 [sq, b, np, hn]
|
404 |
+
(query_layer, key_layer, value_layer) = split_tensor_along_last_dim(mixed_x_layer, 3)
|
405 |
+
|
406 |
+
# apply relative positional encoding (rotary embedding)
|
407 |
+
if rotary_pos_emb is not None:
|
408 |
+
query_layer = apply_rotary_pos_emb(query_layer, rotary_pos_emb)
|
409 |
+
key_layer = apply_rotary_pos_emb(key_layer, rotary_pos_emb)
|
410 |
+
|
411 |
+
# adjust key and value for inference
|
412 |
+
if kv_cache is not None:
|
413 |
+
cache_k, cache_v = kv_cache
|
414 |
+
key_layer = torch.cat((cache_k, key_layer), dim=0)
|
415 |
+
value_layer = torch.cat((cache_v, value_layer), dim=0)
|
416 |
+
if use_cache:
|
417 |
+
kv_cache = (key_layer, value_layer)
|
418 |
+
else:
|
419 |
+
kv_cache = None
|
420 |
+
|
421 |
+
if self.multi_query_attention:
|
422 |
+
key_layer = key_layer.unsqueeze(-2)
|
423 |
+
key_layer = key_layer.expand(
|
424 |
+
-1, -1, -1, self.num_attention_heads_per_partition // self.num_multi_query_groups_per_partition, -1
|
425 |
+
)
|
426 |
+
key_layer = key_layer.contiguous().view(
|
427 |
+
key_layer.size()[:2] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
428 |
+
)
|
429 |
+
value_layer = value_layer.unsqueeze(-2)
|
430 |
+
value_layer = value_layer.expand(
|
431 |
+
-1, -1, -1, self.num_attention_heads_per_partition // self.num_multi_query_groups_per_partition, -1
|
432 |
+
)
|
433 |
+
value_layer = value_layer.contiguous().view(
|
434 |
+
value_layer.size()[:2] + (self.num_attention_heads_per_partition, self.hidden_size_per_attention_head)
|
435 |
+
)
|
436 |
+
|
437 |
+
# ==================================
|
438 |
+
# core attention computation
|
439 |
+
# ==================================
|
440 |
+
|
441 |
+
context_layer = self.core_attention(query_layer, key_layer, value_layer, attention_mask)
|
442 |
+
|
443 |
+
# =================
|
444 |
+
# Output. [sq, b, h]
|
445 |
+
# =================
|
446 |
+
|
447 |
+
output = self.dense(context_layer)
|
448 |
+
|
449 |
+
return output, kv_cache
|
450 |
+
|
451 |
+
|
452 |
+
def _config_to_kwargs(args):
|
453 |
+
common_kwargs = {
|
454 |
+
"dtype": args.torch_dtype,
|
455 |
+
}
|
456 |
+
return common_kwargs
|
457 |
+
|
458 |
+
|
459 |
+
class MLP(torch.nn.Module):
|
460 |
+
"""MLP.
|
461 |
+
|
462 |
+
MLP will take the input with h hidden state, project it to 4*h
|
463 |
+
hidden dimension, perform nonlinear transformation, and project the
|
464 |
+
state back into h hidden dimension.
|
465 |
+
"""
|
466 |
+
|
467 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
468 |
+
super(MLP, self).__init__()
|
469 |
+
|
470 |
+
self.add_bias = config.add_bias_linear
|
471 |
+
|
472 |
+
# Project to 4h. If using swiglu double the output width, see https://arxiv.org/pdf/2002.05202.pdf
|
473 |
+
self.dense_h_to_4h = nn.Linear(
|
474 |
+
config.hidden_size,
|
475 |
+
config.ffn_hidden_size * 2,
|
476 |
+
bias=self.add_bias,
|
477 |
+
device=device,
|
478 |
+
**_config_to_kwargs(config)
|
479 |
+
)
|
480 |
+
|
481 |
+
def swiglu(x):
|
482 |
+
x = torch.chunk(x, 2, dim=-1)
|
483 |
+
return F.silu(x[0]) * x[1]
|
484 |
+
|
485 |
+
self.activation_func = swiglu
|
486 |
+
|
487 |
+
# Project back to h.
|
488 |
+
self.dense_4h_to_h = nn.Linear(
|
489 |
+
config.ffn_hidden_size,
|
490 |
+
config.hidden_size,
|
491 |
+
bias=self.add_bias,
|
492 |
+
device=device,
|
493 |
+
**_config_to_kwargs(config)
|
494 |
+
)
|
495 |
+
|
496 |
+
def forward(self, hidden_states):
|
497 |
+
# [s, b, 4hp]
|
498 |
+
intermediate_parallel = self.dense_h_to_4h(hidden_states)
|
499 |
+
intermediate_parallel = self.activation_func(intermediate_parallel)
|
500 |
+
# [s, b, h]
|
501 |
+
output = self.dense_4h_to_h(intermediate_parallel)
|
502 |
+
return output
|
503 |
+
|
504 |
+
|
505 |
+
class GLMBlock(torch.nn.Module):
|
506 |
+
"""A single transformer layer.
|
507 |
+
|
508 |
+
Transformer layer takes input with size [s, b, h] and returns an
|
509 |
+
output of the same size.
|
510 |
+
"""
|
511 |
+
|
512 |
+
def __init__(self, config: ChatGLMConfig, layer_number, device=None):
|
513 |
+
super(GLMBlock, self).__init__()
|
514 |
+
self.layer_number = layer_number
|
515 |
+
|
516 |
+
self.apply_residual_connection_post_layernorm = config.apply_residual_connection_post_layernorm
|
517 |
+
|
518 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
519 |
+
|
520 |
+
LayerNormFunc = RMSNorm if config.rmsnorm else LayerNorm
|
521 |
+
# Layernorm on the input data.
|
522 |
+
self.input_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
523 |
+
dtype=config.torch_dtype)
|
524 |
+
|
525 |
+
# Self attention.
|
526 |
+
self.self_attention = SelfAttention(config, layer_number, device=device)
|
527 |
+
self.hidden_dropout = config.hidden_dropout
|
528 |
+
|
529 |
+
# Layernorm on the attention output
|
530 |
+
self.post_attention_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
531 |
+
dtype=config.torch_dtype)
|
532 |
+
|
533 |
+
# MLP
|
534 |
+
self.mlp = MLP(config, device=device)
|
535 |
+
|
536 |
+
def forward(
|
537 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_cache=None, use_cache=True,
|
538 |
+
):
|
539 |
+
# hidden_states: [s, b, h]
|
540 |
+
|
541 |
+
# Layer norm at the beginning of the transformer layer.
|
542 |
+
layernorm_output = self.input_layernorm(hidden_states)
|
543 |
+
# Self attention.
|
544 |
+
attention_output, kv_cache = self.self_attention(
|
545 |
+
layernorm_output,
|
546 |
+
attention_mask,
|
547 |
+
rotary_pos_emb,
|
548 |
+
kv_cache=kv_cache,
|
549 |
+
use_cache=use_cache
|
550 |
+
)
|
551 |
+
|
552 |
+
# Residual connection.
|
553 |
+
if self.apply_residual_connection_post_layernorm:
|
554 |
+
residual = layernorm_output
|
555 |
+
else:
|
556 |
+
residual = hidden_states
|
557 |
+
|
558 |
+
layernorm_input = torch.nn.functional.dropout(attention_output, p=self.hidden_dropout, training=self.training)
|
559 |
+
layernorm_input = residual + layernorm_input
|
560 |
+
|
561 |
+
# Layer norm post the self attention.
|
562 |
+
layernorm_output = self.post_attention_layernorm(layernorm_input)
|
563 |
+
|
564 |
+
# MLP.
|
565 |
+
mlp_output = self.mlp(layernorm_output)
|
566 |
+
|
567 |
+
# Second residual connection.
|
568 |
+
if self.apply_residual_connection_post_layernorm:
|
569 |
+
residual = layernorm_output
|
570 |
+
else:
|
571 |
+
residual = layernorm_input
|
572 |
+
|
573 |
+
output = torch.nn.functional.dropout(mlp_output, p=self.hidden_dropout, training=self.training)
|
574 |
+
output = residual + output
|
575 |
+
|
576 |
+
return output, kv_cache
|
577 |
+
|
578 |
+
|
579 |
+
class GLMTransformer(torch.nn.Module):
|
580 |
+
"""Transformer class."""
|
581 |
+
|
582 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
583 |
+
super(GLMTransformer, self).__init__()
|
584 |
+
|
585 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
586 |
+
self.post_layer_norm = config.post_layer_norm
|
587 |
+
|
588 |
+
# Number of layers.
|
589 |
+
self.num_layers = config.num_layers
|
590 |
+
|
591 |
+
# Transformer layers.
|
592 |
+
def build_layer(layer_number):
|
593 |
+
return GLMBlock(config, layer_number, device=device)
|
594 |
+
|
595 |
+
self.layers = torch.nn.ModuleList([build_layer(i + 1) for i in range(self.num_layers)])
|
596 |
+
|
597 |
+
if self.post_layer_norm:
|
598 |
+
LayerNormFunc = RMSNorm if config.rmsnorm else LayerNorm
|
599 |
+
# Final layer norm before output.
|
600 |
+
self.final_layernorm = LayerNormFunc(config.hidden_size, eps=config.layernorm_epsilon, device=device,
|
601 |
+
dtype=config.torch_dtype)
|
602 |
+
|
603 |
+
self.gradient_checkpointing = False
|
604 |
+
|
605 |
+
def _get_layer(self, layer_number):
|
606 |
+
return self.layers[layer_number]
|
607 |
+
|
608 |
+
def forward(
|
609 |
+
self, hidden_states, attention_mask, rotary_pos_emb, kv_caches=None,
|
610 |
+
use_cache: Optional[bool] = True,
|
611 |
+
output_hidden_states: Optional[bool] = False,
|
612 |
+
):
|
613 |
+
if not kv_caches:
|
614 |
+
kv_caches = [None for _ in range(self.num_layers)]
|
615 |
+
presents = () if use_cache else None
|
616 |
+
if self.gradient_checkpointing and self.training:
|
617 |
+
if use_cache:
|
618 |
+
logger.warning_once(
|
619 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
620 |
+
)
|
621 |
+
use_cache = False
|
622 |
+
|
623 |
+
all_self_attentions = None
|
624 |
+
all_hidden_states = () if output_hidden_states else None
|
625 |
+
for index in range(self.num_layers):
|
626 |
+
if output_hidden_states:
|
627 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
628 |
+
|
629 |
+
layer = self._get_layer(index)
|
630 |
+
if self.gradient_checkpointing and self.training:
|
631 |
+
layer_ret = torch.utils.checkpoint.checkpoint(
|
632 |
+
layer,
|
633 |
+
hidden_states,
|
634 |
+
attention_mask,
|
635 |
+
rotary_pos_emb,
|
636 |
+
kv_caches[index],
|
637 |
+
use_cache
|
638 |
+
)
|
639 |
+
else:
|
640 |
+
layer_ret = layer(
|
641 |
+
hidden_states,
|
642 |
+
attention_mask,
|
643 |
+
rotary_pos_emb,
|
644 |
+
kv_cache=kv_caches[index],
|
645 |
+
use_cache=use_cache
|
646 |
+
)
|
647 |
+
hidden_states, kv_cache = layer_ret
|
648 |
+
if use_cache:
|
649 |
+
presents = presents + (kv_cache,)
|
650 |
+
|
651 |
+
if output_hidden_states:
|
652 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
653 |
+
|
654 |
+
# Final layer norm.
|
655 |
+
if self.post_layer_norm:
|
656 |
+
hidden_states = self.final_layernorm(hidden_states)
|
657 |
+
|
658 |
+
return hidden_states, presents, all_hidden_states, all_self_attentions
|
659 |
+
|
660 |
+
|
661 |
+
class ChatGLMPreTrainedModel(PreTrainedModel):
|
662 |
+
"""
|
663 |
+
An abstract class to handle weights initialization and
|
664 |
+
a simple interface for downloading and loading pretrained models.
|
665 |
+
"""
|
666 |
+
|
667 |
+
is_parallelizable = False
|
668 |
+
supports_gradient_checkpointing = True
|
669 |
+
config_class = ChatGLMConfig
|
670 |
+
base_model_prefix = "transformer"
|
671 |
+
_no_split_modules = ["GLMBlock"]
|
672 |
+
|
673 |
+
def _init_weights(self, module: nn.Module):
|
674 |
+
"""Initialize the weights."""
|
675 |
+
return
|
676 |
+
|
677 |
+
def get_masks(self, input_ids, past_key_values, padding_mask=None):
|
678 |
+
batch_size, seq_length = input_ids.shape
|
679 |
+
full_attention_mask = torch.ones(batch_size, seq_length, seq_length, device=input_ids.device)
|
680 |
+
full_attention_mask.tril_()
|
681 |
+
past_length = 0
|
682 |
+
if past_key_values:
|
683 |
+
past_length = past_key_values[0][0].shape[0]
|
684 |
+
if past_length:
|
685 |
+
full_attention_mask = torch.cat((torch.ones(batch_size, seq_length, past_length,
|
686 |
+
device=input_ids.device), full_attention_mask), dim=-1)
|
687 |
+
if padding_mask is not None:
|
688 |
+
full_attention_mask = full_attention_mask * padding_mask.unsqueeze(1)
|
689 |
+
if not past_length and padding_mask is not None:
|
690 |
+
full_attention_mask -= padding_mask.unsqueeze(-1) - 1
|
691 |
+
full_attention_mask = (full_attention_mask < 0.5).bool()
|
692 |
+
full_attention_mask.unsqueeze_(1)
|
693 |
+
return full_attention_mask
|
694 |
+
|
695 |
+
def get_position_ids(self, input_ids, device):
|
696 |
+
batch_size, seq_length = input_ids.shape
|
697 |
+
position_ids = torch.arange(seq_length, dtype=torch.long, device=device).unsqueeze(0).repeat(batch_size, 1)
|
698 |
+
return position_ids
|
699 |
+
|
700 |
+
def _set_gradient_checkpointing(self, module, value=False):
|
701 |
+
if isinstance(module, GLMTransformer):
|
702 |
+
module.gradient_checkpointing = value
|
703 |
+
|
704 |
+
|
705 |
+
class Embedding(torch.nn.Module):
|
706 |
+
"""Language model embeddings."""
|
707 |
+
|
708 |
+
def __init__(self, config: ChatGLMConfig, device=None):
|
709 |
+
super(Embedding, self).__init__()
|
710 |
+
|
711 |
+
self.hidden_size = config.hidden_size
|
712 |
+
# Word embeddings (parallel).
|
713 |
+
self.word_embeddings = nn.Embedding(
|
714 |
+
config.padded_vocab_size,
|
715 |
+
self.hidden_size,
|
716 |
+
dtype=config.torch_dtype,
|
717 |
+
device=device
|
718 |
+
)
|
719 |
+
self.fp32_residual_connection = config.fp32_residual_connection
|
720 |
+
|
721 |
+
def forward(self, input_ids):
|
722 |
+
# Embeddings.
|
723 |
+
words_embeddings = self.word_embeddings(input_ids)
|
724 |
+
embeddings = words_embeddings
|
725 |
+
# Data format change to avoid explicit tranposes : [b s h] --> [s b h].
|
726 |
+
embeddings = embeddings.transpose(0, 1).contiguous()
|
727 |
+
# If the input flag for fp32 residual connection is set, convert for float.
|
728 |
+
if self.fp32_residual_connection:
|
729 |
+
embeddings = embeddings.float()
|
730 |
+
return embeddings
|
731 |
+
|
732 |
+
|
733 |
+
class ChatGLMModel(ChatGLMPreTrainedModel):
|
734 |
+
def __init__(self, config: ChatGLMConfig, device=None, empty_init=True):
|
735 |
+
super().__init__(config)
|
736 |
+
if empty_init:
|
737 |
+
init_method = skip_init
|
738 |
+
else:
|
739 |
+
init_method = default_init
|
740 |
+
init_kwargs = {}
|
741 |
+
if device is not None:
|
742 |
+
init_kwargs["device"] = device
|
743 |
+
self.embedding = init_method(Embedding, config, **init_kwargs)
|
744 |
+
self.num_layers = config.num_layers
|
745 |
+
self.multi_query_group_num = config.multi_query_group_num
|
746 |
+
self.kv_channels = config.kv_channels
|
747 |
+
|
748 |
+
# Rotary positional embeddings
|
749 |
+
self.seq_length = config.seq_length
|
750 |
+
rotary_dim = (
|
751 |
+
config.hidden_size // config.num_attention_heads if config.kv_channels is None else config.kv_channels
|
752 |
+
)
|
753 |
+
|
754 |
+
self.rotary_pos_emb = RotaryEmbedding(rotary_dim // 2, original_impl=config.original_rope, device=device,
|
755 |
+
dtype=config.torch_dtype)
|
756 |
+
self.encoder = init_method(GLMTransformer, config, **init_kwargs)
|
757 |
+
self.output_layer = init_method(nn.Linear, config.hidden_size, config.padded_vocab_size, bias=False,
|
758 |
+
dtype=config.torch_dtype, **init_kwargs)
|
759 |
+
self.pre_seq_len = config.pre_seq_len
|
760 |
+
self.prefix_projection = config.prefix_projection
|
761 |
+
if self.pre_seq_len is not None:
|
762 |
+
for param in self.parameters():
|
763 |
+
param.requires_grad = False
|
764 |
+
self.prefix_tokens = torch.arange(self.pre_seq_len).long()
|
765 |
+
self.prefix_encoder = PrefixEncoder(config)
|
766 |
+
self.dropout = torch.nn.Dropout(0.1)
|
767 |
+
|
768 |
+
def get_input_embeddings(self):
|
769 |
+
return self.embedding.word_embeddings
|
770 |
+
|
771 |
+
def get_prompt(self, batch_size, device, dtype=torch.half):
|
772 |
+
prefix_tokens = self.prefix_tokens.unsqueeze(0).expand(batch_size, -1).to(device)
|
773 |
+
past_key_values = self.prefix_encoder(prefix_tokens).type(dtype)
|
774 |
+
past_key_values = past_key_values.view(
|
775 |
+
batch_size,
|
776 |
+
self.pre_seq_len,
|
777 |
+
self.num_layers * 2,
|
778 |
+
self.multi_query_group_num,
|
779 |
+
self.kv_channels
|
780 |
+
)
|
781 |
+
# seq_len, b, nh, hidden_size
|
782 |
+
past_key_values = self.dropout(past_key_values)
|
783 |
+
past_key_values = past_key_values.permute([2, 1, 0, 3, 4]).split(2)
|
784 |
+
return past_key_values
|
785 |
+
|
786 |
+
def forward(
|
787 |
+
self,
|
788 |
+
input_ids,
|
789 |
+
position_ids: Optional[torch.Tensor] = None,
|
790 |
+
attention_mask: Optional[torch.BoolTensor] = None,
|
791 |
+
full_attention_mask: Optional[torch.BoolTensor] = None,
|
792 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
793 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
794 |
+
use_cache: Optional[bool] = None,
|
795 |
+
output_hidden_states: Optional[bool] = None,
|
796 |
+
return_dict: Optional[bool] = None,
|
797 |
+
):
|
798 |
+
output_hidden_states = (
|
799 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
800 |
+
)
|
801 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
802 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
803 |
+
|
804 |
+
batch_size, seq_length = input_ids.shape
|
805 |
+
|
806 |
+
if inputs_embeds is None:
|
807 |
+
inputs_embeds = self.embedding(input_ids)
|
808 |
+
|
809 |
+
if self.pre_seq_len is not None:
|
810 |
+
if past_key_values is None:
|
811 |
+
past_key_values = self.get_prompt(batch_size=batch_size, device=input_ids.device,
|
812 |
+
dtype=inputs_embeds.dtype)
|
813 |
+
if attention_mask is not None:
|
814 |
+
attention_mask = torch.cat([attention_mask.new_ones((batch_size, self.pre_seq_len)),
|
815 |
+
attention_mask], dim=-1)
|
816 |
+
|
817 |
+
if full_attention_mask is None:
|
818 |
+
if (attention_mask is not None and not attention_mask.all()) or (past_key_values and seq_length != 1):
|
819 |
+
full_attention_mask = self.get_masks(input_ids, past_key_values, padding_mask=attention_mask)
|
820 |
+
|
821 |
+
# Rotary positional embeddings
|
822 |
+
rotary_pos_emb = self.rotary_pos_emb(self.seq_length)
|
823 |
+
if position_ids is not None:
|
824 |
+
rotary_pos_emb = rotary_pos_emb[position_ids]
|
825 |
+
else:
|
826 |
+
rotary_pos_emb = rotary_pos_emb[None, :seq_length]
|
827 |
+
rotary_pos_emb = rotary_pos_emb.transpose(0, 1).contiguous()
|
828 |
+
|
829 |
+
# Run encoder.
|
830 |
+
hidden_states, presents, all_hidden_states, all_self_attentions = self.encoder(
|
831 |
+
inputs_embeds, full_attention_mask, rotary_pos_emb=rotary_pos_emb,
|
832 |
+
kv_caches=past_key_values, use_cache=use_cache, output_hidden_states=output_hidden_states
|
833 |
+
)
|
834 |
+
|
835 |
+
if not return_dict:
|
836 |
+
return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions] if v is not None)
|
837 |
+
|
838 |
+
return BaseModelOutputWithPast(
|
839 |
+
last_hidden_state=hidden_states,
|
840 |
+
past_key_values=presents,
|
841 |
+
hidden_states=all_hidden_states,
|
842 |
+
attentions=all_self_attentions,
|
843 |
+
)
|
844 |
+
|
845 |
+
def quantize(self, weight_bit_width: int):
|
846 |
+
from .quantization import quantize
|
847 |
+
quantize(self.encoder, weight_bit_width)
|
848 |
+
return self
|
849 |
+
|
850 |
+
|
851 |
+
class ChatGLMForConditionalGeneration(ChatGLMPreTrainedModel):
|
852 |
+
def __init__(self, config: ChatGLMConfig, empty_init=True, device=None):
|
853 |
+
super().__init__(config)
|
854 |
+
|
855 |
+
self.max_sequence_length = config.max_length
|
856 |
+
self.transformer = ChatGLMModel(config, empty_init=empty_init, device=device)
|
857 |
+
self.config = config
|
858 |
+
self.quantized = False
|
859 |
+
|
860 |
+
if self.config.quantization_bit:
|
861 |
+
self.quantize(self.config.quantization_bit, empty_init=True)
|
862 |
+
|
863 |
+
def _update_model_kwargs_for_generation(
|
864 |
+
self,
|
865 |
+
outputs: ModelOutput,
|
866 |
+
model_kwargs: Dict[str, Any],
|
867 |
+
is_encoder_decoder: bool = False,
|
868 |
+
standardize_cache_format: bool = False,
|
869 |
+
) -> Dict[str, Any]:
|
870 |
+
# update past_key_values
|
871 |
+
model_kwargs["past_key_values"] = self._extract_past_from_model_output(
|
872 |
+
outputs, standardize_cache_format=standardize_cache_format
|
873 |
+
)
|
874 |
+
|
875 |
+
# update attention mask
|
876 |
+
if "attention_mask" in model_kwargs:
|
877 |
+
attention_mask = model_kwargs["attention_mask"]
|
878 |
+
model_kwargs["attention_mask"] = torch.cat(
|
879 |
+
[attention_mask, attention_mask.new_ones((attention_mask.shape[0], 1))], dim=-1
|
880 |
+
)
|
881 |
+
|
882 |
+
# update position ids
|
883 |
+
if "position_ids" in model_kwargs:
|
884 |
+
position_ids = model_kwargs["position_ids"]
|
885 |
+
new_position_id = position_ids[..., -1:].clone()
|
886 |
+
new_position_id += 1
|
887 |
+
model_kwargs["position_ids"] = torch.cat(
|
888 |
+
[position_ids, new_position_id], dim=-1
|
889 |
+
)
|
890 |
+
|
891 |
+
model_kwargs["is_first_forward"] = False
|
892 |
+
return model_kwargs
|
893 |
+
|
894 |
+
def prepare_inputs_for_generation(
|
895 |
+
self,
|
896 |
+
input_ids: torch.LongTensor,
|
897 |
+
past_key_values: Optional[torch.Tensor] = None,
|
898 |
+
attention_mask: Optional[torch.Tensor] = None,
|
899 |
+
position_ids: Optional[torch.Tensor] = None,
|
900 |
+
use_cache: Optional[bool] = None,
|
901 |
+
is_first_forward: bool = True,
|
902 |
+
**kwargs
|
903 |
+
) -> dict:
|
904 |
+
# only last token for input_ids if past is not None
|
905 |
+
if position_ids is None:
|
906 |
+
position_ids = self.get_position_ids(input_ids, device=input_ids.device)
|
907 |
+
if not is_first_forward:
|
908 |
+
if past_key_values is not None:
|
909 |
+
position_ids = position_ids[..., -1:]
|
910 |
+
input_ids = input_ids[:, -1:]
|
911 |
+
return {
|
912 |
+
"input_ids": input_ids,
|
913 |
+
"past_key_values": past_key_values,
|
914 |
+
"position_ids": position_ids,
|
915 |
+
"attention_mask": attention_mask,
|
916 |
+
"return_last_logit": True,
|
917 |
+
"use_cache": use_cache
|
918 |
+
}
|
919 |
+
|
920 |
+
def forward(
|
921 |
+
self,
|
922 |
+
input_ids: Optional[torch.Tensor] = None,
|
923 |
+
position_ids: Optional[torch.Tensor] = None,
|
924 |
+
attention_mask: Optional[torch.Tensor] = None,
|
925 |
+
past_key_values: Optional[Tuple[torch.FloatTensor]] = None,
|
926 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
927 |
+
labels: Optional[torch.Tensor] = None,
|
928 |
+
use_cache: Optional[bool] = None,
|
929 |
+
output_attentions: Optional[bool] = None,
|
930 |
+
output_hidden_states: Optional[bool] = None,
|
931 |
+
return_dict: Optional[bool] = None,
|
932 |
+
return_last_logit: Optional[bool] = False,
|
933 |
+
):
|
934 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
935 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
936 |
+
|
937 |
+
transformer_outputs = self.transformer(
|
938 |
+
input_ids=input_ids,
|
939 |
+
position_ids=position_ids,
|
940 |
+
attention_mask=attention_mask,
|
941 |
+
past_key_values=past_key_values,
|
942 |
+
inputs_embeds=inputs_embeds,
|
943 |
+
use_cache=use_cache,
|
944 |
+
output_hidden_states=output_hidden_states,
|
945 |
+
return_dict=return_dict,
|
946 |
+
)
|
947 |
+
|
948 |
+
hidden_states = transformer_outputs[0]
|
949 |
+
if return_last_logit:
|
950 |
+
hidden_states = hidden_states[-1:]
|
951 |
+
lm_logits = self.transformer.output_layer(hidden_states)
|
952 |
+
lm_logits = lm_logits.transpose(0, 1).contiguous()
|
953 |
+
|
954 |
+
loss = None
|
955 |
+
if labels is not None:
|
956 |
+
lm_logits = lm_logits.to(torch.float32)
|
957 |
+
|
958 |
+
# Shift so that tokens < n predict n
|
959 |
+
shift_logits = lm_logits[..., :-1, :].contiguous()
|
960 |
+
shift_labels = labels[..., 1:].contiguous()
|
961 |
+
# Flatten the tokens
|
962 |
+
loss_fct = CrossEntropyLoss(ignore_index=-100)
|
963 |
+
loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
|
964 |
+
|
965 |
+
lm_logits = lm_logits.to(hidden_states.dtype)
|
966 |
+
loss = loss.to(hidden_states.dtype)
|
967 |
+
|
968 |
+
if not return_dict:
|
969 |
+
output = (lm_logits,) + transformer_outputs[1:]
|
970 |
+
return ((loss,) + output) if loss is not None else output
|
971 |
+
|
972 |
+
return CausalLMOutputWithPast(
|
973 |
+
loss=loss,
|
974 |
+
logits=lm_logits,
|
975 |
+
past_key_values=transformer_outputs.past_key_values,
|
976 |
+
hidden_states=transformer_outputs.hidden_states,
|
977 |
+
attentions=transformer_outputs.attentions,
|
978 |
+
)
|
979 |
+
|
980 |
+
@staticmethod
|
981 |
+
def _reorder_cache(
|
982 |
+
past: Tuple[Tuple[torch.Tensor, torch.Tensor], ...], beam_idx: torch.LongTensor
|
983 |
+
) -> Tuple[Tuple[torch.Tensor, torch.Tensor], ...]:
|
984 |
+
"""
|
985 |
+
This function is used to re-order the `past_key_values` cache if [`~PreTrainedModel.beam_search`] or
|
986 |
+
[`~PreTrainedModel.beam_sample`] is called. This is required to match `past_key_values` with the correct
|
987 |
+
beam_idx at every generation step.
|
988 |
+
|
989 |
+
Output shares the same memory storage as `past`.
|
990 |
+
"""
|
991 |
+
return tuple(
|
992 |
+
(
|
993 |
+
layer_past[0].index_select(1, beam_idx.to(layer_past[0].device)),
|
994 |
+
layer_past[1].index_select(1, beam_idx.to(layer_past[1].device)),
|
995 |
+
)
|
996 |
+
for layer_past in past
|
997 |
+
)
|
998 |
+
|
999 |
+
def process_response(self, response):
|
1000 |
+
response = response.strip()
|
1001 |
+
response = response.replace("[[训练时间]]", "2023年")
|
1002 |
+
return response
|
1003 |
+
|
1004 |
+
def build_inputs(self, tokenizer, query: str, history: List[Tuple[str, str]] = None):
|
1005 |
+
prompt = tokenizer.build_prompt(query, history=history)
|
1006 |
+
inputs = tokenizer([prompt], return_tensors="pt")
|
1007 |
+
inputs = inputs.to(self.device)
|
1008 |
+
return inputs
|
1009 |
+
|
1010 |
+
def build_stream_inputs(self, tokenizer, query: str, history: List[Tuple[str, str]] = None):
|
1011 |
+
if history:
|
1012 |
+
prompt = "\n\n[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
1013 |
+
input_ids = tokenizer.encode(prompt, add_special_tokens=False)
|
1014 |
+
input_ids = input_ids[1:]
|
1015 |
+
inputs = tokenizer.batch_encode_plus([(input_ids, None)], return_tensors="pt", add_special_tokens=False)
|
1016 |
+
else:
|
1017 |
+
prompt = "[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
1018 |
+
inputs = tokenizer([prompt], return_tensors="pt")
|
1019 |
+
inputs = inputs.to(self.device)
|
1020 |
+
return inputs
|
1021 |
+
|
1022 |
+
@torch.inference_mode()
|
1023 |
+
def chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, max_length: int = 8192, num_beams=1,
|
1024 |
+
do_sample=True, top_p=0.8, temperature=0.8, logits_processor=None, **kwargs):
|
1025 |
+
if history is None:
|
1026 |
+
history = []
|
1027 |
+
if logits_processor is None:
|
1028 |
+
logits_processor = LogitsProcessorList()
|
1029 |
+
logits_processor.append(InvalidScoreLogitsProcessor())
|
1030 |
+
gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p,
|
1031 |
+
"temperature": temperature, "logits_processor": logits_processor, **kwargs}
|
1032 |
+
inputs = self.build_inputs(tokenizer, query, history=history)
|
1033 |
+
outputs = self.generate(**inputs, **gen_kwargs)
|
1034 |
+
outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
|
1035 |
+
response = tokenizer.decode(outputs)
|
1036 |
+
response = self.process_response(response)
|
1037 |
+
history = history + [(query, response)]
|
1038 |
+
return response, history
|
1039 |
+
|
1040 |
+
@torch.inference_mode()
|
1041 |
+
def stream_chat(self, tokenizer, query: str, history: List[Tuple[str, str]] = None, past_key_values=None,
|
1042 |
+
max_length: int = 8192, do_sample=True, top_p=0.8, temperature=0.8, logits_processor=None,
|
1043 |
+
return_past_key_values=False, **kwargs):
|
1044 |
+
if history is None:
|
1045 |
+
history = []
|
1046 |
+
if logits_processor is None:
|
1047 |
+
logits_processor = LogitsProcessorList()
|
1048 |
+
logits_processor.append(InvalidScoreLogitsProcessor())
|
1049 |
+
gen_kwargs = {"max_length": max_length, "do_sample": do_sample, "top_p": top_p,
|
1050 |
+
"temperature": temperature, "logits_processor": logits_processor, **kwargs}
|
1051 |
+
if past_key_values is None and not return_past_key_values:
|
1052 |
+
inputs = self.build_inputs(tokenizer, query, history=history)
|
1053 |
+
else:
|
1054 |
+
inputs = self.build_stream_inputs(tokenizer, query, history=history)
|
1055 |
+
if past_key_values is not None:
|
1056 |
+
past_length = past_key_values[0][0].shape[0]
|
1057 |
+
if self.transformer.pre_seq_len is not None:
|
1058 |
+
past_length -= self.transformer.pre_seq_len
|
1059 |
+
inputs.position_ids += past_length
|
1060 |
+
attention_mask = inputs.attention_mask
|
1061 |
+
attention_mask = torch.cat((attention_mask.new_ones(1, past_length), attention_mask), dim=1)
|
1062 |
+
inputs['attention_mask'] = attention_mask
|
1063 |
+
for outputs in self.stream_generate(**inputs, past_key_values=past_key_values,
|
1064 |
+
return_past_key_values=return_past_key_values, **gen_kwargs):
|
1065 |
+
if return_past_key_values:
|
1066 |
+
outputs, past_key_values = outputs
|
1067 |
+
outputs = outputs.tolist()[0][len(inputs["input_ids"][0]):]
|
1068 |
+
response = tokenizer.decode(outputs)
|
1069 |
+
if response and response[-1] != "�":
|
1070 |
+
response = self.process_response(response)
|
1071 |
+
new_history = history + [(query, response)]
|
1072 |
+
if return_past_key_values:
|
1073 |
+
yield response, new_history, past_key_values
|
1074 |
+
else:
|
1075 |
+
yield response, new_history
|
1076 |
+
|
1077 |
+
@torch.inference_mode()
|
1078 |
+
def stream_generate(
|
1079 |
+
self,
|
1080 |
+
input_ids,
|
1081 |
+
generation_config: Optional[GenerationConfig] = None,
|
1082 |
+
logits_processor: Optional[LogitsProcessorList] = None,
|
1083 |
+
stopping_criteria: Optional[StoppingCriteriaList] = None,
|
1084 |
+
prefix_allowed_tokens_fn: Optional[Callable[[int, torch.Tensor], List[int]]] = None,
|
1085 |
+
return_past_key_values=False,
|
1086 |
+
**kwargs,
|
1087 |
+
):
|
1088 |
+
batch_size, input_ids_seq_length = input_ids.shape[0], input_ids.shape[-1]
|
1089 |
+
|
1090 |
+
if generation_config is None:
|
1091 |
+
generation_config = self.generation_config
|
1092 |
+
generation_config = copy.deepcopy(generation_config)
|
1093 |
+
model_kwargs = generation_config.update(**kwargs)
|
1094 |
+
model_kwargs["use_cache"] = generation_config.use_cache
|
1095 |
+
bos_token_id, eos_token_id = generation_config.bos_token_id, generation_config.eos_token_id
|
1096 |
+
|
1097 |
+
if isinstance(eos_token_id, int):
|
1098 |
+
eos_token_id = [eos_token_id]
|
1099 |
+
|
1100 |
+
has_default_max_length = kwargs.get("max_length") is None and generation_config.max_length is not None
|
1101 |
+
if has_default_max_length and generation_config.max_new_tokens is None:
|
1102 |
+
warnings.warn(
|
1103 |
+
f"Using `max_length`'s default ({generation_config.max_length}) to control the generation length. "
|
1104 |
+
"This behaviour is deprecated and will be removed from the config in v5 of Transformers -- we"
|
1105 |
+
" recommend using `max_new_tokens` to control the maximum length of the generation.",
|
1106 |
+
UserWarning,
|
1107 |
+
)
|
1108 |
+
elif generation_config.max_new_tokens is not None:
|
1109 |
+
generation_config.max_length = generation_config.max_new_tokens + input_ids_seq_length
|
1110 |
+
if not has_default_max_length:
|
1111 |
+
logger.warn(
|
1112 |
+
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(="
|
1113 |
+
f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "
|
1114 |
+
"Please refer to the documentation for more information. "
|
1115 |
+
"(https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)",
|
1116 |
+
UserWarning,
|
1117 |
+
)
|
1118 |
+
|
1119 |
+
if input_ids_seq_length >= generation_config.max_length:
|
1120 |
+
input_ids_string = "decoder_input_ids" if self.config.is_encoder_decoder else "input_ids"
|
1121 |
+
logger.warning(
|
1122 |
+
f"Input length of {input_ids_string} is {input_ids_seq_length}, but `max_length` is set to"
|
1123 |
+
f" {generation_config.max_length}. This can lead to unexpected behavior. You should consider"
|
1124 |
+
" increasing `max_new_tokens`."
|
1125 |
+
)
|
1126 |
+
|
1127 |
+
# 2. Set generation parameters if not already defined
|
1128 |
+
logits_processor = logits_processor if logits_processor is not None else LogitsProcessorList()
|
1129 |
+
stopping_criteria = stopping_criteria if stopping_criteria is not None else StoppingCriteriaList()
|
1130 |
+
|
1131 |
+
logits_processor = self._get_logits_processor(
|
1132 |
+
generation_config=generation_config,
|
1133 |
+
input_ids_seq_length=input_ids_seq_length,
|
1134 |
+
encoder_input_ids=input_ids,
|
1135 |
+
prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,
|
1136 |
+
logits_processor=logits_processor,
|
1137 |
+
)
|
1138 |
+
|
1139 |
+
stopping_criteria = self._get_stopping_criteria(
|
1140 |
+
generation_config=generation_config, stopping_criteria=stopping_criteria
|
1141 |
+
)
|
1142 |
+
logits_warper = self._get_logits_warper(generation_config)
|
1143 |
+
|
1144 |
+
unfinished_sequences = input_ids.new(input_ids.shape[0]).fill_(1)
|
1145 |
+
scores = None
|
1146 |
+
while True:
|
1147 |
+
model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
|
1148 |
+
# forward pass to get next token
|
1149 |
+
outputs = self(
|
1150 |
+
**model_inputs,
|
1151 |
+
return_dict=True,
|
1152 |
+
output_attentions=False,
|
1153 |
+
output_hidden_states=False,
|
1154 |
+
)
|
1155 |
+
|
1156 |
+
next_token_logits = outputs.logits[:, -1, :]
|
1157 |
+
|
1158 |
+
# pre-process distribution
|
1159 |
+
next_token_scores = logits_processor(input_ids, next_token_logits)
|
1160 |
+
next_token_scores = logits_warper(input_ids, next_token_scores)
|
1161 |
+
|
1162 |
+
# sample
|
1163 |
+
probs = nn.functional.softmax(next_token_scores, dim=-1)
|
1164 |
+
if generation_config.do_sample:
|
1165 |
+
next_tokens = torch.multinomial(probs, num_samples=1).squeeze(1)
|
1166 |
+
else:
|
1167 |
+
next_tokens = torch.argmax(probs, dim=-1)
|
1168 |
+
|
1169 |
+
# update generated ids, model inputs, and length for next step
|
1170 |
+
input_ids = torch.cat([input_ids, next_tokens[:, None]], dim=-1)
|
1171 |
+
model_kwargs = self._update_model_kwargs_for_generation(
|
1172 |
+
outputs, model_kwargs, is_encoder_decoder=self.config.is_encoder_decoder
|
1173 |
+
)
|
1174 |
+
unfinished_sequences = unfinished_sequences.mul((sum(next_tokens != i for i in eos_token_id)).long())
|
1175 |
+
if return_past_key_values:
|
1176 |
+
yield input_ids, outputs.past_key_values
|
1177 |
+
else:
|
1178 |
+
yield input_ids
|
1179 |
+
# stop when each sentence is finished, or if we exceed the maximum length
|
1180 |
+
if unfinished_sequences.max() == 0 or stopping_criteria(input_ids, scores):
|
1181 |
+
break
|
1182 |
+
|
1183 |
+
def quantize(self, bits: int, empty_init=False, device=None, **kwargs):
|
1184 |
+
if bits == 0:
|
1185 |
+
return
|
1186 |
+
|
1187 |
+
from .quantization import quantize
|
1188 |
+
|
1189 |
+
if self.quantized:
|
1190 |
+
logger.info("Already quantized.")
|
1191 |
+
return self
|
1192 |
+
|
1193 |
+
self.quantized = True
|
1194 |
+
|
1195 |
+
self.config.quantization_bit = bits
|
1196 |
+
|
1197 |
+
self.transformer.encoder = quantize(self.transformer.encoder, bits, empty_init=empty_init, device=device,
|
1198 |
+
**kwargs)
|
1199 |
+
return self
|
1200 |
+
|
1201 |
+
|
1202 |
+
class ChatGLMForSequenceClassification(ChatGLMPreTrainedModel):
|
1203 |
+
def __init__(self, config: ChatGLMConfig, empty_init=True, device=None):
|
1204 |
+
super().__init__(config)
|
1205 |
+
|
1206 |
+
self.num_labels = config.num_labels
|
1207 |
+
self.transformer = ChatGLMModel(config, empty_init=empty_init, device=device)
|
1208 |
+
|
1209 |
+
self.classifier_head = nn.Linear(config.hidden_size, config.num_labels, bias=True, dtype=torch.half)
|
1210 |
+
if config.classifier_dropout is not None:
|
1211 |
+
self.dropout = nn.Dropout(config.classifier_dropout)
|
1212 |
+
else:
|
1213 |
+
self.dropout = None
|
1214 |
+
self.config = config
|
1215 |
+
|
1216 |
+
if self.config.quantization_bit:
|
1217 |
+
self.quantize(self.config.quantization_bit, empty_init=True)
|
1218 |
+
|
1219 |
+
def forward(
|
1220 |
+
self,
|
1221 |
+
input_ids: Optional[torch.LongTensor] = None,
|
1222 |
+
position_ids: Optional[torch.LongTensor] = None,
|
1223 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1224 |
+
full_attention_mask: Optional[torch.Tensor] = None,
|
1225 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
1226 |
+
inputs_embeds: Optional[torch.LongTensor] = None,
|
1227 |
+
labels: Optional[torch.LongTensor] = None,
|
1228 |
+
use_cache: Optional[bool] = None,
|
1229 |
+
output_hidden_states: Optional[bool] = None,
|
1230 |
+
return_dict: Optional[bool] = None,
|
1231 |
+
) -> Union[Tuple[torch.Tensor, ...], SequenceClassifierOutputWithPast]:
|
1232 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1233 |
+
|
1234 |
+
transformer_outputs = self.transformer(
|
1235 |
+
input_ids=input_ids,
|
1236 |
+
position_ids=position_ids,
|
1237 |
+
attention_mask=attention_mask,
|
1238 |
+
full_attention_mask=full_attention_mask,
|
1239 |
+
past_key_values=past_key_values,
|
1240 |
+
inputs_embeds=inputs_embeds,
|
1241 |
+
use_cache=use_cache,
|
1242 |
+
output_hidden_states=output_hidden_states,
|
1243 |
+
return_dict=return_dict,
|
1244 |
+
)
|
1245 |
+
|
1246 |
+
hidden_states = transformer_outputs[0]
|
1247 |
+
pooled_hidden_states = hidden_states[-1]
|
1248 |
+
if self.dropout is not None:
|
1249 |
+
pooled_hidden_states = self.dropout(pooled_hidden_states)
|
1250 |
+
logits = self.classifier_head(pooled_hidden_states)
|
1251 |
+
|
1252 |
+
loss = None
|
1253 |
+
if labels is not None:
|
1254 |
+
if self.config.problem_type is None:
|
1255 |
+
if self.num_labels == 1:
|
1256 |
+
self.config.problem_type = "regression"
|
1257 |
+
elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
|
1258 |
+
self.config.problem_type = "single_label_classification"
|
1259 |
+
else:
|
1260 |
+
self.config.problem_type = "multi_label_classification"
|
1261 |
+
|
1262 |
+
if self.config.problem_type == "regression":
|
1263 |
+
loss_fct = MSELoss()
|
1264 |
+
if self.num_labels == 1:
|
1265 |
+
loss = loss_fct(logits.squeeze().float(), labels.squeeze())
|
1266 |
+
else:
|
1267 |
+
loss = loss_fct(logits.float(), labels)
|
1268 |
+
elif self.config.problem_type == "single_label_classification":
|
1269 |
+
loss_fct = CrossEntropyLoss()
|
1270 |
+
loss = loss_fct(logits.view(-1, self.num_labels).float(), labels.view(-1))
|
1271 |
+
elif self.config.problem_type == "multi_label_classification":
|
1272 |
+
loss_fct = BCEWithLogitsLoss()
|
1273 |
+
loss = loss_fct(logits.float(), labels.view(-1, self.num_labels))
|
1274 |
+
|
1275 |
+
if not return_dict:
|
1276 |
+
output = (logits,) + transformer_outputs[1:]
|
1277 |
+
return ((loss,) + output) if loss is not None else output
|
1278 |
+
|
1279 |
+
return SequenceClassifierOutputWithPast(
|
1280 |
+
loss=loss,
|
1281 |
+
logits=logits,
|
1282 |
+
past_key_values=transformer_outputs.past_key_values,
|
1283 |
+
hidden_states=transformer_outputs.hidden_states,
|
1284 |
+
attentions=transformer_outputs.attentions,
|
1285 |
+
)
|
checkpoint-3000/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d933d739be3ea081921f3f2720b05f67648f7469fcd8090da4997203ccd8d0ee
|
3 |
+
size 14681455
|
checkpoint-3000/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8c027dc9dc576448d290ff5857990857beba3d336cdaed8ff78183b6eaaeb9a8
|
3 |
+
size 7340861
|
checkpoint-3000/quantization.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
checkpoint-3000/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cff56eb2132f83374842f7d3d336ebe853f1a9cd3e56b4675981d6fadecb6c5b
|
3 |
+
size 14575
|
checkpoint-3000/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:789a1605f05260342a605be992efe3dec445d76b75c62bdef618345fc0105cc0
|
3 |
+
size 627
|
checkpo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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import torch
|
3 |
+
from typing import List, Optional, Union, Dict
|
4 |
+
from sentencepiece import SentencePieceProcessor
|
5 |
+
from transformers import PreTrainedTokenizer
|
6 |
+
from transformers.utils import logging, PaddingStrategy
|
7 |
+
from transformers.tokenization_utils_base import EncodedInput, BatchEncoding
|
8 |
+
|
9 |
+
|
10 |
+
class SPTokenizer:
|
11 |
+
def __init__(self, model_path: str):
|
12 |
+
# reload tokenizer
|
13 |
+
assert os.path.isfile(model_path), model_path
|
14 |
+
self.sp_model = SentencePieceProcessor(model_file=model_path)
|
15 |
+
|
16 |
+
# BOS / EOS token IDs
|
17 |
+
self.n_words: int = self.sp_model.vocab_size()
|
18 |
+
self.bos_id: int = self.sp_model.bos_id()
|
19 |
+
self.eos_id: int = self.sp_model.eos_id()
|
20 |
+
self.pad_id: int = self.sp_model.unk_id()
|
21 |
+
assert self.sp_model.vocab_size() == self.sp_model.get_piece_size()
|
22 |
+
|
23 |
+
special_tokens = ["[MASK]", "[gMASK]", "[sMASK]", "sop", "eop"]
|
24 |
+
self.special_tokens = {}
|
25 |
+
self.index_special_tokens = {}
|
26 |
+
for token in special_tokens:
|
27 |
+
self.special_tokens[token] = self.n_words
|
28 |
+
self.index_special_tokens[self.n_words] = token
|
29 |
+
self.n_words += 1
|
30 |
+
|
31 |
+
def tokenize(self, s: str):
|
32 |
+
return self.sp_model.EncodeAsPieces(s)
|
33 |
+
|
34 |
+
def encode(self, s: str, bos: bool = False, eos: bool = False) -> List[int]:
|
35 |
+
assert type(s) is str
|
36 |
+
t = self.sp_model.encode(s)
|
37 |
+
if bos:
|
38 |
+
t = [self.bos_id] + t
|
39 |
+
if eos:
|
40 |
+
t = t + [self.eos_id]
|
41 |
+
return t
|
42 |
+
|
43 |
+
def decode(self, t: List[int]) -> str:
|
44 |
+
return self.sp_model.decode(t)
|
45 |
+
|
46 |
+
def decode_tokens(self, tokens: List[str]) -> str:
|
47 |
+
text = self.sp_model.DecodePieces(tokens)
|
48 |
+
return text
|
49 |
+
|
50 |
+
def convert_token_to_id(self, token):
|
51 |
+
""" Converts a token (str) in an id using the vocab. """
|
52 |
+
if token in self.special_tokens:
|
53 |
+
return self.special_tokens[token]
|
54 |
+
return self.sp_model.PieceToId(token)
|
55 |
+
|
56 |
+
def convert_id_to_token(self, index):
|
57 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
58 |
+
if index in self.index_special_tokens or index in [self.eos_id, self.bos_id, self.pad_id] or index < 0:
|
59 |
+
return ""
|
60 |
+
return self.sp_model.IdToPiece(index)
|
61 |
+
|
62 |
+
|
63 |
+
class ChatGLMTokenizer(PreTrainedTokenizer):
|
64 |
+
vocab_files_names = {"vocab_file": "tokenizer.model"}
|
65 |
+
|
66 |
+
model_input_names = ["input_ids", "attention_mask", "position_ids"]
|
67 |
+
|
68 |
+
def __init__(self, vocab_file, padding_side="left", clean_up_tokenization_spaces=False, **kwargs):
|
69 |
+
self.name = "GLMTokenizer"
|
70 |
+
|
71 |
+
self.vocab_file = vocab_file
|
72 |
+
self.tokenizer = SPTokenizer(vocab_file)
|
73 |
+
self.special_tokens = {
|
74 |
+
"<bos>": self.tokenizer.bos_id,
|
75 |
+
"<eos>": self.tokenizer.eos_id,
|
76 |
+
"<pad>": self.tokenizer.pad_id
|
77 |
+
}
|
78 |
+
super().__init__(padding_side=padding_side, clean_up_tokenization_spaces=clean_up_tokenization_spaces, **kwargs)
|
79 |
+
|
80 |
+
def get_command(self, token):
|
81 |
+
if token in self.special_tokens:
|
82 |
+
return self.special_tokens[token]
|
83 |
+
assert token in self.tokenizer.special_tokens, f"{token} is not a special token for {self.name}"
|
84 |
+
return self.tokenizer.special_tokens[token]
|
85 |
+
|
86 |
+
@property
|
87 |
+
def unk_token(self) -> str:
|
88 |
+
return "<unk>"
|
89 |
+
|
90 |
+
@property
|
91 |
+
def pad_token(self) -> str:
|
92 |
+
return "<unk>"
|
93 |
+
|
94 |
+
@property
|
95 |
+
def pad_token_id(self):
|
96 |
+
return self.get_command("<pad>")
|
97 |
+
|
98 |
+
@property
|
99 |
+
def eos_token(self) -> str:
|
100 |
+
return "</s>"
|
101 |
+
|
102 |
+
@property
|
103 |
+
def eos_token_id(self):
|
104 |
+
return self.get_command("<eos>")
|
105 |
+
|
106 |
+
@property
|
107 |
+
def vocab_size(self):
|
108 |
+
return self.tokenizer.n_words
|
109 |
+
|
110 |
+
def get_vocab(self):
|
111 |
+
""" Returns vocab as a dict """
|
112 |
+
vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
|
113 |
+
vocab.update(self.added_tokens_encoder)
|
114 |
+
return vocab
|
115 |
+
|
116 |
+
def _tokenize(self, text, **kwargs):
|
117 |
+
return self.tokenizer.tokenize(text)
|
118 |
+
|
119 |
+
def _convert_token_to_id(self, token):
|
120 |
+
""" Converts a token (str) in an id using the vocab. """
|
121 |
+
return self.tokenizer.convert_token_to_id(token)
|
122 |
+
|
123 |
+
def _convert_id_to_token(self, index):
|
124 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
125 |
+
return self.tokenizer.convert_id_to_token(index)
|
126 |
+
|
127 |
+
def convert_tokens_to_string(self, tokens: List[str]) -> str:
|
128 |
+
return self.tokenizer.decode_tokens(tokens)
|
129 |
+
|
130 |
+
def save_vocabulary(self, save_directory, filename_prefix=None):
|
131 |
+
"""
|
132 |
+
Save the vocabulary and special tokens file to a directory.
|
133 |
+
|
134 |
+
Args:
|
135 |
+
save_directory (`str`):
|
136 |
+
The directory in which to save the vocabulary.
|
137 |
+
filename_prefix (`str`, *optional*):
|
138 |
+
An optional prefix to add to the named of the saved files.
|
139 |
+
|
140 |
+
Returns:
|
141 |
+
`Tuple(str)`: Paths to the files saved.
|
142 |
+
"""
|
143 |
+
if os.path.isdir(save_directory):
|
144 |
+
vocab_file = os.path.join(
|
145 |
+
save_directory, self.vocab_files_names["vocab_file"]
|
146 |
+
)
|
147 |
+
else:
|
148 |
+
vocab_file = save_directory
|
149 |
+
|
150 |
+
with open(self.vocab_file, 'rb') as fin:
|
151 |
+
proto_str = fin.read()
|
152 |
+
|
153 |
+
with open(vocab_file, "wb") as writer:
|
154 |
+
writer.write(proto_str)
|
155 |
+
|
156 |
+
return (vocab_file,)
|
157 |
+
|
158 |
+
def get_prefix_tokens(self):
|
159 |
+
prefix_tokens = [self.get_command("[gMASK]"), self.get_command("sop")]
|
160 |
+
return prefix_tokens
|
161 |
+
|
162 |
+
def build_prompt(self, query, history=None):
|
163 |
+
if history is None:
|
164 |
+
history = []
|
165 |
+
prompt = ""
|
166 |
+
for i, (old_query, response) in enumerate(history):
|
167 |
+
prompt += "[Round {}]\n\n问:{}\n\n答:{}\n\n".format(i + 1, old_query, response)
|
168 |
+
prompt += "[Round {}]\n\n问:{}\n\n答:".format(len(history) + 1, query)
|
169 |
+
return prompt
|
170 |
+
|
171 |
+
def build_inputs_with_special_tokens(
|
172 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
173 |
+
) -> List[int]:
|
174 |
+
"""
|
175 |
+
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
|
176 |
+
adding special tokens. A BERT sequence has the following format:
|
177 |
+
|
178 |
+
- single sequence: `[CLS] X [SEP]`
|
179 |
+
- pair of sequences: `[CLS] A [SEP] B [SEP]`
|
180 |
+
|
181 |
+
Args:
|
182 |
+
token_ids_0 (`List[int]`):
|
183 |
+
List of IDs to which the special tokens will be added.
|
184 |
+
token_ids_1 (`List[int]`, *optional*):
|
185 |
+
Optional second list of IDs for sequence pairs.
|
186 |
+
|
187 |
+
Returns:
|
188 |
+
`List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
|
189 |
+
"""
|
190 |
+
prefix_tokens = self.get_prefix_tokens()
|
191 |
+
token_ids_0 = prefix_tokens + token_ids_0
|
192 |
+
if token_ids_1 is not None:
|
193 |
+
token_ids_0 = token_ids_0 + token_ids_1 + [self.get_command("<eos>")]
|
194 |
+
return token_ids_0
|
195 |
+
|
196 |
+
def _pad(
|
197 |
+
self,
|
198 |
+
encoded_inputs: Union[Dict[str, EncodedInput], BatchEncoding],
|
199 |
+
max_length: Optional[int] = None,
|
200 |
+
padding_strategy: PaddingStrategy = PaddingStrategy.DO_NOT_PAD,
|
201 |
+
pad_to_multiple_of: Optional[int] = None,
|
202 |
+
return_attention_mask: Optional[bool] = None,
|
203 |
+
) -> dict:
|
204 |
+
"""
|
205 |
+
Pad encoded inputs (on left/right and up to predefined length or max length in the batch)
|
206 |
+
|
207 |
+
Args:
|
208 |
+
encoded_inputs:
|
209 |
+
Dictionary of tokenized inputs (`List[int]`) or batch of tokenized inputs (`List[List[int]]`).
|
210 |
+
max_length: maximum length of the returned list and optionally padding length (see below).
|
211 |
+
Will truncate by taking into account the special tokens.
|
212 |
+
padding_strategy: PaddingStrategy to use for padding.
|
213 |
+
|
214 |
+
- PaddingStrategy.LONGEST Pad to the longest sequence in the batch
|
215 |
+
- PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
|
216 |
+
- PaddingStrategy.DO_NOT_PAD: Do not pad
|
217 |
+
The tokenizer padding sides are defined in self.padding_side:
|
218 |
+
|
219 |
+
- 'left': pads on the left of the sequences
|
220 |
+
- 'right': pads on the right of the sequences
|
221 |
+
pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
|
222 |
+
This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
|
223 |
+
`>= 7.5` (Volta).
|
224 |
+
return_attention_mask:
|
225 |
+
(optional) Set to False to avoid returning attention mask (default: set to model specifics)
|
226 |
+
"""
|
227 |
+
# Load from model defaults
|
228 |
+
assert self.padding_side == "left"
|
229 |
+
|
230 |
+
required_input = encoded_inputs[self.model_input_names[0]]
|
231 |
+
seq_length = len(required_input)
|
232 |
+
|
233 |
+
if padding_strategy == PaddingStrategy.LONGEST:
|
234 |
+
max_length = len(required_input)
|
235 |
+
|
236 |
+
if max_length is not None and pad_to_multiple_of is not None and (max_length % pad_to_multiple_of != 0):
|
237 |
+
max_length = ((max_length // pad_to_multiple_of) + 1) * pad_to_multiple_of
|
238 |
+
|
239 |
+
needs_to_be_padded = padding_strategy != PaddingStrategy.DO_NOT_PAD and len(required_input) != max_length
|
240 |
+
|
241 |
+
# Initialize attention mask if not present.
|
242 |
+
if "attention_mask" not in encoded_inputs:
|
243 |
+
encoded_inputs["attention_mask"] = [1] * seq_length
|
244 |
+
|
245 |
+
if "position_ids" not in encoded_inputs:
|
246 |
+
encoded_inputs["position_ids"] = list(range(seq_length))
|
247 |
+
|
248 |
+
if needs_to_be_padded:
|
249 |
+
difference = max_length - len(required_input)
|
250 |
+
|
251 |
+
if "attention_mask" in encoded_inputs:
|
252 |
+
encoded_inputs["attention_mask"] = [0] * difference + encoded_inputs["attention_mask"]
|
253 |
+
if "position_ids" in encoded_inputs:
|
254 |
+
encoded_inputs["position_ids"] = [0] * difference + encoded_inputs["position_ids"]
|
255 |
+
encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input
|
256 |
+
|
257 |
+
return encoded_inputs
|
checkpoint-3000/tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7dc4c393423b76e4373e5157ddc34803a0189ba96b21ddbb40269d31468a6f2
|
3 |
+
size 1018370
|
checkpoint-3000/tokenizer_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"auto_map": {
|
3 |
+
"AutoTokenizer": [
|
4 |
+
"tokenization_chatglm.ChatGLMTokenizer",
|
5 |
+
null
|
6 |
+
]
|
7 |
+
},
|
8 |
+
"clean_up_tokenization_spaces": false,
|
9 |
+
"do_lower_case": false,
|
10 |
+
"model_max_length": 1000000000000000019884624838656,
|
11 |
+
"padding_side": "left",
|
12 |
+
"remove_space": false,
|
13 |
+
"tokenizer_class": "ChatGLMTokenizer"
|
14 |
+
}
|
checkpoint-3000/trainer_state.json
ADDED
@@ -0,0 +1,1816 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 0.2770786672516105,
|
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.0,
|
12 |
+
"learning_rate": 0.019933333333333334,
|
13 |
+
"loss": 2.6644,
|
14 |
+
"step": 10
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"epoch": 0.0,
|
18 |
+
"learning_rate": 0.019866666666666668,
|
19 |
+
"loss": 1.7151,
|
20 |
+
"step": 20
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"epoch": 0.0,
|
24 |
+
"learning_rate": 0.0198,
|
25 |
+
"loss": 1.6228,
|
26 |
+
"step": 30
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"epoch": 0.0,
|
30 |
+
"learning_rate": 0.019733333333333335,
|
31 |
+
"loss": 1.401,
|
32 |
+
"step": 40
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"epoch": 0.0,
|
36 |
+
"learning_rate": 0.019666666666666666,
|
37 |
+
"loss": 1.6172,
|
38 |
+
"step": 50
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"epoch": 0.01,
|
42 |
+
"learning_rate": 0.0196,
|
43 |
+
"loss": 1.4695,
|
44 |
+
"step": 60
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"epoch": 0.01,
|
48 |
+
"learning_rate": 0.019533333333333333,
|
49 |
+
"loss": 1.5137,
|
50 |
+
"step": 70
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"epoch": 0.01,
|
54 |
+
"learning_rate": 0.019466666666666667,
|
55 |
+
"loss": 1.5425,
|
56 |
+
"step": 80
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"epoch": 0.01,
|
60 |
+
"learning_rate": 0.0194,
|
61 |
+
"loss": 1.4272,
|
62 |
+
"step": 90
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"epoch": 0.01,
|
66 |
+
"learning_rate": 0.019333333333333334,
|
67 |
+
"loss": 1.3727,
|
68 |
+
"step": 100
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"epoch": 0.01,
|
72 |
+
"learning_rate": 0.019266666666666668,
|
73 |
+
"loss": 1.3114,
|
74 |
+
"step": 110
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"epoch": 0.01,
|
78 |
+
"learning_rate": 0.0192,
|
79 |
+
"loss": 1.4758,
|
80 |
+
"step": 120
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"epoch": 0.01,
|
84 |
+
"learning_rate": 0.019133333333333332,
|
85 |
+
"loss": 1.5219,
|
86 |
+
"step": 130
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"epoch": 0.01,
|
90 |
+
"learning_rate": 0.01906666666666667,
|
91 |
+
"loss": 1.376,
|
92 |
+
"step": 140
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"epoch": 0.01,
|
96 |
+
"learning_rate": 0.019,
|
97 |
+
"loss": 1.4257,
|
98 |
+
"step": 150
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"epoch": 0.01,
|
102 |
+
"learning_rate": 0.018933333333333333,
|
103 |
+
"loss": 1.3474,
|
104 |
+
"step": 160
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"epoch": 0.02,
|
108 |
+
"learning_rate": 0.018866666666666667,
|
109 |
+
"loss": 1.2929,
|
110 |
+
"step": 170
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"epoch": 0.02,
|
114 |
+
"learning_rate": 0.0188,
|
115 |
+
"loss": 1.3208,
|
116 |
+
"step": 180
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"epoch": 0.02,
|
120 |
+
"learning_rate": 0.018733333333333334,
|
121 |
+
"loss": 1.3381,
|
122 |
+
"step": 190
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"epoch": 0.02,
|
126 |
+
"learning_rate": 0.018666666666666668,
|
127 |
+
"loss": 1.3644,
|
128 |
+
"step": 200
|
129 |
+
},
|
130 |
+
{
|
131 |
+
"epoch": 0.02,
|
132 |
+
"learning_rate": 0.018600000000000002,
|
133 |
+
"loss": 1.2932,
|
134 |
+
"step": 210
|
135 |
+
},
|
136 |
+
{
|
137 |
+
"epoch": 0.02,
|
138 |
+
"learning_rate": 0.018533333333333332,
|
139 |
+
"loss": 1.4092,
|
140 |
+
"step": 220
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"epoch": 0.02,
|
144 |
+
"learning_rate": 0.018466666666666666,
|
145 |
+
"loss": 1.3006,
|
146 |
+
"step": 230
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"epoch": 0.02,
|
150 |
+
"learning_rate": 0.0184,
|
151 |
+
"loss": 1.4572,
|
152 |
+
"step": 240
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"epoch": 0.02,
|
156 |
+
"learning_rate": 0.018333333333333333,
|
157 |
+
"loss": 1.2789,
|
158 |
+
"step": 250
|
159 |
+
},
|
160 |
+
{
|
161 |
+
"epoch": 0.02,
|
162 |
+
"learning_rate": 0.018266666666666667,
|
163 |
+
"loss": 1.4444,
|
164 |
+
"step": 260
|
165 |
+
},
|
166 |
+
{
|
167 |
+
"epoch": 0.02,
|
168 |
+
"learning_rate": 0.0182,
|
169 |
+
"loss": 1.4511,
|
170 |
+
"step": 270
|
171 |
+
},
|
172 |
+
{
|
173 |
+
"epoch": 0.03,
|
174 |
+
"learning_rate": 0.01813333333333333,
|
175 |
+
"loss": 1.3541,
|
176 |
+
"step": 280
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"epoch": 0.03,
|
180 |
+
"learning_rate": 0.01806666666666667,
|
181 |
+
"loss": 1.3228,
|
182 |
+
"step": 290
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"epoch": 0.03,
|
186 |
+
"learning_rate": 0.018000000000000002,
|
187 |
+
"loss": 1.3185,
|
188 |
+
"step": 300
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"epoch": 0.03,
|
192 |
+
"learning_rate": 0.017933333333333332,
|
193 |
+
"loss": 1.199,
|
194 |
+
"step": 310
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"epoch": 0.03,
|
198 |
+
"learning_rate": 0.017866666666666666,
|
199 |
+
"loss": 1.3417,
|
200 |
+
"step": 320
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"epoch": 0.03,
|
204 |
+
"learning_rate": 0.0178,
|
205 |
+
"loss": 1.4251,
|
206 |
+
"step": 330
|
207 |
+
},
|
208 |
+
{
|
209 |
+
"epoch": 0.03,
|
210 |
+
"learning_rate": 0.017733333333333334,
|
211 |
+
"loss": 1.3574,
|
212 |
+
"step": 340
|
213 |
+
},
|
214 |
+
{
|
215 |
+
"epoch": 0.03,
|
216 |
+
"learning_rate": 0.017666666666666667,
|
217 |
+
"loss": 1.2547,
|
218 |
+
"step": 350
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"epoch": 0.03,
|
222 |
+
"learning_rate": 0.0176,
|
223 |
+
"loss": 1.2651,
|
224 |
+
"step": 360
|
225 |
+
},
|
226 |
+
{
|
227 |
+
"epoch": 0.03,
|
228 |
+
"learning_rate": 0.017533333333333335,
|
229 |
+
"loss": 1.3414,
|
230 |
+
"step": 370
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"epoch": 0.04,
|
234 |
+
"learning_rate": 0.017466666666666665,
|
235 |
+
"loss": 1.3322,
|
236 |
+
"step": 380
|
237 |
+
},
|
238 |
+
{
|
239 |
+
"epoch": 0.04,
|
240 |
+
"learning_rate": 0.0174,
|
241 |
+
"loss": 1.4147,
|
242 |
+
"step": 390
|
243 |
+
},
|
244 |
+
{
|
245 |
+
"epoch": 0.04,
|
246 |
+
"learning_rate": 0.017333333333333336,
|
247 |
+
"loss": 1.2813,
|
248 |
+
"step": 400
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"epoch": 0.04,
|
252 |
+
"learning_rate": 0.017266666666666666,
|
253 |
+
"loss": 1.3687,
|
254 |
+
"step": 410
|
255 |
+
},
|
256 |
+
{
|
257 |
+
"epoch": 0.04,
|
258 |
+
"learning_rate": 0.0172,
|
259 |
+
"loss": 1.5593,
|
260 |
+
"step": 420
|
261 |
+
},
|
262 |
+
{
|
263 |
+
"epoch": 0.04,
|
264 |
+
"learning_rate": 0.017133333333333334,
|
265 |
+
"loss": 1.3073,
|
266 |
+
"step": 430
|
267 |
+
},
|
268 |
+
{
|
269 |
+
"epoch": 0.04,
|
270 |
+
"learning_rate": 0.017066666666666667,
|
271 |
+
"loss": 1.2359,
|
272 |
+
"step": 440
|
273 |
+
},
|
274 |
+
{
|
275 |
+
"epoch": 0.04,
|
276 |
+
"learning_rate": 0.017,
|
277 |
+
"loss": 1.2474,
|
278 |
+
"step": 450
|
279 |
+
},
|
280 |
+
{
|
281 |
+
"epoch": 0.04,
|
282 |
+
"learning_rate": 0.016933333333333335,
|
283 |
+
"loss": 1.3874,
|
284 |
+
"step": 460
|
285 |
+
},
|
286 |
+
{
|
287 |
+
"epoch": 0.04,
|
288 |
+
"learning_rate": 0.01686666666666667,
|
289 |
+
"loss": 1.3203,
|
290 |
+
"step": 470
|
291 |
+
},
|
292 |
+
{
|
293 |
+
"epoch": 0.04,
|
294 |
+
"learning_rate": 0.0168,
|
295 |
+
"loss": 1.2875,
|
296 |
+
"step": 480
|
297 |
+
},
|
298 |
+
{
|
299 |
+
"epoch": 0.05,
|
300 |
+
"learning_rate": 0.016733333333333333,
|
301 |
+
"loss": 1.2767,
|
302 |
+
"step": 490
|
303 |
+
},
|
304 |
+
{
|
305 |
+
"epoch": 0.05,
|
306 |
+
"learning_rate": 0.016666666666666666,
|
307 |
+
"loss": 1.3017,
|
308 |
+
"step": 500
|
309 |
+
},
|
310 |
+
{
|
311 |
+
"epoch": 0.05,
|
312 |
+
"learning_rate": 0.0166,
|
313 |
+
"loss": 1.2321,
|
314 |
+
"step": 510
|
315 |
+
},
|
316 |
+
{
|
317 |
+
"epoch": 0.05,
|
318 |
+
"learning_rate": 0.016533333333333334,
|
319 |
+
"loss": 1.1719,
|
320 |
+
"step": 520
|
321 |
+
},
|
322 |
+
{
|
323 |
+
"epoch": 0.05,
|
324 |
+
"learning_rate": 0.016466666666666668,
|
325 |
+
"loss": 1.2552,
|
326 |
+
"step": 530
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"epoch": 0.05,
|
330 |
+
"learning_rate": 0.016399999999999998,
|
331 |
+
"loss": 1.3816,
|
332 |
+
"step": 540
|
333 |
+
},
|
334 |
+
{
|
335 |
+
"epoch": 0.05,
|
336 |
+
"learning_rate": 0.01633333333333333,
|
337 |
+
"loss": 1.2956,
|
338 |
+
"step": 550
|
339 |
+
},
|
340 |
+
{
|
341 |
+
"epoch": 0.05,
|
342 |
+
"learning_rate": 0.01626666666666667,
|
343 |
+
"loss": 1.2061,
|
344 |
+
"step": 560
|
345 |
+
},
|
346 |
+
{
|
347 |
+
"epoch": 0.05,
|
348 |
+
"learning_rate": 0.016200000000000003,
|
349 |
+
"loss": 1.2086,
|
350 |
+
"step": 570
|
351 |
+
},
|
352 |
+
{
|
353 |
+
"epoch": 0.05,
|
354 |
+
"learning_rate": 0.016133333333333333,
|
355 |
+
"loss": 1.1633,
|
356 |
+
"step": 580
|
357 |
+
},
|
358 |
+
{
|
359 |
+
"epoch": 0.05,
|
360 |
+
"learning_rate": 0.016066666666666667,
|
361 |
+
"loss": 1.2638,
|
362 |
+
"step": 590
|
363 |
+
},
|
364 |
+
{
|
365 |
+
"epoch": 0.06,
|
366 |
+
"learning_rate": 0.016,
|
367 |
+
"loss": 1.3441,
|
368 |
+
"step": 600
|
369 |
+
},
|
370 |
+
{
|
371 |
+
"epoch": 0.06,
|
372 |
+
"learning_rate": 0.015933333333333334,
|
373 |
+
"loss": 1.2924,
|
374 |
+
"step": 610
|
375 |
+
},
|
376 |
+
{
|
377 |
+
"epoch": 0.06,
|
378 |
+
"learning_rate": 0.015866666666666668,
|
379 |
+
"loss": 1.1818,
|
380 |
+
"step": 620
|
381 |
+
},
|
382 |
+
{
|
383 |
+
"epoch": 0.06,
|
384 |
+
"learning_rate": 0.0158,
|
385 |
+
"loss": 1.3918,
|
386 |
+
"step": 630
|
387 |
+
},
|
388 |
+
{
|
389 |
+
"epoch": 0.06,
|
390 |
+
"learning_rate": 0.015733333333333332,
|
391 |
+
"loss": 1.2232,
|
392 |
+
"step": 640
|
393 |
+
},
|
394 |
+
{
|
395 |
+
"epoch": 0.06,
|
396 |
+
"learning_rate": 0.015666666666666666,
|
397 |
+
"loss": 1.2472,
|
398 |
+
"step": 650
|
399 |
+
},
|
400 |
+
{
|
401 |
+
"epoch": 0.06,
|
402 |
+
"learning_rate": 0.015600000000000001,
|
403 |
+
"loss": 1.2398,
|
404 |
+
"step": 660
|
405 |
+
},
|
406 |
+
{
|
407 |
+
"epoch": 0.06,
|
408 |
+
"learning_rate": 0.015533333333333333,
|
409 |
+
"loss": 1.3649,
|
410 |
+
"step": 670
|
411 |
+
},
|
412 |
+
{
|
413 |
+
"epoch": 0.06,
|
414 |
+
"learning_rate": 0.015466666666666667,
|
415 |
+
"loss": 1.2302,
|
416 |
+
"step": 680
|
417 |
+
},
|
418 |
+
{
|
419 |
+
"epoch": 0.06,
|
420 |
+
"learning_rate": 0.0154,
|
421 |
+
"loss": 1.2053,
|
422 |
+
"step": 690
|
423 |
+
},
|
424 |
+
{
|
425 |
+
"epoch": 0.06,
|
426 |
+
"learning_rate": 0.015333333333333334,
|
427 |
+
"loss": 1.2974,
|
428 |
+
"step": 700
|
429 |
+
},
|
430 |
+
{
|
431 |
+
"epoch": 0.07,
|
432 |
+
"learning_rate": 0.015266666666666666,
|
433 |
+
"loss": 1.3036,
|
434 |
+
"step": 710
|
435 |
+
},
|
436 |
+
{
|
437 |
+
"epoch": 0.07,
|
438 |
+
"learning_rate": 0.0152,
|
439 |
+
"loss": 1.3162,
|
440 |
+
"step": 720
|
441 |
+
},
|
442 |
+
{
|
443 |
+
"epoch": 0.07,
|
444 |
+
"learning_rate": 0.015133333333333334,
|
445 |
+
"loss": 1.2567,
|
446 |
+
"step": 730
|
447 |
+
},
|
448 |
+
{
|
449 |
+
"epoch": 0.07,
|
450 |
+
"learning_rate": 0.015066666666666666,
|
451 |
+
"loss": 1.2578,
|
452 |
+
"step": 740
|
453 |
+
},
|
454 |
+
{
|
455 |
+
"epoch": 0.07,
|
456 |
+
"learning_rate": 0.015,
|
457 |
+
"loss": 1.2692,
|
458 |
+
"step": 750
|
459 |
+
},
|
460 |
+
{
|
461 |
+
"epoch": 0.07,
|
462 |
+
"learning_rate": 0.014933333333333335,
|
463 |
+
"loss": 1.1332,
|
464 |
+
"step": 760
|
465 |
+
},
|
466 |
+
{
|
467 |
+
"epoch": 0.07,
|
468 |
+
"learning_rate": 0.014866666666666667,
|
469 |
+
"loss": 1.2949,
|
470 |
+
"step": 770
|
471 |
+
},
|
472 |
+
{
|
473 |
+
"epoch": 0.07,
|
474 |
+
"learning_rate": 0.0148,
|
475 |
+
"loss": 1.2703,
|
476 |
+
"step": 780
|
477 |
+
},
|
478 |
+
{
|
479 |
+
"epoch": 0.07,
|
480 |
+
"learning_rate": 0.014733333333333334,
|
481 |
+
"loss": 1.3891,
|
482 |
+
"step": 790
|
483 |
+
},
|
484 |
+
{
|
485 |
+
"epoch": 0.07,
|
486 |
+
"learning_rate": 0.014666666666666666,
|
487 |
+
"loss": 1.3594,
|
488 |
+
"step": 800
|
489 |
+
},
|
490 |
+
{
|
491 |
+
"epoch": 0.07,
|
492 |
+
"learning_rate": 0.0146,
|
493 |
+
"loss": 1.166,
|
494 |
+
"step": 810
|
495 |
+
},
|
496 |
+
{
|
497 |
+
"epoch": 0.08,
|
498 |
+
"learning_rate": 0.014533333333333334,
|
499 |
+
"loss": 1.3256,
|
500 |
+
"step": 820
|
501 |
+
},
|
502 |
+
{
|
503 |
+
"epoch": 0.08,
|
504 |
+
"learning_rate": 0.014466666666666668,
|
505 |
+
"loss": 1.2669,
|
506 |
+
"step": 830
|
507 |
+
},
|
508 |
+
{
|
509 |
+
"epoch": 0.08,
|
510 |
+
"learning_rate": 0.0144,
|
511 |
+
"loss": 1.241,
|
512 |
+
"step": 840
|
513 |
+
},
|
514 |
+
{
|
515 |
+
"epoch": 0.08,
|
516 |
+
"learning_rate": 0.014333333333333333,
|
517 |
+
"loss": 1.2591,
|
518 |
+
"step": 850
|
519 |
+
},
|
520 |
+
{
|
521 |
+
"epoch": 0.08,
|
522 |
+
"learning_rate": 0.014266666666666667,
|
523 |
+
"loss": 1.238,
|
524 |
+
"step": 860
|
525 |
+
},
|
526 |
+
{
|
527 |
+
"epoch": 0.08,
|
528 |
+
"learning_rate": 0.014199999999999999,
|
529 |
+
"loss": 1.3583,
|
530 |
+
"step": 870
|
531 |
+
},
|
532 |
+
{
|
533 |
+
"epoch": 0.08,
|
534 |
+
"learning_rate": 0.014133333333333333,
|
535 |
+
"loss": 1.164,
|
536 |
+
"step": 880
|
537 |
+
},
|
538 |
+
{
|
539 |
+
"epoch": 0.08,
|
540 |
+
"learning_rate": 0.014066666666666668,
|
541 |
+
"loss": 1.2367,
|
542 |
+
"step": 890
|
543 |
+
},
|
544 |
+
{
|
545 |
+
"epoch": 0.08,
|
546 |
+
"learning_rate": 0.013999999999999999,
|
547 |
+
"loss": 1.1864,
|
548 |
+
"step": 900
|
549 |
+
},
|
550 |
+
{
|
551 |
+
"epoch": 0.08,
|
552 |
+
"learning_rate": 0.013933333333333334,
|
553 |
+
"loss": 1.2259,
|
554 |
+
"step": 910
|
555 |
+
},
|
556 |
+
{
|
557 |
+
"epoch": 0.08,
|
558 |
+
"learning_rate": 0.013866666666666668,
|
559 |
+
"loss": 1.2129,
|
560 |
+
"step": 920
|
561 |
+
},
|
562 |
+
{
|
563 |
+
"epoch": 0.09,
|
564 |
+
"learning_rate": 0.0138,
|
565 |
+
"loss": 1.2085,
|
566 |
+
"step": 930
|
567 |
+
},
|
568 |
+
{
|
569 |
+
"epoch": 0.09,
|
570 |
+
"learning_rate": 0.013733333333333334,
|
571 |
+
"loss": 1.2316,
|
572 |
+
"step": 940
|
573 |
+
},
|
574 |
+
{
|
575 |
+
"epoch": 0.09,
|
576 |
+
"learning_rate": 0.013666666666666667,
|
577 |
+
"loss": 1.2721,
|
578 |
+
"step": 950
|
579 |
+
},
|
580 |
+
{
|
581 |
+
"epoch": 0.09,
|
582 |
+
"learning_rate": 0.013600000000000001,
|
583 |
+
"loss": 1.2428,
|
584 |
+
"step": 960
|
585 |
+
},
|
586 |
+
{
|
587 |
+
"epoch": 0.09,
|
588 |
+
"learning_rate": 0.013533333333333333,
|
589 |
+
"loss": 1.2126,
|
590 |
+
"step": 970
|
591 |
+
},
|
592 |
+
{
|
593 |
+
"epoch": 0.09,
|
594 |
+
"learning_rate": 0.013466666666666667,
|
595 |
+
"loss": 1.1583,
|
596 |
+
"step": 980
|
597 |
+
},
|
598 |
+
{
|
599 |
+
"epoch": 0.09,
|
600 |
+
"learning_rate": 0.0134,
|
601 |
+
"loss": 1.2776,
|
602 |
+
"step": 990
|
603 |
+
},
|
604 |
+
{
|
605 |
+
"epoch": 0.09,
|
606 |
+
"learning_rate": 0.013333333333333332,
|
607 |
+
"loss": 1.2317,
|
608 |
+
"step": 1000
|
609 |
+
},
|
610 |
+
{
|
611 |
+
"epoch": 0.09,
|
612 |
+
"learning_rate": 0.013266666666666666,
|
613 |
+
"loss": 1.2047,
|
614 |
+
"step": 1010
|
615 |
+
},
|
616 |
+
{
|
617 |
+
"epoch": 0.09,
|
618 |
+
"learning_rate": 0.013200000000000002,
|
619 |
+
"loss": 1.202,
|
620 |
+
"step": 1020
|
621 |
+
},
|
622 |
+
{
|
623 |
+
"epoch": 0.1,
|
624 |
+
"learning_rate": 0.013133333333333332,
|
625 |
+
"loss": 1.1877,
|
626 |
+
"step": 1030
|
627 |
+
},
|
628 |
+
{
|
629 |
+
"epoch": 0.1,
|
630 |
+
"learning_rate": 0.013066666666666667,
|
631 |
+
"loss": 1.3071,
|
632 |
+
"step": 1040
|
633 |
+
},
|
634 |
+
{
|
635 |
+
"epoch": 0.1,
|
636 |
+
"learning_rate": 0.013000000000000001,
|
637 |
+
"loss": 1.2976,
|
638 |
+
"step": 1050
|
639 |
+
},
|
640 |
+
{
|
641 |
+
"epoch": 0.1,
|
642 |
+
"learning_rate": 0.012933333333333333,
|
643 |
+
"loss": 1.4156,
|
644 |
+
"step": 1060
|
645 |
+
},
|
646 |
+
{
|
647 |
+
"epoch": 0.1,
|
648 |
+
"learning_rate": 0.012866666666666667,
|
649 |
+
"loss": 1.173,
|
650 |
+
"step": 1070
|
651 |
+
},
|
652 |
+
{
|
653 |
+
"epoch": 0.1,
|
654 |
+
"learning_rate": 0.0128,
|
655 |
+
"loss": 1.2263,
|
656 |
+
"step": 1080
|
657 |
+
},
|
658 |
+
{
|
659 |
+
"epoch": 0.1,
|
660 |
+
"learning_rate": 0.012733333333333334,
|
661 |
+
"loss": 1.3235,
|
662 |
+
"step": 1090
|
663 |
+
},
|
664 |
+
{
|
665 |
+
"epoch": 0.1,
|
666 |
+
"learning_rate": 0.012666666666666666,
|
667 |
+
"loss": 1.1923,
|
668 |
+
"step": 1100
|
669 |
+
},
|
670 |
+
{
|
671 |
+
"epoch": 0.1,
|
672 |
+
"learning_rate": 0.0126,
|
673 |
+
"loss": 1.2879,
|
674 |
+
"step": 1110
|
675 |
+
},
|
676 |
+
{
|
677 |
+
"epoch": 0.1,
|
678 |
+
"learning_rate": 0.012533333333333334,
|
679 |
+
"loss": 1.196,
|
680 |
+
"step": 1120
|
681 |
+
},
|
682 |
+
{
|
683 |
+
"epoch": 0.1,
|
684 |
+
"learning_rate": 0.012466666666666666,
|
685 |
+
"loss": 1.2605,
|
686 |
+
"step": 1130
|
687 |
+
},
|
688 |
+
{
|
689 |
+
"epoch": 0.11,
|
690 |
+
"learning_rate": 0.0124,
|
691 |
+
"loss": 1.2303,
|
692 |
+
"step": 1140
|
693 |
+
},
|
694 |
+
{
|
695 |
+
"epoch": 0.11,
|
696 |
+
"learning_rate": 0.012333333333333335,
|
697 |
+
"loss": 1.2381,
|
698 |
+
"step": 1150
|
699 |
+
},
|
700 |
+
{
|
701 |
+
"epoch": 0.11,
|
702 |
+
"learning_rate": 0.012266666666666665,
|
703 |
+
"loss": 1.2709,
|
704 |
+
"step": 1160
|
705 |
+
},
|
706 |
+
{
|
707 |
+
"epoch": 0.11,
|
708 |
+
"learning_rate": 0.0122,
|
709 |
+
"loss": 1.2121,
|
710 |
+
"step": 1170
|
711 |
+
},
|
712 |
+
{
|
713 |
+
"epoch": 0.11,
|
714 |
+
"learning_rate": 0.012133333333333335,
|
715 |
+
"loss": 1.3713,
|
716 |
+
"step": 1180
|
717 |
+
},
|
718 |
+
{
|
719 |
+
"epoch": 0.11,
|
720 |
+
"learning_rate": 0.012066666666666668,
|
721 |
+
"loss": 1.2923,
|
722 |
+
"step": 1190
|
723 |
+
},
|
724 |
+
{
|
725 |
+
"epoch": 0.11,
|
726 |
+
"learning_rate": 0.012,
|
727 |
+
"loss": 1.2947,
|
728 |
+
"step": 1200
|
729 |
+
},
|
730 |
+
{
|
731 |
+
"epoch": 0.11,
|
732 |
+
"learning_rate": 0.011933333333333334,
|
733 |
+
"loss": 1.1538,
|
734 |
+
"step": 1210
|
735 |
+
},
|
736 |
+
{
|
737 |
+
"epoch": 0.11,
|
738 |
+
"learning_rate": 0.011866666666666668,
|
739 |
+
"loss": 1.1312,
|
740 |
+
"step": 1220
|
741 |
+
},
|
742 |
+
{
|
743 |
+
"epoch": 0.11,
|
744 |
+
"learning_rate": 0.0118,
|
745 |
+
"loss": 1.1807,
|
746 |
+
"step": 1230
|
747 |
+
},
|
748 |
+
{
|
749 |
+
"epoch": 0.11,
|
750 |
+
"learning_rate": 0.011733333333333333,
|
751 |
+
"loss": 1.2729,
|
752 |
+
"step": 1240
|
753 |
+
},
|
754 |
+
{
|
755 |
+
"epoch": 0.12,
|
756 |
+
"learning_rate": 0.011666666666666667,
|
757 |
+
"loss": 1.21,
|
758 |
+
"step": 1250
|
759 |
+
},
|
760 |
+
{
|
761 |
+
"epoch": 0.12,
|
762 |
+
"learning_rate": 0.0116,
|
763 |
+
"loss": 1.1986,
|
764 |
+
"step": 1260
|
765 |
+
},
|
766 |
+
{
|
767 |
+
"epoch": 0.12,
|
768 |
+
"learning_rate": 0.011533333333333333,
|
769 |
+
"loss": 1.2003,
|
770 |
+
"step": 1270
|
771 |
+
},
|
772 |
+
{
|
773 |
+
"epoch": 0.12,
|
774 |
+
"learning_rate": 0.011466666666666667,
|
775 |
+
"loss": 1.1773,
|
776 |
+
"step": 1280
|
777 |
+
},
|
778 |
+
{
|
779 |
+
"epoch": 0.12,
|
780 |
+
"learning_rate": 0.011399999999999999,
|
781 |
+
"loss": 1.3241,
|
782 |
+
"step": 1290
|
783 |
+
},
|
784 |
+
{
|
785 |
+
"epoch": 0.12,
|
786 |
+
"learning_rate": 0.011333333333333332,
|
787 |
+
"loss": 1.2157,
|
788 |
+
"step": 1300
|
789 |
+
},
|
790 |
+
{
|
791 |
+
"epoch": 0.12,
|
792 |
+
"learning_rate": 0.011266666666666668,
|
793 |
+
"loss": 1.2549,
|
794 |
+
"step": 1310
|
795 |
+
},
|
796 |
+
{
|
797 |
+
"epoch": 0.12,
|
798 |
+
"learning_rate": 0.011200000000000002,
|
799 |
+
"loss": 1.3245,
|
800 |
+
"step": 1320
|
801 |
+
},
|
802 |
+
{
|
803 |
+
"epoch": 0.12,
|
804 |
+
"learning_rate": 0.011133333333333334,
|
805 |
+
"loss": 1.2109,
|
806 |
+
"step": 1330
|
807 |
+
},
|
808 |
+
{
|
809 |
+
"epoch": 0.12,
|
810 |
+
"learning_rate": 0.011066666666666667,
|
811 |
+
"loss": 1.1979,
|
812 |
+
"step": 1340
|
813 |
+
},
|
814 |
+
{
|
815 |
+
"epoch": 0.12,
|
816 |
+
"learning_rate": 0.011000000000000001,
|
817 |
+
"loss": 1.2804,
|
818 |
+
"step": 1350
|
819 |
+
},
|
820 |
+
{
|
821 |
+
"epoch": 0.13,
|
822 |
+
"learning_rate": 0.010933333333333333,
|
823 |
+
"loss": 1.2655,
|
824 |
+
"step": 1360
|
825 |
+
},
|
826 |
+
{
|
827 |
+
"epoch": 0.13,
|
828 |
+
"learning_rate": 0.010866666666666667,
|
829 |
+
"loss": 1.1264,
|
830 |
+
"step": 1370
|
831 |
+
},
|
832 |
+
{
|
833 |
+
"epoch": 0.13,
|
834 |
+
"learning_rate": 0.0108,
|
835 |
+
"loss": 1.2949,
|
836 |
+
"step": 1380
|
837 |
+
},
|
838 |
+
{
|
839 |
+
"epoch": 0.13,
|
840 |
+
"learning_rate": 0.010733333333333333,
|
841 |
+
"loss": 1.2038,
|
842 |
+
"step": 1390
|
843 |
+
},
|
844 |
+
{
|
845 |
+
"epoch": 0.13,
|
846 |
+
"learning_rate": 0.010666666666666666,
|
847 |
+
"loss": 1.2514,
|
848 |
+
"step": 1400
|
849 |
+
},
|
850 |
+
{
|
851 |
+
"epoch": 0.13,
|
852 |
+
"learning_rate": 0.0106,
|
853 |
+
"loss": 1.1692,
|
854 |
+
"step": 1410
|
855 |
+
},
|
856 |
+
{
|
857 |
+
"epoch": 0.13,
|
858 |
+
"learning_rate": 0.010533333333333332,
|
859 |
+
"loss": 1.1947,
|
860 |
+
"step": 1420
|
861 |
+
},
|
862 |
+
{
|
863 |
+
"epoch": 0.13,
|
864 |
+
"learning_rate": 0.010466666666666666,
|
865 |
+
"loss": 1.3294,
|
866 |
+
"step": 1430
|
867 |
+
},
|
868 |
+
{
|
869 |
+
"epoch": 0.13,
|
870 |
+
"learning_rate": 0.010400000000000001,
|
871 |
+
"loss": 1.2169,
|
872 |
+
"step": 1440
|
873 |
+
},
|
874 |
+
{
|
875 |
+
"epoch": 0.13,
|
876 |
+
"learning_rate": 0.010333333333333335,
|
877 |
+
"loss": 1.3113,
|
878 |
+
"step": 1450
|
879 |
+
},
|
880 |
+
{
|
881 |
+
"epoch": 0.13,
|
882 |
+
"learning_rate": 0.010266666666666667,
|
883 |
+
"loss": 1.1322,
|
884 |
+
"step": 1460
|
885 |
+
},
|
886 |
+
{
|
887 |
+
"epoch": 0.14,
|
888 |
+
"learning_rate": 0.0102,
|
889 |
+
"loss": 1.4228,
|
890 |
+
"step": 1470
|
891 |
+
},
|
892 |
+
{
|
893 |
+
"epoch": 0.14,
|
894 |
+
"learning_rate": 0.010133333333333334,
|
895 |
+
"loss": 1.2384,
|
896 |
+
"step": 1480
|
897 |
+
},
|
898 |
+
{
|
899 |
+
"epoch": 0.14,
|
900 |
+
"learning_rate": 0.010066666666666666,
|
901 |
+
"loss": 1.2107,
|
902 |
+
"step": 1490
|
903 |
+
},
|
904 |
+
{
|
905 |
+
"epoch": 0.14,
|
906 |
+
"learning_rate": 0.01,
|
907 |
+
"loss": 1.2655,
|
908 |
+
"step": 1500
|
909 |
+
},
|
910 |
+
{
|
911 |
+
"epoch": 0.14,
|
912 |
+
"learning_rate": 0.009933333333333334,
|
913 |
+
"loss": 1.2991,
|
914 |
+
"step": 1510
|
915 |
+
},
|
916 |
+
{
|
917 |
+
"epoch": 0.14,
|
918 |
+
"learning_rate": 0.009866666666666668,
|
919 |
+
"loss": 1.324,
|
920 |
+
"step": 1520
|
921 |
+
},
|
922 |
+
{
|
923 |
+
"epoch": 0.14,
|
924 |
+
"learning_rate": 0.0098,
|
925 |
+
"loss": 1.3443,
|
926 |
+
"step": 1530
|
927 |
+
},
|
928 |
+
{
|
929 |
+
"epoch": 0.14,
|
930 |
+
"learning_rate": 0.009733333333333333,
|
931 |
+
"loss": 1.1389,
|
932 |
+
"step": 1540
|
933 |
+
},
|
934 |
+
{
|
935 |
+
"epoch": 0.14,
|
936 |
+
"learning_rate": 0.009666666666666667,
|
937 |
+
"loss": 1.2308,
|
938 |
+
"step": 1550
|
939 |
+
},
|
940 |
+
{
|
941 |
+
"epoch": 0.14,
|
942 |
+
"learning_rate": 0.0096,
|
943 |
+
"loss": 1.1847,
|
944 |
+
"step": 1560
|
945 |
+
},
|
946 |
+
{
|
947 |
+
"epoch": 0.15,
|
948 |
+
"learning_rate": 0.009533333333333335,
|
949 |
+
"loss": 1.3154,
|
950 |
+
"step": 1570
|
951 |
+
},
|
952 |
+
{
|
953 |
+
"epoch": 0.15,
|
954 |
+
"learning_rate": 0.009466666666666667,
|
955 |
+
"loss": 1.233,
|
956 |
+
"step": 1580
|
957 |
+
},
|
958 |
+
{
|
959 |
+
"epoch": 0.15,
|
960 |
+
"learning_rate": 0.0094,
|
961 |
+
"loss": 1.147,
|
962 |
+
"step": 1590
|
963 |
+
},
|
964 |
+
{
|
965 |
+
"epoch": 0.15,
|
966 |
+
"learning_rate": 0.009333333333333334,
|
967 |
+
"loss": 1.1824,
|
968 |
+
"step": 1600
|
969 |
+
},
|
970 |
+
{
|
971 |
+
"epoch": 0.15,
|
972 |
+
"learning_rate": 0.009266666666666666,
|
973 |
+
"loss": 1.2093,
|
974 |
+
"step": 1610
|
975 |
+
},
|
976 |
+
{
|
977 |
+
"epoch": 0.15,
|
978 |
+
"learning_rate": 0.0092,
|
979 |
+
"loss": 1.2111,
|
980 |
+
"step": 1620
|
981 |
+
},
|
982 |
+
{
|
983 |
+
"epoch": 0.15,
|
984 |
+
"learning_rate": 0.009133333333333334,
|
985 |
+
"loss": 1.0596,
|
986 |
+
"step": 1630
|
987 |
+
},
|
988 |
+
{
|
989 |
+
"epoch": 0.15,
|
990 |
+
"learning_rate": 0.009066666666666666,
|
991 |
+
"loss": 1.3025,
|
992 |
+
"step": 1640
|
993 |
+
},
|
994 |
+
{
|
995 |
+
"epoch": 0.15,
|
996 |
+
"learning_rate": 0.009000000000000001,
|
997 |
+
"loss": 1.1726,
|
998 |
+
"step": 1650
|
999 |
+
},
|
1000 |
+
{
|
1001 |
+
"epoch": 0.15,
|
1002 |
+
"learning_rate": 0.008933333333333333,
|
1003 |
+
"loss": 1.2078,
|
1004 |
+
"step": 1660
|
1005 |
+
},
|
1006 |
+
{
|
1007 |
+
"epoch": 0.15,
|
1008 |
+
"learning_rate": 0.008866666666666667,
|
1009 |
+
"loss": 1.2652,
|
1010 |
+
"step": 1670
|
1011 |
+
},
|
1012 |
+
{
|
1013 |
+
"epoch": 0.16,
|
1014 |
+
"learning_rate": 0.0088,
|
1015 |
+
"loss": 1.2033,
|
1016 |
+
"step": 1680
|
1017 |
+
},
|
1018 |
+
{
|
1019 |
+
"epoch": 0.16,
|
1020 |
+
"learning_rate": 0.008733333333333333,
|
1021 |
+
"loss": 1.1598,
|
1022 |
+
"step": 1690
|
1023 |
+
},
|
1024 |
+
{
|
1025 |
+
"epoch": 0.16,
|
1026 |
+
"learning_rate": 0.008666666666666668,
|
1027 |
+
"loss": 1.1904,
|
1028 |
+
"step": 1700
|
1029 |
+
},
|
1030 |
+
{
|
1031 |
+
"epoch": 0.16,
|
1032 |
+
"learning_rate": 0.0086,
|
1033 |
+
"loss": 1.242,
|
1034 |
+
"step": 1710
|
1035 |
+
},
|
1036 |
+
{
|
1037 |
+
"epoch": 0.16,
|
1038 |
+
"learning_rate": 0.008533333333333334,
|
1039 |
+
"loss": 1.3042,
|
1040 |
+
"step": 1720
|
1041 |
+
},
|
1042 |
+
{
|
1043 |
+
"epoch": 0.16,
|
1044 |
+
"learning_rate": 0.008466666666666667,
|
1045 |
+
"loss": 1.3653,
|
1046 |
+
"step": 1730
|
1047 |
+
},
|
1048 |
+
{
|
1049 |
+
"epoch": 0.16,
|
1050 |
+
"learning_rate": 0.0084,
|
1051 |
+
"loss": 1.1784,
|
1052 |
+
"step": 1740
|
1053 |
+
},
|
1054 |
+
{
|
1055 |
+
"epoch": 0.16,
|
1056 |
+
"learning_rate": 0.008333333333333333,
|
1057 |
+
"loss": 1.2306,
|
1058 |
+
"step": 1750
|
1059 |
+
},
|
1060 |
+
{
|
1061 |
+
"epoch": 0.16,
|
1062 |
+
"learning_rate": 0.008266666666666667,
|
1063 |
+
"loss": 1.2139,
|
1064 |
+
"step": 1760
|
1065 |
+
},
|
1066 |
+
{
|
1067 |
+
"epoch": 0.16,
|
1068 |
+
"learning_rate": 0.008199999999999999,
|
1069 |
+
"loss": 1.1891,
|
1070 |
+
"step": 1770
|
1071 |
+
},
|
1072 |
+
{
|
1073 |
+
"epoch": 0.16,
|
1074 |
+
"learning_rate": 0.008133333333333334,
|
1075 |
+
"loss": 1.2619,
|
1076 |
+
"step": 1780
|
1077 |
+
},
|
1078 |
+
{
|
1079 |
+
"epoch": 0.17,
|
1080 |
+
"learning_rate": 0.008066666666666666,
|
1081 |
+
"loss": 1.0873,
|
1082 |
+
"step": 1790
|
1083 |
+
},
|
1084 |
+
{
|
1085 |
+
"epoch": 0.17,
|
1086 |
+
"learning_rate": 0.008,
|
1087 |
+
"loss": 1.2537,
|
1088 |
+
"step": 1800
|
1089 |
+
},
|
1090 |
+
{
|
1091 |
+
"epoch": 0.17,
|
1092 |
+
"learning_rate": 0.007933333333333334,
|
1093 |
+
"loss": 1.2575,
|
1094 |
+
"step": 1810
|
1095 |
+
},
|
1096 |
+
{
|
1097 |
+
"epoch": 0.17,
|
1098 |
+
"learning_rate": 0.007866666666666666,
|
1099 |
+
"loss": 1.1043,
|
1100 |
+
"step": 1820
|
1101 |
+
},
|
1102 |
+
{
|
1103 |
+
"epoch": 0.17,
|
1104 |
+
"learning_rate": 0.0078000000000000005,
|
1105 |
+
"loss": 1.2063,
|
1106 |
+
"step": 1830
|
1107 |
+
},
|
1108 |
+
{
|
1109 |
+
"epoch": 0.17,
|
1110 |
+
"learning_rate": 0.007733333333333333,
|
1111 |
+
"loss": 1.1602,
|
1112 |
+
"step": 1840
|
1113 |
+
},
|
1114 |
+
{
|
1115 |
+
"epoch": 0.17,
|
1116 |
+
"learning_rate": 0.007666666666666667,
|
1117 |
+
"loss": 1.1474,
|
1118 |
+
"step": 1850
|
1119 |
+
},
|
1120 |
+
{
|
1121 |
+
"epoch": 0.17,
|
1122 |
+
"learning_rate": 0.0076,
|
1123 |
+
"loss": 1.1482,
|
1124 |
+
"step": 1860
|
1125 |
+
},
|
1126 |
+
{
|
1127 |
+
"epoch": 0.17,
|
1128 |
+
"learning_rate": 0.007533333333333333,
|
1129 |
+
"loss": 1.2124,
|
1130 |
+
"step": 1870
|
1131 |
+
},
|
1132 |
+
{
|
1133 |
+
"epoch": 0.17,
|
1134 |
+
"learning_rate": 0.0074666666666666675,
|
1135 |
+
"loss": 1.195,
|
1136 |
+
"step": 1880
|
1137 |
+
},
|
1138 |
+
{
|
1139 |
+
"epoch": 0.17,
|
1140 |
+
"learning_rate": 0.0074,
|
1141 |
+
"loss": 1.1426,
|
1142 |
+
"step": 1890
|
1143 |
+
},
|
1144 |
+
{
|
1145 |
+
"epoch": 0.18,
|
1146 |
+
"learning_rate": 0.007333333333333333,
|
1147 |
+
"loss": 1.2067,
|
1148 |
+
"step": 1900
|
1149 |
+
},
|
1150 |
+
{
|
1151 |
+
"epoch": 0.18,
|
1152 |
+
"learning_rate": 0.007266666666666667,
|
1153 |
+
"loss": 1.1649,
|
1154 |
+
"step": 1910
|
1155 |
+
},
|
1156 |
+
{
|
1157 |
+
"epoch": 0.18,
|
1158 |
+
"learning_rate": 0.0072,
|
1159 |
+
"loss": 1.0978,
|
1160 |
+
"step": 1920
|
1161 |
+
},
|
1162 |
+
{
|
1163 |
+
"epoch": 0.18,
|
1164 |
+
"learning_rate": 0.0071333333333333335,
|
1165 |
+
"loss": 1.2298,
|
1166 |
+
"step": 1930
|
1167 |
+
},
|
1168 |
+
{
|
1169 |
+
"epoch": 0.18,
|
1170 |
+
"learning_rate": 0.007066666666666666,
|
1171 |
+
"loss": 1.195,
|
1172 |
+
"step": 1940
|
1173 |
+
},
|
1174 |
+
{
|
1175 |
+
"epoch": 0.18,
|
1176 |
+
"learning_rate": 0.006999999999999999,
|
1177 |
+
"loss": 1.2032,
|
1178 |
+
"step": 1950
|
1179 |
+
},
|
1180 |
+
{
|
1181 |
+
"epoch": 0.18,
|
1182 |
+
"learning_rate": 0.006933333333333334,
|
1183 |
+
"loss": 1.1134,
|
1184 |
+
"step": 1960
|
1185 |
+
},
|
1186 |
+
{
|
1187 |
+
"epoch": 0.18,
|
1188 |
+
"learning_rate": 0.006866666666666667,
|
1189 |
+
"loss": 1.2925,
|
1190 |
+
"step": 1970
|
1191 |
+
},
|
1192 |
+
{
|
1193 |
+
"epoch": 0.18,
|
1194 |
+
"learning_rate": 0.0068000000000000005,
|
1195 |
+
"loss": 1.1389,
|
1196 |
+
"step": 1980
|
1197 |
+
},
|
1198 |
+
{
|
1199 |
+
"epoch": 0.18,
|
1200 |
+
"learning_rate": 0.006733333333333333,
|
1201 |
+
"loss": 1.1952,
|
1202 |
+
"step": 1990
|
1203 |
+
},
|
1204 |
+
{
|
1205 |
+
"epoch": 0.18,
|
1206 |
+
"learning_rate": 0.006666666666666666,
|
1207 |
+
"loss": 1.0672,
|
1208 |
+
"step": 2000
|
1209 |
+
},
|
1210 |
+
{
|
1211 |
+
"epoch": 0.19,
|
1212 |
+
"learning_rate": 0.006600000000000001,
|
1213 |
+
"loss": 1.2243,
|
1214 |
+
"step": 2010
|
1215 |
+
},
|
1216 |
+
{
|
1217 |
+
"epoch": 0.19,
|
1218 |
+
"learning_rate": 0.006533333333333334,
|
1219 |
+
"loss": 1.218,
|
1220 |
+
"step": 2020
|
1221 |
+
},
|
1222 |
+
{
|
1223 |
+
"epoch": 0.19,
|
1224 |
+
"learning_rate": 0.006466666666666667,
|
1225 |
+
"loss": 1.1988,
|
1226 |
+
"step": 2030
|
1227 |
+
},
|
1228 |
+
{
|
1229 |
+
"epoch": 0.19,
|
1230 |
+
"learning_rate": 0.0064,
|
1231 |
+
"loss": 1.1776,
|
1232 |
+
"step": 2040
|
1233 |
+
},
|
1234 |
+
{
|
1235 |
+
"epoch": 0.19,
|
1236 |
+
"learning_rate": 0.006333333333333333,
|
1237 |
+
"loss": 1.1506,
|
1238 |
+
"step": 2050
|
1239 |
+
},
|
1240 |
+
{
|
1241 |
+
"epoch": 0.19,
|
1242 |
+
"learning_rate": 0.006266666666666667,
|
1243 |
+
"loss": 1.0386,
|
1244 |
+
"step": 2060
|
1245 |
+
},
|
1246 |
+
{
|
1247 |
+
"epoch": 0.19,
|
1248 |
+
"learning_rate": 0.0062,
|
1249 |
+
"loss": 1.2601,
|
1250 |
+
"step": 2070
|
1251 |
+
},
|
1252 |
+
{
|
1253 |
+
"epoch": 0.19,
|
1254 |
+
"learning_rate": 0.006133333333333333,
|
1255 |
+
"loss": 1.058,
|
1256 |
+
"step": 2080
|
1257 |
+
},
|
1258 |
+
{
|
1259 |
+
"epoch": 0.19,
|
1260 |
+
"learning_rate": 0.006066666666666667,
|
1261 |
+
"loss": 1.2243,
|
1262 |
+
"step": 2090
|
1263 |
+
},
|
1264 |
+
{
|
1265 |
+
"epoch": 0.19,
|
1266 |
+
"learning_rate": 0.006,
|
1267 |
+
"loss": 1.2445,
|
1268 |
+
"step": 2100
|
1269 |
+
},
|
1270 |
+
{
|
1271 |
+
"epoch": 0.19,
|
1272 |
+
"learning_rate": 0.005933333333333334,
|
1273 |
+
"loss": 1.2567,
|
1274 |
+
"step": 2110
|
1275 |
+
},
|
1276 |
+
{
|
1277 |
+
"epoch": 0.2,
|
1278 |
+
"learning_rate": 0.005866666666666667,
|
1279 |
+
"loss": 1.1815,
|
1280 |
+
"step": 2120
|
1281 |
+
},
|
1282 |
+
{
|
1283 |
+
"epoch": 0.2,
|
1284 |
+
"learning_rate": 0.0058,
|
1285 |
+
"loss": 1.3061,
|
1286 |
+
"step": 2130
|
1287 |
+
},
|
1288 |
+
{
|
1289 |
+
"epoch": 0.2,
|
1290 |
+
"learning_rate": 0.005733333333333333,
|
1291 |
+
"loss": 1.3064,
|
1292 |
+
"step": 2140
|
1293 |
+
},
|
1294 |
+
{
|
1295 |
+
"epoch": 0.2,
|
1296 |
+
"learning_rate": 0.005666666666666666,
|
1297 |
+
"loss": 1.2739,
|
1298 |
+
"step": 2150
|
1299 |
+
},
|
1300 |
+
{
|
1301 |
+
"epoch": 0.2,
|
1302 |
+
"learning_rate": 0.005600000000000001,
|
1303 |
+
"loss": 1.2754,
|
1304 |
+
"step": 2160
|
1305 |
+
},
|
1306 |
+
{
|
1307 |
+
"epoch": 0.2,
|
1308 |
+
"learning_rate": 0.005533333333333334,
|
1309 |
+
"loss": 1.1678,
|
1310 |
+
"step": 2170
|
1311 |
+
},
|
1312 |
+
{
|
1313 |
+
"epoch": 0.2,
|
1314 |
+
"learning_rate": 0.0054666666666666665,
|
1315 |
+
"loss": 1.191,
|
1316 |
+
"step": 2180
|
1317 |
+
},
|
1318 |
+
{
|
1319 |
+
"epoch": 0.2,
|
1320 |
+
"learning_rate": 0.0054,
|
1321 |
+
"loss": 1.2127,
|
1322 |
+
"step": 2190
|
1323 |
+
},
|
1324 |
+
{
|
1325 |
+
"epoch": 0.2,
|
1326 |
+
"learning_rate": 0.005333333333333333,
|
1327 |
+
"loss": 1.3057,
|
1328 |
+
"step": 2200
|
1329 |
+
},
|
1330 |
+
{
|
1331 |
+
"epoch": 0.2,
|
1332 |
+
"learning_rate": 0.005266666666666666,
|
1333 |
+
"loss": 1.1092,
|
1334 |
+
"step": 2210
|
1335 |
+
},
|
1336 |
+
{
|
1337 |
+
"epoch": 0.21,
|
1338 |
+
"learning_rate": 0.005200000000000001,
|
1339 |
+
"loss": 1.1615,
|
1340 |
+
"step": 2220
|
1341 |
+
},
|
1342 |
+
{
|
1343 |
+
"epoch": 0.21,
|
1344 |
+
"learning_rate": 0.0051333333333333335,
|
1345 |
+
"loss": 1.1769,
|
1346 |
+
"step": 2230
|
1347 |
+
},
|
1348 |
+
{
|
1349 |
+
"epoch": 0.21,
|
1350 |
+
"learning_rate": 0.005066666666666667,
|
1351 |
+
"loss": 1.1396,
|
1352 |
+
"step": 2240
|
1353 |
+
},
|
1354 |
+
{
|
1355 |
+
"epoch": 0.21,
|
1356 |
+
"learning_rate": 0.005,
|
1357 |
+
"loss": 1.1663,
|
1358 |
+
"step": 2250
|
1359 |
+
},
|
1360 |
+
{
|
1361 |
+
"epoch": 0.21,
|
1362 |
+
"learning_rate": 0.004933333333333334,
|
1363 |
+
"loss": 1.0931,
|
1364 |
+
"step": 2260
|
1365 |
+
},
|
1366 |
+
{
|
1367 |
+
"epoch": 0.21,
|
1368 |
+
"learning_rate": 0.004866666666666667,
|
1369 |
+
"loss": 1.1143,
|
1370 |
+
"step": 2270
|
1371 |
+
},
|
1372 |
+
{
|
1373 |
+
"epoch": 0.21,
|
1374 |
+
"learning_rate": 0.0048,
|
1375 |
+
"loss": 1.1891,
|
1376 |
+
"step": 2280
|
1377 |
+
},
|
1378 |
+
{
|
1379 |
+
"epoch": 0.21,
|
1380 |
+
"learning_rate": 0.004733333333333333,
|
1381 |
+
"loss": 1.1636,
|
1382 |
+
"step": 2290
|
1383 |
+
},
|
1384 |
+
{
|
1385 |
+
"epoch": 0.21,
|
1386 |
+
"learning_rate": 0.004666666666666667,
|
1387 |
+
"loss": 1.1777,
|
1388 |
+
"step": 2300
|
1389 |
+
},
|
1390 |
+
{
|
1391 |
+
"epoch": 0.21,
|
1392 |
+
"learning_rate": 0.0046,
|
1393 |
+
"loss": 1.1933,
|
1394 |
+
"step": 2310
|
1395 |
+
},
|
1396 |
+
{
|
1397 |
+
"epoch": 0.21,
|
1398 |
+
"learning_rate": 0.004533333333333333,
|
1399 |
+
"loss": 1.1606,
|
1400 |
+
"step": 2320
|
1401 |
+
},
|
1402 |
+
{
|
1403 |
+
"epoch": 0.22,
|
1404 |
+
"learning_rate": 0.0044666666666666665,
|
1405 |
+
"loss": 1.2233,
|
1406 |
+
"step": 2330
|
1407 |
+
},
|
1408 |
+
{
|
1409 |
+
"epoch": 0.22,
|
1410 |
+
"learning_rate": 0.0044,
|
1411 |
+
"loss": 1.2237,
|
1412 |
+
"step": 2340
|
1413 |
+
},
|
1414 |
+
{
|
1415 |
+
"epoch": 0.22,
|
1416 |
+
"learning_rate": 0.004333333333333334,
|
1417 |
+
"loss": 1.2323,
|
1418 |
+
"step": 2350
|
1419 |
+
},
|
1420 |
+
{
|
1421 |
+
"epoch": 0.22,
|
1422 |
+
"learning_rate": 0.004266666666666667,
|
1423 |
+
"loss": 1.0837,
|
1424 |
+
"step": 2360
|
1425 |
+
},
|
1426 |
+
{
|
1427 |
+
"epoch": 0.22,
|
1428 |
+
"learning_rate": 0.0042,
|
1429 |
+
"loss": 1.1411,
|
1430 |
+
"step": 2370
|
1431 |
+
},
|
1432 |
+
{
|
1433 |
+
"epoch": 0.22,
|
1434 |
+
"learning_rate": 0.0041333333333333335,
|
1435 |
+
"loss": 1.0772,
|
1436 |
+
"step": 2380
|
1437 |
+
},
|
1438 |
+
{
|
1439 |
+
"epoch": 0.22,
|
1440 |
+
"learning_rate": 0.004066666666666667,
|
1441 |
+
"loss": 1.1952,
|
1442 |
+
"step": 2390
|
1443 |
+
},
|
1444 |
+
{
|
1445 |
+
"epoch": 0.22,
|
1446 |
+
"learning_rate": 0.004,
|
1447 |
+
"loss": 1.1267,
|
1448 |
+
"step": 2400
|
1449 |
+
},
|
1450 |
+
{
|
1451 |
+
"epoch": 0.22,
|
1452 |
+
"learning_rate": 0.003933333333333333,
|
1453 |
+
"loss": 1.2142,
|
1454 |
+
"step": 2410
|
1455 |
+
},
|
1456 |
+
{
|
1457 |
+
"epoch": 0.22,
|
1458 |
+
"learning_rate": 0.0038666666666666667,
|
1459 |
+
"loss": 1.2375,
|
1460 |
+
"step": 2420
|
1461 |
+
},
|
1462 |
+
{
|
1463 |
+
"epoch": 0.22,
|
1464 |
+
"learning_rate": 0.0038,
|
1465 |
+
"loss": 1.1964,
|
1466 |
+
"step": 2430
|
1467 |
+
},
|
1468 |
+
{
|
1469 |
+
"epoch": 0.23,
|
1470 |
+
"learning_rate": 0.0037333333333333337,
|
1471 |
+
"loss": 1.1305,
|
1472 |
+
"step": 2440
|
1473 |
+
},
|
1474 |
+
{
|
1475 |
+
"epoch": 0.23,
|
1476 |
+
"learning_rate": 0.0036666666666666666,
|
1477 |
+
"loss": 1.1478,
|
1478 |
+
"step": 2450
|
1479 |
+
},
|
1480 |
+
{
|
1481 |
+
"epoch": 0.23,
|
1482 |
+
"learning_rate": 0.0036,
|
1483 |
+
"loss": 1.1542,
|
1484 |
+
"step": 2460
|
1485 |
+
},
|
1486 |
+
{
|
1487 |
+
"epoch": 0.23,
|
1488 |
+
"learning_rate": 0.003533333333333333,
|
1489 |
+
"loss": 1.1168,
|
1490 |
+
"step": 2470
|
1491 |
+
},
|
1492 |
+
{
|
1493 |
+
"epoch": 0.23,
|
1494 |
+
"learning_rate": 0.003466666666666667,
|
1495 |
+
"loss": 1.1185,
|
1496 |
+
"step": 2480
|
1497 |
+
},
|
1498 |
+
{
|
1499 |
+
"epoch": 0.23,
|
1500 |
+
"learning_rate": 0.0034000000000000002,
|
1501 |
+
"loss": 1.0708,
|
1502 |
+
"step": 2490
|
1503 |
+
},
|
1504 |
+
{
|
1505 |
+
"epoch": 0.23,
|
1506 |
+
"learning_rate": 0.003333333333333333,
|
1507 |
+
"loss": 1.1487,
|
1508 |
+
"step": 2500
|
1509 |
+
},
|
1510 |
+
{
|
1511 |
+
"epoch": 0.23,
|
1512 |
+
"learning_rate": 0.003266666666666667,
|
1513 |
+
"loss": 1.1814,
|
1514 |
+
"step": 2510
|
1515 |
+
},
|
1516 |
+
{
|
1517 |
+
"epoch": 0.23,
|
1518 |
+
"learning_rate": 0.0032,
|
1519 |
+
"loss": 1.1583,
|
1520 |
+
"step": 2520
|
1521 |
+
},
|
1522 |
+
{
|
1523 |
+
"epoch": 0.23,
|
1524 |
+
"learning_rate": 0.0031333333333333335,
|
1525 |
+
"loss": 1.2117,
|
1526 |
+
"step": 2530
|
1527 |
+
},
|
1528 |
+
{
|
1529 |
+
"epoch": 0.23,
|
1530 |
+
"learning_rate": 0.0030666666666666663,
|
1531 |
+
"loss": 1.1998,
|
1532 |
+
"step": 2540
|
1533 |
+
},
|
1534 |
+
{
|
1535 |
+
"epoch": 0.24,
|
1536 |
+
"learning_rate": 0.003,
|
1537 |
+
"loss": 1.2355,
|
1538 |
+
"step": 2550
|
1539 |
+
},
|
1540 |
+
{
|
1541 |
+
"epoch": 0.24,
|
1542 |
+
"learning_rate": 0.0029333333333333334,
|
1543 |
+
"loss": 1.2694,
|
1544 |
+
"step": 2560
|
1545 |
+
},
|
1546 |
+
{
|
1547 |
+
"epoch": 0.24,
|
1548 |
+
"learning_rate": 0.0028666666666666667,
|
1549 |
+
"loss": 1.1819,
|
1550 |
+
"step": 2570
|
1551 |
+
},
|
1552 |
+
{
|
1553 |
+
"epoch": 0.24,
|
1554 |
+
"learning_rate": 0.0028000000000000004,
|
1555 |
+
"loss": 1.1469,
|
1556 |
+
"step": 2580
|
1557 |
+
},
|
1558 |
+
{
|
1559 |
+
"epoch": 0.24,
|
1560 |
+
"learning_rate": 0.0027333333333333333,
|
1561 |
+
"loss": 1.1726,
|
1562 |
+
"step": 2590
|
1563 |
+
},
|
1564 |
+
{
|
1565 |
+
"epoch": 0.24,
|
1566 |
+
"learning_rate": 0.0026666666666666666,
|
1567 |
+
"loss": 1.0332,
|
1568 |
+
"step": 2600
|
1569 |
+
},
|
1570 |
+
{
|
1571 |
+
"epoch": 0.24,
|
1572 |
+
"learning_rate": 0.0026000000000000003,
|
1573 |
+
"loss": 1.2277,
|
1574 |
+
"step": 2610
|
1575 |
+
},
|
1576 |
+
{
|
1577 |
+
"epoch": 0.24,
|
1578 |
+
"learning_rate": 0.0025333333333333336,
|
1579 |
+
"loss": 1.1335,
|
1580 |
+
"step": 2620
|
1581 |
+
},
|
1582 |
+
{
|
1583 |
+
"epoch": 0.24,
|
1584 |
+
"learning_rate": 0.002466666666666667,
|
1585 |
+
"loss": 1.0854,
|
1586 |
+
"step": 2630
|
1587 |
+
},
|
1588 |
+
{
|
1589 |
+
"epoch": 0.24,
|
1590 |
+
"learning_rate": 0.0024,
|
1591 |
+
"loss": 1.1181,
|
1592 |
+
"step": 2640
|
1593 |
+
},
|
1594 |
+
{
|
1595 |
+
"epoch": 0.24,
|
1596 |
+
"learning_rate": 0.0023333333333333335,
|
1597 |
+
"loss": 1.1004,
|
1598 |
+
"step": 2650
|
1599 |
+
},
|
1600 |
+
{
|
1601 |
+
"epoch": 0.25,
|
1602 |
+
"learning_rate": 0.0022666666666666664,
|
1603 |
+
"loss": 1.1311,
|
1604 |
+
"step": 2660
|
1605 |
+
},
|
1606 |
+
{
|
1607 |
+
"epoch": 0.25,
|
1608 |
+
"learning_rate": 0.0022,
|
1609 |
+
"loss": 1.0965,
|
1610 |
+
"step": 2670
|
1611 |
+
},
|
1612 |
+
{
|
1613 |
+
"epoch": 0.25,
|
1614 |
+
"learning_rate": 0.0021333333333333334,
|
1615 |
+
"loss": 1.2944,
|
1616 |
+
"step": 2680
|
1617 |
+
},
|
1618 |
+
{
|
1619 |
+
"epoch": 0.25,
|
1620 |
+
"learning_rate": 0.0020666666666666667,
|
1621 |
+
"loss": 1.1267,
|
1622 |
+
"step": 2690
|
1623 |
+
},
|
1624 |
+
{
|
1625 |
+
"epoch": 0.25,
|
1626 |
+
"learning_rate": 0.002,
|
1627 |
+
"loss": 1.0006,
|
1628 |
+
"step": 2700
|
1629 |
+
},
|
1630 |
+
{
|
1631 |
+
"epoch": 0.25,
|
1632 |
+
"learning_rate": 0.0019333333333333333,
|
1633 |
+
"loss": 1.1332,
|
1634 |
+
"step": 2710
|
1635 |
+
},
|
1636 |
+
{
|
1637 |
+
"epoch": 0.25,
|
1638 |
+
"learning_rate": 0.0018666666666666669,
|
1639 |
+
"loss": 1.133,
|
1640 |
+
"step": 2720
|
1641 |
+
},
|
1642 |
+
{
|
1643 |
+
"epoch": 0.25,
|
1644 |
+
"learning_rate": 0.0018,
|
1645 |
+
"loss": 1.1696,
|
1646 |
+
"step": 2730
|
1647 |
+
},
|
1648 |
+
{
|
1649 |
+
"epoch": 0.25,
|
1650 |
+
"learning_rate": 0.0017333333333333335,
|
1651 |
+
"loss": 1.2066,
|
1652 |
+
"step": 2740
|
1653 |
+
},
|
1654 |
+
{
|
1655 |
+
"epoch": 0.25,
|
1656 |
+
"learning_rate": 0.0016666666666666666,
|
1657 |
+
"loss": 1.1698,
|
1658 |
+
"step": 2750
|
1659 |
+
},
|
1660 |
+
{
|
1661 |
+
"epoch": 0.25,
|
1662 |
+
"learning_rate": 0.0016,
|
1663 |
+
"loss": 1.1531,
|
1664 |
+
"step": 2760
|
1665 |
+
},
|
1666 |
+
{
|
1667 |
+
"epoch": 0.26,
|
1668 |
+
"learning_rate": 0.0015333333333333332,
|
1669 |
+
"loss": 1.333,
|
1670 |
+
"step": 2770
|
1671 |
+
},
|
1672 |
+
{
|
1673 |
+
"epoch": 0.26,
|
1674 |
+
"learning_rate": 0.0014666666666666667,
|
1675 |
+
"loss": 1.0968,
|
1676 |
+
"step": 2780
|
1677 |
+
},
|
1678 |
+
{
|
1679 |
+
"epoch": 0.26,
|
1680 |
+
"learning_rate": 0.0014000000000000002,
|
1681 |
+
"loss": 1.2056,
|
1682 |
+
"step": 2790
|
1683 |
+
},
|
1684 |
+
{
|
1685 |
+
"epoch": 0.26,
|
1686 |
+
"learning_rate": 0.0013333333333333333,
|
1687 |
+
"loss": 1.1381,
|
1688 |
+
"step": 2800
|
1689 |
+
},
|
1690 |
+
{
|
1691 |
+
"epoch": 0.26,
|
1692 |
+
"learning_rate": 0.0012666666666666668,
|
1693 |
+
"loss": 1.1355,
|
1694 |
+
"step": 2810
|
1695 |
+
},
|
1696 |
+
{
|
1697 |
+
"epoch": 0.26,
|
1698 |
+
"learning_rate": 0.0012,
|
1699 |
+
"loss": 1.289,
|
1700 |
+
"step": 2820
|
1701 |
+
},
|
1702 |
+
{
|
1703 |
+
"epoch": 0.26,
|
1704 |
+
"learning_rate": 0.0011333333333333332,
|
1705 |
+
"loss": 1.16,
|
1706 |
+
"step": 2830
|
1707 |
+
},
|
1708 |
+
{
|
1709 |
+
"epoch": 0.26,
|
1710 |
+
"learning_rate": 0.0010666666666666667,
|
1711 |
+
"loss": 1.1275,
|
1712 |
+
"step": 2840
|
1713 |
+
},
|
1714 |
+
{
|
1715 |
+
"epoch": 0.26,
|
1716 |
+
"learning_rate": 0.001,
|
1717 |
+
"loss": 1.0971,
|
1718 |
+
"step": 2850
|
1719 |
+
},
|
1720 |
+
{
|
1721 |
+
"epoch": 0.26,
|
1722 |
+
"learning_rate": 0.0009333333333333334,
|
1723 |
+
"loss": 1.0893,
|
1724 |
+
"step": 2860
|
1725 |
+
},
|
1726 |
+
{
|
1727 |
+
"epoch": 0.27,
|
1728 |
+
"learning_rate": 0.0008666666666666667,
|
1729 |
+
"loss": 1.1557,
|
1730 |
+
"step": 2870
|
1731 |
+
},
|
1732 |
+
{
|
1733 |
+
"epoch": 0.27,
|
1734 |
+
"learning_rate": 0.0008,
|
1735 |
+
"loss": 1.1966,
|
1736 |
+
"step": 2880
|
1737 |
+
},
|
1738 |
+
{
|
1739 |
+
"epoch": 0.27,
|
1740 |
+
"learning_rate": 0.0007333333333333333,
|
1741 |
+
"loss": 1.2223,
|
1742 |
+
"step": 2890
|
1743 |
+
},
|
1744 |
+
{
|
1745 |
+
"epoch": 0.27,
|
1746 |
+
"learning_rate": 0.0006666666666666666,
|
1747 |
+
"loss": 1.1097,
|
1748 |
+
"step": 2900
|
1749 |
+
},
|
1750 |
+
{
|
1751 |
+
"epoch": 0.27,
|
1752 |
+
"learning_rate": 0.0006,
|
1753 |
+
"loss": 1.1612,
|
1754 |
+
"step": 2910
|
1755 |
+
},
|
1756 |
+
{
|
1757 |
+
"epoch": 0.27,
|
1758 |
+
"learning_rate": 0.0005333333333333334,
|
1759 |
+
"loss": 1.2289,
|
1760 |
+
"step": 2920
|
1761 |
+
},
|
1762 |
+
{
|
1763 |
+
"epoch": 0.27,
|
1764 |
+
"learning_rate": 0.0004666666666666667,
|
1765 |
+
"loss": 1.222,
|
1766 |
+
"step": 2930
|
1767 |
+
},
|
1768 |
+
{
|
1769 |
+
"epoch": 0.27,
|
1770 |
+
"learning_rate": 0.0004,
|
1771 |
+
"loss": 1.1519,
|
1772 |
+
"step": 2940
|
1773 |
+
},
|
1774 |
+
{
|
1775 |
+
"epoch": 0.27,
|
1776 |
+
"learning_rate": 0.0003333333333333333,
|
1777 |
+
"loss": 1.3762,
|
1778 |
+
"step": 2950
|
1779 |
+
},
|
1780 |
+
{
|
1781 |
+
"epoch": 0.27,
|
1782 |
+
"learning_rate": 0.0002666666666666667,
|
1783 |
+
"loss": 1.2506,
|
1784 |
+
"step": 2960
|
1785 |
+
},
|
1786 |
+
{
|
1787 |
+
"epoch": 0.27,
|
1788 |
+
"learning_rate": 0.0002,
|
1789 |
+
"loss": 1.2153,
|
1790 |
+
"step": 2970
|
1791 |
+
},
|
1792 |
+
{
|
1793 |
+
"epoch": 0.28,
|
1794 |
+
"learning_rate": 0.00013333333333333334,
|
1795 |
+
"loss": 1.1327,
|
1796 |
+
"step": 2980
|
1797 |
+
},
|
1798 |
+
{
|
1799 |
+
"epoch": 0.28,
|
1800 |
+
"learning_rate": 6.666666666666667e-05,
|
1801 |
+
"loss": 1.2242,
|
1802 |
+
"step": 2990
|
1803 |
+
},
|
1804 |
+
{
|
1805 |
+
"epoch": 0.28,
|
1806 |
+
"learning_rate": 0.0,
|
1807 |
+
"loss": 1.1963,
|
1808 |
+
"step": 3000
|
1809 |
+
}
|
1810 |
+
],
|
1811 |
+
"max_steps": 3000,
|
1812 |
+
"num_train_epochs": 1,
|
1813 |
+
"total_flos": 1.73594313916416e+17,
|
1814 |
+
"trial_name": null,
|
1815 |
+
"trial_params": null
|
1816 |
+
}
|
checkpoint-3000/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:70ac9eb43a2d446e07cde6bbbb21250fe0373a4093de76a8aa1f7223e3836bcd
|
3 |
+
size 4155
|
train_results.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"epoch": 0.28,
|
3 |
+
"train_loss": 1.2429857851664226,
|
4 |
+
"train_runtime": 27386.6257,
|
5 |
+
"train_samples": 173235,
|
6 |
+
"train_samples_per_second": 1.753,
|
7 |
+
"train_steps_per_second": 0.11
|
8 |
+
}
|
trainer_state.json
ADDED
@@ -0,0 +1,1825 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 0.2770786672516105,
|
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.0,
|
12 |
+
"learning_rate": 0.019933333333333334,
|
13 |
+
"loss": 2.6644,
|
14 |
+
"step": 10
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"epoch": 0.0,
|
18 |
+
"learning_rate": 0.019866666666666668,
|
19 |
+
"loss": 1.7151,
|
20 |
+
"step": 20
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"epoch": 0.0,
|
24 |
+
"learning_rate": 0.0198,
|
25 |
+
"loss": 1.6228,
|
26 |
+
"step": 30
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"epoch": 0.0,
|
30 |
+
"learning_rate": 0.019733333333333335,
|
31 |
+
"loss": 1.401,
|
32 |
+
"step": 40
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"epoch": 0.0,
|
36 |
+
"learning_rate": 0.019666666666666666,
|
37 |
+
"loss": 1.6172,
|
38 |
+
"step": 50
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"epoch": 0.01,
|
42 |
+
"learning_rate": 0.0196,
|
43 |
+
"loss": 1.4695,
|
44 |
+
"step": 60
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"epoch": 0.01,
|
48 |
+
"learning_rate": 0.019533333333333333,
|
49 |
+
"loss": 1.5137,
|
50 |
+
"step": 70
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"epoch": 0.01,
|
54 |
+
"learning_rate": 0.019466666666666667,
|
55 |
+
"loss": 1.5425,
|
56 |
+
"step": 80
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"epoch": 0.01,
|
60 |
+
"learning_rate": 0.0194,
|
61 |
+
"loss": 1.4272,
|
62 |
+
"step": 90
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"epoch": 0.01,
|
66 |
+
"learning_rate": 0.019333333333333334,
|
67 |
+
"loss": 1.3727,
|
68 |
+
"step": 100
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"epoch": 0.01,
|
72 |
+
"learning_rate": 0.019266666666666668,
|
73 |
+
"loss": 1.3114,
|
74 |
+
"step": 110
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"epoch": 0.01,
|
78 |
+
"learning_rate": 0.0192,
|
79 |
+
"loss": 1.4758,
|
80 |
+
"step": 120
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"epoch": 0.01,
|
84 |
+
"learning_rate": 0.019133333333333332,
|
85 |
+
"loss": 1.5219,
|
86 |
+
"step": 130
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"epoch": 0.01,
|
90 |
+
"learning_rate": 0.01906666666666667,
|
91 |
+
"loss": 1.376,
|
92 |
+
"step": 140
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"epoch": 0.01,
|
96 |
+
"learning_rate": 0.019,
|
97 |
+
"loss": 1.4257,
|
98 |
+
"step": 150
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"epoch": 0.01,
|
102 |
+
"learning_rate": 0.018933333333333333,
|
103 |
+
"loss": 1.3474,
|
104 |
+
"step": 160
|
105 |
+
},
|
106 |
+
{
|
107 |
+
"epoch": 0.02,
|
108 |
+
"learning_rate": 0.018866666666666667,
|
109 |
+
"loss": 1.2929,
|
110 |
+
"step": 170
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"epoch": 0.02,
|
114 |
+
"learning_rate": 0.0188,
|
115 |
+
"loss": 1.3208,
|
116 |
+
"step": 180
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"epoch": 0.02,
|
120 |
+
"learning_rate": 0.018733333333333334,
|
121 |
+
"loss": 1.3381,
|
122 |
+
"step": 190
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"epoch": 0.02,
|
126 |
+
"learning_rate": 0.018666666666666668,
|
127 |
+
"loss": 1.3644,
|
128 |
+
"step": 200
|
129 |
+
},
|
130 |
+
{
|
131 |
+
"epoch": 0.02,
|
132 |
+
"learning_rate": 0.018600000000000002,
|
133 |
+
"loss": 1.2932,
|
134 |
+
"step": 210
|
135 |
+
},
|
136 |
+
{
|
137 |
+
"epoch": 0.02,
|
138 |
+
"learning_rate": 0.018533333333333332,
|
139 |
+
"loss": 1.4092,
|
140 |
+
"step": 220
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"epoch": 0.02,
|
144 |
+
"learning_rate": 0.018466666666666666,
|
145 |
+
"loss": 1.3006,
|
146 |
+
"step": 230
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"epoch": 0.02,
|
150 |
+
"learning_rate": 0.0184,
|
151 |
+
"loss": 1.4572,
|
152 |
+
"step": 240
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"epoch": 0.02,
|
156 |
+
"learning_rate": 0.018333333333333333,
|
157 |
+
"loss": 1.2789,
|
158 |
+
"step": 250
|
159 |
+
},
|
160 |
+
{
|
161 |
+
"epoch": 0.02,
|
162 |
+
"learning_rate": 0.018266666666666667,
|
163 |
+
"loss": 1.4444,
|
164 |
+
"step": 260
|
165 |
+
},
|
166 |
+
{
|
167 |
+
"epoch": 0.02,
|
168 |
+
"learning_rate": 0.0182,
|
169 |
+
"loss": 1.4511,
|
170 |
+
"step": 270
|
171 |
+
},
|
172 |
+
{
|
173 |
+
"epoch": 0.03,
|
174 |
+
"learning_rate": 0.01813333333333333,
|
175 |
+
"loss": 1.3541,
|
176 |
+
"step": 280
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"epoch": 0.03,
|
180 |
+
"learning_rate": 0.01806666666666667,
|
181 |
+
"loss": 1.3228,
|
182 |
+
"step": 290
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"epoch": 0.03,
|
186 |
+
"learning_rate": 0.018000000000000002,
|
187 |
+
"loss": 1.3185,
|
188 |
+
"step": 300
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"epoch": 0.03,
|
192 |
+
"learning_rate": 0.017933333333333332,
|
193 |
+
"loss": 1.199,
|
194 |
+
"step": 310
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"epoch": 0.03,
|
198 |
+
"learning_rate": 0.017866666666666666,
|
199 |
+
"loss": 1.3417,
|
200 |
+
"step": 320
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"epoch": 0.03,
|
204 |
+
"learning_rate": 0.0178,
|
205 |
+
"loss": 1.4251,
|
206 |
+
"step": 330
|
207 |
+
},
|
208 |
+
{
|
209 |
+
"epoch": 0.03,
|
210 |
+
"learning_rate": 0.017733333333333334,
|
211 |
+
"loss": 1.3574,
|
212 |
+
"step": 340
|
213 |
+
},
|
214 |
+
{
|
215 |
+
"epoch": 0.03,
|
216 |
+
"learning_rate": 0.017666666666666667,
|
217 |
+
"loss": 1.2547,
|
218 |
+
"step": 350
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"epoch": 0.03,
|
222 |
+
"learning_rate": 0.0176,
|
223 |
+
"loss": 1.2651,
|
224 |
+
"step": 360
|
225 |
+
},
|
226 |
+
{
|
227 |
+
"epoch": 0.03,
|
228 |
+
"learning_rate": 0.017533333333333335,
|
229 |
+
"loss": 1.3414,
|
230 |
+
"step": 370
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"epoch": 0.04,
|
234 |
+
"learning_rate": 0.017466666666666665,
|
235 |
+
"loss": 1.3322,
|
236 |
+
"step": 380
|
237 |
+
},
|
238 |
+
{
|
239 |
+
"epoch": 0.04,
|
240 |
+
"learning_rate": 0.0174,
|
241 |
+
"loss": 1.4147,
|
242 |
+
"step": 390
|
243 |
+
},
|
244 |
+
{
|
245 |
+
"epoch": 0.04,
|
246 |
+
"learning_rate": 0.017333333333333336,
|
247 |
+
"loss": 1.2813,
|
248 |
+
"step": 400
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"epoch": 0.04,
|
252 |
+
"learning_rate": 0.017266666666666666,
|
253 |
+
"loss": 1.3687,
|
254 |
+
"step": 410
|
255 |
+
},
|
256 |
+
{
|
257 |
+
"epoch": 0.04,
|
258 |
+
"learning_rate": 0.0172,
|
259 |
+
"loss": 1.5593,
|
260 |
+
"step": 420
|
261 |
+
},
|
262 |
+
{
|
263 |
+
"epoch": 0.04,
|
264 |
+
"learning_rate": 0.017133333333333334,
|
265 |
+
"loss": 1.3073,
|
266 |
+
"step": 430
|
267 |
+
},
|
268 |
+
{
|
269 |
+
"epoch": 0.04,
|
270 |
+
"learning_rate": 0.017066666666666667,
|
271 |
+
"loss": 1.2359,
|
272 |
+
"step": 440
|
273 |
+
},
|
274 |
+
{
|
275 |
+
"epoch": 0.04,
|
276 |
+
"learning_rate": 0.017,
|
277 |
+
"loss": 1.2474,
|
278 |
+
"step": 450
|
279 |
+
},
|
280 |
+
{
|
281 |
+
"epoch": 0.04,
|
282 |
+
"learning_rate": 0.016933333333333335,
|
283 |
+
"loss": 1.3874,
|
284 |
+
"step": 460
|
285 |
+
},
|
286 |
+
{
|
287 |
+
"epoch": 0.04,
|
288 |
+
"learning_rate": 0.01686666666666667,
|
289 |
+
"loss": 1.3203,
|
290 |
+
"step": 470
|
291 |
+
},
|
292 |
+
{
|
293 |
+
"epoch": 0.04,
|
294 |
+
"learning_rate": 0.0168,
|
295 |
+
"loss": 1.2875,
|
296 |
+
"step": 480
|
297 |
+
},
|
298 |
+
{
|
299 |
+
"epoch": 0.05,
|
300 |
+
"learning_rate": 0.016733333333333333,
|
301 |
+
"loss": 1.2767,
|
302 |
+
"step": 490
|
303 |
+
},
|
304 |
+
{
|
305 |
+
"epoch": 0.05,
|
306 |
+
"learning_rate": 0.016666666666666666,
|
307 |
+
"loss": 1.3017,
|
308 |
+
"step": 500
|
309 |
+
},
|
310 |
+
{
|
311 |
+
"epoch": 0.05,
|
312 |
+
"learning_rate": 0.0166,
|
313 |
+
"loss": 1.2321,
|
314 |
+
"step": 510
|
315 |
+
},
|
316 |
+
{
|
317 |
+
"epoch": 0.05,
|
318 |
+
"learning_rate": 0.016533333333333334,
|
319 |
+
"loss": 1.1719,
|
320 |
+
"step": 520
|
321 |
+
},
|
322 |
+
{
|
323 |
+
"epoch": 0.05,
|
324 |
+
"learning_rate": 0.016466666666666668,
|
325 |
+
"loss": 1.2552,
|
326 |
+
"step": 530
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"epoch": 0.05,
|
330 |
+
"learning_rate": 0.016399999999999998,
|
331 |
+
"loss": 1.3816,
|
332 |
+
"step": 540
|
333 |
+
},
|
334 |
+
{
|
335 |
+
"epoch": 0.05,
|
336 |
+
"learning_rate": 0.01633333333333333,
|
337 |
+
"loss": 1.2956,
|
338 |
+
"step": 550
|
339 |
+
},
|
340 |
+
{
|
341 |
+
"epoch": 0.05,
|
342 |
+
"learning_rate": 0.01626666666666667,
|
343 |
+
"loss": 1.2061,
|
344 |
+
"step": 560
|
345 |
+
},
|
346 |
+
{
|
347 |
+
"epoch": 0.05,
|
348 |
+
"learning_rate": 0.016200000000000003,
|
349 |
+
"loss": 1.2086,
|
350 |
+
"step": 570
|
351 |
+
},
|
352 |
+
{
|
353 |
+
"epoch": 0.05,
|
354 |
+
"learning_rate": 0.016133333333333333,
|
355 |
+
"loss": 1.1633,
|
356 |
+
"step": 580
|
357 |
+
},
|
358 |
+
{
|
359 |
+
"epoch": 0.05,
|
360 |
+
"learning_rate": 0.016066666666666667,
|
361 |
+
"loss": 1.2638,
|
362 |
+
"step": 590
|
363 |
+
},
|
364 |
+
{
|
365 |
+
"epoch": 0.06,
|
366 |
+
"learning_rate": 0.016,
|
367 |
+
"loss": 1.3441,
|
368 |
+
"step": 600
|
369 |
+
},
|
370 |
+
{
|
371 |
+
"epoch": 0.06,
|
372 |
+
"learning_rate": 0.015933333333333334,
|
373 |
+
"loss": 1.2924,
|
374 |
+
"step": 610
|
375 |
+
},
|
376 |
+
{
|
377 |
+
"epoch": 0.06,
|
378 |
+
"learning_rate": 0.015866666666666668,
|
379 |
+
"loss": 1.1818,
|
380 |
+
"step": 620
|
381 |
+
},
|
382 |
+
{
|
383 |
+
"epoch": 0.06,
|
384 |
+
"learning_rate": 0.0158,
|
385 |
+
"loss": 1.3918,
|
386 |
+
"step": 630
|
387 |
+
},
|
388 |
+
{
|
389 |
+
"epoch": 0.06,
|
390 |
+
"learning_rate": 0.015733333333333332,
|
391 |
+
"loss": 1.2232,
|
392 |
+
"step": 640
|
393 |
+
},
|
394 |
+
{
|
395 |
+
"epoch": 0.06,
|
396 |
+
"learning_rate": 0.015666666666666666,
|
397 |
+
"loss": 1.2472,
|
398 |
+
"step": 650
|
399 |
+
},
|
400 |
+
{
|
401 |
+
"epoch": 0.06,
|
402 |
+
"learning_rate": 0.015600000000000001,
|
403 |
+
"loss": 1.2398,
|
404 |
+
"step": 660
|
405 |
+
},
|
406 |
+
{
|
407 |
+
"epoch": 0.06,
|
408 |
+
"learning_rate": 0.015533333333333333,
|
409 |
+
"loss": 1.3649,
|
410 |
+
"step": 670
|
411 |
+
},
|
412 |
+
{
|
413 |
+
"epoch": 0.06,
|
414 |
+
"learning_rate": 0.015466666666666667,
|
415 |
+
"loss": 1.2302,
|
416 |
+
"step": 680
|
417 |
+
},
|
418 |
+
{
|
419 |
+
"epoch": 0.06,
|
420 |
+
"learning_rate": 0.0154,
|
421 |
+
"loss": 1.2053,
|
422 |
+
"step": 690
|
423 |
+
},
|
424 |
+
{
|
425 |
+
"epoch": 0.06,
|
426 |
+
"learning_rate": 0.015333333333333334,
|
427 |
+
"loss": 1.2974,
|
428 |
+
"step": 700
|
429 |
+
},
|
430 |
+
{
|
431 |
+
"epoch": 0.07,
|
432 |
+
"learning_rate": 0.015266666666666666,
|
433 |
+
"loss": 1.3036,
|
434 |
+
"step": 710
|
435 |
+
},
|
436 |
+
{
|
437 |
+
"epoch": 0.07,
|
438 |
+
"learning_rate": 0.0152,
|
439 |
+
"loss": 1.3162,
|
440 |
+
"step": 720
|
441 |
+
},
|
442 |
+
{
|
443 |
+
"epoch": 0.07,
|
444 |
+
"learning_rate": 0.015133333333333334,
|
445 |
+
"loss": 1.2567,
|
446 |
+
"step": 730
|
447 |
+
},
|
448 |
+
{
|
449 |
+
"epoch": 0.07,
|
450 |
+
"learning_rate": 0.015066666666666666,
|
451 |
+
"loss": 1.2578,
|
452 |
+
"step": 740
|
453 |
+
},
|
454 |
+
{
|
455 |
+
"epoch": 0.07,
|
456 |
+
"learning_rate": 0.015,
|
457 |
+
"loss": 1.2692,
|
458 |
+
"step": 750
|
459 |
+
},
|
460 |
+
{
|
461 |
+
"epoch": 0.07,
|
462 |
+
"learning_rate": 0.014933333333333335,
|
463 |
+
"loss": 1.1332,
|
464 |
+
"step": 760
|
465 |
+
},
|
466 |
+
{
|
467 |
+
"epoch": 0.07,
|
468 |
+
"learning_rate": 0.014866666666666667,
|
469 |
+
"loss": 1.2949,
|
470 |
+
"step": 770
|
471 |
+
},
|
472 |
+
{
|
473 |
+
"epoch": 0.07,
|
474 |
+
"learning_rate": 0.0148,
|
475 |
+
"loss": 1.2703,
|
476 |
+
"step": 780
|
477 |
+
},
|
478 |
+
{
|
479 |
+
"epoch": 0.07,
|
480 |
+
"learning_rate": 0.014733333333333334,
|
481 |
+
"loss": 1.3891,
|
482 |
+
"step": 790
|
483 |
+
},
|
484 |
+
{
|
485 |
+
"epoch": 0.07,
|
486 |
+
"learning_rate": 0.014666666666666666,
|
487 |
+
"loss": 1.3594,
|
488 |
+
"step": 800
|
489 |
+
},
|
490 |
+
{
|
491 |
+
"epoch": 0.07,
|
492 |
+
"learning_rate": 0.0146,
|
493 |
+
"loss": 1.166,
|
494 |
+
"step": 810
|
495 |
+
},
|
496 |
+
{
|
497 |
+
"epoch": 0.08,
|
498 |
+
"learning_rate": 0.014533333333333334,
|
499 |
+
"loss": 1.3256,
|
500 |
+
"step": 820
|
501 |
+
},
|
502 |
+
{
|
503 |
+
"epoch": 0.08,
|
504 |
+
"learning_rate": 0.014466666666666668,
|
505 |
+
"loss": 1.2669,
|
506 |
+
"step": 830
|
507 |
+
},
|
508 |
+
{
|
509 |
+
"epoch": 0.08,
|
510 |
+
"learning_rate": 0.0144,
|
511 |
+
"loss": 1.241,
|
512 |
+
"step": 840
|
513 |
+
},
|
514 |
+
{
|
515 |
+
"epoch": 0.08,
|
516 |
+
"learning_rate": 0.014333333333333333,
|
517 |
+
"loss": 1.2591,
|
518 |
+
"step": 850
|
519 |
+
},
|
520 |
+
{
|
521 |
+
"epoch": 0.08,
|
522 |
+
"learning_rate": 0.014266666666666667,
|
523 |
+
"loss": 1.238,
|
524 |
+
"step": 860
|
525 |
+
},
|
526 |
+
{
|
527 |
+
"epoch": 0.08,
|
528 |
+
"learning_rate": 0.014199999999999999,
|
529 |
+
"loss": 1.3583,
|
530 |
+
"step": 870
|
531 |
+
},
|
532 |
+
{
|
533 |
+
"epoch": 0.08,
|
534 |
+
"learning_rate": 0.014133333333333333,
|
535 |
+
"loss": 1.164,
|
536 |
+
"step": 880
|
537 |
+
},
|
538 |
+
{
|
539 |
+
"epoch": 0.08,
|
540 |
+
"learning_rate": 0.014066666666666668,
|
541 |
+
"loss": 1.2367,
|
542 |
+
"step": 890
|
543 |
+
},
|
544 |
+
{
|
545 |
+
"epoch": 0.08,
|
546 |
+
"learning_rate": 0.013999999999999999,
|
547 |
+
"loss": 1.1864,
|
548 |
+
"step": 900
|
549 |
+
},
|
550 |
+
{
|
551 |
+
"epoch": 0.08,
|
552 |
+
"learning_rate": 0.013933333333333334,
|
553 |
+
"loss": 1.2259,
|
554 |
+
"step": 910
|
555 |
+
},
|
556 |
+
{
|
557 |
+
"epoch": 0.08,
|
558 |
+
"learning_rate": 0.013866666666666668,
|
559 |
+
"loss": 1.2129,
|
560 |
+
"step": 920
|
561 |
+
},
|
562 |
+
{
|
563 |
+
"epoch": 0.09,
|
564 |
+
"learning_rate": 0.0138,
|
565 |
+
"loss": 1.2085,
|
566 |
+
"step": 930
|
567 |
+
},
|
568 |
+
{
|
569 |
+
"epoch": 0.09,
|
570 |
+
"learning_rate": 0.013733333333333334,
|
571 |
+
"loss": 1.2316,
|
572 |
+
"step": 940
|
573 |
+
},
|
574 |
+
{
|
575 |
+
"epoch": 0.09,
|
576 |
+
"learning_rate": 0.013666666666666667,
|
577 |
+
"loss": 1.2721,
|
578 |
+
"step": 950
|
579 |
+
},
|
580 |
+
{
|
581 |
+
"epoch": 0.09,
|
582 |
+
"learning_rate": 0.013600000000000001,
|
583 |
+
"loss": 1.2428,
|
584 |
+
"step": 960
|
585 |
+
},
|
586 |
+
{
|
587 |
+
"epoch": 0.09,
|
588 |
+
"learning_rate": 0.013533333333333333,
|
589 |
+
"loss": 1.2126,
|
590 |
+
"step": 970
|
591 |
+
},
|
592 |
+
{
|
593 |
+
"epoch": 0.09,
|
594 |
+
"learning_rate": 0.013466666666666667,
|
595 |
+
"loss": 1.1583,
|
596 |
+
"step": 980
|
597 |
+
},
|
598 |
+
{
|
599 |
+
"epoch": 0.09,
|
600 |
+
"learning_rate": 0.0134,
|
601 |
+
"loss": 1.2776,
|
602 |
+
"step": 990
|
603 |
+
},
|
604 |
+
{
|
605 |
+
"epoch": 0.09,
|
606 |
+
"learning_rate": 0.013333333333333332,
|
607 |
+
"loss": 1.2317,
|
608 |
+
"step": 1000
|
609 |
+
},
|
610 |
+
{
|
611 |
+
"epoch": 0.09,
|
612 |
+
"learning_rate": 0.013266666666666666,
|
613 |
+
"loss": 1.2047,
|
614 |
+
"step": 1010
|
615 |
+
},
|
616 |
+
{
|
617 |
+
"epoch": 0.09,
|
618 |
+
"learning_rate": 0.013200000000000002,
|
619 |
+
"loss": 1.202,
|
620 |
+
"step": 1020
|
621 |
+
},
|
622 |
+
{
|
623 |
+
"epoch": 0.1,
|
624 |
+
"learning_rate": 0.013133333333333332,
|
625 |
+
"loss": 1.1877,
|
626 |
+
"step": 1030
|
627 |
+
},
|
628 |
+
{
|
629 |
+
"epoch": 0.1,
|
630 |
+
"learning_rate": 0.013066666666666667,
|
631 |
+
"loss": 1.3071,
|
632 |
+
"step": 1040
|
633 |
+
},
|
634 |
+
{
|
635 |
+
"epoch": 0.1,
|
636 |
+
"learning_rate": 0.013000000000000001,
|
637 |
+
"loss": 1.2976,
|
638 |
+
"step": 1050
|
639 |
+
},
|
640 |
+
{
|
641 |
+
"epoch": 0.1,
|
642 |
+
"learning_rate": 0.012933333333333333,
|
643 |
+
"loss": 1.4156,
|
644 |
+
"step": 1060
|
645 |
+
},
|
646 |
+
{
|
647 |
+
"epoch": 0.1,
|
648 |
+
"learning_rate": 0.012866666666666667,
|
649 |
+
"loss": 1.173,
|
650 |
+
"step": 1070
|
651 |
+
},
|
652 |
+
{
|
653 |
+
"epoch": 0.1,
|
654 |
+
"learning_rate": 0.0128,
|
655 |
+
"loss": 1.2263,
|
656 |
+
"step": 1080
|
657 |
+
},
|
658 |
+
{
|
659 |
+
"epoch": 0.1,
|
660 |
+
"learning_rate": 0.012733333333333334,
|
661 |
+
"loss": 1.3235,
|
662 |
+
"step": 1090
|
663 |
+
},
|
664 |
+
{
|
665 |
+
"epoch": 0.1,
|
666 |
+
"learning_rate": 0.012666666666666666,
|
667 |
+
"loss": 1.1923,
|
668 |
+
"step": 1100
|
669 |
+
},
|
670 |
+
{
|
671 |
+
"epoch": 0.1,
|
672 |
+
"learning_rate": 0.0126,
|
673 |
+
"loss": 1.2879,
|
674 |
+
"step": 1110
|
675 |
+
},
|
676 |
+
{
|
677 |
+
"epoch": 0.1,
|
678 |
+
"learning_rate": 0.012533333333333334,
|
679 |
+
"loss": 1.196,
|
680 |
+
"step": 1120
|
681 |
+
},
|
682 |
+
{
|
683 |
+
"epoch": 0.1,
|
684 |
+
"learning_rate": 0.012466666666666666,
|
685 |
+
"loss": 1.2605,
|
686 |
+
"step": 1130
|
687 |
+
},
|
688 |
+
{
|
689 |
+
"epoch": 0.11,
|
690 |
+
"learning_rate": 0.0124,
|
691 |
+
"loss": 1.2303,
|
692 |
+
"step": 1140
|
693 |
+
},
|
694 |
+
{
|
695 |
+
"epoch": 0.11,
|
696 |
+
"learning_rate": 0.012333333333333335,
|
697 |
+
"loss": 1.2381,
|
698 |
+
"step": 1150
|
699 |
+
},
|
700 |
+
{
|
701 |
+
"epoch": 0.11,
|
702 |
+
"learning_rate": 0.012266666666666665,
|
703 |
+
"loss": 1.2709,
|
704 |
+
"step": 1160
|
705 |
+
},
|
706 |
+
{
|
707 |
+
"epoch": 0.11,
|
708 |
+
"learning_rate": 0.0122,
|
709 |
+
"loss": 1.2121,
|
710 |
+
"step": 1170
|
711 |
+
},
|
712 |
+
{
|
713 |
+
"epoch": 0.11,
|
714 |
+
"learning_rate": 0.012133333333333335,
|
715 |
+
"loss": 1.3713,
|
716 |
+
"step": 1180
|
717 |
+
},
|
718 |
+
{
|
719 |
+
"epoch": 0.11,
|
720 |
+
"learning_rate": 0.012066666666666668,
|
721 |
+
"loss": 1.2923,
|
722 |
+
"step": 1190
|
723 |
+
},
|
724 |
+
{
|
725 |
+
"epoch": 0.11,
|
726 |
+
"learning_rate": 0.012,
|
727 |
+
"loss": 1.2947,
|
728 |
+
"step": 1200
|
729 |
+
},
|
730 |
+
{
|
731 |
+
"epoch": 0.11,
|
732 |
+
"learning_rate": 0.011933333333333334,
|
733 |
+
"loss": 1.1538,
|
734 |
+
"step": 1210
|
735 |
+
},
|
736 |
+
{
|
737 |
+
"epoch": 0.11,
|
738 |
+
"learning_rate": 0.011866666666666668,
|
739 |
+
"loss": 1.1312,
|
740 |
+
"step": 1220
|
741 |
+
},
|
742 |
+
{
|
743 |
+
"epoch": 0.11,
|
744 |
+
"learning_rate": 0.0118,
|
745 |
+
"loss": 1.1807,
|
746 |
+
"step": 1230
|
747 |
+
},
|
748 |
+
{
|
749 |
+
"epoch": 0.11,
|
750 |
+
"learning_rate": 0.011733333333333333,
|
751 |
+
"loss": 1.2729,
|
752 |
+
"step": 1240
|
753 |
+
},
|
754 |
+
{
|
755 |
+
"epoch": 0.12,
|
756 |
+
"learning_rate": 0.011666666666666667,
|
757 |
+
"loss": 1.21,
|
758 |
+
"step": 1250
|
759 |
+
},
|
760 |
+
{
|
761 |
+
"epoch": 0.12,
|
762 |
+
"learning_rate": 0.0116,
|
763 |
+
"loss": 1.1986,
|
764 |
+
"step": 1260
|
765 |
+
},
|
766 |
+
{
|
767 |
+
"epoch": 0.12,
|
768 |
+
"learning_rate": 0.011533333333333333,
|
769 |
+
"loss": 1.2003,
|
770 |
+
"step": 1270
|
771 |
+
},
|
772 |
+
{
|
773 |
+
"epoch": 0.12,
|
774 |
+
"learning_rate": 0.011466666666666667,
|
775 |
+
"loss": 1.1773,
|
776 |
+
"step": 1280
|
777 |
+
},
|
778 |
+
{
|
779 |
+
"epoch": 0.12,
|
780 |
+
"learning_rate": 0.011399999999999999,
|
781 |
+
"loss": 1.3241,
|
782 |
+
"step": 1290
|
783 |
+
},
|
784 |
+
{
|
785 |
+
"epoch": 0.12,
|
786 |
+
"learning_rate": 0.011333333333333332,
|
787 |
+
"loss": 1.2157,
|
788 |
+
"step": 1300
|
789 |
+
},
|
790 |
+
{
|
791 |
+
"epoch": 0.12,
|
792 |
+
"learning_rate": 0.011266666666666668,
|
793 |
+
"loss": 1.2549,
|
794 |
+
"step": 1310
|
795 |
+
},
|
796 |
+
{
|
797 |
+
"epoch": 0.12,
|
798 |
+
"learning_rate": 0.011200000000000002,
|
799 |
+
"loss": 1.3245,
|
800 |
+
"step": 1320
|
801 |
+
},
|
802 |
+
{
|
803 |
+
"epoch": 0.12,
|
804 |
+
"learning_rate": 0.011133333333333334,
|
805 |
+
"loss": 1.2109,
|
806 |
+
"step": 1330
|
807 |
+
},
|
808 |
+
{
|
809 |
+
"epoch": 0.12,
|
810 |
+
"learning_rate": 0.011066666666666667,
|
811 |
+
"loss": 1.1979,
|
812 |
+
"step": 1340
|
813 |
+
},
|
814 |
+
{
|
815 |
+
"epoch": 0.12,
|
816 |
+
"learning_rate": 0.011000000000000001,
|
817 |
+
"loss": 1.2804,
|
818 |
+
"step": 1350
|
819 |
+
},
|
820 |
+
{
|
821 |
+
"epoch": 0.13,
|
822 |
+
"learning_rate": 0.010933333333333333,
|
823 |
+
"loss": 1.2655,
|
824 |
+
"step": 1360
|
825 |
+
},
|
826 |
+
{
|
827 |
+
"epoch": 0.13,
|
828 |
+
"learning_rate": 0.010866666666666667,
|
829 |
+
"loss": 1.1264,
|
830 |
+
"step": 1370
|
831 |
+
},
|
832 |
+
{
|
833 |
+
"epoch": 0.13,
|
834 |
+
"learning_rate": 0.0108,
|
835 |
+
"loss": 1.2949,
|
836 |
+
"step": 1380
|
837 |
+
},
|
838 |
+
{
|
839 |
+
"epoch": 0.13,
|
840 |
+
"learning_rate": 0.010733333333333333,
|
841 |
+
"loss": 1.2038,
|
842 |
+
"step": 1390
|
843 |
+
},
|
844 |
+
{
|
845 |
+
"epoch": 0.13,
|
846 |
+
"learning_rate": 0.010666666666666666,
|
847 |
+
"loss": 1.2514,
|
848 |
+
"step": 1400
|
849 |
+
},
|
850 |
+
{
|
851 |
+
"epoch": 0.13,
|
852 |
+
"learning_rate": 0.0106,
|
853 |
+
"loss": 1.1692,
|
854 |
+
"step": 1410
|
855 |
+
},
|
856 |
+
{
|
857 |
+
"epoch": 0.13,
|
858 |
+
"learning_rate": 0.010533333333333332,
|
859 |
+
"loss": 1.1947,
|
860 |
+
"step": 1420
|
861 |
+
},
|
862 |
+
{
|
863 |
+
"epoch": 0.13,
|
864 |
+
"learning_rate": 0.010466666666666666,
|
865 |
+
"loss": 1.3294,
|
866 |
+
"step": 1430
|
867 |
+
},
|
868 |
+
{
|
869 |
+
"epoch": 0.13,
|
870 |
+
"learning_rate": 0.010400000000000001,
|
871 |
+
"loss": 1.2169,
|
872 |
+
"step": 1440
|
873 |
+
},
|
874 |
+
{
|
875 |
+
"epoch": 0.13,
|
876 |
+
"learning_rate": 0.010333333333333335,
|
877 |
+
"loss": 1.3113,
|
878 |
+
"step": 1450
|
879 |
+
},
|
880 |
+
{
|
881 |
+
"epoch": 0.13,
|
882 |
+
"learning_rate": 0.010266666666666667,
|
883 |
+
"loss": 1.1322,
|
884 |
+
"step": 1460
|
885 |
+
},
|
886 |
+
{
|
887 |
+
"epoch": 0.14,
|
888 |
+
"learning_rate": 0.0102,
|
889 |
+
"loss": 1.4228,
|
890 |
+
"step": 1470
|
891 |
+
},
|
892 |
+
{
|
893 |
+
"epoch": 0.14,
|
894 |
+
"learning_rate": 0.010133333333333334,
|
895 |
+
"loss": 1.2384,
|
896 |
+
"step": 1480
|
897 |
+
},
|
898 |
+
{
|
899 |
+
"epoch": 0.14,
|
900 |
+
"learning_rate": 0.010066666666666666,
|
901 |
+
"loss": 1.2107,
|
902 |
+
"step": 1490
|
903 |
+
},
|
904 |
+
{
|
905 |
+
"epoch": 0.14,
|
906 |
+
"learning_rate": 0.01,
|
907 |
+
"loss": 1.2655,
|
908 |
+
"step": 1500
|
909 |
+
},
|
910 |
+
{
|
911 |
+
"epoch": 0.14,
|
912 |
+
"learning_rate": 0.009933333333333334,
|
913 |
+
"loss": 1.2991,
|
914 |
+
"step": 1510
|
915 |
+
},
|
916 |
+
{
|
917 |
+
"epoch": 0.14,
|
918 |
+
"learning_rate": 0.009866666666666668,
|
919 |
+
"loss": 1.324,
|
920 |
+
"step": 1520
|
921 |
+
},
|
922 |
+
{
|
923 |
+
"epoch": 0.14,
|
924 |
+
"learning_rate": 0.0098,
|
925 |
+
"loss": 1.3443,
|
926 |
+
"step": 1530
|
927 |
+
},
|
928 |
+
{
|
929 |
+
"epoch": 0.14,
|
930 |
+
"learning_rate": 0.009733333333333333,
|
931 |
+
"loss": 1.1389,
|
932 |
+
"step": 1540
|
933 |
+
},
|
934 |
+
{
|
935 |
+
"epoch": 0.14,
|
936 |
+
"learning_rate": 0.009666666666666667,
|
937 |
+
"loss": 1.2308,
|
938 |
+
"step": 1550
|
939 |
+
},
|
940 |
+
{
|
941 |
+
"epoch": 0.14,
|
942 |
+
"learning_rate": 0.0096,
|
943 |
+
"loss": 1.1847,
|
944 |
+
"step": 1560
|
945 |
+
},
|
946 |
+
{
|
947 |
+
"epoch": 0.15,
|
948 |
+
"learning_rate": 0.009533333333333335,
|
949 |
+
"loss": 1.3154,
|
950 |
+
"step": 1570
|
951 |
+
},
|
952 |
+
{
|
953 |
+
"epoch": 0.15,
|
954 |
+
"learning_rate": 0.009466666666666667,
|
955 |
+
"loss": 1.233,
|
956 |
+
"step": 1580
|
957 |
+
},
|
958 |
+
{
|
959 |
+
"epoch": 0.15,
|
960 |
+
"learning_rate": 0.0094,
|
961 |
+
"loss": 1.147,
|
962 |
+
"step": 1590
|
963 |
+
},
|
964 |
+
{
|
965 |
+
"epoch": 0.15,
|
966 |
+
"learning_rate": 0.009333333333333334,
|
967 |
+
"loss": 1.1824,
|
968 |
+
"step": 1600
|
969 |
+
},
|
970 |
+
{
|
971 |
+
"epoch": 0.15,
|
972 |
+
"learning_rate": 0.009266666666666666,
|
973 |
+
"loss": 1.2093,
|
974 |
+
"step": 1610
|
975 |
+
},
|
976 |
+
{
|
977 |
+
"epoch": 0.15,
|
978 |
+
"learning_rate": 0.0092,
|
979 |
+
"loss": 1.2111,
|
980 |
+
"step": 1620
|
981 |
+
},
|
982 |
+
{
|
983 |
+
"epoch": 0.15,
|
984 |
+
"learning_rate": 0.009133333333333334,
|
985 |
+
"loss": 1.0596,
|
986 |
+
"step": 1630
|
987 |
+
},
|
988 |
+
{
|
989 |
+
"epoch": 0.15,
|
990 |
+
"learning_rate": 0.009066666666666666,
|
991 |
+
"loss": 1.3025,
|
992 |
+
"step": 1640
|
993 |
+
},
|
994 |
+
{
|
995 |
+
"epoch": 0.15,
|
996 |
+
"learning_rate": 0.009000000000000001,
|
997 |
+
"loss": 1.1726,
|
998 |
+
"step": 1650
|
999 |
+
},
|
1000 |
+
{
|
1001 |
+
"epoch": 0.15,
|
1002 |
+
"learning_rate": 0.008933333333333333,
|
1003 |
+
"loss": 1.2078,
|
1004 |
+
"step": 1660
|
1005 |
+
},
|
1006 |
+
{
|
1007 |
+
"epoch": 0.15,
|
1008 |
+
"learning_rate": 0.008866666666666667,
|
1009 |
+
"loss": 1.2652,
|
1010 |
+
"step": 1670
|
1011 |
+
},
|
1012 |
+
{
|
1013 |
+
"epoch": 0.16,
|
1014 |
+
"learning_rate": 0.0088,
|
1015 |
+
"loss": 1.2033,
|
1016 |
+
"step": 1680
|
1017 |
+
},
|
1018 |
+
{
|
1019 |
+
"epoch": 0.16,
|
1020 |
+
"learning_rate": 0.008733333333333333,
|
1021 |
+
"loss": 1.1598,
|
1022 |
+
"step": 1690
|
1023 |
+
},
|
1024 |
+
{
|
1025 |
+
"epoch": 0.16,
|
1026 |
+
"learning_rate": 0.008666666666666668,
|
1027 |
+
"loss": 1.1904,
|
1028 |
+
"step": 1700
|
1029 |
+
},
|
1030 |
+
{
|
1031 |
+
"epoch": 0.16,
|
1032 |
+
"learning_rate": 0.0086,
|
1033 |
+
"loss": 1.242,
|
1034 |
+
"step": 1710
|
1035 |
+
},
|
1036 |
+
{
|
1037 |
+
"epoch": 0.16,
|
1038 |
+
"learning_rate": 0.008533333333333334,
|
1039 |
+
"loss": 1.3042,
|
1040 |
+
"step": 1720
|
1041 |
+
},
|
1042 |
+
{
|
1043 |
+
"epoch": 0.16,
|
1044 |
+
"learning_rate": 0.008466666666666667,
|
1045 |
+
"loss": 1.3653,
|
1046 |
+
"step": 1730
|
1047 |
+
},
|
1048 |
+
{
|
1049 |
+
"epoch": 0.16,
|
1050 |
+
"learning_rate": 0.0084,
|
1051 |
+
"loss": 1.1784,
|
1052 |
+
"step": 1740
|
1053 |
+
},
|
1054 |
+
{
|
1055 |
+
"epoch": 0.16,
|
1056 |
+
"learning_rate": 0.008333333333333333,
|
1057 |
+
"loss": 1.2306,
|
1058 |
+
"step": 1750
|
1059 |
+
},
|
1060 |
+
{
|
1061 |
+
"epoch": 0.16,
|
1062 |
+
"learning_rate": 0.008266666666666667,
|
1063 |
+
"loss": 1.2139,
|
1064 |
+
"step": 1760
|
1065 |
+
},
|
1066 |
+
{
|
1067 |
+
"epoch": 0.16,
|
1068 |
+
"learning_rate": 0.008199999999999999,
|
1069 |
+
"loss": 1.1891,
|
1070 |
+
"step": 1770
|
1071 |
+
},
|
1072 |
+
{
|
1073 |
+
"epoch": 0.16,
|
1074 |
+
"learning_rate": 0.008133333333333334,
|
1075 |
+
"loss": 1.2619,
|
1076 |
+
"step": 1780
|
1077 |
+
},
|
1078 |
+
{
|
1079 |
+
"epoch": 0.17,
|
1080 |
+
"learning_rate": 0.008066666666666666,
|
1081 |
+
"loss": 1.0873,
|
1082 |
+
"step": 1790
|
1083 |
+
},
|
1084 |
+
{
|
1085 |
+
"epoch": 0.17,
|
1086 |
+
"learning_rate": 0.008,
|
1087 |
+
"loss": 1.2537,
|
1088 |
+
"step": 1800
|
1089 |
+
},
|
1090 |
+
{
|
1091 |
+
"epoch": 0.17,
|
1092 |
+
"learning_rate": 0.007933333333333334,
|
1093 |
+
"loss": 1.2575,
|
1094 |
+
"step": 1810
|
1095 |
+
},
|
1096 |
+
{
|
1097 |
+
"epoch": 0.17,
|
1098 |
+
"learning_rate": 0.007866666666666666,
|
1099 |
+
"loss": 1.1043,
|
1100 |
+
"step": 1820
|
1101 |
+
},
|
1102 |
+
{
|
1103 |
+
"epoch": 0.17,
|
1104 |
+
"learning_rate": 0.0078000000000000005,
|
1105 |
+
"loss": 1.2063,
|
1106 |
+
"step": 1830
|
1107 |
+
},
|
1108 |
+
{
|
1109 |
+
"epoch": 0.17,
|
1110 |
+
"learning_rate": 0.007733333333333333,
|
1111 |
+
"loss": 1.1602,
|
1112 |
+
"step": 1840
|
1113 |
+
},
|
1114 |
+
{
|
1115 |
+
"epoch": 0.17,
|
1116 |
+
"learning_rate": 0.007666666666666667,
|
1117 |
+
"loss": 1.1474,
|
1118 |
+
"step": 1850
|
1119 |
+
},
|
1120 |
+
{
|
1121 |
+
"epoch": 0.17,
|
1122 |
+
"learning_rate": 0.0076,
|
1123 |
+
"loss": 1.1482,
|
1124 |
+
"step": 1860
|
1125 |
+
},
|
1126 |
+
{
|
1127 |
+
"epoch": 0.17,
|
1128 |
+
"learning_rate": 0.007533333333333333,
|
1129 |
+
"loss": 1.2124,
|
1130 |
+
"step": 1870
|
1131 |
+
},
|
1132 |
+
{
|
1133 |
+
"epoch": 0.17,
|
1134 |
+
"learning_rate": 0.0074666666666666675,
|
1135 |
+
"loss": 1.195,
|
1136 |
+
"step": 1880
|
1137 |
+
},
|
1138 |
+
{
|
1139 |
+
"epoch": 0.17,
|
1140 |
+
"learning_rate": 0.0074,
|
1141 |
+
"loss": 1.1426,
|
1142 |
+
"step": 1890
|
1143 |
+
},
|
1144 |
+
{
|
1145 |
+
"epoch": 0.18,
|
1146 |
+
"learning_rate": 0.007333333333333333,
|
1147 |
+
"loss": 1.2067,
|
1148 |
+
"step": 1900
|
1149 |
+
},
|
1150 |
+
{
|
1151 |
+
"epoch": 0.18,
|
1152 |
+
"learning_rate": 0.007266666666666667,
|
1153 |
+
"loss": 1.1649,
|
1154 |
+
"step": 1910
|
1155 |
+
},
|
1156 |
+
{
|
1157 |
+
"epoch": 0.18,
|
1158 |
+
"learning_rate": 0.0072,
|
1159 |
+
"loss": 1.0978,
|
1160 |
+
"step": 1920
|
1161 |
+
},
|
1162 |
+
{
|
1163 |
+
"epoch": 0.18,
|
1164 |
+
"learning_rate": 0.0071333333333333335,
|
1165 |
+
"loss": 1.2298,
|
1166 |
+
"step": 1930
|
1167 |
+
},
|
1168 |
+
{
|
1169 |
+
"epoch": 0.18,
|
1170 |
+
"learning_rate": 0.007066666666666666,
|
1171 |
+
"loss": 1.195,
|
1172 |
+
"step": 1940
|
1173 |
+
},
|
1174 |
+
{
|
1175 |
+
"epoch": 0.18,
|
1176 |
+
"learning_rate": 0.006999999999999999,
|
1177 |
+
"loss": 1.2032,
|
1178 |
+
"step": 1950
|
1179 |
+
},
|
1180 |
+
{
|
1181 |
+
"epoch": 0.18,
|
1182 |
+
"learning_rate": 0.006933333333333334,
|
1183 |
+
"loss": 1.1134,
|
1184 |
+
"step": 1960
|
1185 |
+
},
|
1186 |
+
{
|
1187 |
+
"epoch": 0.18,
|
1188 |
+
"learning_rate": 0.006866666666666667,
|
1189 |
+
"loss": 1.2925,
|
1190 |
+
"step": 1970
|
1191 |
+
},
|
1192 |
+
{
|
1193 |
+
"epoch": 0.18,
|
1194 |
+
"learning_rate": 0.0068000000000000005,
|
1195 |
+
"loss": 1.1389,
|
1196 |
+
"step": 1980
|
1197 |
+
},
|
1198 |
+
{
|
1199 |
+
"epoch": 0.18,
|
1200 |
+
"learning_rate": 0.006733333333333333,
|
1201 |
+
"loss": 1.1952,
|
1202 |
+
"step": 1990
|
1203 |
+
},
|
1204 |
+
{
|
1205 |
+
"epoch": 0.18,
|
1206 |
+
"learning_rate": 0.006666666666666666,
|
1207 |
+
"loss": 1.0672,
|
1208 |
+
"step": 2000
|
1209 |
+
},
|
1210 |
+
{
|
1211 |
+
"epoch": 0.19,
|
1212 |
+
"learning_rate": 0.006600000000000001,
|
1213 |
+
"loss": 1.2243,
|
1214 |
+
"step": 2010
|
1215 |
+
},
|
1216 |
+
{
|
1217 |
+
"epoch": 0.19,
|
1218 |
+
"learning_rate": 0.006533333333333334,
|
1219 |
+
"loss": 1.218,
|
1220 |
+
"step": 2020
|
1221 |
+
},
|
1222 |
+
{
|
1223 |
+
"epoch": 0.19,
|
1224 |
+
"learning_rate": 0.006466666666666667,
|
1225 |
+
"loss": 1.1988,
|
1226 |
+
"step": 2030
|
1227 |
+
},
|
1228 |
+
{
|
1229 |
+
"epoch": 0.19,
|
1230 |
+
"learning_rate": 0.0064,
|
1231 |
+
"loss": 1.1776,
|
1232 |
+
"step": 2040
|
1233 |
+
},
|
1234 |
+
{
|
1235 |
+
"epoch": 0.19,
|
1236 |
+
"learning_rate": 0.006333333333333333,
|
1237 |
+
"loss": 1.1506,
|
1238 |
+
"step": 2050
|
1239 |
+
},
|
1240 |
+
{
|
1241 |
+
"epoch": 0.19,
|
1242 |
+
"learning_rate": 0.006266666666666667,
|
1243 |
+
"loss": 1.0386,
|
1244 |
+
"step": 2060
|
1245 |
+
},
|
1246 |
+
{
|
1247 |
+
"epoch": 0.19,
|
1248 |
+
"learning_rate": 0.0062,
|
1249 |
+
"loss": 1.2601,
|
1250 |
+
"step": 2070
|
1251 |
+
},
|
1252 |
+
{
|
1253 |
+
"epoch": 0.19,
|
1254 |
+
"learning_rate": 0.006133333333333333,
|
1255 |
+
"loss": 1.058,
|
1256 |
+
"step": 2080
|
1257 |
+
},
|
1258 |
+
{
|
1259 |
+
"epoch": 0.19,
|
1260 |
+
"learning_rate": 0.006066666666666667,
|
1261 |
+
"loss": 1.2243,
|
1262 |
+
"step": 2090
|
1263 |
+
},
|
1264 |
+
{
|
1265 |
+
"epoch": 0.19,
|
1266 |
+
"learning_rate": 0.006,
|
1267 |
+
"loss": 1.2445,
|
1268 |
+
"step": 2100
|
1269 |
+
},
|
1270 |
+
{
|
1271 |
+
"epoch": 0.19,
|
1272 |
+
"learning_rate": 0.005933333333333334,
|
1273 |
+
"loss": 1.2567,
|
1274 |
+
"step": 2110
|
1275 |
+
},
|
1276 |
+
{
|
1277 |
+
"epoch": 0.2,
|
1278 |
+
"learning_rate": 0.005866666666666667,
|
1279 |
+
"loss": 1.1815,
|
1280 |
+
"step": 2120
|
1281 |
+
},
|
1282 |
+
{
|
1283 |
+
"epoch": 0.2,
|
1284 |
+
"learning_rate": 0.0058,
|
1285 |
+
"loss": 1.3061,
|
1286 |
+
"step": 2130
|
1287 |
+
},
|
1288 |
+
{
|
1289 |
+
"epoch": 0.2,
|
1290 |
+
"learning_rate": 0.005733333333333333,
|
1291 |
+
"loss": 1.3064,
|
1292 |
+
"step": 2140
|
1293 |
+
},
|
1294 |
+
{
|
1295 |
+
"epoch": 0.2,
|
1296 |
+
"learning_rate": 0.005666666666666666,
|
1297 |
+
"loss": 1.2739,
|
1298 |
+
"step": 2150
|
1299 |
+
},
|
1300 |
+
{
|
1301 |
+
"epoch": 0.2,
|
1302 |
+
"learning_rate": 0.005600000000000001,
|
1303 |
+
"loss": 1.2754,
|
1304 |
+
"step": 2160
|
1305 |
+
},
|
1306 |
+
{
|
1307 |
+
"epoch": 0.2,
|
1308 |
+
"learning_rate": 0.005533333333333334,
|
1309 |
+
"loss": 1.1678,
|
1310 |
+
"step": 2170
|
1311 |
+
},
|
1312 |
+
{
|
1313 |
+
"epoch": 0.2,
|
1314 |
+
"learning_rate": 0.0054666666666666665,
|
1315 |
+
"loss": 1.191,
|
1316 |
+
"step": 2180
|
1317 |
+
},
|
1318 |
+
{
|
1319 |
+
"epoch": 0.2,
|
1320 |
+
"learning_rate": 0.0054,
|
1321 |
+
"loss": 1.2127,
|
1322 |
+
"step": 2190
|
1323 |
+
},
|
1324 |
+
{
|
1325 |
+
"epoch": 0.2,
|
1326 |
+
"learning_rate": 0.005333333333333333,
|
1327 |
+
"loss": 1.3057,
|
1328 |
+
"step": 2200
|
1329 |
+
},
|
1330 |
+
{
|
1331 |
+
"epoch": 0.2,
|
1332 |
+
"learning_rate": 0.005266666666666666,
|
1333 |
+
"loss": 1.1092,
|
1334 |
+
"step": 2210
|
1335 |
+
},
|
1336 |
+
{
|
1337 |
+
"epoch": 0.21,
|
1338 |
+
"learning_rate": 0.005200000000000001,
|
1339 |
+
"loss": 1.1615,
|
1340 |
+
"step": 2220
|
1341 |
+
},
|
1342 |
+
{
|
1343 |
+
"epoch": 0.21,
|
1344 |
+
"learning_rate": 0.0051333333333333335,
|
1345 |
+
"loss": 1.1769,
|
1346 |
+
"step": 2230
|
1347 |
+
},
|
1348 |
+
{
|
1349 |
+
"epoch": 0.21,
|
1350 |
+
"learning_rate": 0.005066666666666667,
|
1351 |
+
"loss": 1.1396,
|
1352 |
+
"step": 2240
|
1353 |
+
},
|
1354 |
+
{
|
1355 |
+
"epoch": 0.21,
|
1356 |
+
"learning_rate": 0.005,
|
1357 |
+
"loss": 1.1663,
|
1358 |
+
"step": 2250
|
1359 |
+
},
|
1360 |
+
{
|
1361 |
+
"epoch": 0.21,
|
1362 |
+
"learning_rate": 0.004933333333333334,
|
1363 |
+
"loss": 1.0931,
|
1364 |
+
"step": 2260
|
1365 |
+
},
|
1366 |
+
{
|
1367 |
+
"epoch": 0.21,
|
1368 |
+
"learning_rate": 0.004866666666666667,
|
1369 |
+
"loss": 1.1143,
|
1370 |
+
"step": 2270
|
1371 |
+
},
|
1372 |
+
{
|
1373 |
+
"epoch": 0.21,
|
1374 |
+
"learning_rate": 0.0048,
|
1375 |
+
"loss": 1.1891,
|
1376 |
+
"step": 2280
|
1377 |
+
},
|
1378 |
+
{
|
1379 |
+
"epoch": 0.21,
|
1380 |
+
"learning_rate": 0.004733333333333333,
|
1381 |
+
"loss": 1.1636,
|
1382 |
+
"step": 2290
|
1383 |
+
},
|
1384 |
+
{
|
1385 |
+
"epoch": 0.21,
|
1386 |
+
"learning_rate": 0.004666666666666667,
|
1387 |
+
"loss": 1.1777,
|
1388 |
+
"step": 2300
|
1389 |
+
},
|
1390 |
+
{
|
1391 |
+
"epoch": 0.21,
|
1392 |
+
"learning_rate": 0.0046,
|
1393 |
+
"loss": 1.1933,
|
1394 |
+
"step": 2310
|
1395 |
+
},
|
1396 |
+
{
|
1397 |
+
"epoch": 0.21,
|
1398 |
+
"learning_rate": 0.004533333333333333,
|
1399 |
+
"loss": 1.1606,
|
1400 |
+
"step": 2320
|
1401 |
+
},
|
1402 |
+
{
|
1403 |
+
"epoch": 0.22,
|
1404 |
+
"learning_rate": 0.0044666666666666665,
|
1405 |
+
"loss": 1.2233,
|
1406 |
+
"step": 2330
|
1407 |
+
},
|
1408 |
+
{
|
1409 |
+
"epoch": 0.22,
|
1410 |
+
"learning_rate": 0.0044,
|
1411 |
+
"loss": 1.2237,
|
1412 |
+
"step": 2340
|
1413 |
+
},
|
1414 |
+
{
|
1415 |
+
"epoch": 0.22,
|
1416 |
+
"learning_rate": 0.004333333333333334,
|
1417 |
+
"loss": 1.2323,
|
1418 |
+
"step": 2350
|
1419 |
+
},
|
1420 |
+
{
|
1421 |
+
"epoch": 0.22,
|
1422 |
+
"learning_rate": 0.004266666666666667,
|
1423 |
+
"loss": 1.0837,
|
1424 |
+
"step": 2360
|
1425 |
+
},
|
1426 |
+
{
|
1427 |
+
"epoch": 0.22,
|
1428 |
+
"learning_rate": 0.0042,
|
1429 |
+
"loss": 1.1411,
|
1430 |
+
"step": 2370
|
1431 |
+
},
|
1432 |
+
{
|
1433 |
+
"epoch": 0.22,
|
1434 |
+
"learning_rate": 0.0041333333333333335,
|
1435 |
+
"loss": 1.0772,
|
1436 |
+
"step": 2380
|
1437 |
+
},
|
1438 |
+
{
|
1439 |
+
"epoch": 0.22,
|
1440 |
+
"learning_rate": 0.004066666666666667,
|
1441 |
+
"loss": 1.1952,
|
1442 |
+
"step": 2390
|
1443 |
+
},
|
1444 |
+
{
|
1445 |
+
"epoch": 0.22,
|
1446 |
+
"learning_rate": 0.004,
|
1447 |
+
"loss": 1.1267,
|
1448 |
+
"step": 2400
|
1449 |
+
},
|
1450 |
+
{
|
1451 |
+
"epoch": 0.22,
|
1452 |
+
"learning_rate": 0.003933333333333333,
|
1453 |
+
"loss": 1.2142,
|
1454 |
+
"step": 2410
|
1455 |
+
},
|
1456 |
+
{
|
1457 |
+
"epoch": 0.22,
|
1458 |
+
"learning_rate": 0.0038666666666666667,
|
1459 |
+
"loss": 1.2375,
|
1460 |
+
"step": 2420
|
1461 |
+
},
|
1462 |
+
{
|
1463 |
+
"epoch": 0.22,
|
1464 |
+
"learning_rate": 0.0038,
|
1465 |
+
"loss": 1.1964,
|
1466 |
+
"step": 2430
|
1467 |
+
},
|
1468 |
+
{
|
1469 |
+
"epoch": 0.23,
|
1470 |
+
"learning_rate": 0.0037333333333333337,
|
1471 |
+
"loss": 1.1305,
|
1472 |
+
"step": 2440
|
1473 |
+
},
|
1474 |
+
{
|
1475 |
+
"epoch": 0.23,
|
1476 |
+
"learning_rate": 0.0036666666666666666,
|
1477 |
+
"loss": 1.1478,
|
1478 |
+
"step": 2450
|
1479 |
+
},
|
1480 |
+
{
|
1481 |
+
"epoch": 0.23,
|
1482 |
+
"learning_rate": 0.0036,
|
1483 |
+
"loss": 1.1542,
|
1484 |
+
"step": 2460
|
1485 |
+
},
|
1486 |
+
{
|
1487 |
+
"epoch": 0.23,
|
1488 |
+
"learning_rate": 0.003533333333333333,
|
1489 |
+
"loss": 1.1168,
|
1490 |
+
"step": 2470
|
1491 |
+
},
|
1492 |
+
{
|
1493 |
+
"epoch": 0.23,
|
1494 |
+
"learning_rate": 0.003466666666666667,
|
1495 |
+
"loss": 1.1185,
|
1496 |
+
"step": 2480
|
1497 |
+
},
|
1498 |
+
{
|
1499 |
+
"epoch": 0.23,
|
1500 |
+
"learning_rate": 0.0034000000000000002,
|
1501 |
+
"loss": 1.0708,
|
1502 |
+
"step": 2490
|
1503 |
+
},
|
1504 |
+
{
|
1505 |
+
"epoch": 0.23,
|
1506 |
+
"learning_rate": 0.003333333333333333,
|
1507 |
+
"loss": 1.1487,
|
1508 |
+
"step": 2500
|
1509 |
+
},
|
1510 |
+
{
|
1511 |
+
"epoch": 0.23,
|
1512 |
+
"learning_rate": 0.003266666666666667,
|
1513 |
+
"loss": 1.1814,
|
1514 |
+
"step": 2510
|
1515 |
+
},
|
1516 |
+
{
|
1517 |
+
"epoch": 0.23,
|
1518 |
+
"learning_rate": 0.0032,
|
1519 |
+
"loss": 1.1583,
|
1520 |
+
"step": 2520
|
1521 |
+
},
|
1522 |
+
{
|
1523 |
+
"epoch": 0.23,
|
1524 |
+
"learning_rate": 0.0031333333333333335,
|
1525 |
+
"loss": 1.2117,
|
1526 |
+
"step": 2530
|
1527 |
+
},
|
1528 |
+
{
|
1529 |
+
"epoch": 0.23,
|
1530 |
+
"learning_rate": 0.0030666666666666663,
|
1531 |
+
"loss": 1.1998,
|
1532 |
+
"step": 2540
|
1533 |
+
},
|
1534 |
+
{
|
1535 |
+
"epoch": 0.24,
|
1536 |
+
"learning_rate": 0.003,
|
1537 |
+
"loss": 1.2355,
|
1538 |
+
"step": 2550
|
1539 |
+
},
|
1540 |
+
{
|
1541 |
+
"epoch": 0.24,
|
1542 |
+
"learning_rate": 0.0029333333333333334,
|
1543 |
+
"loss": 1.2694,
|
1544 |
+
"step": 2560
|
1545 |
+
},
|
1546 |
+
{
|
1547 |
+
"epoch": 0.24,
|
1548 |
+
"learning_rate": 0.0028666666666666667,
|
1549 |
+
"loss": 1.1819,
|
1550 |
+
"step": 2570
|
1551 |
+
},
|
1552 |
+
{
|
1553 |
+
"epoch": 0.24,
|
1554 |
+
"learning_rate": 0.0028000000000000004,
|
1555 |
+
"loss": 1.1469,
|
1556 |
+
"step": 2580
|
1557 |
+
},
|
1558 |
+
{
|
1559 |
+
"epoch": 0.24,
|
1560 |
+
"learning_rate": 0.0027333333333333333,
|
1561 |
+
"loss": 1.1726,
|
1562 |
+
"step": 2590
|
1563 |
+
},
|
1564 |
+
{
|
1565 |
+
"epoch": 0.24,
|
1566 |
+
"learning_rate": 0.0026666666666666666,
|
1567 |
+
"loss": 1.0332,
|
1568 |
+
"step": 2600
|
1569 |
+
},
|
1570 |
+
{
|
1571 |
+
"epoch": 0.24,
|
1572 |
+
"learning_rate": 0.0026000000000000003,
|
1573 |
+
"loss": 1.2277,
|
1574 |
+
"step": 2610
|
1575 |
+
},
|
1576 |
+
{
|
1577 |
+
"epoch": 0.24,
|
1578 |
+
"learning_rate": 0.0025333333333333336,
|
1579 |
+
"loss": 1.1335,
|
1580 |
+
"step": 2620
|
1581 |
+
},
|
1582 |
+
{
|
1583 |
+
"epoch": 0.24,
|
1584 |
+
"learning_rate": 0.002466666666666667,
|
1585 |
+
"loss": 1.0854,
|
1586 |
+
"step": 2630
|
1587 |
+
},
|
1588 |
+
{
|
1589 |
+
"epoch": 0.24,
|
1590 |
+
"learning_rate": 0.0024,
|
1591 |
+
"loss": 1.1181,
|
1592 |
+
"step": 2640
|
1593 |
+
},
|
1594 |
+
{
|
1595 |
+
"epoch": 0.24,
|
1596 |
+
"learning_rate": 0.0023333333333333335,
|
1597 |
+
"loss": 1.1004,
|
1598 |
+
"step": 2650
|
1599 |
+
},
|
1600 |
+
{
|
1601 |
+
"epoch": 0.25,
|
1602 |
+
"learning_rate": 0.0022666666666666664,
|
1603 |
+
"loss": 1.1311,
|
1604 |
+
"step": 2660
|
1605 |
+
},
|
1606 |
+
{
|
1607 |
+
"epoch": 0.25,
|
1608 |
+
"learning_rate": 0.0022,
|
1609 |
+
"loss": 1.0965,
|
1610 |
+
"step": 2670
|
1611 |
+
},
|
1612 |
+
{
|
1613 |
+
"epoch": 0.25,
|
1614 |
+
"learning_rate": 0.0021333333333333334,
|
1615 |
+
"loss": 1.2944,
|
1616 |
+
"step": 2680
|
1617 |
+
},
|
1618 |
+
{
|
1619 |
+
"epoch": 0.25,
|
1620 |
+
"learning_rate": 0.0020666666666666667,
|
1621 |
+
"loss": 1.1267,
|
1622 |
+
"step": 2690
|
1623 |
+
},
|
1624 |
+
{
|
1625 |
+
"epoch": 0.25,
|
1626 |
+
"learning_rate": 0.002,
|
1627 |
+
"loss": 1.0006,
|
1628 |
+
"step": 2700
|
1629 |
+
},
|
1630 |
+
{
|
1631 |
+
"epoch": 0.25,
|
1632 |
+
"learning_rate": 0.0019333333333333333,
|
1633 |
+
"loss": 1.1332,
|
1634 |
+
"step": 2710
|
1635 |
+
},
|
1636 |
+
{
|
1637 |
+
"epoch": 0.25,
|
1638 |
+
"learning_rate": 0.0018666666666666669,
|
1639 |
+
"loss": 1.133,
|
1640 |
+
"step": 2720
|
1641 |
+
},
|
1642 |
+
{
|
1643 |
+
"epoch": 0.25,
|
1644 |
+
"learning_rate": 0.0018,
|
1645 |
+
"loss": 1.1696,
|
1646 |
+
"step": 2730
|
1647 |
+
},
|
1648 |
+
{
|
1649 |
+
"epoch": 0.25,
|
1650 |
+
"learning_rate": 0.0017333333333333335,
|
1651 |
+
"loss": 1.2066,
|
1652 |
+
"step": 2740
|
1653 |
+
},
|
1654 |
+
{
|
1655 |
+
"epoch": 0.25,
|
1656 |
+
"learning_rate": 0.0016666666666666666,
|
1657 |
+
"loss": 1.1698,
|
1658 |
+
"step": 2750
|
1659 |
+
},
|
1660 |
+
{
|
1661 |
+
"epoch": 0.25,
|
1662 |
+
"learning_rate": 0.0016,
|
1663 |
+
"loss": 1.1531,
|
1664 |
+
"step": 2760
|
1665 |
+
},
|
1666 |
+
{
|
1667 |
+
"epoch": 0.26,
|
1668 |
+
"learning_rate": 0.0015333333333333332,
|
1669 |
+
"loss": 1.333,
|
1670 |
+
"step": 2770
|
1671 |
+
},
|
1672 |
+
{
|
1673 |
+
"epoch": 0.26,
|
1674 |
+
"learning_rate": 0.0014666666666666667,
|
1675 |
+
"loss": 1.0968,
|
1676 |
+
"step": 2780
|
1677 |
+
},
|
1678 |
+
{
|
1679 |
+
"epoch": 0.26,
|
1680 |
+
"learning_rate": 0.0014000000000000002,
|
1681 |
+
"loss": 1.2056,
|
1682 |
+
"step": 2790
|
1683 |
+
},
|
1684 |
+
{
|
1685 |
+
"epoch": 0.26,
|
1686 |
+
"learning_rate": 0.0013333333333333333,
|
1687 |
+
"loss": 1.1381,
|
1688 |
+
"step": 2800
|
1689 |
+
},
|
1690 |
+
{
|
1691 |
+
"epoch": 0.26,
|
1692 |
+
"learning_rate": 0.0012666666666666668,
|
1693 |
+
"loss": 1.1355,
|
1694 |
+
"step": 2810
|
1695 |
+
},
|
1696 |
+
{
|
1697 |
+
"epoch": 0.26,
|
1698 |
+
"learning_rate": 0.0012,
|
1699 |
+
"loss": 1.289,
|
1700 |
+
"step": 2820
|
1701 |
+
},
|
1702 |
+
{
|
1703 |
+
"epoch": 0.26,
|
1704 |
+
"learning_rate": 0.0011333333333333332,
|
1705 |
+
"loss": 1.16,
|
1706 |
+
"step": 2830
|
1707 |
+
},
|
1708 |
+
{
|
1709 |
+
"epoch": 0.26,
|
1710 |
+
"learning_rate": 0.0010666666666666667,
|
1711 |
+
"loss": 1.1275,
|
1712 |
+
"step": 2840
|
1713 |
+
},
|
1714 |
+
{
|
1715 |
+
"epoch": 0.26,
|
1716 |
+
"learning_rate": 0.001,
|
1717 |
+
"loss": 1.0971,
|
1718 |
+
"step": 2850
|
1719 |
+
},
|
1720 |
+
{
|
1721 |
+
"epoch": 0.26,
|
1722 |
+
"learning_rate": 0.0009333333333333334,
|
1723 |
+
"loss": 1.0893,
|
1724 |
+
"step": 2860
|
1725 |
+
},
|
1726 |
+
{
|
1727 |
+
"epoch": 0.27,
|
1728 |
+
"learning_rate": 0.0008666666666666667,
|
1729 |
+
"loss": 1.1557,
|
1730 |
+
"step": 2870
|
1731 |
+
},
|
1732 |
+
{
|
1733 |
+
"epoch": 0.27,
|
1734 |
+
"learning_rate": 0.0008,
|
1735 |
+
"loss": 1.1966,
|
1736 |
+
"step": 2880
|
1737 |
+
},
|
1738 |
+
{
|
1739 |
+
"epoch": 0.27,
|
1740 |
+
"learning_rate": 0.0007333333333333333,
|
1741 |
+
"loss": 1.2223,
|
1742 |
+
"step": 2890
|
1743 |
+
},
|
1744 |
+
{
|
1745 |
+
"epoch": 0.27,
|
1746 |
+
"learning_rate": 0.0006666666666666666,
|
1747 |
+
"loss": 1.1097,
|
1748 |
+
"step": 2900
|
1749 |
+
},
|
1750 |
+
{
|
1751 |
+
"epoch": 0.27,
|
1752 |
+
"learning_rate": 0.0006,
|
1753 |
+
"loss": 1.1612,
|
1754 |
+
"step": 2910
|
1755 |
+
},
|
1756 |
+
{
|
1757 |
+
"epoch": 0.27,
|
1758 |
+
"learning_rate": 0.0005333333333333334,
|
1759 |
+
"loss": 1.2289,
|
1760 |
+
"step": 2920
|
1761 |
+
},
|
1762 |
+
{
|
1763 |
+
"epoch": 0.27,
|
1764 |
+
"learning_rate": 0.0004666666666666667,
|
1765 |
+
"loss": 1.222,
|
1766 |
+
"step": 2930
|
1767 |
+
},
|
1768 |
+
{
|
1769 |
+
"epoch": 0.27,
|
1770 |
+
"learning_rate": 0.0004,
|
1771 |
+
"loss": 1.1519,
|
1772 |
+
"step": 2940
|
1773 |
+
},
|
1774 |
+
{
|
1775 |
+
"epoch": 0.27,
|
1776 |
+
"learning_rate": 0.0003333333333333333,
|
1777 |
+
"loss": 1.3762,
|
1778 |
+
"step": 2950
|
1779 |
+
},
|
1780 |
+
{
|
1781 |
+
"epoch": 0.27,
|
1782 |
+
"learning_rate": 0.0002666666666666667,
|
1783 |
+
"loss": 1.2506,
|
1784 |
+
"step": 2960
|
1785 |
+
},
|
1786 |
+
{
|
1787 |
+
"epoch": 0.27,
|
1788 |
+
"learning_rate": 0.0002,
|
1789 |
+
"loss": 1.2153,
|
1790 |
+
"step": 2970
|
1791 |
+
},
|
1792 |
+
{
|
1793 |
+
"epoch": 0.28,
|
1794 |
+
"learning_rate": 0.00013333333333333334,
|
1795 |
+
"loss": 1.1327,
|
1796 |
+
"step": 2980
|
1797 |
+
},
|
1798 |
+
{
|
1799 |
+
"epoch": 0.28,
|
1800 |
+
"learning_rate": 6.666666666666667e-05,
|
1801 |
+
"loss": 1.2242,
|
1802 |
+
"step": 2990
|
1803 |
+
},
|
1804 |
+
{
|
1805 |
+
"epoch": 0.28,
|
1806 |
+
"learning_rate": 0.0,
|
1807 |
+
"loss": 1.1963,
|
1808 |
+
"step": 3000
|
1809 |
+
},
|
1810 |
+
{
|
1811 |
+
"epoch": 0.28,
|
1812 |
+
"step": 3000,
|
1813 |
+
"total_flos": 1.73594313916416e+17,
|
1814 |
+
"train_loss": 1.2429857851664226,
|
1815 |
+
"train_runtime": 27386.6257,
|
1816 |
+
"train_samples_per_second": 1.753,
|
1817 |
+
"train_steps_per_second": 0.11
|
1818 |
+
}
|
1819 |
+
],
|
1820 |
+
"max_steps": 3000,
|
1821 |
+
"num_train_epochs": 1,
|
1822 |
+
"total_flos": 1.73594313916416e+17,
|
1823 |
+
"trial_name": null,
|
1824 |
+
"trial_params": null
|
1825 |
+
}
|