Kunger commited on
Commit
ae0200d
1 Parent(s): ac38a99

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/modeling_orion-checkpoint.py ADDED
@@ -0,0 +1,1118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 OrionStar Inc. team. All rights reserved.
2
+ # Copied and adapted from https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py
3
+
4
+ from transformers import AutoConfig, AutoModel
5
+
6
+ from .configuration_orion import OrionConfig
7
+
8
+ import numbers
9
+ import importlib
10
+ import math
11
+ from typing import List, Optional, Tuple, Union
12
+
13
+ import torch
14
+ import torch.nn.functional as F
15
+ from torch.nn.parameter import Parameter
16
+ import torch.utils.checkpoint
17
+ from torch import nn
18
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
19
+ from torch.nn import init
20
+
21
+ from transformers.activations import ACT2FN
22
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
23
+ from transformers.modeling_utils import PreTrainedModel
24
+ from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
25
+ from transformers.utils import (
26
+ add_start_docstrings,
27
+ add_start_docstrings_to_model_forward,
28
+ # is_flash_attn_available,
29
+ logging,
30
+ replace_return_docstrings,
31
+ )
32
+ from .generation_utils import build_chat_input, TextIterStreamer
33
+ from transformers.generation.utils import GenerationConfig
34
+ from threading import Thread
35
+
36
+ # if is_flash_attn_available():
37
+ if True:
38
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
39
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
40
+
41
+ logger = logging.get_logger(__name__)
42
+
43
+ _CONFIG_FOR_DOC = "OrionConfig"
44
+
45
+ def _get_unpad_data(padding_mask):
46
+ seqlens_in_batch = padding_mask.sum(dim=-1, dtype=torch.int32)
47
+ indices = torch.nonzero(padding_mask.flatten(), as_tuple=False).flatten()
48
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
49
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
50
+ return (
51
+ indices,
52
+ cu_seqlens,
53
+ max_seqlen_in_batch,
54
+ )
55
+
56
+
57
+ # Copied from transformers.models.bart.modeling_bart._make_causal_mask
58
+ def _make_causal_mask(
59
+ input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
60
+ ):
61
+ """
62
+ Make causal mask used for bi-directional self-attention.
63
+ """
64
+ bsz, tgt_len = input_ids_shape
65
+ mask = torch.full((tgt_len, tgt_len), torch.finfo(dtype).min, device=device)
66
+ mask_cond = torch.arange(mask.size(-1), device=device)
67
+ mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
68
+ mask = mask.to(dtype)
69
+
70
+ if past_key_values_length > 0:
71
+ mask = torch.cat([torch.zeros(tgt_len, past_key_values_length, dtype=dtype, device=device), mask], dim=-1)
72
+ return mask[None, None, :, :].expand(bsz, 1, tgt_len, tgt_len + past_key_values_length)
73
+
74
+
75
+ # Copied from transformers.models.bart.modeling_bart._expand_mask
76
+ def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
77
+ """
78
+ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
79
+ """
80
+ bsz, src_len = mask.size()
81
+ tgt_len = tgt_len if tgt_len is not None else src_len
82
+
83
+ expanded_mask = mask[:, None, None, :].expand(bsz, 1, tgt_len, src_len).to(dtype)
84
+
85
+ inverted_mask = 1.0 - expanded_mask
86
+
87
+ return inverted_mask.masked_fill(inverted_mask.to(torch.bool), torch.finfo(dtype).min)
88
+
89
+ class OrionRotaryEmbedding(nn.Module):
90
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
91
+ super().__init__()
92
+
93
+ self.dim = dim
94
+ self.max_position_embeddings = max_position_embeddings
95
+ self.base = base
96
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
97
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
98
+
99
+ # Build here to make `torch.jit.trace` work.
100
+ self._set_cos_sin_cache(
101
+ seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
102
+ )
103
+
104
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
105
+ self.max_seq_len_cached = seq_len
106
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
107
+
108
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
109
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
110
+ emb = torch.cat((freqs, freqs), dim=-1)
111
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
112
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
113
+
114
+ def forward(self, x, seq_len=None):
115
+ # x: [bs, num_attention_heads, seq_len, head_size]
116
+ if seq_len > self.max_seq_len_cached:
117
+ self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
118
+
119
+ return (
120
+ self.cos_cached[:seq_len].to(dtype=x.dtype),
121
+ self.sin_cached[:seq_len].to(dtype=x.dtype),
122
+ )
123
+
124
+
125
+ class OrionLinearScalingRotaryEmbedding(OrionRotaryEmbedding):
126
+ """OrionRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
127
+
128
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
129
+ self.scaling_factor = scaling_factor
130
+ super().__init__(dim, max_position_embeddings, base, device)
131
+
132
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
133
+ self.max_seq_len_cached = seq_len
134
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
135
+ t = t / self.scaling_factor
136
+
137
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
138
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
139
+ emb = torch.cat((freqs, freqs), dim=-1)
140
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
141
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
142
+
143
+
144
+ class OrionDynamicNTKScalingRotaryEmbedding(OrionRotaryEmbedding):
145
+ """OrionRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
146
+
147
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
148
+ self.scaling_factor = scaling_factor
149
+ super().__init__(dim, max_position_embeddings, base, device)
150
+
151
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
152
+ self.max_seq_len_cached = seq_len
153
+
154
+ if seq_len > self.max_position_embeddings:
155
+ base = self.base * (
156
+ (self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
157
+ ) ** (self.dim / (self.dim - 2))
158
+ inv_freq = 1.0 / (base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
159
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
160
+
161
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
162
+
163
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
164
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
165
+ emb = torch.cat((freqs, freqs), dim=-1)
166
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
167
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
168
+
169
+
170
+ def rotate_half(x):
171
+ """Rotates half the hidden dims of the input."""
172
+ x1 = x[..., : x.shape[-1] // 2]
173
+ x2 = x[..., x.shape[-1] // 2 :]
174
+ return torch.cat((-x2, x1), dim=-1)
175
+
176
+
177
+ # Copied from transformers.models.gpt_neox.modeling_gpt_neox.apply_rotary_pos_emb
178
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids):
179
+ cos = cos[position_ids].unsqueeze(1) # [seq_len, dim] -> [batch_size, 1, seq_len, head_dim]
180
+ sin = sin[position_ids].unsqueeze(1)
181
+ q_embed = (q * cos) + (rotate_half(q) * sin)
182
+ k_embed = (k * cos) + (rotate_half(k) * sin)
183
+ return q_embed, k_embed
184
+
185
+
186
+ class OrionMLP(nn.Module):
187
+ def __init__(self, config):
188
+ super().__init__()
189
+ self.config = config
190
+ self.hidden_size = config.hidden_size
191
+ self.intermediate_size = config.intermediate_size
192
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
193
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
194
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
195
+ self.act_fn = ACT2FN[config.hidden_act]
196
+
197
+ def forward(self, x):
198
+ if self.config.pretraining_tp > 1:
199
+ slice = self.intermediate_size // self.config.pretraining_tp
200
+ gate_proj_slices = self.gate_proj.weight.split(slice, dim=0)
201
+ up_proj_slices = self.up_proj.weight.split(slice, dim=0)
202
+ down_proj_slices = self.down_proj.weight.split(slice, dim=1)
203
+
204
+ gate_proj = torch.cat(
205
+ [F.linear(x, gate_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1
206
+ )
207
+ up_proj = torch.cat([F.linear(x, up_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1)
208
+
209
+ intermediate_states = (self.act_fn(gate_proj) * up_proj).split(slice, dim=2)
210
+ down_proj = [
211
+ F.linear(intermediate_states[i], down_proj_slices[i]) for i in range(self.config.pretraining_tp)
212
+ ]
213
+ down_proj = sum(down_proj)
214
+ else:
215
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
216
+
217
+ return down_proj
218
+
219
+
220
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
221
+ """
222
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
223
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
224
+ """
225
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
226
+ if n_rep == 1:
227
+ return hidden_states
228
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
229
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
230
+
231
+
232
+ class OrionAttention(nn.Module):
233
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
234
+
235
+ def __init__(self, config: OrionConfig):
236
+ super().__init__()
237
+ self.config = config
238
+ self.hidden_size = config.hidden_size
239
+ self.num_heads = config.num_attention_heads
240
+ self.head_dim = self.hidden_size // self.num_heads
241
+ self.num_key_value_heads = config.num_key_value_heads
242
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
243
+ self.max_position_embeddings = config.max_position_embeddings
244
+ self.rope_theta = config.rope_theta
245
+
246
+ if (self.head_dim * self.num_heads) != self.hidden_size:
247
+ raise ValueError(
248
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
249
+ f" and `num_heads`: {self.num_heads})."
250
+ )
251
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
252
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
253
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
254
+ self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias)
255
+ self._init_rope()
256
+
257
+ def _init_rope(self):
258
+ if self.config.rope_scaling is None:
259
+ self.rotary_emb = OrionRotaryEmbedding(
260
+ self.head_dim,
261
+ max_position_embeddings=self.max_position_embeddings,
262
+ base=self.rope_theta,
263
+ )
264
+ else:
265
+ scaling_type = self.config.rope_scaling["type"]
266
+ scaling_factor = self.config.rope_scaling["factor"]
267
+ if scaling_type == "linear":
268
+ self.rotary_emb = OrionLinearScalingRotaryEmbedding(
269
+ self.head_dim,
270
+ max_position_embeddings=self.max_position_embeddings,
271
+ scaling_factor=scaling_factor,
272
+ base=self.rope_theta,
273
+ )
274
+ elif scaling_type == "dynamic":
275
+ self.rotary_emb = OrionDynamicNTKScalingRotaryEmbedding(
276
+ self.head_dim,
277
+ max_position_embeddings=self.max_position_embeddings,
278
+ scaling_factor=scaling_factor,
279
+ base=self.rope_theta,
280
+ )
281
+ else:
282
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
283
+
284
+ def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
285
+ return tensor.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous()
286
+
287
+ def forward(
288
+ self,
289
+ hidden_states: torch.Tensor,
290
+ attention_mask: Optional[torch.Tensor] = None,
291
+ position_ids: Optional[torch.LongTensor] = None,
292
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
293
+ output_attentions: bool = False,
294
+ use_cache: bool = False,
295
+ padding_mask: Optional[torch.LongTensor] = None,
296
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
297
+ bsz, q_len, _ = hidden_states.size()
298
+
299
+ if self.config.pretraining_tp > 1:
300
+ key_value_slicing = (self.num_key_value_heads * self.head_dim) // self.config.pretraining_tp
301
+ query_slices = self.q_proj.weight.split(
302
+ (self.num_heads * self.head_dim) // self.config.pretraining_tp, dim=0
303
+ )
304
+ key_slices = self.k_proj.weight.split(key_value_slicing, dim=0)
305
+ value_slices = self.v_proj.weight.split(key_value_slicing, dim=0)
306
+
307
+ query_states = [F.linear(hidden_states, query_slices[i]) for i in range(self.config.pretraining_tp)]
308
+ query_states = torch.cat(query_states, dim=-1)
309
+
310
+ key_states = [F.linear(hidden_states, key_slices[i]) for i in range(self.config.pretraining_tp)]
311
+ key_states = torch.cat(key_states, dim=-1)
312
+
313
+ value_states = [F.linear(hidden_states, value_slices[i]) for i in range(self.config.pretraining_tp)]
314
+ value_states = torch.cat(value_states, dim=-1)
315
+
316
+ else:
317
+ query_states = self.q_proj(hidden_states)
318
+ key_states = self.k_proj(hidden_states)
319
+ value_states = self.v_proj(hidden_states)
320
+
321
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
322
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
323
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
324
+
325
+ kv_seq_len = key_states.shape[-2]
326
+ if past_key_value is not None:
327
+ kv_seq_len += past_key_value[0].shape[-2]
328
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
329
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
330
+
331
+ if past_key_value is not None:
332
+ # reuse k, v, self_attention
333
+ key_states = torch.cat([past_key_value[0], key_states], dim=2)
334
+ value_states = torch.cat([past_key_value[1], value_states], dim=2)
335
+
336
+ past_key_value = (key_states, value_states) if use_cache else None
337
+
338
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
339
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
340
+
341
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
342
+
343
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
344
+ raise ValueError(
345
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
346
+ f" {attn_weights.size()}"
347
+ )
348
+
349
+ if attention_mask is not None:
350
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
351
+ raise ValueError(
352
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
353
+ )
354
+ attn_weights = attn_weights + attention_mask
355
+
356
+ # upcast attention to fp32
357
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
358
+ attn_output = torch.matmul(attn_weights, value_states)
359
+
360
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
361
+ raise ValueError(
362
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
363
+ f" {attn_output.size()}"
364
+ )
365
+
366
+ attn_output = attn_output.transpose(1, 2).contiguous()
367
+
368
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
369
+
370
+ if self.config.pretraining_tp > 1:
371
+ attn_output = attn_output.split(self.hidden_size // self.config.pretraining_tp, dim=2)
372
+ o_proj_slices = self.o_proj.weight.split(self.hidden_size // self.config.pretraining_tp, dim=1)
373
+ attn_output = sum([F.linear(attn_output[i], o_proj_slices[i]) for i in range(self.config.pretraining_tp)])
374
+ else:
375
+ attn_output = self.o_proj(attn_output)
376
+
377
+ if not output_attentions:
378
+ attn_weights = None
379
+
380
+ return attn_output, attn_weights, past_key_value
381
+
382
+
383
+ class OrionFlashAttention2(OrionAttention):
384
+ """
385
+ Orion flash attention module. This module inherits from `OrionAttention` as the weights of the module stays
386
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
387
+ flash attention and deal with padding tokens in case the input contains any of them.
388
+ """
389
+
390
+ def forward(
391
+ self,
392
+ hidden_states: torch.Tensor,
393
+ attention_mask: Optional[torch.Tensor] = None,
394
+ position_ids: Optional[torch.LongTensor] = None,
395
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
396
+ output_attentions: bool = False,
397
+ use_cache: bool = False,
398
+ padding_mask: Optional[torch.LongTensor] = None,
399
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
400
+ # OrionFlashAttention2 attention does not support output_attentions
401
+ output_attentions = False
402
+
403
+ bsz, q_len, _ = hidden_states.size()
404
+
405
+ query_states = self.q_proj(hidden_states)
406
+ key_states = self.k_proj(hidden_states)
407
+ value_states = self.v_proj(hidden_states)
408
+
409
+ # Flash attention requires the input to have the shape
410
+ # batch_size x seq_length x head_dime x hidden_dim
411
+ # therefore we just need to keep the original shape
412
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
413
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
414
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
415
+
416
+ kv_seq_len = key_states.shape[-2]
417
+ if past_key_value is not None:
418
+ kv_seq_len += past_key_value[0].shape[-2]
419
+
420
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
421
+
422
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
423
+
424
+ if past_key_value is not None:
425
+ # reuse k, v, self_attention
426
+ key_states = torch.cat([past_key_value[0], key_states], dim=2)
427
+ value_states = torch.cat([past_key_value[1], value_states], dim=2)
428
+
429
+ past_key_value = (key_states, value_states) if use_cache else None
430
+
431
+ query_states = query_states.transpose(1, 2)
432
+ key_states = key_states.transpose(1, 2)
433
+ value_states = value_states.transpose(1, 2)
434
+
435
+ # TODO: llama does not have dropout in the config??
436
+ # It is recommended to use dropout with FA according to the docs
437
+ # when training.
438
+ dropout_rate = 0.0 # if not self.training else self.attn_dropout
439
+
440
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
441
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
442
+ # cast them back in float16 just to be sure everything works as expected.
443
+ # This might slowdown training & inference so it is recommended to not cast the LayerNorms
444
+ # in fp32. (LlamaRMSNorm handles it correctly)
445
+ input_dtype = query_states.dtype
446
+ if input_dtype == torch.float32:
447
+ logger.warning_once(
448
+ "The input hidden states seems to be silently casted in float32, this might be related to"
449
+ " the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
450
+ " float16."
451
+ )
452
+
453
+ query_states = query_states.to(torch.float16)
454
+ key_states = key_states.to(torch.float16)
455
+ value_states = value_states.to(torch.float16)
456
+
457
+ attn_output = self._flash_attention_forward(
458
+ query_states, key_states, value_states, padding_mask, q_len, dropout=dropout_rate
459
+ )
460
+
461
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
462
+ attn_output = self.o_proj(attn_output)
463
+
464
+ if not output_attentions:
465
+ attn_weights = None
466
+
467
+ return attn_output, attn_weights, past_key_value
468
+
469
+ def _flash_attention_forward(
470
+ self, query_states, key_states, value_states, padding_mask, query_length, dropout=0.0, softmax_scale=None
471
+ ):
472
+ """
473
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
474
+ first unpad the input, then computes the attention scores and pad the final attention scores.
475
+
476
+ Args:
477
+ query_states (`torch.Tensor`):
478
+ Input query states to be passed to Flash Attention API
479
+ key_states (`torch.Tensor`):
480
+ Input key states to be passed to Flash Attention API
481
+ value_states (`torch.Tensor`):
482
+ Input value states to be passed to Flash Attention API
483
+ padding_mask (`torch.Tensor`):
484
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
485
+ position of padding tokens and 1 for the position of non-padding tokens.
486
+ dropout (`int`, *optional*):
487
+ Attention dropout
488
+ softmax_scale (`float`, *optional*):
489
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
490
+ """
491
+ # Contains at least one padding token in the sequence
492
+ if padding_mask is not None:
493
+ batch_size = query_states.shape[0]
494
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
495
+ query_states, key_states, value_states, padding_mask, query_length
496
+ )
497
+
498
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
499
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
500
+
501
+ attn_output_unpad = flash_attn_varlen_func(
502
+ query_states,
503
+ key_states,
504
+ value_states,
505
+ cu_seqlens_q=cu_seqlens_q,
506
+ cu_seqlens_k=cu_seqlens_k,
507
+ max_seqlen_q=max_seqlen_in_batch_q,
508
+ max_seqlen_k=max_seqlen_in_batch_k,
509
+ dropout_p=dropout,
510
+ softmax_scale=softmax_scale,
511
+ causal=True,
512
+ )
513
+
514
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
515
+ else:
516
+ attn_output = flash_attn_func(
517
+ query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=True
518
+ )
519
+
520
+ return attn_output
521
+
522
+ def _upad_input(self, query_layer, key_layer, value_layer, padding_mask, query_length):
523
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(padding_mask)
524
+ batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
525
+
526
+ key_layer = index_first_axis(
527
+ key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
528
+ )
529
+ value_layer = index_first_axis(
530
+ value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
531
+ )
532
+ if query_length == kv_seq_len:
533
+ query_layer = index_first_axis(
534
+ query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim), indices_k
535
+ )
536
+ cu_seqlens_q = cu_seqlens_k
537
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
538
+ indices_q = indices_k
539
+ elif query_length == 1:
540
+ max_seqlen_in_batch_q = 1
541
+ cu_seqlens_q = torch.arange(
542
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
543
+ ) # There is a memcpy here, that is very bad.
544
+ indices_q = cu_seqlens_q[:-1]
545
+ query_layer = query_layer.squeeze(1)
546
+ else:
547
+ # The -q_len: slice assumes left padding.
548
+ padding_mask = padding_mask[:, -query_length:]
549
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, padding_mask)
550
+
551
+ return (
552
+ query_layer,
553
+ key_layer,
554
+ value_layer,
555
+ indices_q,
556
+ (cu_seqlens_q, cu_seqlens_k),
557
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
558
+ )
559
+
560
+
561
+ class OrionDecoderLayer(nn.Module):
562
+ def __init__(self, config: OrionConfig):
563
+ super().__init__()
564
+ self.hidden_size = config.hidden_size
565
+ self.self_attn = (
566
+ OrionAttention(config=config)
567
+ if not getattr(config, "_flash_attn_2_enabled", False)
568
+ else OrionFlashAttention2(config=config)
569
+ )
570
+ self.mlp = OrionMLP(config)
571
+ self.input_layernorm = nn.LayerNorm(config.hidden_size, eps=config.rms_norm_eps)
572
+ self.post_attention_layernorm = nn.LayerNorm(config.hidden_size, eps=config.rms_norm_eps)
573
+
574
+ def forward(
575
+ self,
576
+ hidden_states: torch.Tensor,
577
+ attention_mask: Optional[torch.Tensor] = None,
578
+ position_ids: Optional[torch.LongTensor] = None,
579
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
580
+ output_attentions: Optional[bool] = False,
581
+ use_cache: Optional[bool] = False,
582
+ padding_mask: Optional[torch.LongTensor] = None,
583
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
584
+ """
585
+ Args:
586
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
587
+ attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
588
+ `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
589
+ output_attentions (`bool`, *optional*):
590
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
591
+ returned tensors for more detail.
592
+ use_cache (`bool`, *optional*):
593
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
594
+ (see `past_key_values`).
595
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
596
+ """
597
+
598
+ residual = hidden_states
599
+
600
+ hidden_states = self.input_layernorm(hidden_states)
601
+
602
+ # Self Attention
603
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
604
+ hidden_states=hidden_states,
605
+ attention_mask=attention_mask,
606
+ position_ids=position_ids,
607
+ past_key_value=past_key_value,
608
+ output_attentions=output_attentions,
609
+ use_cache=use_cache,
610
+ padding_mask=padding_mask,
611
+ )
612
+ hidden_states = residual + hidden_states
613
+
614
+ # Fully Connected
615
+ residual = hidden_states
616
+ hidden_states = self.post_attention_layernorm(hidden_states)
617
+ hidden_states = self.mlp(hidden_states)
618
+ hidden_states = residual + hidden_states
619
+
620
+ outputs = (hidden_states,)
621
+
622
+ if output_attentions:
623
+ outputs += (self_attn_weights,)
624
+
625
+ if use_cache:
626
+ outputs += (present_key_value,)
627
+
628
+ return outputs
629
+
630
+ class OrionPreTrainedModel(PreTrainedModel):
631
+ config_class = OrionConfig
632
+ base_model_prefix = "model"
633
+ supports_gradient_checkpointing = True
634
+ _no_split_modules = ["OrionDecoderLayer"]
635
+ _skip_keys_device_placement = "past_key_values"
636
+ _supports_flash_attn_2 = True
637
+
638
+ def _init_weights(self, module):
639
+ std = self.config.initializer_range
640
+ if isinstance(module, nn.Linear):
641
+ module.weight.data.normal_(mean=0.0, std=std)
642
+ if module.bias is not None:
643
+ module.bias.data.zero_()
644
+ elif isinstance(module, nn.Embedding):
645
+ module.weight.data.normal_(mean=0.0, std=std)
646
+ if module.padding_idx is not None:
647
+ module.weight.data[module.padding_idx].zero_()
648
+
649
+ def _set_gradient_checkpointing(self, module, value=False):
650
+ if isinstance(module, OrionModel):
651
+ module.gradient_checkpointing = value
652
+
653
+ class OrionModel(OrionPreTrainedModel):
654
+ """
655
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`OrionDecoderLayer`]
656
+
657
+ Args:
658
+ config: OrionConfig
659
+ """
660
+
661
+ def __init__(self, config: OrionConfig):
662
+ super().__init__(config)
663
+ self.padding_idx = config.pad_token_id
664
+ self.vocab_size = config.vocab_size
665
+
666
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
667
+ self.layers = nn.ModuleList([OrionDecoderLayer(config) for _ in range(config.num_hidden_layers)])
668
+ self.norm = nn.LayerNorm(config.hidden_size, eps=config.rms_norm_eps)
669
+
670
+ self.gradient_checkpointing = False
671
+ # Initialize weights and apply final processing
672
+ self.post_init()
673
+
674
+ def get_input_embeddings(self):
675
+ return self.embed_tokens
676
+
677
+ def set_input_embeddings(self, value):
678
+ self.embed_tokens = value
679
+
680
+ # Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
681
+ def _prepare_decoder_attention_mask(self, attention_mask, input_shape, inputs_embeds, past_key_values_length):
682
+ # create causal mask
683
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
684
+ combined_attention_mask = None
685
+ if input_shape[-1] > 1:
686
+ combined_attention_mask = _make_causal_mask(
687
+ input_shape,
688
+ inputs_embeds.dtype,
689
+ device=inputs_embeds.device,
690
+ past_key_values_length=past_key_values_length,
691
+ )
692
+
693
+ if attention_mask is not None:
694
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
695
+ expanded_attn_mask = _expand_mask(attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]).to(
696
+ inputs_embeds.device
697
+ )
698
+ combined_attention_mask = (
699
+ expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask + combined_attention_mask
700
+ )
701
+
702
+ return combined_attention_mask
703
+
704
+ def forward(
705
+ self,
706
+ input_ids: torch.LongTensor = None,
707
+ attention_mask: Optional[torch.Tensor] = None,
708
+ position_ids: Optional[torch.LongTensor] = None,
709
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
710
+ inputs_embeds: Optional[torch.FloatTensor] = None,
711
+ use_cache: Optional[bool] = None,
712
+ output_attentions: Optional[bool] = None,
713
+ output_hidden_states: Optional[bool] = None,
714
+ return_dict: Optional[bool] = None,
715
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
716
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
717
+ output_hidden_states = (
718
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
719
+ )
720
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
721
+
722
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
723
+
724
+ # retrieve input_ids and inputs_embeds
725
+ if input_ids is not None and inputs_embeds is not None:
726
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
727
+ elif input_ids is not None:
728
+ batch_size, seq_length = input_ids.shape
729
+ elif inputs_embeds is not None:
730
+ batch_size, seq_length, _ = inputs_embeds.shape
731
+ else:
732
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
733
+
734
+ seq_length_with_past = seq_length
735
+ past_key_values_length = 0
736
+
737
+ if past_key_values is not None:
738
+ past_key_values_length = past_key_values[0][0].shape[2]
739
+ seq_length_with_past = seq_length_with_past + past_key_values_length
740
+
741
+ if position_ids is None:
742
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
743
+ position_ids = torch.arange(
744
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
745
+ )
746
+ position_ids = position_ids.unsqueeze(0)
747
+
748
+ if inputs_embeds is None:
749
+ inputs_embeds = self.embed_tokens(input_ids)
750
+ # embed positions
751
+ if attention_mask is None:
752
+ attention_mask = torch.ones(
753
+ (batch_size, seq_length_with_past), dtype=torch.bool, device=inputs_embeds.device
754
+ )
755
+ padding_mask = None
756
+ else:
757
+ if 0 in attention_mask:
758
+ padding_mask = attention_mask
759
+ else:
760
+ padding_mask = None
761
+
762
+ attention_mask = self._prepare_decoder_attention_mask(
763
+ attention_mask, (batch_size, seq_length), inputs_embeds, past_key_values_length
764
+ )
765
+
766
+ hidden_states = inputs_embeds
767
+
768
+ if self.gradient_checkpointing and self.training:
769
+ if use_cache:
770
+ logger.warning_once(
771
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
772
+ )
773
+ use_cache = False
774
+
775
+ # decoder layers
776
+ all_hidden_states = () if output_hidden_states else None
777
+ all_self_attns = () if output_attentions else None
778
+ next_decoder_cache = () if use_cache else None
779
+
780
+ for idx, decoder_layer in enumerate(self.layers):
781
+ if output_hidden_states:
782
+ all_hidden_states += (hidden_states,)
783
+
784
+ past_key_value = past_key_values[idx] if past_key_values is not None else None
785
+
786
+ if self.gradient_checkpointing and self.training:
787
+
788
+ def create_custom_forward(module):
789
+ def custom_forward(*inputs):
790
+ # None for past_key_value
791
+ return module(*inputs, past_key_value, output_attentions, padding_mask=padding_mask)
792
+
793
+ return custom_forward
794
+
795
+ layer_outputs = torch.utils.checkpoint.checkpoint(
796
+ create_custom_forward(decoder_layer), hidden_states, attention_mask, position_ids
797
+ )
798
+ else:
799
+ layer_outputs = decoder_layer(
800
+ hidden_states,
801
+ attention_mask=attention_mask,
802
+ position_ids=position_ids,
803
+ past_key_value=past_key_value,
804
+ output_attentions=output_attentions,
805
+ use_cache=use_cache,
806
+ padding_mask=padding_mask,
807
+ )
808
+
809
+ hidden_states = layer_outputs[0]
810
+
811
+ if use_cache:
812
+ next_decoder_cache += (layer_outputs[2 if output_attentions else 1],)
813
+
814
+ if output_attentions:
815
+ all_self_attns += (layer_outputs[1],)
816
+
817
+ hidden_states = self.norm(hidden_states)
818
+
819
+ # add hidden states from the last decoder layer
820
+ if output_hidden_states:
821
+ all_hidden_states += (hidden_states,)
822
+
823
+ next_cache = next_decoder_cache if use_cache else None
824
+ if not return_dict:
825
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
826
+ return BaseModelOutputWithPast(
827
+ last_hidden_state=hidden_states,
828
+ past_key_values=next_cache,
829
+ hidden_states=all_hidden_states,
830
+ attentions=all_self_attns,
831
+ )
832
+
833
+
834
+ class OrionForCausalLM(OrionPreTrainedModel):
835
+ model_type = "orion"
836
+ _tied_weights_keys = ["lm_head.weight"]
837
+
838
+ def __init__(self, config):
839
+ super().__init__(config)
840
+ self.model = OrionModel(config)
841
+ self.vocab_size = config.vocab_size
842
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
843
+
844
+ # Initialize weights and apply final processing
845
+ self.post_init()
846
+
847
+ def get_input_embeddings(self):
848
+ return self.model.embed_tokens
849
+
850
+ def set_input_embeddings(self, value):
851
+ self.model.embed_tokens = value
852
+
853
+ def get_output_embeddings(self):
854
+ return self.lm_head
855
+
856
+ def set_output_embeddings(self, new_embeddings):
857
+ self.lm_head = new_embeddings
858
+
859
+ def set_decoder(self, decoder):
860
+ self.model = decoder
861
+
862
+ def get_decoder(self):
863
+ return self.model
864
+
865
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
866
+ def forward(
867
+ self,
868
+ input_ids: torch.LongTensor = None,
869
+ attention_mask: Optional[torch.Tensor] = None,
870
+ position_ids: Optional[torch.LongTensor] = None,
871
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
872
+ inputs_embeds: Optional[torch.FloatTensor] = None,
873
+ labels: Optional[torch.LongTensor] = None,
874
+ use_cache: Optional[bool] = None,
875
+ output_attentions: Optional[bool] = None,
876
+ output_hidden_states: Optional[bool] = None,
877
+ return_dict: Optional[bool] = None,
878
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
879
+ r"""
880
+ Args:
881
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
882
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
883
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
884
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
885
+
886
+ Returns:
887
+
888
+ Example:
889
+
890
+ ```python
891
+ >>> from transformers import AutoTokenizer, OrionForCausalLM
892
+
893
+ >>> model = OrionForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
894
+ >>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
895
+
896
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
897
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
898
+
899
+ >>> # Generate
900
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
901
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
902
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
903
+ ```"""
904
+
905
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
906
+ output_hidden_states = (
907
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
908
+ )
909
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
910
+
911
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
912
+ outputs = self.model(
913
+ input_ids=input_ids,
914
+ attention_mask=attention_mask,
915
+ position_ids=position_ids,
916
+ past_key_values=past_key_values,
917
+ inputs_embeds=inputs_embeds,
918
+ use_cache=use_cache,
919
+ output_attentions=output_attentions,
920
+ output_hidden_states=output_hidden_states,
921
+ return_dict=return_dict,
922
+ )
923
+
924
+ hidden_states = outputs[0]
925
+ if self.config.pretraining_tp > 1:
926
+ lm_head_slices = self.lm_head.weight.split(self.vocab_size // self.config.pretraining_tp, dim=0)
927
+ logits = [F.linear(hidden_states, lm_head_slices[i]) for i in range(self.config.pretraining_tp)]
928
+ logits = torch.cat(logits, dim=-1)
929
+ else:
930
+ logits = self.lm_head(hidden_states)
931
+ logits = logits.float()
932
+
933
+ loss = None
934
+ if labels is not None:
935
+ # Shift so that tokens < n predict n
936
+ shift_logits = logits[..., :-1, :].contiguous()
937
+ shift_labels = labels[..., 1:].contiguous()
938
+ # Flatten the tokens
939
+ loss_fct = CrossEntropyLoss()
940
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
941
+ shift_labels = shift_labels.view(-1)
942
+ # Enable model parallelism
943
+ shift_labels = shift_labels.to(shift_logits.device)
944
+ loss = loss_fct(shift_logits, shift_labels)
945
+
946
+ if not return_dict:
947
+ output = (logits,) + outputs[1:]
948
+ return (loss,) + output if loss is not None else output
949
+
950
+ return CausalLMOutputWithPast(
951
+ loss=loss,
952
+ logits=logits,
953
+ past_key_values=outputs.past_key_values,
954
+ hidden_states=outputs.hidden_states,
955
+ attentions=outputs.attentions,
956
+ )
957
+
958
+ def chat(self, tokenizer, messages: List[dict], streaming=False,generation_config: Optional[GenerationConfig]=None):
959
+ generation_config = generation_config or self.generation_config
960
+ input_tokens = build_chat_input(tokenizer,messages)
961
+ input_ids = torch.LongTensor([input_tokens]).to(self.device)
962
+
963
+ if streaming:
964
+ streamer = TextIterStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
965
+ Thread(target=self.generate, kwargs=dict(
966
+ inputs=input_ids, streamer=streamer,
967
+ generation_config=generation_config,
968
+ )).start()
969
+ return streamer
970
+ else:
971
+ outputs = self.generate(input_ids, generation_config=generation_config)
972
+ response = tokenizer.decode(outputs[0][len(input_ids[0]):], skip_special_tokens=True)
973
+ return response
974
+
975
+ def prepare_inputs_for_generation(
976
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
977
+ ):
978
+ if past_key_values:
979
+ input_ids = input_ids[:, -1:]
980
+
981
+ position_ids = kwargs.get("position_ids", None)
982
+ if attention_mask is not None and position_ids is None:
983
+ # create position_ids on the fly for batch generation
984
+ position_ids = attention_mask.long().cumsum(-1) - 1
985
+ position_ids.masked_fill_(attention_mask == 0, 1)
986
+ if past_key_values:
987
+ position_ids = position_ids[:, -1].unsqueeze(-1)
988
+
989
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
990
+ if inputs_embeds is not None and past_key_values is None:
991
+ model_inputs = {"inputs_embeds": inputs_embeds}
992
+ else:
993
+ model_inputs = {"input_ids": input_ids}
994
+
995
+ model_inputs.update(
996
+ {
997
+ "position_ids": position_ids,
998
+ "past_key_values": past_key_values,
999
+ "use_cache": kwargs.get("use_cache"),
1000
+ "attention_mask": attention_mask,
1001
+ }
1002
+ )
1003
+ return model_inputs
1004
+
1005
+ @staticmethod
1006
+ def _reorder_cache(past_key_values, beam_idx):
1007
+ reordered_past = ()
1008
+ for layer_past in past_key_values:
1009
+ reordered_past += (
1010
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1011
+ )
1012
+ return reordered_past
1013
+
1014
+ class OrionForSequenceClassification(OrionPreTrainedModel):
1015
+ def __init__(self, config):
1016
+ super().__init__(config)
1017
+ self.num_labels = config.num_labels
1018
+ self.model = OrionModel(config)
1019
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1020
+
1021
+ # Initialize weights and apply final processing
1022
+ self.post_init()
1023
+
1024
+ def get_input_embeddings(self):
1025
+ return self.model.embed_tokens
1026
+
1027
+ def set_input_embeddings(self, value):
1028
+ self.model.embed_tokens = value
1029
+
1030
+ def forward(
1031
+ self,
1032
+ input_ids: torch.LongTensor = None,
1033
+ attention_mask: Optional[torch.Tensor] = None,
1034
+ position_ids: Optional[torch.LongTensor] = None,
1035
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1036
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1037
+ labels: Optional[torch.LongTensor] = None,
1038
+ use_cache: Optional[bool] = None,
1039
+ output_attentions: Optional[bool] = None,
1040
+ output_hidden_states: Optional[bool] = None,
1041
+ return_dict: Optional[bool] = None,
1042
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1043
+ r"""
1044
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1045
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1046
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1047
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1048
+ """
1049
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1050
+
1051
+ transformer_outputs = self.model(
1052
+ input_ids,
1053
+ attention_mask=attention_mask,
1054
+ position_ids=position_ids,
1055
+ past_key_values=past_key_values,
1056
+ inputs_embeds=inputs_embeds,
1057
+ use_cache=use_cache,
1058
+ output_attentions=output_attentions,
1059
+ output_hidden_states=output_hidden_states,
1060
+ return_dict=return_dict,
1061
+ )
1062
+ hidden_states = transformer_outputs[0]
1063
+ logits = self.score(hidden_states)
1064
+
1065
+ if input_ids is not None:
1066
+ batch_size = input_ids.shape[0]
1067
+ else:
1068
+ batch_size = inputs_embeds.shape[0]
1069
+
1070
+ if self.config.pad_token_id is None and batch_size != 1:
1071
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1072
+ if self.config.pad_token_id is None:
1073
+ sequence_lengths = -1
1074
+ else:
1075
+ if input_ids is not None:
1076
+ sequence_lengths = (torch.eq(input_ids, self.config.pad_token_id).long().argmax(-1) - 1).to(
1077
+ logits.device
1078
+ )
1079
+ else:
1080
+ sequence_lengths = -1
1081
+
1082
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1083
+
1084
+ loss = None
1085
+ if labels is not None:
1086
+ labels = labels.to(logits.device)
1087
+ if self.config.problem_type is None:
1088
+ if self.num_labels == 1:
1089
+ self.config.problem_type = "regression"
1090
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1091
+ self.config.problem_type = "single_label_classification"
1092
+ else:
1093
+ self.config.problem_type = "multi_label_classification"
1094
+
1095
+ if self.config.problem_type == "regression":
1096
+ loss_fct = MSELoss()
1097
+ if self.num_labels == 1:
1098
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1099
+ else:
1100
+ loss = loss_fct(pooled_logits, labels)
1101
+ elif self.config.problem_type == "single_label_classification":
1102
+ loss_fct = CrossEntropyLoss()
1103
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1104
+ elif self.config.problem_type == "multi_label_classification":
1105
+ loss_fct = BCEWithLogitsLoss()
1106
+ loss = loss_fct(pooled_logits, labels)
1107
+ if not return_dict:
1108
+ output = (pooled_logits,) + transformer_outputs[1:]
1109
+ return ((loss,) + output) if loss is not None else output
1110
+
1111
+ return SequenceClassifierOutputWithPast(
1112
+ loss=loss,
1113
+ logits=pooled_logits,
1114
+ past_key_values=transformer_outputs.past_key_values,
1115
+ hidden_states=transformer_outputs.hidden_states,
1116
+ attentions=transformer_outputs.attentions,
1117
+ )
1118
+
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/autodl-tmp/Sakura-13B-LNovel-v0.11pre1/",
3
+ "architectures": [
4
+ "OrionForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_orion.OrionConfig",
9
+ "AutoModelForCausalLM": "modeling_orion.OrionForCausalLM"
10
+ },
11
+ "bos_token_id": 1,
12
+ "eos_token_id": 2,
13
+ "hidden_act": "silu",
14
+ "hidden_size": 5120,
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 15360,
17
+ "max_position_embeddings": 4096,
18
+ "max_sequence_length": 4096,
19
+ "model_type": "orion",
20
+ "num_attention_heads": 40,
21
+ "num_hidden_layers": 40,
22
+ "num_key_value_heads": 40,
23
+ "pad_token_id": 0,
24
+ "pretraining_tp": 1,
25
+ "quantization_config": {
26
+ "bits": 4,
27
+ "group_size": 128,
28
+ "modules_to_not_convert": null,
29
+ "quant_method": "awq",
30
+ "version": "gemm",
31
+ "zero_point": true
32
+ },
33
+ "rms_norm_eps": 1e-05,
34
+ "rope_scaling": null,
35
+ "rope_theta": 10000.0,
36
+ "tie_word_embeddings": false,
37
+ "torch_dtype": "bfloat16",
38
+ "transformers_version": "4.38.2",
39
+ "use_cache": false,
40
+ "vocab_size": 84608
41
+ }
configuration_orion.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2024, OrionStar Inc. All rights reserved.
2
+
3
+ from transformers import PretrainedConfig
4
+
5
+ class OrionConfig(PretrainedConfig):
6
+ model_type = "orion"
7
+ keys_to_ignore_at_inference = ["past_key_values"]
8
+
9
+ def __init__(
10
+ self,
11
+ vocab_size=84608,
12
+ hidden_size=4096,
13
+ intermediate_size=15360,
14
+ num_hidden_layers=40,
15
+ num_attention_heads=40,
16
+ num_key_value_heads=40,
17
+ hidden_act="silu",
18
+ max_position_embeddings=4096,
19
+ initializer_range=0.02,
20
+ rms_norm_eps=1e-5,
21
+ use_cache=True,
22
+ pad_token_id=None,
23
+ bos_token_id=1,
24
+ eos_token_id=2,
25
+ pretraining_tp=1,
26
+ tie_word_embeddings=False,
27
+ rope_theta=10000.0,
28
+ rope_scaling=None,
29
+ attention_bias=False,
30
+ **kwargs,
31
+ ):
32
+ self.vocab_size = vocab_size
33
+ self.max_position_embeddings = max_position_embeddings
34
+ self.hidden_size = hidden_size
35
+ self.intermediate_size = intermediate_size
36
+ self.num_hidden_layers = num_hidden_layers
37
+ self.num_attention_heads = num_attention_heads
38
+
39
+ # for backward compatibility
40
+ if num_key_value_heads is None:
41
+ num_key_value_heads = num_attention_heads
42
+
43
+ self.num_key_value_heads = num_key_value_heads
44
+ self.hidden_act = hidden_act
45
+ self.initializer_range = initializer_range
46
+ self.rms_norm_eps = rms_norm_eps
47
+ self.pretraining_tp = pretraining_tp
48
+ self.use_cache = use_cache
49
+ self.rope_theta = rope_theta
50
+ self.rope_scaling = rope_scaling
51
+ self._rope_scaling_validation()
52
+ self.attention_bias = attention_bias
53
+
54
+ super().__init__(
55
+ pad_token_id=pad_token_id,
56
+ bos_token_id=bos_token_id,
57
+ eos_token_id=eos_token_id,
58
+ tie_word_embeddings=tie_word_embeddings,
59
+ **kwargs,
60
+ )
61
+
62
+ def _rope_scaling_validation(self):
63
+ """
64
+ Validate the `rope_scaling` configuration.
65
+ """
66
+ if self.rope_scaling is None:
67
+ return
68
+
69
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
70
+ raise ValueError(
71
+ "`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, "
72
+ f"got {self.rope_scaling}"
73
+ )
74
+ rope_scaling_type = self.rope_scaling.get("type", None)
75
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
76
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
77
+ raise ValueError(
78
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
79
+ )
80
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
81
+ raise ValueError(f"`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}")
82
+
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "do_sample": true,
5
+ "eos_token_id": 2,
6
+ "max_new_tokens": 1024,
7
+ "pad_token_id": 0,
8
+ "repetition_penalty": 1.05,
9
+ "temperature": 0.3,
10
+ "top_k": 5,
11
+ "top_p": 0.9,
12
+ "transformers_version": "4.38.2"
13
+ }
generation_utils.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+ from queue import Queue
3
+
4
+ # build chat input prompt
5
+ def build_chat_input(tokenizer, messages: List[dict]):
6
+ # chat format:
7
+ # single-turn: <s>Human: Hello!\n\nAssistant: </s>
8
+ # multi-turn: <s>Human: Hello!\n\nAssistant: </s>Hi!</s>Human: How are you?\n\nAssistant: </s>I'm fine</s>
9
+
10
+ prompt = "<s>"
11
+ for msg in messages:
12
+ role = msg["role"]
13
+ message = msg["content"]
14
+ if message is None :
15
+ continue
16
+ if role == "user":
17
+ prompt += "Human: " + message + "\n\nAssistant: </s>"
18
+ if role == "assistant":
19
+ prompt += message + "</s>"
20
+
21
+ input_tokens = tokenizer.encode(prompt)
22
+ return input_tokens
23
+
24
+
25
+ class TextIterStreamer:
26
+ def __init__(self, tokenizer, skip_prompt=False, skip_special_tokens=False):
27
+ self.tokenizer = tokenizer
28
+ self.skip_prompt = skip_prompt
29
+ self.skip_special_tokens = skip_special_tokens
30
+ self.tokens = []
31
+ self.text_queue = Queue()
32
+ self.next_tokens_are_prompt = True
33
+
34
+ def put(self, value):
35
+ if self.skip_prompt and self.next_tokens_are_prompt:
36
+ self.next_tokens_are_prompt = False
37
+ else:
38
+ if len(value.shape) > 1:
39
+ value = value[0]
40
+ self.tokens.extend(value.tolist())
41
+ self.text_queue.put(
42
+ self.tokenizer.decode(self.tokens, skip_special_tokens=self.skip_special_tokens))
43
+
44
+ def end(self):
45
+ self.text_queue.put(None)
46
+
47
+ def __iter__(self):
48
+ return self
49
+
50
+ def __next__(self):
51
+ value = self.text_queue.get()
52
+ if value is None:
53
+ raise StopIteration()
54
+ else:
55
+ return value
56
+
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c850a344867d9b4c5b36fe42e9d67950ac295a0ad2502c59c35c77e7dbd66361
3
+ size 4994012488
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85fd4e66e142bb3b54c9e73d1c8ea994dc402e4150c27369f4ecdbff97b0ba66
3
+ size 3822516504
model.safetensors.index.json ADDED
@@ -0,0 +1,1011 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 8816414720
4
+ },
5
+ "weight_map": {
6
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
7
+ "model.layers.0.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
18
+ "model.layers.0.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
19
+ "model.layers.0.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
20
+ "model.layers.0.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
21
+ "model.layers.0.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
22
+ "model.layers.0.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
23
+ "model.layers.0.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
24
+ "model.layers.0.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
25
+ "model.layers.0.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
26
+ "model.layers.0.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
27
+ "model.layers.0.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
28
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.0.input_layernorm.bias": "model-00001-of-00002.safetensors",
30
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.0.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
32
+ "model.layers.1.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
33
+ "model.layers.1.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
34
+ "model.layers.1.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
35
+ "model.layers.1.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
36
+ "model.layers.1.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
37
+ "model.layers.1.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
38
+ "model.layers.1.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
39
+ "model.layers.1.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
40
+ "model.layers.1.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
41
+ "model.layers.1.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
42
+ "model.layers.1.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
43
+ "model.layers.1.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
44
+ "model.layers.1.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
45
+ "model.layers.1.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
46
+ "model.layers.1.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
47
+ "model.layers.1.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
48
+ "model.layers.1.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
49
+ "model.layers.1.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
50
+ "model.layers.1.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
51
+ "model.layers.1.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
52
+ "model.layers.1.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
53
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.1.input_layernorm.bias": "model-00001-of-00002.safetensors",
55
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.1.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
57
+ "model.layers.2.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
58
+ "model.layers.2.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
59
+ "model.layers.2.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
60
+ "model.layers.2.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
61
+ "model.layers.2.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
62
+ "model.layers.2.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
63
+ "model.layers.2.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
64
+ "model.layers.2.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
65
+ "model.layers.2.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
66
+ "model.layers.2.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
67
+ "model.layers.2.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
68
+ "model.layers.2.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
69
+ "model.layers.2.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
70
+ "model.layers.2.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
71
+ "model.layers.2.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
72
+ "model.layers.2.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
73
+ "model.layers.2.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
74
+ "model.layers.2.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
75
+ "model.layers.2.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
76
+ "model.layers.2.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
77
+ "model.layers.2.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
78
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.2.input_layernorm.bias": "model-00001-of-00002.safetensors",
80
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.2.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
82
+ "model.layers.3.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
83
+ "model.layers.3.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
84
+ "model.layers.3.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
85
+ "model.layers.3.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
86
+ "model.layers.3.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
87
+ "model.layers.3.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
88
+ "model.layers.3.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
89
+ "model.layers.3.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
90
+ "model.layers.3.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
91
+ "model.layers.3.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
92
+ "model.layers.3.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
93
+ "model.layers.3.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
94
+ "model.layers.3.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
95
+ "model.layers.3.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
96
+ "model.layers.3.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
97
+ "model.layers.3.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
98
+ "model.layers.3.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
99
+ "model.layers.3.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
100
+ "model.layers.3.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
101
+ "model.layers.3.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
102
+ "model.layers.3.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
103
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.3.input_layernorm.bias": "model-00001-of-00002.safetensors",
105
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.3.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
107
+ "model.layers.4.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
108
+ "model.layers.4.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
109
+ "model.layers.4.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
110
+ "model.layers.4.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
111
+ "model.layers.4.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
112
+ "model.layers.4.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
113
+ "model.layers.4.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
114
+ "model.layers.4.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
115
+ "model.layers.4.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
116
+ "model.layers.4.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
117
+ "model.layers.4.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
118
+ "model.layers.4.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
119
+ "model.layers.4.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
120
+ "model.layers.4.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
121
+ "model.layers.4.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
122
+ "model.layers.4.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
123
+ "model.layers.4.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
124
+ "model.layers.4.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
125
+ "model.layers.4.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
126
+ "model.layers.4.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
127
+ "model.layers.4.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
128
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.4.input_layernorm.bias": "model-00001-of-00002.safetensors",
130
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.4.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
132
+ "model.layers.5.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
133
+ "model.layers.5.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
134
+ "model.layers.5.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
135
+ "model.layers.5.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
136
+ "model.layers.5.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
137
+ "model.layers.5.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
138
+ "model.layers.5.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
139
+ "model.layers.5.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
140
+ "model.layers.5.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
141
+ "model.layers.5.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
142
+ "model.layers.5.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
143
+ "model.layers.5.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
144
+ "model.layers.5.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
145
+ "model.layers.5.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
146
+ "model.layers.5.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
147
+ "model.layers.5.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
148
+ "model.layers.5.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
149
+ "model.layers.5.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
150
+ "model.layers.5.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
151
+ "model.layers.5.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
152
+ "model.layers.5.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
153
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.5.input_layernorm.bias": "model-00001-of-00002.safetensors",
155
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.5.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
157
+ "model.layers.6.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
158
+ "model.layers.6.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
159
+ "model.layers.6.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
160
+ "model.layers.6.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
161
+ "model.layers.6.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
162
+ "model.layers.6.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
163
+ "model.layers.6.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
164
+ "model.layers.6.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
165
+ "model.layers.6.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
166
+ "model.layers.6.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
167
+ "model.layers.6.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
168
+ "model.layers.6.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
169
+ "model.layers.6.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
170
+ "model.layers.6.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
171
+ "model.layers.6.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
172
+ "model.layers.6.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
173
+ "model.layers.6.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
174
+ "model.layers.6.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
175
+ "model.layers.6.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
176
+ "model.layers.6.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
177
+ "model.layers.6.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
178
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
179
+ "model.layers.6.input_layernorm.bias": "model-00001-of-00002.safetensors",
180
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
181
+ "model.layers.6.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
182
+ "model.layers.7.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
183
+ "model.layers.7.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
184
+ "model.layers.7.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
185
+ "model.layers.7.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
186
+ "model.layers.7.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
187
+ "model.layers.7.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
188
+ "model.layers.7.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
189
+ "model.layers.7.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
190
+ "model.layers.7.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
191
+ "model.layers.7.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
192
+ "model.layers.7.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
193
+ "model.layers.7.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
194
+ "model.layers.7.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
195
+ "model.layers.7.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
196
+ "model.layers.7.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
197
+ "model.layers.7.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
198
+ "model.layers.7.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
199
+ "model.layers.7.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
200
+ "model.layers.7.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
201
+ "model.layers.7.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
202
+ "model.layers.7.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
203
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
204
+ "model.layers.7.input_layernorm.bias": "model-00001-of-00002.safetensors",
205
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
206
+ "model.layers.7.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
207
+ "model.layers.8.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
208
+ "model.layers.8.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
209
+ "model.layers.8.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
210
+ "model.layers.8.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
211
+ "model.layers.8.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
212
+ "model.layers.8.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
213
+ "model.layers.8.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
214
+ "model.layers.8.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
215
+ "model.layers.8.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
216
+ "model.layers.8.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
217
+ "model.layers.8.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
218
+ "model.layers.8.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
219
+ "model.layers.8.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
220
+ "model.layers.8.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
221
+ "model.layers.8.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
222
+ "model.layers.8.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
223
+ "model.layers.8.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
224
+ "model.layers.8.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
225
+ "model.layers.8.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
226
+ "model.layers.8.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
227
+ "model.layers.8.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
228
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
229
+ "model.layers.8.input_layernorm.bias": "model-00001-of-00002.safetensors",
230
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
231
+ "model.layers.8.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
232
+ "model.layers.9.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
233
+ "model.layers.9.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
234
+ "model.layers.9.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
235
+ "model.layers.9.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
236
+ "model.layers.9.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
237
+ "model.layers.9.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
238
+ "model.layers.9.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
239
+ "model.layers.9.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
240
+ "model.layers.9.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
241
+ "model.layers.9.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
242
+ "model.layers.9.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
243
+ "model.layers.9.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
244
+ "model.layers.9.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
245
+ "model.layers.9.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
246
+ "model.layers.9.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
247
+ "model.layers.9.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
248
+ "model.layers.9.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
249
+ "model.layers.9.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
250
+ "model.layers.9.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
251
+ "model.layers.9.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
252
+ "model.layers.9.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
253
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
254
+ "model.layers.9.input_layernorm.bias": "model-00001-of-00002.safetensors",
255
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
256
+ "model.layers.9.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
257
+ "model.layers.10.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
258
+ "model.layers.10.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
259
+ "model.layers.10.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
260
+ "model.layers.10.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
261
+ "model.layers.10.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
262
+ "model.layers.10.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
263
+ "model.layers.10.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
264
+ "model.layers.10.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
265
+ "model.layers.10.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
266
+ "model.layers.10.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
267
+ "model.layers.10.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
268
+ "model.layers.10.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
269
+ "model.layers.10.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
270
+ "model.layers.10.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
271
+ "model.layers.10.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
272
+ "model.layers.10.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
273
+ "model.layers.10.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
274
+ "model.layers.10.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
275
+ "model.layers.10.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
276
+ "model.layers.10.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
277
+ "model.layers.10.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
278
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
279
+ "model.layers.10.input_layernorm.bias": "model-00001-of-00002.safetensors",
280
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
281
+ "model.layers.10.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
282
+ "model.layers.11.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
283
+ "model.layers.11.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
284
+ "model.layers.11.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
285
+ "model.layers.11.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
286
+ "model.layers.11.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
287
+ "model.layers.11.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
288
+ "model.layers.11.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
289
+ "model.layers.11.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
290
+ "model.layers.11.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
291
+ "model.layers.11.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
292
+ "model.layers.11.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
293
+ "model.layers.11.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
294
+ "model.layers.11.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
295
+ "model.layers.11.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
296
+ "model.layers.11.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
297
+ "model.layers.11.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
298
+ "model.layers.11.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
299
+ "model.layers.11.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
300
+ "model.layers.11.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
301
+ "model.layers.11.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
302
+ "model.layers.11.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
303
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
304
+ "model.layers.11.input_layernorm.bias": "model-00001-of-00002.safetensors",
305
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
306
+ "model.layers.11.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
307
+ "model.layers.12.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
308
+ "model.layers.12.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
309
+ "model.layers.12.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
310
+ "model.layers.12.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
311
+ "model.layers.12.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
312
+ "model.layers.12.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
313
+ "model.layers.12.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
314
+ "model.layers.12.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
315
+ "model.layers.12.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
316
+ "model.layers.12.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
317
+ "model.layers.12.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
318
+ "model.layers.12.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
319
+ "model.layers.12.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
320
+ "model.layers.12.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
321
+ "model.layers.12.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
322
+ "model.layers.12.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
323
+ "model.layers.12.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
324
+ "model.layers.12.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
325
+ "model.layers.12.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
326
+ "model.layers.12.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
327
+ "model.layers.12.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
328
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
329
+ "model.layers.12.input_layernorm.bias": "model-00001-of-00002.safetensors",
330
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
331
+ "model.layers.12.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
332
+ "model.layers.13.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
333
+ "model.layers.13.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
334
+ "model.layers.13.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
335
+ "model.layers.13.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
336
+ "model.layers.13.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
337
+ "model.layers.13.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
338
+ "model.layers.13.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
339
+ "model.layers.13.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
340
+ "model.layers.13.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
341
+ "model.layers.13.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
342
+ "model.layers.13.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
343
+ "model.layers.13.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
344
+ "model.layers.13.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
345
+ "model.layers.13.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
346
+ "model.layers.13.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
347
+ "model.layers.13.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
348
+ "model.layers.13.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
349
+ "model.layers.13.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
350
+ "model.layers.13.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
351
+ "model.layers.13.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
352
+ "model.layers.13.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
353
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
354
+ "model.layers.13.input_layernorm.bias": "model-00001-of-00002.safetensors",
355
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
356
+ "model.layers.13.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
357
+ "model.layers.14.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
358
+ "model.layers.14.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
359
+ "model.layers.14.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
360
+ "model.layers.14.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
361
+ "model.layers.14.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
362
+ "model.layers.14.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
363
+ "model.layers.14.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
364
+ "model.layers.14.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
365
+ "model.layers.14.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
366
+ "model.layers.14.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
367
+ "model.layers.14.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
368
+ "model.layers.14.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
369
+ "model.layers.14.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
370
+ "model.layers.14.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
371
+ "model.layers.14.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
372
+ "model.layers.14.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
373
+ "model.layers.14.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
374
+ "model.layers.14.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
375
+ "model.layers.14.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
376
+ "model.layers.14.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
377
+ "model.layers.14.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
378
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
379
+ "model.layers.14.input_layernorm.bias": "model-00001-of-00002.safetensors",
380
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
381
+ "model.layers.14.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
382
+ "model.layers.15.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
383
+ "model.layers.15.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
384
+ "model.layers.15.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
385
+ "model.layers.15.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
386
+ "model.layers.15.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
387
+ "model.layers.15.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
388
+ "model.layers.15.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
389
+ "model.layers.15.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
390
+ "model.layers.15.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
391
+ "model.layers.15.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
392
+ "model.layers.15.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
393
+ "model.layers.15.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
394
+ "model.layers.15.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
395
+ "model.layers.15.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
396
+ "model.layers.15.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
397
+ "model.layers.15.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
398
+ "model.layers.15.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
399
+ "model.layers.15.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
400
+ "model.layers.15.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
401
+ "model.layers.15.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
402
+ "model.layers.15.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
403
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
404
+ "model.layers.15.input_layernorm.bias": "model-00001-of-00002.safetensors",
405
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
406
+ "model.layers.15.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
407
+ "model.layers.16.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
408
+ "model.layers.16.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
409
+ "model.layers.16.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
410
+ "model.layers.16.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
411
+ "model.layers.16.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
412
+ "model.layers.16.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
413
+ "model.layers.16.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
414
+ "model.layers.16.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
415
+ "model.layers.16.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
416
+ "model.layers.16.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
417
+ "model.layers.16.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
418
+ "model.layers.16.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
419
+ "model.layers.16.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
420
+ "model.layers.16.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
421
+ "model.layers.16.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
422
+ "model.layers.16.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
423
+ "model.layers.16.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
424
+ "model.layers.16.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
425
+ "model.layers.16.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
426
+ "model.layers.16.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
427
+ "model.layers.16.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
428
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
429
+ "model.layers.16.input_layernorm.bias": "model-00001-of-00002.safetensors",
430
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
431
+ "model.layers.16.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
432
+ "model.layers.17.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
433
+ "model.layers.17.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
434
+ "model.layers.17.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
435
+ "model.layers.17.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
436
+ "model.layers.17.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
437
+ "model.layers.17.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
438
+ "model.layers.17.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
439
+ "model.layers.17.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
440
+ "model.layers.17.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
441
+ "model.layers.17.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
442
+ "model.layers.17.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
443
+ "model.layers.17.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
444
+ "model.layers.17.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
445
+ "model.layers.17.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
446
+ "model.layers.17.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
447
+ "model.layers.17.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
448
+ "model.layers.17.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
449
+ "model.layers.17.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
450
+ "model.layers.17.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
451
+ "model.layers.17.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
452
+ "model.layers.17.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
453
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
454
+ "model.layers.17.input_layernorm.bias": "model-00001-of-00002.safetensors",
455
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
456
+ "model.layers.17.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
457
+ "model.layers.18.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
458
+ "model.layers.18.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
459
+ "model.layers.18.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
460
+ "model.layers.18.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
461
+ "model.layers.18.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
462
+ "model.layers.18.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
463
+ "model.layers.18.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
464
+ "model.layers.18.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
465
+ "model.layers.18.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
466
+ "model.layers.18.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
467
+ "model.layers.18.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
468
+ "model.layers.18.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
469
+ "model.layers.18.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
470
+ "model.layers.18.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
471
+ "model.layers.18.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
472
+ "model.layers.18.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
473
+ "model.layers.18.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
474
+ "model.layers.18.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
475
+ "model.layers.18.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
476
+ "model.layers.18.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
477
+ "model.layers.18.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
478
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
479
+ "model.layers.18.input_layernorm.bias": "model-00001-of-00002.safetensors",
480
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
481
+ "model.layers.18.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
482
+ "model.layers.19.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
483
+ "model.layers.19.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
484
+ "model.layers.19.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
485
+ "model.layers.19.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
486
+ "model.layers.19.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
487
+ "model.layers.19.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
488
+ "model.layers.19.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
489
+ "model.layers.19.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
490
+ "model.layers.19.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
491
+ "model.layers.19.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
492
+ "model.layers.19.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
493
+ "model.layers.19.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
494
+ "model.layers.19.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
495
+ "model.layers.19.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
496
+ "model.layers.19.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
497
+ "model.layers.19.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
498
+ "model.layers.19.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
499
+ "model.layers.19.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
500
+ "model.layers.19.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
501
+ "model.layers.19.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
502
+ "model.layers.19.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
503
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
504
+ "model.layers.19.input_layernorm.bias": "model-00001-of-00002.safetensors",
505
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
506
+ "model.layers.19.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
507
+ "model.layers.20.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
508
+ "model.layers.20.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
509
+ "model.layers.20.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
510
+ "model.layers.20.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
511
+ "model.layers.20.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
512
+ "model.layers.20.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
513
+ "model.layers.20.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
514
+ "model.layers.20.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
515
+ "model.layers.20.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
516
+ "model.layers.20.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
517
+ "model.layers.20.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
518
+ "model.layers.20.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
519
+ "model.layers.20.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
520
+ "model.layers.20.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
521
+ "model.layers.20.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
522
+ "model.layers.20.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
523
+ "model.layers.20.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
524
+ "model.layers.20.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
525
+ "model.layers.20.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
526
+ "model.layers.20.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
527
+ "model.layers.20.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
528
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
529
+ "model.layers.20.input_layernorm.bias": "model-00001-of-00002.safetensors",
530
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
531
+ "model.layers.20.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
532
+ "model.layers.21.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
533
+ "model.layers.21.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
534
+ "model.layers.21.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
535
+ "model.layers.21.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
536
+ "model.layers.21.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
537
+ "model.layers.21.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
538
+ "model.layers.21.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
539
+ "model.layers.21.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
540
+ "model.layers.21.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
541
+ "model.layers.21.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
542
+ "model.layers.21.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
543
+ "model.layers.21.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
544
+ "model.layers.21.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
545
+ "model.layers.21.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
546
+ "model.layers.21.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
547
+ "model.layers.21.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
548
+ "model.layers.21.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
549
+ "model.layers.21.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
550
+ "model.layers.21.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
551
+ "model.layers.21.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
552
+ "model.layers.21.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
553
+ "model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
554
+ "model.layers.21.input_layernorm.bias": "model-00001-of-00002.safetensors",
555
+ "model.layers.21.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
556
+ "model.layers.21.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
557
+ "model.layers.22.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
558
+ "model.layers.22.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
559
+ "model.layers.22.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
560
+ "model.layers.22.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
561
+ "model.layers.22.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
562
+ "model.layers.22.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
563
+ "model.layers.22.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
564
+ "model.layers.22.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
565
+ "model.layers.22.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
566
+ "model.layers.22.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
567
+ "model.layers.22.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
568
+ "model.layers.22.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
569
+ "model.layers.22.mlp.gate_proj.qweight": "model-00001-of-00002.safetensors",
570
+ "model.layers.22.mlp.gate_proj.qzeros": "model-00001-of-00002.safetensors",
571
+ "model.layers.22.mlp.gate_proj.scales": "model-00001-of-00002.safetensors",
572
+ "model.layers.22.mlp.up_proj.qweight": "model-00001-of-00002.safetensors",
573
+ "model.layers.22.mlp.up_proj.qzeros": "model-00001-of-00002.safetensors",
574
+ "model.layers.22.mlp.up_proj.scales": "model-00001-of-00002.safetensors",
575
+ "model.layers.22.mlp.down_proj.qweight": "model-00001-of-00002.safetensors",
576
+ "model.layers.22.mlp.down_proj.qzeros": "model-00001-of-00002.safetensors",
577
+ "model.layers.22.mlp.down_proj.scales": "model-00001-of-00002.safetensors",
578
+ "model.layers.22.input_layernorm.weight": "model-00001-of-00002.safetensors",
579
+ "model.layers.22.input_layernorm.bias": "model-00001-of-00002.safetensors",
580
+ "model.layers.22.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
581
+ "model.layers.22.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
582
+ "model.layers.23.self_attn.q_proj.qweight": "model-00001-of-00002.safetensors",
583
+ "model.layers.23.self_attn.q_proj.qzeros": "model-00001-of-00002.safetensors",
584
+ "model.layers.23.self_attn.q_proj.scales": "model-00001-of-00002.safetensors",
585
+ "model.layers.23.self_attn.k_proj.qweight": "model-00001-of-00002.safetensors",
586
+ "model.layers.23.self_attn.k_proj.qzeros": "model-00001-of-00002.safetensors",
587
+ "model.layers.23.self_attn.k_proj.scales": "model-00001-of-00002.safetensors",
588
+ "model.layers.23.self_attn.v_proj.qweight": "model-00001-of-00002.safetensors",
589
+ "model.layers.23.self_attn.v_proj.qzeros": "model-00001-of-00002.safetensors",
590
+ "model.layers.23.self_attn.v_proj.scales": "model-00001-of-00002.safetensors",
591
+ "model.layers.23.self_attn.o_proj.qweight": "model-00001-of-00002.safetensors",
592
+ "model.layers.23.self_attn.o_proj.qzeros": "model-00001-of-00002.safetensors",
593
+ "model.layers.23.self_attn.o_proj.scales": "model-00001-of-00002.safetensors",
594
+ "model.layers.23.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
595
+ "model.layers.23.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
596
+ "model.layers.23.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
597
+ "model.layers.23.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
598
+ "model.layers.23.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
599
+ "model.layers.23.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
600
+ "model.layers.23.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
601
+ "model.layers.23.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
602
+ "model.layers.23.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
603
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
604
+ "model.layers.23.input_layernorm.bias": "model-00002-of-00002.safetensors",
605
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
606
+ "model.layers.23.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
607
+ "model.layers.24.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
608
+ "model.layers.24.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
609
+ "model.layers.24.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
610
+ "model.layers.24.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
611
+ "model.layers.24.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
612
+ "model.layers.24.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
613
+ "model.layers.24.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
614
+ "model.layers.24.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
615
+ "model.layers.24.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
616
+ "model.layers.24.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
617
+ "model.layers.24.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
618
+ "model.layers.24.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
619
+ "model.layers.24.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
620
+ "model.layers.24.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
621
+ "model.layers.24.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
622
+ "model.layers.24.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
623
+ "model.layers.24.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
624
+ "model.layers.24.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
625
+ "model.layers.24.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
626
+ "model.layers.24.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
627
+ "model.layers.24.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
628
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
629
+ "model.layers.24.input_layernorm.bias": "model-00002-of-00002.safetensors",
630
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
631
+ "model.layers.24.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
632
+ "model.layers.25.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
633
+ "model.layers.25.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
634
+ "model.layers.25.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
635
+ "model.layers.25.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
636
+ "model.layers.25.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
637
+ "model.layers.25.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
638
+ "model.layers.25.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
639
+ "model.layers.25.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
640
+ "model.layers.25.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
641
+ "model.layers.25.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
642
+ "model.layers.25.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
643
+ "model.layers.25.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
644
+ "model.layers.25.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
645
+ "model.layers.25.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
646
+ "model.layers.25.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
647
+ "model.layers.25.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
648
+ "model.layers.25.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
649
+ "model.layers.25.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
650
+ "model.layers.25.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
651
+ "model.layers.25.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
652
+ "model.layers.25.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
653
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
654
+ "model.layers.25.input_layernorm.bias": "model-00002-of-00002.safetensors",
655
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
656
+ "model.layers.25.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
657
+ "model.layers.26.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
658
+ "model.layers.26.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
659
+ "model.layers.26.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
660
+ "model.layers.26.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
661
+ "model.layers.26.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
662
+ "model.layers.26.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
663
+ "model.layers.26.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
664
+ "model.layers.26.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
665
+ "model.layers.26.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
666
+ "model.layers.26.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
667
+ "model.layers.26.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
668
+ "model.layers.26.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
669
+ "model.layers.26.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
670
+ "model.layers.26.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
671
+ "model.layers.26.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
672
+ "model.layers.26.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
673
+ "model.layers.26.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
674
+ "model.layers.26.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
675
+ "model.layers.26.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
676
+ "model.layers.26.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
677
+ "model.layers.26.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
678
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
679
+ "model.layers.26.input_layernorm.bias": "model-00002-of-00002.safetensors",
680
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
681
+ "model.layers.26.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
682
+ "model.layers.27.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
683
+ "model.layers.27.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
684
+ "model.layers.27.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
685
+ "model.layers.27.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
686
+ "model.layers.27.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
687
+ "model.layers.27.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
688
+ "model.layers.27.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
689
+ "model.layers.27.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
690
+ "model.layers.27.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
691
+ "model.layers.27.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
692
+ "model.layers.27.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
693
+ "model.layers.27.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
694
+ "model.layers.27.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
695
+ "model.layers.27.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
696
+ "model.layers.27.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
697
+ "model.layers.27.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
698
+ "model.layers.27.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
699
+ "model.layers.27.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
700
+ "model.layers.27.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
701
+ "model.layers.27.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
702
+ "model.layers.27.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
703
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
704
+ "model.layers.27.input_layernorm.bias": "model-00002-of-00002.safetensors",
705
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
706
+ "model.layers.27.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
707
+ "model.layers.28.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
708
+ "model.layers.28.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
709
+ "model.layers.28.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
710
+ "model.layers.28.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
711
+ "model.layers.28.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
712
+ "model.layers.28.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
713
+ "model.layers.28.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
714
+ "model.layers.28.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
715
+ "model.layers.28.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
716
+ "model.layers.28.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
717
+ "model.layers.28.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
718
+ "model.layers.28.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
719
+ "model.layers.28.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
720
+ "model.layers.28.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
721
+ "model.layers.28.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
722
+ "model.layers.28.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
723
+ "model.layers.28.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
724
+ "model.layers.28.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
725
+ "model.layers.28.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
726
+ "model.layers.28.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
727
+ "model.layers.28.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
728
+ "model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
729
+ "model.layers.28.input_layernorm.bias": "model-00002-of-00002.safetensors",
730
+ "model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
731
+ "model.layers.28.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
732
+ "model.layers.29.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
733
+ "model.layers.29.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
734
+ "model.layers.29.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
735
+ "model.layers.29.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
736
+ "model.layers.29.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
737
+ "model.layers.29.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
738
+ "model.layers.29.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
739
+ "model.layers.29.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
740
+ "model.layers.29.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
741
+ "model.layers.29.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
742
+ "model.layers.29.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
743
+ "model.layers.29.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
744
+ "model.layers.29.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
745
+ "model.layers.29.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
746
+ "model.layers.29.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
747
+ "model.layers.29.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
748
+ "model.layers.29.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
749
+ "model.layers.29.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
750
+ "model.layers.29.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
751
+ "model.layers.29.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
752
+ "model.layers.29.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
753
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
754
+ "model.layers.29.input_layernorm.bias": "model-00002-of-00002.safetensors",
755
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
756
+ "model.layers.29.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
757
+ "model.layers.30.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
758
+ "model.layers.30.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
759
+ "model.layers.30.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
760
+ "model.layers.30.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
761
+ "model.layers.30.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
762
+ "model.layers.30.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
763
+ "model.layers.30.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
764
+ "model.layers.30.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
765
+ "model.layers.30.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
766
+ "model.layers.30.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
767
+ "model.layers.30.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
768
+ "model.layers.30.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
769
+ "model.layers.30.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
770
+ "model.layers.30.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
771
+ "model.layers.30.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
772
+ "model.layers.30.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
773
+ "model.layers.30.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
774
+ "model.layers.30.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
775
+ "model.layers.30.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
776
+ "model.layers.30.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
777
+ "model.layers.30.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
778
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
779
+ "model.layers.30.input_layernorm.bias": "model-00002-of-00002.safetensors",
780
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
781
+ "model.layers.30.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
782
+ "model.layers.31.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
783
+ "model.layers.31.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
784
+ "model.layers.31.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
785
+ "model.layers.31.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
786
+ "model.layers.31.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
787
+ "model.layers.31.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
788
+ "model.layers.31.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
789
+ "model.layers.31.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
790
+ "model.layers.31.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
791
+ "model.layers.31.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
792
+ "model.layers.31.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
793
+ "model.layers.31.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
794
+ "model.layers.31.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
795
+ "model.layers.31.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
796
+ "model.layers.31.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
797
+ "model.layers.31.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
798
+ "model.layers.31.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
799
+ "model.layers.31.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
800
+ "model.layers.31.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
801
+ "model.layers.31.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
802
+ "model.layers.31.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
803
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
804
+ "model.layers.31.input_layernorm.bias": "model-00002-of-00002.safetensors",
805
+ "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
806
+ "model.layers.31.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
807
+ "model.layers.32.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
808
+ "model.layers.32.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
809
+ "model.layers.32.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
810
+ "model.layers.32.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
811
+ "model.layers.32.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
812
+ "model.layers.32.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
813
+ "model.layers.32.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
814
+ "model.layers.32.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
815
+ "model.layers.32.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
816
+ "model.layers.32.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
817
+ "model.layers.32.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
818
+ "model.layers.32.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
819
+ "model.layers.32.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
820
+ "model.layers.32.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
821
+ "model.layers.32.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
822
+ "model.layers.32.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
823
+ "model.layers.32.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
824
+ "model.layers.32.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
825
+ "model.layers.32.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
826
+ "model.layers.32.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
827
+ "model.layers.32.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
828
+ "model.layers.32.input_layernorm.weight": "model-00002-of-00002.safetensors",
829
+ "model.layers.32.input_layernorm.bias": "model-00002-of-00002.safetensors",
830
+ "model.layers.32.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
831
+ "model.layers.32.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
832
+ "model.layers.33.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
833
+ "model.layers.33.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
834
+ "model.layers.33.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
835
+ "model.layers.33.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
836
+ "model.layers.33.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
837
+ "model.layers.33.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
838
+ "model.layers.33.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
839
+ "model.layers.33.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
840
+ "model.layers.33.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
841
+ "model.layers.33.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
842
+ "model.layers.33.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
843
+ "model.layers.33.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
844
+ "model.layers.33.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
845
+ "model.layers.33.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
846
+ "model.layers.33.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
847
+ "model.layers.33.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
848
+ "model.layers.33.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
849
+ "model.layers.33.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
850
+ "model.layers.33.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
851
+ "model.layers.33.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
852
+ "model.layers.33.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
853
+ "model.layers.33.input_layernorm.weight": "model-00002-of-00002.safetensors",
854
+ "model.layers.33.input_layernorm.bias": "model-00002-of-00002.safetensors",
855
+ "model.layers.33.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
856
+ "model.layers.33.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
857
+ "model.layers.34.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
858
+ "model.layers.34.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
859
+ "model.layers.34.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
860
+ "model.layers.34.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
861
+ "model.layers.34.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
862
+ "model.layers.34.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
863
+ "model.layers.34.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
864
+ "model.layers.34.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
865
+ "model.layers.34.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
866
+ "model.layers.34.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
867
+ "model.layers.34.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
868
+ "model.layers.34.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
869
+ "model.layers.34.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
870
+ "model.layers.34.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
871
+ "model.layers.34.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
872
+ "model.layers.34.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
873
+ "model.layers.34.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
874
+ "model.layers.34.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
875
+ "model.layers.34.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
876
+ "model.layers.34.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
877
+ "model.layers.34.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
878
+ "model.layers.34.input_layernorm.weight": "model-00002-of-00002.safetensors",
879
+ "model.layers.34.input_layernorm.bias": "model-00002-of-00002.safetensors",
880
+ "model.layers.34.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
881
+ "model.layers.34.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
882
+ "model.layers.35.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
883
+ "model.layers.35.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
884
+ "model.layers.35.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
885
+ "model.layers.35.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
886
+ "model.layers.35.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
887
+ "model.layers.35.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
888
+ "model.layers.35.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
889
+ "model.layers.35.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
890
+ "model.layers.35.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
891
+ "model.layers.35.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
892
+ "model.layers.35.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
893
+ "model.layers.35.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
894
+ "model.layers.35.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
895
+ "model.layers.35.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
896
+ "model.layers.35.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
897
+ "model.layers.35.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
898
+ "model.layers.35.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
899
+ "model.layers.35.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
900
+ "model.layers.35.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
901
+ "model.layers.35.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
902
+ "model.layers.35.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
903
+ "model.layers.35.input_layernorm.weight": "model-00002-of-00002.safetensors",
904
+ "model.layers.35.input_layernorm.bias": "model-00002-of-00002.safetensors",
905
+ "model.layers.35.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
906
+ "model.layers.35.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
907
+ "model.layers.36.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
908
+ "model.layers.36.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
909
+ "model.layers.36.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
910
+ "model.layers.36.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
911
+ "model.layers.36.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
912
+ "model.layers.36.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
913
+ "model.layers.36.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
914
+ "model.layers.36.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
915
+ "model.layers.36.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
916
+ "model.layers.36.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
917
+ "model.layers.36.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
918
+ "model.layers.36.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
919
+ "model.layers.36.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
920
+ "model.layers.36.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
921
+ "model.layers.36.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
922
+ "model.layers.36.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
923
+ "model.layers.36.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
924
+ "model.layers.36.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
925
+ "model.layers.36.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
926
+ "model.layers.36.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
927
+ "model.layers.36.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
928
+ "model.layers.36.input_layernorm.weight": "model-00002-of-00002.safetensors",
929
+ "model.layers.36.input_layernorm.bias": "model-00002-of-00002.safetensors",
930
+ "model.layers.36.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
931
+ "model.layers.36.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
932
+ "model.layers.37.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
933
+ "model.layers.37.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
934
+ "model.layers.37.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
935
+ "model.layers.37.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
936
+ "model.layers.37.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
937
+ "model.layers.37.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
938
+ "model.layers.37.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
939
+ "model.layers.37.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
940
+ "model.layers.37.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
941
+ "model.layers.37.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
942
+ "model.layers.37.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
943
+ "model.layers.37.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
944
+ "model.layers.37.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
945
+ "model.layers.37.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
946
+ "model.layers.37.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
947
+ "model.layers.37.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
948
+ "model.layers.37.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
949
+ "model.layers.37.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
950
+ "model.layers.37.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
951
+ "model.layers.37.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
952
+ "model.layers.37.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
953
+ "model.layers.37.input_layernorm.weight": "model-00002-of-00002.safetensors",
954
+ "model.layers.37.input_layernorm.bias": "model-00002-of-00002.safetensors",
955
+ "model.layers.37.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
956
+ "model.layers.37.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
957
+ "model.layers.38.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
958
+ "model.layers.38.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
959
+ "model.layers.38.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
960
+ "model.layers.38.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
961
+ "model.layers.38.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
962
+ "model.layers.38.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
963
+ "model.layers.38.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
964
+ "model.layers.38.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
965
+ "model.layers.38.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
966
+ "model.layers.38.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
967
+ "model.layers.38.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
968
+ "model.layers.38.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
969
+ "model.layers.38.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
970
+ "model.layers.38.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
971
+ "model.layers.38.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
972
+ "model.layers.38.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
973
+ "model.layers.38.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
974
+ "model.layers.38.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
975
+ "model.layers.38.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
976
+ "model.layers.38.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
977
+ "model.layers.38.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
978
+ "model.layers.38.input_layernorm.weight": "model-00002-of-00002.safetensors",
979
+ "model.layers.38.input_layernorm.bias": "model-00002-of-00002.safetensors",
980
+ "model.layers.38.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
981
+ "model.layers.38.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
982
+ "model.layers.39.self_attn.q_proj.qweight": "model-00002-of-00002.safetensors",
983
+ "model.layers.39.self_attn.q_proj.qzeros": "model-00002-of-00002.safetensors",
984
+ "model.layers.39.self_attn.q_proj.scales": "model-00002-of-00002.safetensors",
985
+ "model.layers.39.self_attn.k_proj.qweight": "model-00002-of-00002.safetensors",
986
+ "model.layers.39.self_attn.k_proj.qzeros": "model-00002-of-00002.safetensors",
987
+ "model.layers.39.self_attn.k_proj.scales": "model-00002-of-00002.safetensors",
988
+ "model.layers.39.self_attn.v_proj.qweight": "model-00002-of-00002.safetensors",
989
+ "model.layers.39.self_attn.v_proj.qzeros": "model-00002-of-00002.safetensors",
990
+ "model.layers.39.self_attn.v_proj.scales": "model-00002-of-00002.safetensors",
991
+ "model.layers.39.self_attn.o_proj.qweight": "model-00002-of-00002.safetensors",
992
+ "model.layers.39.self_attn.o_proj.qzeros": "model-00002-of-00002.safetensors",
993
+ "model.layers.39.self_attn.o_proj.scales": "model-00002-of-00002.safetensors",
994
+ "model.layers.39.mlp.gate_proj.qweight": "model-00002-of-00002.safetensors",
995
+ "model.layers.39.mlp.gate_proj.qzeros": "model-00002-of-00002.safetensors",
996
+ "model.layers.39.mlp.gate_proj.scales": "model-00002-of-00002.safetensors",
997
+ "model.layers.39.mlp.up_proj.qweight": "model-00002-of-00002.safetensors",
998
+ "model.layers.39.mlp.up_proj.qzeros": "model-00002-of-00002.safetensors",
999
+ "model.layers.39.mlp.up_proj.scales": "model-00002-of-00002.safetensors",
1000
+ "model.layers.39.mlp.down_proj.qweight": "model-00002-of-00002.safetensors",
1001
+ "model.layers.39.mlp.down_proj.qzeros": "model-00002-of-00002.safetensors",
1002
+ "model.layers.39.mlp.down_proj.scales": "model-00002-of-00002.safetensors",
1003
+ "model.layers.39.input_layernorm.weight": "model-00002-of-00002.safetensors",
1004
+ "model.layers.39.input_layernorm.bias": "model-00002-of-00002.safetensors",
1005
+ "model.layers.39.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
1006
+ "model.layers.39.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
1007
+ "model.norm.weight": "model-00002-of-00002.safetensors",
1008
+ "model.norm.bias": "model-00002-of-00002.safetensors",
1009
+ "lm_head.weight": "model-00002-of-00002.safetensors"
1010
+ }
1011
+ }
modeling_orion.py ADDED
@@ -0,0 +1,1118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 OrionStar Inc. team. All rights reserved.
2
+ # Copied and adapted from https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py
3
+
4
+ from transformers import AutoConfig, AutoModel
5
+
6
+ from .configuration_orion import OrionConfig
7
+
8
+ import numbers
9
+ import importlib
10
+ import math
11
+ from typing import List, Optional, Tuple, Union
12
+
13
+ import torch
14
+ import torch.nn.functional as F
15
+ from torch.nn.parameter import Parameter
16
+ import torch.utils.checkpoint
17
+ from torch import nn
18
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
19
+ from torch.nn import init
20
+
21
+ from transformers.activations import ACT2FN
22
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
23
+ from transformers.modeling_utils import PreTrainedModel
24
+ from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
25
+ from transformers.utils import (
26
+ add_start_docstrings,
27
+ add_start_docstrings_to_model_forward,
28
+ # is_flash_attn_available,
29
+ logging,
30
+ replace_return_docstrings,
31
+ )
32
+ from .generation_utils import build_chat_input, TextIterStreamer
33
+ from transformers.generation.utils import GenerationConfig
34
+ from threading import Thread
35
+
36
+ # if is_flash_attn_available():
37
+ if True:
38
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
39
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
40
+
41
+ logger = logging.get_logger(__name__)
42
+
43
+ _CONFIG_FOR_DOC = "OrionConfig"
44
+
45
+ def _get_unpad_data(padding_mask):
46
+ seqlens_in_batch = padding_mask.sum(dim=-1, dtype=torch.int32)
47
+ indices = torch.nonzero(padding_mask.flatten(), as_tuple=False).flatten()
48
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
49
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
50
+ return (
51
+ indices,
52
+ cu_seqlens,
53
+ max_seqlen_in_batch,
54
+ )
55
+
56
+
57
+ # Copied from transformers.models.bart.modeling_bart._make_causal_mask
58
+ def _make_causal_mask(
59
+ input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
60
+ ):
61
+ """
62
+ Make causal mask used for bi-directional self-attention.
63
+ """
64
+ bsz, tgt_len = input_ids_shape
65
+ mask = torch.full((tgt_len, tgt_len), torch.finfo(dtype).min, device=device)
66
+ mask_cond = torch.arange(mask.size(-1), device=device)
67
+ mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
68
+ mask = mask.to(dtype)
69
+
70
+ if past_key_values_length > 0:
71
+ mask = torch.cat([torch.zeros(tgt_len, past_key_values_length, dtype=dtype, device=device), mask], dim=-1)
72
+ return mask[None, None, :, :].expand(bsz, 1, tgt_len, tgt_len + past_key_values_length)
73
+
74
+
75
+ # Copied from transformers.models.bart.modeling_bart._expand_mask
76
+ def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
77
+ """
78
+ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
79
+ """
80
+ bsz, src_len = mask.size()
81
+ tgt_len = tgt_len if tgt_len is not None else src_len
82
+
83
+ expanded_mask = mask[:, None, None, :].expand(bsz, 1, tgt_len, src_len).to(dtype)
84
+
85
+ inverted_mask = 1.0 - expanded_mask
86
+
87
+ return inverted_mask.masked_fill(inverted_mask.to(torch.bool), torch.finfo(dtype).min)
88
+
89
+ class OrionRotaryEmbedding(nn.Module):
90
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
91
+ super().__init__()
92
+
93
+ self.dim = dim
94
+ self.max_position_embeddings = max_position_embeddings
95
+ self.base = base
96
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
97
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
98
+
99
+ # Build here to make `torch.jit.trace` work.
100
+ self._set_cos_sin_cache(
101
+ seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
102
+ )
103
+
104
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
105
+ self.max_seq_len_cached = seq_len
106
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
107
+
108
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
109
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
110
+ emb = torch.cat((freqs, freqs), dim=-1)
111
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
112
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
113
+
114
+ def forward(self, x, seq_len=None):
115
+ # x: [bs, num_attention_heads, seq_len, head_size]
116
+ if seq_len > self.max_seq_len_cached:
117
+ self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
118
+
119
+ return (
120
+ self.cos_cached[:seq_len].to(dtype=x.dtype),
121
+ self.sin_cached[:seq_len].to(dtype=x.dtype),
122
+ )
123
+
124
+
125
+ class OrionLinearScalingRotaryEmbedding(OrionRotaryEmbedding):
126
+ """OrionRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
127
+
128
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
129
+ self.scaling_factor = scaling_factor
130
+ super().__init__(dim, max_position_embeddings, base, device)
131
+
132
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
133
+ self.max_seq_len_cached = seq_len
134
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
135
+ t = t / self.scaling_factor
136
+
137
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
138
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
139
+ emb = torch.cat((freqs, freqs), dim=-1)
140
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
141
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
142
+
143
+
144
+ class OrionDynamicNTKScalingRotaryEmbedding(OrionRotaryEmbedding):
145
+ """OrionRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
146
+
147
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
148
+ self.scaling_factor = scaling_factor
149
+ super().__init__(dim, max_position_embeddings, base, device)
150
+
151
+ def _set_cos_sin_cache(self, seq_len, device, dtype):
152
+ self.max_seq_len_cached = seq_len
153
+
154
+ if seq_len > self.max_position_embeddings:
155
+ base = self.base * (
156
+ (self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
157
+ ) ** (self.dim / (self.dim - 2))
158
+ inv_freq = 1.0 / (base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
159
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
160
+
161
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
162
+
163
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
164
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
165
+ emb = torch.cat((freqs, freqs), dim=-1)
166
+ self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
167
+ self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
168
+
169
+
170
+ def rotate_half(x):
171
+ """Rotates half the hidden dims of the input."""
172
+ x1 = x[..., : x.shape[-1] // 2]
173
+ x2 = x[..., x.shape[-1] // 2 :]
174
+ return torch.cat((-x2, x1), dim=-1)
175
+
176
+
177
+ # Copied from transformers.models.gpt_neox.modeling_gpt_neox.apply_rotary_pos_emb
178
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids):
179
+ cos = cos[position_ids].unsqueeze(1) # [seq_len, dim] -> [batch_size, 1, seq_len, head_dim]
180
+ sin = sin[position_ids].unsqueeze(1)
181
+ q_embed = (q * cos) + (rotate_half(q) * sin)
182
+ k_embed = (k * cos) + (rotate_half(k) * sin)
183
+ return q_embed, k_embed
184
+
185
+
186
+ class OrionMLP(nn.Module):
187
+ def __init__(self, config):
188
+ super().__init__()
189
+ self.config = config
190
+ self.hidden_size = config.hidden_size
191
+ self.intermediate_size = config.intermediate_size
192
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
193
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
194
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
195
+ self.act_fn = ACT2FN[config.hidden_act]
196
+
197
+ def forward(self, x):
198
+ if self.config.pretraining_tp > 1:
199
+ slice = self.intermediate_size // self.config.pretraining_tp
200
+ gate_proj_slices = self.gate_proj.weight.split(slice, dim=0)
201
+ up_proj_slices = self.up_proj.weight.split(slice, dim=0)
202
+ down_proj_slices = self.down_proj.weight.split(slice, dim=1)
203
+
204
+ gate_proj = torch.cat(
205
+ [F.linear(x, gate_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1
206
+ )
207
+ up_proj = torch.cat([F.linear(x, up_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1)
208
+
209
+ intermediate_states = (self.act_fn(gate_proj) * up_proj).split(slice, dim=2)
210
+ down_proj = [
211
+ F.linear(intermediate_states[i], down_proj_slices[i]) for i in range(self.config.pretraining_tp)
212
+ ]
213
+ down_proj = sum(down_proj)
214
+ else:
215
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
216
+
217
+ return down_proj
218
+
219
+
220
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
221
+ """
222
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
223
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
224
+ """
225
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
226
+ if n_rep == 1:
227
+ return hidden_states
228
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
229
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
230
+
231
+
232
+ class OrionAttention(nn.Module):
233
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
234
+
235
+ def __init__(self, config: OrionConfig):
236
+ super().__init__()
237
+ self.config = config
238
+ self.hidden_size = config.hidden_size
239
+ self.num_heads = config.num_attention_heads
240
+ self.head_dim = self.hidden_size // self.num_heads
241
+ self.num_key_value_heads = config.num_key_value_heads
242
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
243
+ self.max_position_embeddings = config.max_position_embeddings
244
+ self.rope_theta = config.rope_theta
245
+
246
+ if (self.head_dim * self.num_heads) != self.hidden_size:
247
+ raise ValueError(
248
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
249
+ f" and `num_heads`: {self.num_heads})."
250
+ )
251
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
252
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
253
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
254
+ self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias)
255
+ self._init_rope()
256
+
257
+ def _init_rope(self):
258
+ if self.config.rope_scaling is None:
259
+ self.rotary_emb = OrionRotaryEmbedding(
260
+ self.head_dim,
261
+ max_position_embeddings=self.max_position_embeddings,
262
+ base=self.rope_theta,
263
+ )
264
+ else:
265
+ scaling_type = self.config.rope_scaling["type"]
266
+ scaling_factor = self.config.rope_scaling["factor"]
267
+ if scaling_type == "linear":
268
+ self.rotary_emb = OrionLinearScalingRotaryEmbedding(
269
+ self.head_dim,
270
+ max_position_embeddings=self.max_position_embeddings,
271
+ scaling_factor=scaling_factor,
272
+ base=self.rope_theta,
273
+ )
274
+ elif scaling_type == "dynamic":
275
+ self.rotary_emb = OrionDynamicNTKScalingRotaryEmbedding(
276
+ self.head_dim,
277
+ max_position_embeddings=self.max_position_embeddings,
278
+ scaling_factor=scaling_factor,
279
+ base=self.rope_theta,
280
+ )
281
+ else:
282
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
283
+
284
+ def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
285
+ return tensor.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous()
286
+
287
+ def forward(
288
+ self,
289
+ hidden_states: torch.Tensor,
290
+ attention_mask: Optional[torch.Tensor] = None,
291
+ position_ids: Optional[torch.LongTensor] = None,
292
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
293
+ output_attentions: bool = False,
294
+ use_cache: bool = False,
295
+ padding_mask: Optional[torch.LongTensor] = None,
296
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
297
+ bsz, q_len, _ = hidden_states.size()
298
+
299
+ if self.config.pretraining_tp > 1:
300
+ key_value_slicing = (self.num_key_value_heads * self.head_dim) // self.config.pretraining_tp
301
+ query_slices = self.q_proj.weight.split(
302
+ (self.num_heads * self.head_dim) // self.config.pretraining_tp, dim=0
303
+ )
304
+ key_slices = self.k_proj.weight.split(key_value_slicing, dim=0)
305
+ value_slices = self.v_proj.weight.split(key_value_slicing, dim=0)
306
+
307
+ query_states = [F.linear(hidden_states, query_slices[i]) for i in range(self.config.pretraining_tp)]
308
+ query_states = torch.cat(query_states, dim=-1)
309
+
310
+ key_states = [F.linear(hidden_states, key_slices[i]) for i in range(self.config.pretraining_tp)]
311
+ key_states = torch.cat(key_states, dim=-1)
312
+
313
+ value_states = [F.linear(hidden_states, value_slices[i]) for i in range(self.config.pretraining_tp)]
314
+ value_states = torch.cat(value_states, dim=-1)
315
+
316
+ else:
317
+ query_states = self.q_proj(hidden_states)
318
+ key_states = self.k_proj(hidden_states)
319
+ value_states = self.v_proj(hidden_states)
320
+
321
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
322
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
323
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
324
+
325
+ kv_seq_len = key_states.shape[-2]
326
+ if past_key_value is not None:
327
+ kv_seq_len += past_key_value[0].shape[-2]
328
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
329
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
330
+
331
+ if past_key_value is not None:
332
+ # reuse k, v, self_attention
333
+ key_states = torch.cat([past_key_value[0], key_states], dim=2)
334
+ value_states = torch.cat([past_key_value[1], value_states], dim=2)
335
+
336
+ past_key_value = (key_states, value_states) if use_cache else None
337
+
338
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
339
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
340
+
341
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
342
+
343
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
344
+ raise ValueError(
345
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
346
+ f" {attn_weights.size()}"
347
+ )
348
+
349
+ if attention_mask is not None:
350
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
351
+ raise ValueError(
352
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
353
+ )
354
+ attn_weights = attn_weights + attention_mask
355
+
356
+ # upcast attention to fp32
357
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
358
+ attn_output = torch.matmul(attn_weights, value_states)
359
+
360
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
361
+ raise ValueError(
362
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
363
+ f" {attn_output.size()}"
364
+ )
365
+
366
+ attn_output = attn_output.transpose(1, 2).contiguous()
367
+
368
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
369
+
370
+ if self.config.pretraining_tp > 1:
371
+ attn_output = attn_output.split(self.hidden_size // self.config.pretraining_tp, dim=2)
372
+ o_proj_slices = self.o_proj.weight.split(self.hidden_size // self.config.pretraining_tp, dim=1)
373
+ attn_output = sum([F.linear(attn_output[i], o_proj_slices[i]) for i in range(self.config.pretraining_tp)])
374
+ else:
375
+ attn_output = self.o_proj(attn_output)
376
+
377
+ if not output_attentions:
378
+ attn_weights = None
379
+
380
+ return attn_output, attn_weights, past_key_value
381
+
382
+
383
+ class OrionFlashAttention2(OrionAttention):
384
+ """
385
+ Orion flash attention module. This module inherits from `OrionAttention` as the weights of the module stays
386
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
387
+ flash attention and deal with padding tokens in case the input contains any of them.
388
+ """
389
+
390
+ def forward(
391
+ self,
392
+ hidden_states: torch.Tensor,
393
+ attention_mask: Optional[torch.Tensor] = None,
394
+ position_ids: Optional[torch.LongTensor] = None,
395
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
396
+ output_attentions: bool = False,
397
+ use_cache: bool = False,
398
+ padding_mask: Optional[torch.LongTensor] = None,
399
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
400
+ # OrionFlashAttention2 attention does not support output_attentions
401
+ output_attentions = False
402
+
403
+ bsz, q_len, _ = hidden_states.size()
404
+
405
+ query_states = self.q_proj(hidden_states)
406
+ key_states = self.k_proj(hidden_states)
407
+ value_states = self.v_proj(hidden_states)
408
+
409
+ # Flash attention requires the input to have the shape
410
+ # batch_size x seq_length x head_dime x hidden_dim
411
+ # therefore we just need to keep the original shape
412
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
413
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
414
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
415
+
416
+ kv_seq_len = key_states.shape[-2]
417
+ if past_key_value is not None:
418
+ kv_seq_len += past_key_value[0].shape[-2]
419
+
420
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
421
+
422
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
423
+
424
+ if past_key_value is not None:
425
+ # reuse k, v, self_attention
426
+ key_states = torch.cat([past_key_value[0], key_states], dim=2)
427
+ value_states = torch.cat([past_key_value[1], value_states], dim=2)
428
+
429
+ past_key_value = (key_states, value_states) if use_cache else None
430
+
431
+ query_states = query_states.transpose(1, 2)
432
+ key_states = key_states.transpose(1, 2)
433
+ value_states = value_states.transpose(1, 2)
434
+
435
+ # TODO: llama does not have dropout in the config??
436
+ # It is recommended to use dropout with FA according to the docs
437
+ # when training.
438
+ dropout_rate = 0.0 # if not self.training else self.attn_dropout
439
+
440
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
441
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
442
+ # cast them back in float16 just to be sure everything works as expected.
443
+ # This might slowdown training & inference so it is recommended to not cast the LayerNorms
444
+ # in fp32. (LlamaRMSNorm handles it correctly)
445
+ input_dtype = query_states.dtype
446
+ if input_dtype == torch.float32:
447
+ logger.warning_once(
448
+ "The input hidden states seems to be silently casted in float32, this might be related to"
449
+ " the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
450
+ " float16."
451
+ )
452
+
453
+ query_states = query_states.to(torch.float16)
454
+ key_states = key_states.to(torch.float16)
455
+ value_states = value_states.to(torch.float16)
456
+
457
+ attn_output = self._flash_attention_forward(
458
+ query_states, key_states, value_states, padding_mask, q_len, dropout=dropout_rate
459
+ )
460
+
461
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
462
+ attn_output = self.o_proj(attn_output)
463
+
464
+ if not output_attentions:
465
+ attn_weights = None
466
+
467
+ return attn_output, attn_weights, past_key_value
468
+
469
+ def _flash_attention_forward(
470
+ self, query_states, key_states, value_states, padding_mask, query_length, dropout=0.0, softmax_scale=None
471
+ ):
472
+ """
473
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
474
+ first unpad the input, then computes the attention scores and pad the final attention scores.
475
+
476
+ Args:
477
+ query_states (`torch.Tensor`):
478
+ Input query states to be passed to Flash Attention API
479
+ key_states (`torch.Tensor`):
480
+ Input key states to be passed to Flash Attention API
481
+ value_states (`torch.Tensor`):
482
+ Input value states to be passed to Flash Attention API
483
+ padding_mask (`torch.Tensor`):
484
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
485
+ position of padding tokens and 1 for the position of non-padding tokens.
486
+ dropout (`int`, *optional*):
487
+ Attention dropout
488
+ softmax_scale (`float`, *optional*):
489
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
490
+ """
491
+ # Contains at least one padding token in the sequence
492
+ if padding_mask is not None:
493
+ batch_size = query_states.shape[0]
494
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
495
+ query_states, key_states, value_states, padding_mask, query_length
496
+ )
497
+
498
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
499
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
500
+
501
+ attn_output_unpad = flash_attn_varlen_func(
502
+ query_states,
503
+ key_states,
504
+ value_states,
505
+ cu_seqlens_q=cu_seqlens_q,
506
+ cu_seqlens_k=cu_seqlens_k,
507
+ max_seqlen_q=max_seqlen_in_batch_q,
508
+ max_seqlen_k=max_seqlen_in_batch_k,
509
+ dropout_p=dropout,
510
+ softmax_scale=softmax_scale,
511
+ causal=True,
512
+ )
513
+
514
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
515
+ else:
516
+ attn_output = flash_attn_func(
517
+ query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=True
518
+ )
519
+
520
+ return attn_output
521
+
522
+ def _upad_input(self, query_layer, key_layer, value_layer, padding_mask, query_length):
523
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(padding_mask)
524
+ batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
525
+
526
+ key_layer = index_first_axis(
527
+ key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
528
+ )
529
+ value_layer = index_first_axis(
530
+ value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
531
+ )
532
+ if query_length == kv_seq_len:
533
+ query_layer = index_first_axis(
534
+ query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim), indices_k
535
+ )
536
+ cu_seqlens_q = cu_seqlens_k
537
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
538
+ indices_q = indices_k
539
+ elif query_length == 1:
540
+ max_seqlen_in_batch_q = 1
541
+ cu_seqlens_q = torch.arange(
542
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
543
+ ) # There is a memcpy here, that is very bad.
544
+ indices_q = cu_seqlens_q[:-1]
545
+ query_layer = query_layer.squeeze(1)
546
+ else:
547
+ # The -q_len: slice assumes left padding.
548
+ padding_mask = padding_mask[:, -query_length:]
549
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, padding_mask)
550
+
551
+ return (
552
+ query_layer,
553
+ key_layer,
554
+ value_layer,
555
+ indices_q,
556
+ (cu_seqlens_q, cu_seqlens_k),
557
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
558
+ )
559
+
560
+
561
+ class OrionDecoderLayer(nn.Module):
562
+ def __init__(self, config: OrionConfig):
563
+ super().__init__()
564
+ self.hidden_size = config.hidden_size
565
+ self.self_attn = (
566
+ OrionAttention(config=config)
567
+ if not getattr(config, "_flash_attn_2_enabled", False)
568
+ else OrionFlashAttention2(config=config)
569
+ )
570
+ self.mlp = OrionMLP(config)
571
+ self.input_layernorm = nn.LayerNorm(config.hidden_size, eps=config.rms_norm_eps)
572
+ self.post_attention_layernorm = nn.LayerNorm(config.hidden_size, eps=config.rms_norm_eps)
573
+
574
+ def forward(
575
+ self,
576
+ hidden_states: torch.Tensor,
577
+ attention_mask: Optional[torch.Tensor] = None,
578
+ position_ids: Optional[torch.LongTensor] = None,
579
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
580
+ output_attentions: Optional[bool] = False,
581
+ use_cache: Optional[bool] = False,
582
+ padding_mask: Optional[torch.LongTensor] = None,
583
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
584
+ """
585
+ Args:
586
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
587
+ attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
588
+ `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
589
+ output_attentions (`bool`, *optional*):
590
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
591
+ returned tensors for more detail.
592
+ use_cache (`bool`, *optional*):
593
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
594
+ (see `past_key_values`).
595
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
596
+ """
597
+
598
+ residual = hidden_states
599
+
600
+ hidden_states = self.input_layernorm(hidden_states)
601
+
602
+ # Self Attention
603
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
604
+ hidden_states=hidden_states,
605
+ attention_mask=attention_mask,
606
+ position_ids=position_ids,
607
+ past_key_value=past_key_value,
608
+ output_attentions=output_attentions,
609
+ use_cache=use_cache,
610
+ padding_mask=padding_mask,
611
+ )
612
+ hidden_states = residual + hidden_states
613
+
614
+ # Fully Connected
615
+ residual = hidden_states
616
+ hidden_states = self.post_attention_layernorm(hidden_states)
617
+ hidden_states = self.mlp(hidden_states)
618
+ hidden_states = residual + hidden_states
619
+
620
+ outputs = (hidden_states,)
621
+
622
+ if output_attentions:
623
+ outputs += (self_attn_weights,)
624
+
625
+ if use_cache:
626
+ outputs += (present_key_value,)
627
+
628
+ return outputs
629
+
630
+ class OrionPreTrainedModel(PreTrainedModel):
631
+ config_class = OrionConfig
632
+ base_model_prefix = "model"
633
+ supports_gradient_checkpointing = True
634
+ _no_split_modules = ["OrionDecoderLayer"]
635
+ _skip_keys_device_placement = "past_key_values"
636
+ _supports_flash_attn_2 = True
637
+
638
+ def _init_weights(self, module):
639
+ std = self.config.initializer_range
640
+ if isinstance(module, nn.Linear):
641
+ module.weight.data.normal_(mean=0.0, std=std)
642
+ if module.bias is not None:
643
+ module.bias.data.zero_()
644
+ elif isinstance(module, nn.Embedding):
645
+ module.weight.data.normal_(mean=0.0, std=std)
646
+ if module.padding_idx is not None:
647
+ module.weight.data[module.padding_idx].zero_()
648
+
649
+ def _set_gradient_checkpointing(self, module, value=False):
650
+ if isinstance(module, OrionModel):
651
+ module.gradient_checkpointing = value
652
+
653
+ class OrionModel(OrionPreTrainedModel):
654
+ """
655
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`OrionDecoderLayer`]
656
+
657
+ Args:
658
+ config: OrionConfig
659
+ """
660
+
661
+ def __init__(self, config: OrionConfig):
662
+ super().__init__(config)
663
+ self.padding_idx = config.pad_token_id
664
+ self.vocab_size = config.vocab_size
665
+
666
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
667
+ self.layers = nn.ModuleList([OrionDecoderLayer(config) for _ in range(config.num_hidden_layers)])
668
+ self.norm = nn.LayerNorm(config.hidden_size, eps=config.rms_norm_eps)
669
+
670
+ self.gradient_checkpointing = False
671
+ # Initialize weights and apply final processing
672
+ self.post_init()
673
+
674
+ def get_input_embeddings(self):
675
+ return self.embed_tokens
676
+
677
+ def set_input_embeddings(self, value):
678
+ self.embed_tokens = value
679
+
680
+ # Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
681
+ def _prepare_decoder_attention_mask(self, attention_mask, input_shape, inputs_embeds, past_key_values_length):
682
+ # create causal mask
683
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
684
+ combined_attention_mask = None
685
+ if input_shape[-1] > 1:
686
+ combined_attention_mask = _make_causal_mask(
687
+ input_shape,
688
+ inputs_embeds.dtype,
689
+ device=inputs_embeds.device,
690
+ past_key_values_length=past_key_values_length,
691
+ )
692
+
693
+ if attention_mask is not None:
694
+ # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
695
+ expanded_attn_mask = _expand_mask(attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]).to(
696
+ inputs_embeds.device
697
+ )
698
+ combined_attention_mask = (
699
+ expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask + combined_attention_mask
700
+ )
701
+
702
+ return combined_attention_mask
703
+
704
+ def forward(
705
+ self,
706
+ input_ids: torch.LongTensor = None,
707
+ attention_mask: Optional[torch.Tensor] = None,
708
+ position_ids: Optional[torch.LongTensor] = None,
709
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
710
+ inputs_embeds: Optional[torch.FloatTensor] = None,
711
+ use_cache: Optional[bool] = None,
712
+ output_attentions: Optional[bool] = None,
713
+ output_hidden_states: Optional[bool] = None,
714
+ return_dict: Optional[bool] = None,
715
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
716
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
717
+ output_hidden_states = (
718
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
719
+ )
720
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
721
+
722
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
723
+
724
+ # retrieve input_ids and inputs_embeds
725
+ if input_ids is not None and inputs_embeds is not None:
726
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
727
+ elif input_ids is not None:
728
+ batch_size, seq_length = input_ids.shape
729
+ elif inputs_embeds is not None:
730
+ batch_size, seq_length, _ = inputs_embeds.shape
731
+ else:
732
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
733
+
734
+ seq_length_with_past = seq_length
735
+ past_key_values_length = 0
736
+
737
+ if past_key_values is not None:
738
+ past_key_values_length = past_key_values[0][0].shape[2]
739
+ seq_length_with_past = seq_length_with_past + past_key_values_length
740
+
741
+ if position_ids is None:
742
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
743
+ position_ids = torch.arange(
744
+ past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
745
+ )
746
+ position_ids = position_ids.unsqueeze(0)
747
+
748
+ if inputs_embeds is None:
749
+ inputs_embeds = self.embed_tokens(input_ids)
750
+ # embed positions
751
+ if attention_mask is None:
752
+ attention_mask = torch.ones(
753
+ (batch_size, seq_length_with_past), dtype=torch.bool, device=inputs_embeds.device
754
+ )
755
+ padding_mask = None
756
+ else:
757
+ if 0 in attention_mask:
758
+ padding_mask = attention_mask
759
+ else:
760
+ padding_mask = None
761
+
762
+ attention_mask = self._prepare_decoder_attention_mask(
763
+ attention_mask, (batch_size, seq_length), inputs_embeds, past_key_values_length
764
+ )
765
+
766
+ hidden_states = inputs_embeds
767
+
768
+ if self.gradient_checkpointing and self.training:
769
+ if use_cache:
770
+ logger.warning_once(
771
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
772
+ )
773
+ use_cache = False
774
+
775
+ # decoder layers
776
+ all_hidden_states = () if output_hidden_states else None
777
+ all_self_attns = () if output_attentions else None
778
+ next_decoder_cache = () if use_cache else None
779
+
780
+ for idx, decoder_layer in enumerate(self.layers):
781
+ if output_hidden_states:
782
+ all_hidden_states += (hidden_states,)
783
+
784
+ past_key_value = past_key_values[idx] if past_key_values is not None else None
785
+
786
+ if self.gradient_checkpointing and self.training:
787
+
788
+ def create_custom_forward(module):
789
+ def custom_forward(*inputs):
790
+ # None for past_key_value
791
+ return module(*inputs, past_key_value, output_attentions, padding_mask=padding_mask)
792
+
793
+ return custom_forward
794
+
795
+ layer_outputs = torch.utils.checkpoint.checkpoint(
796
+ create_custom_forward(decoder_layer), hidden_states, attention_mask, position_ids
797
+ )
798
+ else:
799
+ layer_outputs = decoder_layer(
800
+ hidden_states,
801
+ attention_mask=attention_mask,
802
+ position_ids=position_ids,
803
+ past_key_value=past_key_value,
804
+ output_attentions=output_attentions,
805
+ use_cache=use_cache,
806
+ padding_mask=padding_mask,
807
+ )
808
+
809
+ hidden_states = layer_outputs[0]
810
+
811
+ if use_cache:
812
+ next_decoder_cache += (layer_outputs[2 if output_attentions else 1],)
813
+
814
+ if output_attentions:
815
+ all_self_attns += (layer_outputs[1],)
816
+
817
+ hidden_states = self.norm(hidden_states)
818
+
819
+ # add hidden states from the last decoder layer
820
+ if output_hidden_states:
821
+ all_hidden_states += (hidden_states,)
822
+
823
+ next_cache = next_decoder_cache if use_cache else None
824
+ if not return_dict:
825
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
826
+ return BaseModelOutputWithPast(
827
+ last_hidden_state=hidden_states,
828
+ past_key_values=next_cache,
829
+ hidden_states=all_hidden_states,
830
+ attentions=all_self_attns,
831
+ )
832
+
833
+
834
+ class OrionForCausalLM(OrionPreTrainedModel):
835
+ model_type = "orion"
836
+ _tied_weights_keys = ["lm_head.weight"]
837
+
838
+ def __init__(self, config):
839
+ super().__init__(config)
840
+ self.model = OrionModel(config)
841
+ self.vocab_size = config.vocab_size
842
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
843
+
844
+ # Initialize weights and apply final processing
845
+ self.post_init()
846
+
847
+ def get_input_embeddings(self):
848
+ return self.model.embed_tokens
849
+
850
+ def set_input_embeddings(self, value):
851
+ self.model.embed_tokens = value
852
+
853
+ def get_output_embeddings(self):
854
+ return self.lm_head
855
+
856
+ def set_output_embeddings(self, new_embeddings):
857
+ self.lm_head = new_embeddings
858
+
859
+ def set_decoder(self, decoder):
860
+ self.model = decoder
861
+
862
+ def get_decoder(self):
863
+ return self.model
864
+
865
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
866
+ def forward(
867
+ self,
868
+ input_ids: torch.LongTensor = None,
869
+ attention_mask: Optional[torch.Tensor] = None,
870
+ position_ids: Optional[torch.LongTensor] = None,
871
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
872
+ inputs_embeds: Optional[torch.FloatTensor] = None,
873
+ labels: Optional[torch.LongTensor] = None,
874
+ use_cache: Optional[bool] = None,
875
+ output_attentions: Optional[bool] = None,
876
+ output_hidden_states: Optional[bool] = None,
877
+ return_dict: Optional[bool] = None,
878
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
879
+ r"""
880
+ Args:
881
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
882
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
883
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
884
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
885
+
886
+ Returns:
887
+
888
+ Example:
889
+
890
+ ```python
891
+ >>> from transformers import AutoTokenizer, OrionForCausalLM
892
+
893
+ >>> model = OrionForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
894
+ >>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
895
+
896
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
897
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
898
+
899
+ >>> # Generate
900
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
901
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
902
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
903
+ ```"""
904
+
905
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
906
+ output_hidden_states = (
907
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
908
+ )
909
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
910
+
911
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
912
+ outputs = self.model(
913
+ input_ids=input_ids,
914
+ attention_mask=attention_mask,
915
+ position_ids=position_ids,
916
+ past_key_values=past_key_values,
917
+ inputs_embeds=inputs_embeds,
918
+ use_cache=use_cache,
919
+ output_attentions=output_attentions,
920
+ output_hidden_states=output_hidden_states,
921
+ return_dict=return_dict,
922
+ )
923
+
924
+ hidden_states = outputs[0]
925
+ if self.config.pretraining_tp > 1:
926
+ lm_head_slices = self.lm_head.weight.split(self.vocab_size // self.config.pretraining_tp, dim=0)
927
+ logits = [F.linear(hidden_states, lm_head_slices[i]) for i in range(self.config.pretraining_tp)]
928
+ logits = torch.cat(logits, dim=-1)
929
+ else:
930
+ logits = self.lm_head(hidden_states)
931
+ logits = logits.float()
932
+
933
+ loss = None
934
+ if labels is not None:
935
+ # Shift so that tokens < n predict n
936
+ shift_logits = logits[..., :-1, :].contiguous()
937
+ shift_labels = labels[..., 1:].contiguous()
938
+ # Flatten the tokens
939
+ loss_fct = CrossEntropyLoss()
940
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
941
+ shift_labels = shift_labels.view(-1)
942
+ # Enable model parallelism
943
+ shift_labels = shift_labels.to(shift_logits.device)
944
+ loss = loss_fct(shift_logits, shift_labels)
945
+
946
+ if not return_dict:
947
+ output = (logits,) + outputs[1:]
948
+ return (loss,) + output if loss is not None else output
949
+
950
+ return CausalLMOutputWithPast(
951
+ loss=loss,
952
+ logits=logits,
953
+ past_key_values=outputs.past_key_values,
954
+ hidden_states=outputs.hidden_states,
955
+ attentions=outputs.attentions,
956
+ )
957
+
958
+ def chat(self, tokenizer, messages: List[dict], streaming=False,generation_config: Optional[GenerationConfig]=None):
959
+ generation_config = generation_config or self.generation_config
960
+ input_tokens = build_chat_input(tokenizer,messages)
961
+ input_ids = torch.LongTensor([input_tokens]).to(self.device)
962
+
963
+ if streaming:
964
+ streamer = TextIterStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
965
+ Thread(target=self.generate, kwargs=dict(
966
+ inputs=input_ids, streamer=streamer,
967
+ generation_config=generation_config,
968
+ )).start()
969
+ return streamer
970
+ else:
971
+ outputs = self.generate(input_ids, generation_config=generation_config)
972
+ response = tokenizer.decode(outputs[0][len(input_ids[0]):], skip_special_tokens=True)
973
+ return response
974
+
975
+ def prepare_inputs_for_generation(
976
+ self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
977
+ ):
978
+ if past_key_values:
979
+ input_ids = input_ids[:, -1:]
980
+
981
+ position_ids = kwargs.get("position_ids", None)
982
+ if attention_mask is not None and position_ids is None:
983
+ # create position_ids on the fly for batch generation
984
+ position_ids = attention_mask.long().cumsum(-1) - 1
985
+ position_ids.masked_fill_(attention_mask == 0, 1)
986
+ if past_key_values:
987
+ position_ids = position_ids[:, -1].unsqueeze(-1)
988
+
989
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
990
+ if inputs_embeds is not None and past_key_values is None:
991
+ model_inputs = {"inputs_embeds": inputs_embeds}
992
+ else:
993
+ model_inputs = {"input_ids": input_ids}
994
+
995
+ model_inputs.update(
996
+ {
997
+ "position_ids": position_ids,
998
+ "past_key_values": past_key_values,
999
+ "use_cache": kwargs.get("use_cache"),
1000
+ "attention_mask": attention_mask,
1001
+ }
1002
+ )
1003
+ return model_inputs
1004
+
1005
+ @staticmethod
1006
+ def _reorder_cache(past_key_values, beam_idx):
1007
+ reordered_past = ()
1008
+ for layer_past in past_key_values:
1009
+ reordered_past += (
1010
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1011
+ )
1012
+ return reordered_past
1013
+
1014
+ class OrionForSequenceClassification(OrionPreTrainedModel):
1015
+ def __init__(self, config):
1016
+ super().__init__(config)
1017
+ self.num_labels = config.num_labels
1018
+ self.model = OrionModel(config)
1019
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1020
+
1021
+ # Initialize weights and apply final processing
1022
+ self.post_init()
1023
+
1024
+ def get_input_embeddings(self):
1025
+ return self.model.embed_tokens
1026
+
1027
+ def set_input_embeddings(self, value):
1028
+ self.model.embed_tokens = value
1029
+
1030
+ def forward(
1031
+ self,
1032
+ input_ids: torch.LongTensor = None,
1033
+ attention_mask: Optional[torch.Tensor] = None,
1034
+ position_ids: Optional[torch.LongTensor] = None,
1035
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1036
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1037
+ labels: Optional[torch.LongTensor] = None,
1038
+ use_cache: Optional[bool] = None,
1039
+ output_attentions: Optional[bool] = None,
1040
+ output_hidden_states: Optional[bool] = None,
1041
+ return_dict: Optional[bool] = None,
1042
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1043
+ r"""
1044
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1045
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1046
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1047
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1048
+ """
1049
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1050
+
1051
+ transformer_outputs = self.model(
1052
+ input_ids,
1053
+ attention_mask=attention_mask,
1054
+ position_ids=position_ids,
1055
+ past_key_values=past_key_values,
1056
+ inputs_embeds=inputs_embeds,
1057
+ use_cache=use_cache,
1058
+ output_attentions=output_attentions,
1059
+ output_hidden_states=output_hidden_states,
1060
+ return_dict=return_dict,
1061
+ )
1062
+ hidden_states = transformer_outputs[0]
1063
+ logits = self.score(hidden_states)
1064
+
1065
+ if input_ids is not None:
1066
+ batch_size = input_ids.shape[0]
1067
+ else:
1068
+ batch_size = inputs_embeds.shape[0]
1069
+
1070
+ if self.config.pad_token_id is None and batch_size != 1:
1071
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1072
+ if self.config.pad_token_id is None:
1073
+ sequence_lengths = -1
1074
+ else:
1075
+ if input_ids is not None:
1076
+ sequence_lengths = (torch.eq(input_ids, self.config.pad_token_id).long().argmax(-1) - 1).to(
1077
+ logits.device
1078
+ )
1079
+ else:
1080
+ sequence_lengths = -1
1081
+
1082
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1083
+
1084
+ loss = None
1085
+ if labels is not None:
1086
+ labels = labels.to(logits.device)
1087
+ if self.config.problem_type is None:
1088
+ if self.num_labels == 1:
1089
+ self.config.problem_type = "regression"
1090
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1091
+ self.config.problem_type = "single_label_classification"
1092
+ else:
1093
+ self.config.problem_type = "multi_label_classification"
1094
+
1095
+ if self.config.problem_type == "regression":
1096
+ loss_fct = MSELoss()
1097
+ if self.num_labels == 1:
1098
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1099
+ else:
1100
+ loss = loss_fct(pooled_logits, labels)
1101
+ elif self.config.problem_type == "single_label_classification":
1102
+ loss_fct = CrossEntropyLoss()
1103
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1104
+ elif self.config.problem_type == "multi_label_classification":
1105
+ loss_fct = BCEWithLogitsLoss()
1106
+ loss = loss_fct(pooled_logits, labels)
1107
+ if not return_dict:
1108
+ output = (pooled_logits,) + transformer_outputs[1:]
1109
+ return ((loss,) + output) if loss is not None else output
1110
+
1111
+ return SequenceClassifierOutputWithPast(
1112
+ loss=loss,
1113
+ logits=pooled_logits,
1114
+ past_key_values=transformer_outputs.past_key_values,
1115
+ hidden_states=transformer_outputs.hidden_states,
1116
+ attentions=transformer_outputs.attentions,
1117
+ )
1118
+
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": true,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": true,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenization_orion.py ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2024, OrionStar Inc. All rights reserved.
2
+
3
+ import os
4
+ from shutil import copyfile
5
+ from typing import Any, Dict, List, Optional, Tuple
6
+ import re
7
+
8
+ import sentencepiece as spm
9
+ from transformers.tokenization_utils import AddedToken, PreTrainedTokenizer
10
+
11
+
12
+ VOCAB_FILES_NAMES = {"vocab_file": "tokenizer.model"}
13
+
14
+ PRETRAINED_VOCAB_FILES_MAP = {
15
+ "vocab_file": {},
16
+ "tokenizer_file": {},
17
+ }
18
+ PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {}
19
+
20
+
21
+ class OrionTokenizer(PreTrainedTokenizer):
22
+ """
23
+ Construct a Orion tokenizer. Based on byte-level Byte-Pair-Encoding.
24
+
25
+ Args:
26
+ vocab_file (`str`):
27
+ Path to the vocabulary file.
28
+ """
29
+
30
+ vocab_files_names = VOCAB_FILES_NAMES
31
+ pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
32
+ max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
33
+ model_input_names = ["input_ids", "attention_mask"]
34
+
35
+ def __init__(
36
+ self,
37
+ vocab_file,
38
+ unk_token="<unk>",
39
+ bos_token="<s>",
40
+ eos_token="</s>",
41
+ pad_token=None,
42
+ sp_model_kwargs: Optional[Dict[str, Any]] = None,
43
+ add_bos_token=True,
44
+ add_eos_token=False,
45
+ clean_up_tokenization_spaces=False,
46
+ **kwargs,
47
+ ):
48
+ self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
49
+ bos_token = (
50
+ AddedToken(bos_token, lstrip=False, rstrip=False)
51
+ if isinstance(bos_token, str)
52
+ else bos_token
53
+ )
54
+ eos_token = (
55
+ AddedToken(eos_token, lstrip=False, rstrip=False)
56
+ if isinstance(eos_token, str)
57
+ else eos_token
58
+ )
59
+ unk_token = (
60
+ AddedToken(unk_token, lstrip=False, rstrip=False)
61
+ if isinstance(unk_token, str)
62
+ else unk_token
63
+ )
64
+ pad_token = (
65
+ AddedToken(pad_token, lstrip=False, rstrip=False)
66
+ if isinstance(pad_token, str)
67
+ else pad_token
68
+ )
69
+ self.vocab_file = vocab_file
70
+ self.add_bos_token = add_bos_token
71
+ self.add_eos_token = add_eos_token
72
+ self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
73
+ self.sp_model.Load(vocab_file)
74
+
75
+ super().__init__(
76
+ bos_token=bos_token,
77
+ eos_token=eos_token,
78
+ unk_token=unk_token,
79
+ pad_token=pad_token,
80
+ add_bos_token=add_bos_token,
81
+ add_eos_token=add_eos_token,
82
+ sp_model_kwargs=self.sp_model_kwargs,
83
+ clean_up_tokenization_spaces=clean_up_tokenization_spaces,
84
+ **kwargs,
85
+ )
86
+
87
+ def __getstate__(self):
88
+ state = self.__dict__.copy()
89
+ state["sp_model"] = None
90
+ return state
91
+
92
+ def __setstate__(self, d):
93
+ self.__dict__ = d
94
+ self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
95
+ self.sp_model.Load(self.vocab_file)
96
+
97
+ @property
98
+ def vocab_size(self):
99
+ """Returns vocab size"""
100
+ return self.sp_model.get_piece_size()
101
+
102
+ def get_vocab(self):
103
+ """Returns vocab as a dict"""
104
+ vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
105
+ vocab.update(self.added_tokens_encoder)
106
+ return vocab
107
+
108
+ def _tokenize(self, text):
109
+ """Returns a tokenized string."""
110
+ return self.sp_model.encode(text, out_type=str)
111
+
112
+ def _convert_token_to_id(self, token):
113
+ """Converts a token (str) in an id using the vocab."""
114
+ return self.sp_model.piece_to_id(token)
115
+
116
+ def _convert_id_to_token(self, index):
117
+ """Converts an index (integer) in a token (str) using the vocab."""
118
+ token = self.sp_model.IdToPiece(index)
119
+ return token
120
+
121
+ def convert_tokens_to_string(self, tokens):
122
+ """Converts a sequence of tokens (string) in a single string."""
123
+ zhPattern = re.compile(u'[\u4e00-\u9fa5]+')
124
+ need_convert_punctuation=(",",";","!","?",":","(",")")
125
+ current_sub_tokens = []
126
+ out_string = ""
127
+ prev_is_special = False
128
+ for i, token in enumerate(tokens):
129
+ # make sure that special tokens are not decoded using sentencepiece model
130
+ if token in self.all_special_tokens:
131
+ if not prev_is_special and i != 0:
132
+ out_string += " "
133
+ out_string += self.sp_model.decode(current_sub_tokens) + token
134
+ prev_is_special = True
135
+ current_sub_tokens = []
136
+ if any([True if punctuation in token else False for punctuation in need_convert_punctuation]):
137
+ out_string += self.sp_model.decode(current_sub_tokens)
138
+ token=self.sp_model.decode(token)
139
+ if zhPattern.search(out_string[-20:]):
140
+ token = self.to_zh_punctuation(token)
141
+ out_string += token
142
+ current_sub_tokens = []
143
+ else:
144
+ current_sub_tokens.append(token)
145
+ prev_is_special = False
146
+ out_string += self.sp_model.decode(current_sub_tokens)
147
+ return out_string
148
+
149
+ def to_zh_punctuation(self, token):
150
+ return token.replace(",",",").replace(";",";").replace("!","!").replace("?","?").replace(":",":").replace("(","(").replace(")",")")
151
+
152
+ def save_vocabulary(
153
+ self, save_directory, filename_prefix: Optional[str] = None
154
+ ) -> Tuple[str]:
155
+ """
156
+ Save the vocabulary and special tokens file to a directory.
157
+
158
+ Args:
159
+ save_directory (`str`):
160
+ The directory in which to save the vocabulary.
161
+
162
+ Returns:
163
+ `Tuple(str)`: Paths to the files saved.
164
+ """
165
+ if not os.path.isdir(save_directory):
166
+ logger.error(f"Vocabulary path ({save_directory}) should be a directory")
167
+ return
168
+ out_vocab_file = os.path.join(
169
+ save_directory,
170
+ (filename_prefix + "-" if filename_prefix else "")
171
+ + VOCAB_FILES_NAMES["vocab_file"],
172
+ )
173
+
174
+ if os.path.abspath(self.vocab_file) != os.path.abspath(
175
+ out_vocab_file
176
+ ) and os.path.isfile(self.vocab_file):
177
+ copyfile(self.vocab_file, out_vocab_file)
178
+ elif not os.path.isfile(self.vocab_file):
179
+ with open(out_vocab_file, "wb") as fi:
180
+ content_spiece_model = self.sp_model.serialized_model_proto()
181
+ fi.write(content_spiece_model)
182
+
183
+ return (out_vocab_file,)
184
+
185
+ def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
186
+ bos_token_id = [self.bos_token_id] if self.add_bos_token else []
187
+ eos_token_id = [self.eos_token_id] if self.add_eos_token else []
188
+
189
+ output = bos_token_id + token_ids_0 + eos_token_id
190
+
191
+ if token_ids_1 is not None:
192
+ output = output + bos_token_id + token_ids_1 + eos_token_id
193
+
194
+ return output
195
+
196
+ def get_special_tokens_mask(
197
+ self,
198
+ token_ids_0: List[int],
199
+ token_ids_1: Optional[List[int]] = None,
200
+ already_has_special_tokens: bool = False,
201
+ ) -> List[int]:
202
+ """
203
+ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
204
+ special tokens using the tokenizer `prepare_for_model` method.
205
+
206
+ Args:
207
+ token_ids_0 (`List[int]`):
208
+ List of IDs.
209
+ token_ids_1 (`List[int]`, *optional*):
210
+ Optional second list of IDs for sequence pairs.
211
+ already_has_special_tokens (`bool`, *optional*, defaults to `False`):
212
+ Whether or not the token list is already formatted with special tokens for the model.
213
+
214
+ Returns:
215
+ `List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
216
+ """
217
+ if already_has_special_tokens:
218
+ return super().get_special_tokens_mask(
219
+ token_ids_0=token_ids_0,
220
+ token_ids_1=token_ids_1,
221
+ already_has_special_tokens=True,
222
+ )
223
+
224
+ bos_token_id = [1] if self.add_bos_token else []
225
+ eos_token_id = [1] if self.add_eos_token else []
226
+
227
+ if token_ids_1 is None:
228
+ return bos_token_id + ([0] * len(token_ids_0)) + eos_token_id
229
+ return (
230
+ bos_token_id
231
+ + ([0] * len(token_ids_0))
232
+ + eos_token_id
233
+ + bos_token_id
234
+ + ([0] * len(token_ids_1))
235
+ + eos_token_id
236
+ )
237
+
238
+ def create_token_type_ids_from_sequences(
239
+ self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
240
+ ) -> List[int]:
241
+ """
242
+ Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT
243
+ sequence pair mask has the following format:
244
+
245
+ ```
246
+ 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
247
+ | first sequence | second sequence |
248
+ ```
249
+
250
+ if token_ids_1 is None, only returns the first portion of the mask (0s).
251
+
252
+ Args:
253
+ token_ids_0 (`List[int]`):
254
+ List of ids.
255
+ token_ids_1 (`List[int]`, *optional*):
256
+ Optional second list of IDs for sequence pairs.
257
+
258
+ Returns:
259
+ `List[int]`: List of [token type IDs](../glossary#token-type-ids) according to the given sequence(s).
260
+ """
261
+ bos_token_id = [self.bos_token_id] if self.add_bos_token else []
262
+ eos_token_id = [self.eos_token_id] if self.add_eos_token else []
263
+
264
+ output = [0] * len(bos_token_id + token_ids_0 + eos_token_id)
265
+
266
+ if token_ids_1 is not None:
267
+ output += [1] * len(bos_token_id + token_ids_1 + eos_token_id)
268
+
269
+ return output
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ded43118b7418f56db97a4eed08a5c265c03120158229ddd4fbcc9658241d5f0
3
+ size 1520600
tokenizer_config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": true,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": true,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ }
29
+ },
30
+ "auto_map": {
31
+ "AutoTokenizer": [
32
+ "tokenization_orion.OrionTokenizer",
33
+ null
34
+ ]
35
+ },
36
+ "bos_token": "<s>",
37
+ "chat_template": "{% for message in messages %}{% if loop.first %}{{ bos_token }}{% endif %}{% if message['role'] == 'user' %}{{ 'Human: ' + message['content'] + '\n\nAssistant: ' + eos_token }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token }}{% endif %}{% endfor %}",
38
+ "clean_up_tokenization_spaces": false,
39
+ "eos_token": "</s>",
40
+ "model_max_length": 2048,
41
+ "pad_token": "<unk>",
42
+ "padding_side": "left",
43
+ "sp_model_kwargs": {},
44
+ "tokenizer_class": "OrionTokenizer",
45
+ "unk_token": "<unk>"
46
+ }