bbasavar commited on
Commit
bccdf3d
·
verified ·
1 Parent(s): 94cb444

Upload folder using huggingface_hub

Browse files
Files changed (45) hide show
  1. checkpoint-2000/config.json +37 -0
  2. checkpoint-2000/config_custom.py +191 -0
  3. checkpoint-2000/generation_config.json +9 -0
  4. checkpoint-2000/model.safetensors +3 -0
  5. checkpoint-2000/optimizer.pt +3 -0
  6. checkpoint-2000/rng_state.pth +3 -0
  7. checkpoint-2000/scheduler.pt +3 -0
  8. checkpoint-2000/special_tokens_map.json +24 -0
  9. checkpoint-2000/tokenizer.json +0 -0
  10. checkpoint-2000/tokenizer_config.json +215 -0
  11. checkpoint-2000/trainer_state.json +206 -0
  12. checkpoint-2000/training_args.bin +3 -0
  13. checkpoint-4000/config.json +37 -0
  14. checkpoint-4000/config_custom.py +191 -0
  15. checkpoint-4000/generation_config.json +9 -0
  16. checkpoint-4000/model.safetensors +3 -0
  17. checkpoint-4000/optimizer.pt +3 -0
  18. checkpoint-4000/rng_state.pth +3 -0
  19. checkpoint-4000/scheduler.pt +3 -0
  20. checkpoint-4000/special_tokens_map.json +24 -0
  21. checkpoint-4000/tokenizer.json +0 -0
  22. checkpoint-4000/tokenizer_config.json +215 -0
  23. checkpoint-4000/trainer_state.json +378 -0
  24. checkpoint-4000/training_args.bin +3 -0
  25. checkpoint-6000/config.json +37 -0
  26. checkpoint-6000/config_custom.py +191 -0
  27. checkpoint-6000/generation_config.json +9 -0
  28. checkpoint-6000/model.safetensors +3 -0
  29. checkpoint-6000/optimizer.pt +3 -0
  30. checkpoint-6000/rng_state.pth +3 -0
  31. checkpoint-6000/scheduler.pt +3 -0
  32. checkpoint-6000/special_tokens_map.json +24 -0
  33. checkpoint-6000/tokenizer.json +0 -0
  34. checkpoint-6000/tokenizer_config.json +215 -0
  35. checkpoint-6000/trainer_state.json +550 -0
  36. checkpoint-6000/training_args.bin +3 -0
  37. config.json +37 -0
  38. config_custom.py +191 -0
  39. generation_config.json +9 -0
  40. model.safetensors +3 -0
  41. modeling_custom.py +1569 -0
  42. special_tokens_map.json +24 -0
  43. tokenizer.json +0 -0
  44. tokenizer_config.json +215 -0
  45. training_args.bin +3 -0
checkpoint-2000/config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPTNeoXForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "config_custom.GPTNeoXConfig",
9
+ "AutoModel": "modeling_custom.GPTNeoXModel",
10
+ "AutoModelForCausalLM": "modeling_custom.GPTNeoXForCausalLM"
11
+ },
12
+ "bos_token_id": 0,
13
+ "classifier_dropout": 0.1,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 0,
16
+ "hidden_act": "gelu",
17
+ "hidden_dropout": 0.0,
18
+ "hidden_size": 768,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 3072,
21
+ "layer_norm_eps": 1e-05,
22
+ "max_position_embeddings": 2048,
23
+ "model_type": "gpt_neox",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "pad_token_id": 0,
27
+ "partial_rotary_factor": 0.25,
28
+ "rope_scaling": null,
29
+ "rope_theta": 10000,
30
+ "rotary_emb_base": 10000,
31
+ "rotary_pct": 0.25,
32
+ "tie_word_embeddings": false,
33
+ "transformers_version": "4.57.1",
34
+ "use_cache": true,
35
+ "use_parallel_residual": true,
36
+ "vocab_size": 50304
37
+ }
checkpoint-2000/config_custom.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """GPTNeoX model configuration"""
16
+
17
+ from transformers.configuration_utils import PretrainedConfig
18
+ from transformers.modeling_rope_utils import rope_config_validation
19
+ from transformers.utils import logging
20
+
21
+
22
+ logger = logging.get_logger(__name__)
23
+
24
+
25
+ class GPTNeoXConfig(PretrainedConfig):
26
+ r"""
27
+ This is the configuration class to store the configuration of a [`GPTNeoXModel`]. It is used to instantiate an
28
+ GPTNeoX model according to the specified arguments, defining the model architecture. Instantiating a configuration
29
+ with the defaults will yield a similar configuration to that of the GPTNeoX
30
+ [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) architecture.
31
+
32
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
33
+ documentation from [`PretrainedConfig`] for more information.
34
+
35
+
36
+ Args:
37
+ vocab_size (`int`, *optional*, defaults to 50432):
38
+ Vocabulary size of the GPTNeoX model. Defines the number of different tokens that can be represented by the
39
+ `inputs_ids` passed when calling [`GPTNeoXModel`].
40
+ hidden_size (`int`, *optional*, defaults to 6144):
41
+ Dimension of the encoder layers and the pooler layer.
42
+ num_hidden_layers (`int`, *optional*, defaults to 44):
43
+ Number of hidden layers in the Transformer encoder.
44
+ num_attention_heads (`int`, *optional*, defaults to 64):
45
+ Number of attention heads for each attention layer in the Transformer encoder.
46
+ intermediate_size (`int`, *optional*, defaults to 24576):
47
+ Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
48
+ hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
49
+ The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
50
+ `"relu"`, `"selu"` and `"gelu_new"` are supported.
51
+ rotary_pct (`float`, *optional*, defaults to 0.25):
52
+ percentage of hidden dimensions to allocate to rotary embeddings
53
+ rotary_emb_base (`int`, *optional*, defaults to 10000)
54
+ base for computing rotary embeddings frequency
55
+ attention_dropout (`float`, *optional*, defaults to 0.0):
56
+ The dropout ratio probability of the attention score.
57
+ hidden_dropout (`float`, *optional*, defaults to 0.0):
58
+ The dropout ratio of (1) the word embeddings, (2) the post-attention hidden states, and (3) the post-mlp
59
+ hidden states.
60
+ classifier_dropout (`float`, *optional*, defaults to 0.1):
61
+ Argument used when doing token classification, used in the model [`GPTNeoXForTokenClassification`].
62
+
63
+ The dropout ratio for the hidden layer.
64
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
65
+ The maximum sequence length that this model might ever be used with. Typically set this to something large
66
+ just in case (e.g., 512 or 1024 or 2048).
67
+ initializer_range (`float`, *optional*, defaults to 1e-5):
68
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
69
+ layer_norm_eps (`float`, *optional*, defaults to 1e-12):
70
+ The epsilon used by the layer normalization layers.
71
+ use_cache (`bool`, *optional*, defaults to `True`):
72
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
73
+ relevant if `config.is_decoder=True`.
74
+ use_parallel_residual (`bool`, *optional*, defaults to `True`):
75
+ Whether to use a "parallel" formulation in each Transformer layer, which can provide a slight training
76
+ speedup at large scales (e.g. 20B).
77
+ rope_scaling (`Dict`, *optional*):
78
+ Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
79
+ and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
80
+ accordingly.
81
+ Expected contents:
82
+ `rope_type` (`str`):
83
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
84
+ 'llama3'], with 'default' being the original RoPE implementation.
85
+ `factor` (`float`, *optional*):
86
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
87
+ most scaling types, a `factor` of x will enable the model to handle sequences of length x *
88
+ original maximum pre-trained length.
89
+ `original_max_position_embeddings` (`int`, *optional*):
90
+ Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
91
+ pretraining.
92
+ `attention_factor` (`float`, *optional*):
93
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
94
+ computation. If unspecified, it defaults to value recommended by the implementation, using the
95
+ `factor` field to infer the suggested value.
96
+ `beta_fast` (`float`, *optional*):
97
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
98
+ ramp function. If unspecified, it defaults to 32.
99
+ `beta_slow` (`float`, *optional*):
100
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
101
+ ramp function. If unspecified, it defaults to 1.
102
+ `short_factor` (`List[float]`, *optional*):
103
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<
104
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
105
+ size divided by the number of attention heads divided by 2
106
+ `long_factor` (`List[float]`, *optional*):
107
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<
108
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
109
+ size divided by the number of attention heads divided by 2
110
+ `low_freq_factor` (`float`, *optional*):
111
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
112
+ `high_freq_factor` (`float`, *optional*):
113
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
114
+ attention_bias (`bool`, *optional*, defaults to `True`):
115
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
116
+
117
+ Example:
118
+
119
+ ```python
120
+ >>> from transformers import GPTNeoXConfig, GPTNeoXModel
121
+
122
+ >>> # Initializing a GPTNeoX gpt-neox-20b style configuration
123
+ >>> configuration = GPTNeoXConfig()
124
+
125
+ >>> # Initializing a model (with random weights) from the gpt-neox-20b style configuration
126
+ >>> model = GPTNeoXModel(configuration) # doctest: +SKIP
127
+
128
+ >>> # Accessing the model configuration
129
+ >>> configuration = model.config # doctest: +SKIP
130
+ ```"""
131
+
132
+ model_type = "gpt_neox"
133
+ keys_to_ignore_at_inference = ["past_key_values"]
134
+
135
+ def __init__(
136
+ self,
137
+ vocab_size=50432,
138
+ hidden_size=6144,
139
+ num_hidden_layers=44,
140
+ num_attention_heads=64,
141
+ intermediate_size=24576,
142
+ hidden_act="gelu",
143
+ rotary_pct=0.25,
144
+ rotary_emb_base=10000,
145
+ attention_dropout=0.0,
146
+ hidden_dropout=0.0,
147
+ classifier_dropout=0.1,
148
+ max_position_embeddings=2048,
149
+ initializer_range=0.02,
150
+ layer_norm_eps=1e-5,
151
+ use_cache=True,
152
+ bos_token_id=0,
153
+ eos_token_id=2,
154
+ tie_word_embeddings=False,
155
+ use_parallel_residual=True,
156
+ rope_scaling=None,
157
+ attention_bias=True,
158
+ **kwargs,
159
+ ):
160
+ super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
161
+ self.vocab_size = vocab_size
162
+ self.max_position_embeddings = max_position_embeddings
163
+ self.hidden_size = hidden_size
164
+ self.num_hidden_layers = num_hidden_layers
165
+ self.num_attention_heads = num_attention_heads
166
+ self.intermediate_size = intermediate_size
167
+ self.hidden_act = hidden_act
168
+ self.rotary_pct = rotary_pct
169
+ self.partial_rotary_factor = rotary_pct
170
+ self.rotary_emb_base = rotary_emb_base
171
+ self.rope_theta = rotary_emb_base
172
+ self.attention_dropout = attention_dropout
173
+ self.hidden_dropout = hidden_dropout
174
+ self.classifier_dropout = classifier_dropout
175
+ self.initializer_range = initializer_range
176
+ self.layer_norm_eps = layer_norm_eps
177
+ self.use_cache = use_cache
178
+ self.tie_word_embeddings = tie_word_embeddings
179
+ self.use_parallel_residual = use_parallel_residual
180
+ self.rope_scaling = rope_scaling
181
+ self.attention_bias = attention_bias
182
+ # Validate the correctness of rotary position embeddings parameters
183
+ # BC: if there is a 'type' field, move it to 'rope_type'.
184
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
185
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
186
+ rope_config_validation(self)
187
+
188
+ if self.hidden_size % self.num_attention_heads != 0:
189
+ raise ValueError(
190
+ "The hidden size is not divisble by the number of attention heads! Make sure to update them!"
191
+ )
checkpoint-2000/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": [
5
+ 0
6
+ ],
7
+ "pad_token_id": 0,
8
+ "transformers_version": "4.57.1"
9
+ }
checkpoint-2000/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:733081b4403a1b41f6e304454273619ed56837fbfe231f8457aaa1bee0f69dc5
3
+ size 324662984
checkpoint-2000/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e3f5f710ab0bae281751160bb3d7e1693ae51e307a09bb654e86ae088b745b9
3
+ size 649415674
checkpoint-2000/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b3ee827a7a00012c0a116546df467feee35e70376d81a7a85b1a70eb90414d3
3
+ size 14244
checkpoint-2000/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fa32bff93aa9f36de56b9987e5b87998a3a15c8a67f628db402d3759b9c402d
3
+ size 1064
checkpoint-2000/special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
checkpoint-2000/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-2000/tokenizer_config.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|padding|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "50254": {
23
+ "content": " ",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "50255": {
31
+ "content": " ",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": false
37
+ },
38
+ "50256": {
39
+ "content": " ",
40
+ "lstrip": false,
41
+ "normalized": true,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "50257": {
47
+ "content": " ",
48
+ "lstrip": false,
49
+ "normalized": true,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "50258": {
55
+ "content": " ",
56
+ "lstrip": false,
57
+ "normalized": true,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "50259": {
63
+ "content": " ",
64
+ "lstrip": false,
65
+ "normalized": true,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "50260": {
71
+ "content": " ",
72
+ "lstrip": false,
73
+ "normalized": true,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": false
77
+ },
78
+ "50261": {
79
+ "content": " ",
80
+ "lstrip": false,
81
+ "normalized": true,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": false
85
+ },
86
+ "50262": {
87
+ "content": " ",
88
+ "lstrip": false,
89
+ "normalized": true,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": false
93
+ },
94
+ "50263": {
95
+ "content": " ",
96
+ "lstrip": false,
97
+ "normalized": true,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": false
101
+ },
102
+ "50264": {
103
+ "content": " ",
104
+ "lstrip": false,
105
+ "normalized": true,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": false
109
+ },
110
+ "50265": {
111
+ "content": " ",
112
+ "lstrip": false,
113
+ "normalized": true,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": false
117
+ },
118
+ "50266": {
119
+ "content": " ",
120
+ "lstrip": false,
121
+ "normalized": true,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "50267": {
127
+ "content": " ",
128
+ "lstrip": false,
129
+ "normalized": true,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "50268": {
135
+ "content": " ",
136
+ "lstrip": false,
137
+ "normalized": true,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "50269": {
143
+ "content": " ",
144
+ "lstrip": false,
145
+ "normalized": true,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "50270": {
151
+ "content": " ",
152
+ "lstrip": false,
153
+ "normalized": true,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "50271": {
159
+ "content": " ",
160
+ "lstrip": false,
161
+ "normalized": true,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "50272": {
167
+ "content": " ",
168
+ "lstrip": false,
169
+ "normalized": true,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "50273": {
175
+ "content": " ",
176
+ "lstrip": false,
177
+ "normalized": true,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "50274": {
183
+ "content": " ",
184
+ "lstrip": false,
185
+ "normalized": true,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "50275": {
191
+ "content": " ",
192
+ "lstrip": false,
193
+ "normalized": true,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "50276": {
199
+ "content": " ",
200
+ "lstrip": false,
201
+ "normalized": true,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ }
206
+ },
207
+ "bos_token": "<|endoftext|>",
208
+ "clean_up_tokenization_spaces": true,
209
+ "eos_token": "<|endoftext|>",
210
+ "extra_special_tokens": {},
211
+ "model_max_length": 1000000000000000019884624838656,
212
+ "pad_token": "<|endoftext|>",
213
+ "tokenizer_class": "GPTNeoXTokenizer",
214
+ "unk_token": "<|endoftext|>"
215
+ }
checkpoint-2000/trainer_state.json ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.22456140350877193,
6
+ "eval_steps": 500,
7
+ "global_step": 2000,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.011228070175438596,
14
+ "grad_norm": 0.60546875,
15
+ "learning_rate": 0.00024749999999999994,
16
+ "loss": 8.5199,
17
+ "step": 100
18
+ },
19
+ {
20
+ "epoch": 0.02245614035087719,
21
+ "grad_norm": 0.55859375,
22
+ "learning_rate": 0.0002998664031981949,
23
+ "loss": 6.415,
24
+ "step": 200
25
+ },
26
+ {
27
+ "epoch": 0.03368421052631579,
28
+ "grad_norm": 0.48046875,
29
+ "learning_rate": 0.0002993145411731054,
30
+ "loss": 5.8846,
31
+ "step": 300
32
+ },
33
+ {
34
+ "epoch": 0.04491228070175438,
35
+ "grad_norm": 0.5,
36
+ "learning_rate": 0.00029833654740795074,
37
+ "loss": 5.5615,
38
+ "step": 400
39
+ },
40
+ {
41
+ "epoch": 0.056140350877192984,
42
+ "grad_norm": 0.63671875,
43
+ "learning_rate": 0.00029693521301859697,
44
+ "loss": 5.3436,
45
+ "step": 500
46
+ },
47
+ {
48
+ "epoch": 0.056140350877192984,
49
+ "eval_loss": 5.2718000411987305,
50
+ "eval_runtime": 296.6131,
51
+ "eval_samples_per_second": 50.571,
52
+ "eval_steps_per_second": 6.321,
53
+ "step": 500
54
+ },
55
+ {
56
+ "epoch": 0.06736842105263158,
57
+ "grad_norm": 0.484375,
58
+ "learning_rate": 0.00029511453730114126,
59
+ "loss": 5.1964,
60
+ "step": 600
61
+ },
62
+ {
63
+ "epoch": 0.07859649122807018,
64
+ "grad_norm": 0.45703125,
65
+ "learning_rate": 0.0002928797163182408,
66
+ "loss": 5.0532,
67
+ "step": 700
68
+ },
69
+ {
70
+ "epoch": 0.08982456140350877,
71
+ "grad_norm": 0.3984375,
72
+ "learning_rate": 0.00029023712806996646,
73
+ "loss": 4.9288,
74
+ "step": 800
75
+ },
76
+ {
77
+ "epoch": 0.10105263157894737,
78
+ "grad_norm": 0.408203125,
79
+ "learning_rate": 0.0002871943142915013,
80
+ "loss": 4.8118,
81
+ "step": 900
82
+ },
83
+ {
84
+ "epoch": 0.11228070175438597,
85
+ "grad_norm": 0.609375,
86
+ "learning_rate": 0.0002837599589296326,
87
+ "loss": 4.6787,
88
+ "step": 1000
89
+ },
90
+ {
91
+ "epoch": 0.11228070175438597,
92
+ "eval_loss": 4.601714134216309,
93
+ "eval_runtime": 296.6412,
94
+ "eval_samples_per_second": 50.566,
95
+ "eval_steps_per_second": 6.321,
96
+ "step": 1000
97
+ },
98
+ {
99
+ "epoch": 0.12350877192982457,
100
+ "grad_norm": 0.49609375,
101
+ "learning_rate": 0.00027994386335946324,
102
+ "loss": 4.5393,
103
+ "step": 1100
104
+ },
105
+ {
106
+ "epoch": 0.13473684210526315,
107
+ "grad_norm": 0.4375,
108
+ "learning_rate": 0.0002757569184120724,
109
+ "loss": 4.3818,
110
+ "step": 1200
111
+ },
112
+ {
113
+ "epoch": 0.14596491228070174,
114
+ "grad_norm": 0.431640625,
115
+ "learning_rate": 0.00027121107329295584,
116
+ "loss": 4.2778,
117
+ "step": 1300
118
+ },
119
+ {
120
+ "epoch": 0.15719298245614036,
121
+ "grad_norm": 0.380859375,
122
+ "learning_rate": 0.0002663193014799507,
123
+ "loss": 4.2072,
124
+ "step": 1400
125
+ },
126
+ {
127
+ "epoch": 0.16842105263157894,
128
+ "grad_norm": 0.462890625,
129
+ "learning_rate": 0.000261095563697969,
130
+ "loss": 4.1242,
131
+ "step": 1500
132
+ },
133
+ {
134
+ "epoch": 0.16842105263157894,
135
+ "eval_loss": 4.072988510131836,
136
+ "eval_runtime": 296.6152,
137
+ "eval_samples_per_second": 50.571,
138
+ "eval_steps_per_second": 6.321,
139
+ "step": 1500
140
+ },
141
+ {
142
+ "epoch": 0.17964912280701753,
143
+ "grad_norm": 0.40625,
144
+ "learning_rate": 0.0002555547680762069,
145
+ "loss": 4.0549,
146
+ "step": 1600
147
+ },
148
+ {
149
+ "epoch": 0.19087719298245615,
150
+ "grad_norm": 0.47265625,
151
+ "learning_rate": 0.00024971272760153834,
152
+ "loss": 4.0018,
153
+ "step": 1700
154
+ },
155
+ {
156
+ "epoch": 0.20210526315789473,
157
+ "grad_norm": 0.4453125,
158
+ "learning_rate": 0.00024358611498951694,
159
+ "loss": 3.9404,
160
+ "step": 1800
161
+ },
162
+ {
163
+ "epoch": 0.21333333333333335,
164
+ "grad_norm": 0.40234375,
165
+ "learning_rate": 0.0002371924151017814,
166
+ "loss": 3.9074,
167
+ "step": 1900
168
+ },
169
+ {
170
+ "epoch": 0.22456140350877193,
171
+ "grad_norm": 0.39453125,
172
+ "learning_rate": 0.00023054987504566113,
173
+ "loss": 3.8638,
174
+ "step": 2000
175
+ },
176
+ {
177
+ "epoch": 0.22456140350877193,
178
+ "eval_loss": 3.8390953540802,
179
+ "eval_runtime": 296.6249,
180
+ "eval_samples_per_second": 50.569,
181
+ "eval_steps_per_second": 6.321,
182
+ "step": 2000
183
+ }
184
+ ],
185
+ "logging_steps": 100,
186
+ "max_steps": 6000,
187
+ "num_input_tokens_seen": 0,
188
+ "num_train_epochs": 1,
189
+ "save_steps": 2000,
190
+ "stateful_callbacks": {
191
+ "TrainerControl": {
192
+ "args": {
193
+ "should_epoch_stop": false,
194
+ "should_evaluate": false,
195
+ "should_log": false,
196
+ "should_save": true,
197
+ "should_training_stop": false
198
+ },
199
+ "attributes": {}
200
+ }
201
+ },
202
+ "total_flos": 9.7273358843904e+16,
203
+ "train_batch_size": 8,
204
+ "trial_name": null,
205
+ "trial_params": null
206
+ }
checkpoint-2000/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16bb5f9341aac44319789787905b9f8cd32fdefcafde13dd02317a8f825218ad
3
+ size 5432
checkpoint-4000/config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPTNeoXForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "config_custom.GPTNeoXConfig",
9
+ "AutoModel": "modeling_custom.GPTNeoXModel",
10
+ "AutoModelForCausalLM": "modeling_custom.GPTNeoXForCausalLM"
11
+ },
12
+ "bos_token_id": 0,
13
+ "classifier_dropout": 0.1,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 0,
16
+ "hidden_act": "gelu",
17
+ "hidden_dropout": 0.0,
18
+ "hidden_size": 768,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 3072,
21
+ "layer_norm_eps": 1e-05,
22
+ "max_position_embeddings": 2048,
23
+ "model_type": "gpt_neox",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "pad_token_id": 0,
27
+ "partial_rotary_factor": 0.25,
28
+ "rope_scaling": null,
29
+ "rope_theta": 10000,
30
+ "rotary_emb_base": 10000,
31
+ "rotary_pct": 0.25,
32
+ "tie_word_embeddings": false,
33
+ "transformers_version": "4.57.1",
34
+ "use_cache": true,
35
+ "use_parallel_residual": true,
36
+ "vocab_size": 50304
37
+ }
checkpoint-4000/config_custom.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """GPTNeoX model configuration"""
16
+
17
+ from transformers.configuration_utils import PretrainedConfig
18
+ from transformers.modeling_rope_utils import rope_config_validation
19
+ from transformers.utils import logging
20
+
21
+
22
+ logger = logging.get_logger(__name__)
23
+
24
+
25
+ class GPTNeoXConfig(PretrainedConfig):
26
+ r"""
27
+ This is the configuration class to store the configuration of a [`GPTNeoXModel`]. It is used to instantiate an
28
+ GPTNeoX model according to the specified arguments, defining the model architecture. Instantiating a configuration
29
+ with the defaults will yield a similar configuration to that of the GPTNeoX
30
+ [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) architecture.
31
+
32
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
33
+ documentation from [`PretrainedConfig`] for more information.
34
+
35
+
36
+ Args:
37
+ vocab_size (`int`, *optional*, defaults to 50432):
38
+ Vocabulary size of the GPTNeoX model. Defines the number of different tokens that can be represented by the
39
+ `inputs_ids` passed when calling [`GPTNeoXModel`].
40
+ hidden_size (`int`, *optional*, defaults to 6144):
41
+ Dimension of the encoder layers and the pooler layer.
42
+ num_hidden_layers (`int`, *optional*, defaults to 44):
43
+ Number of hidden layers in the Transformer encoder.
44
+ num_attention_heads (`int`, *optional*, defaults to 64):
45
+ Number of attention heads for each attention layer in the Transformer encoder.
46
+ intermediate_size (`int`, *optional*, defaults to 24576):
47
+ Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
48
+ hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
49
+ The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
50
+ `"relu"`, `"selu"` and `"gelu_new"` are supported.
51
+ rotary_pct (`float`, *optional*, defaults to 0.25):
52
+ percentage of hidden dimensions to allocate to rotary embeddings
53
+ rotary_emb_base (`int`, *optional*, defaults to 10000)
54
+ base for computing rotary embeddings frequency
55
+ attention_dropout (`float`, *optional*, defaults to 0.0):
56
+ The dropout ratio probability of the attention score.
57
+ hidden_dropout (`float`, *optional*, defaults to 0.0):
58
+ The dropout ratio of (1) the word embeddings, (2) the post-attention hidden states, and (3) the post-mlp
59
+ hidden states.
60
+ classifier_dropout (`float`, *optional*, defaults to 0.1):
61
+ Argument used when doing token classification, used in the model [`GPTNeoXForTokenClassification`].
62
+
63
+ The dropout ratio for the hidden layer.
64
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
65
+ The maximum sequence length that this model might ever be used with. Typically set this to something large
66
+ just in case (e.g., 512 or 1024 or 2048).
67
+ initializer_range (`float`, *optional*, defaults to 1e-5):
68
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
69
+ layer_norm_eps (`float`, *optional*, defaults to 1e-12):
70
+ The epsilon used by the layer normalization layers.
71
+ use_cache (`bool`, *optional*, defaults to `True`):
72
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
73
+ relevant if `config.is_decoder=True`.
74
+ use_parallel_residual (`bool`, *optional*, defaults to `True`):
75
+ Whether to use a "parallel" formulation in each Transformer layer, which can provide a slight training
76
+ speedup at large scales (e.g. 20B).
77
+ rope_scaling (`Dict`, *optional*):
78
+ Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
79
+ and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
80
+ accordingly.
81
+ Expected contents:
82
+ `rope_type` (`str`):
83
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
84
+ 'llama3'], with 'default' being the original RoPE implementation.
85
+ `factor` (`float`, *optional*):
86
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
87
+ most scaling types, a `factor` of x will enable the model to handle sequences of length x *
88
+ original maximum pre-trained length.
89
+ `original_max_position_embeddings` (`int`, *optional*):
90
+ Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
91
+ pretraining.
92
+ `attention_factor` (`float`, *optional*):
93
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
94
+ computation. If unspecified, it defaults to value recommended by the implementation, using the
95
+ `factor` field to infer the suggested value.
96
+ `beta_fast` (`float`, *optional*):
97
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
98
+ ramp function. If unspecified, it defaults to 32.
99
+ `beta_slow` (`float`, *optional*):
100
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
101
+ ramp function. If unspecified, it defaults to 1.
102
+ `short_factor` (`List[float]`, *optional*):
103
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<
104
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
105
+ size divided by the number of attention heads divided by 2
106
+ `long_factor` (`List[float]`, *optional*):
107
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<
108
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
109
+ size divided by the number of attention heads divided by 2
110
+ `low_freq_factor` (`float`, *optional*):
111
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
112
+ `high_freq_factor` (`float`, *optional*):
113
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
114
+ attention_bias (`bool`, *optional*, defaults to `True`):
115
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
116
+
117
+ Example:
118
+
119
+ ```python
120
+ >>> from transformers import GPTNeoXConfig, GPTNeoXModel
121
+
122
+ >>> # Initializing a GPTNeoX gpt-neox-20b style configuration
123
+ >>> configuration = GPTNeoXConfig()
124
+
125
+ >>> # Initializing a model (with random weights) from the gpt-neox-20b style configuration
126
+ >>> model = GPTNeoXModel(configuration) # doctest: +SKIP
127
+
128
+ >>> # Accessing the model configuration
129
+ >>> configuration = model.config # doctest: +SKIP
130
+ ```"""
131
+
132
+ model_type = "gpt_neox"
133
+ keys_to_ignore_at_inference = ["past_key_values"]
134
+
135
+ def __init__(
136
+ self,
137
+ vocab_size=50432,
138
+ hidden_size=6144,
139
+ num_hidden_layers=44,
140
+ num_attention_heads=64,
141
+ intermediate_size=24576,
142
+ hidden_act="gelu",
143
+ rotary_pct=0.25,
144
+ rotary_emb_base=10000,
145
+ attention_dropout=0.0,
146
+ hidden_dropout=0.0,
147
+ classifier_dropout=0.1,
148
+ max_position_embeddings=2048,
149
+ initializer_range=0.02,
150
+ layer_norm_eps=1e-5,
151
+ use_cache=True,
152
+ bos_token_id=0,
153
+ eos_token_id=2,
154
+ tie_word_embeddings=False,
155
+ use_parallel_residual=True,
156
+ rope_scaling=None,
157
+ attention_bias=True,
158
+ **kwargs,
159
+ ):
160
+ super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
161
+ self.vocab_size = vocab_size
162
+ self.max_position_embeddings = max_position_embeddings
163
+ self.hidden_size = hidden_size
164
+ self.num_hidden_layers = num_hidden_layers
165
+ self.num_attention_heads = num_attention_heads
166
+ self.intermediate_size = intermediate_size
167
+ self.hidden_act = hidden_act
168
+ self.rotary_pct = rotary_pct
169
+ self.partial_rotary_factor = rotary_pct
170
+ self.rotary_emb_base = rotary_emb_base
171
+ self.rope_theta = rotary_emb_base
172
+ self.attention_dropout = attention_dropout
173
+ self.hidden_dropout = hidden_dropout
174
+ self.classifier_dropout = classifier_dropout
175
+ self.initializer_range = initializer_range
176
+ self.layer_norm_eps = layer_norm_eps
177
+ self.use_cache = use_cache
178
+ self.tie_word_embeddings = tie_word_embeddings
179
+ self.use_parallel_residual = use_parallel_residual
180
+ self.rope_scaling = rope_scaling
181
+ self.attention_bias = attention_bias
182
+ # Validate the correctness of rotary position embeddings parameters
183
+ # BC: if there is a 'type' field, move it to 'rope_type'.
184
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
185
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
186
+ rope_config_validation(self)
187
+
188
+ if self.hidden_size % self.num_attention_heads != 0:
189
+ raise ValueError(
190
+ "The hidden size is not divisble by the number of attention heads! Make sure to update them!"
191
+ )
checkpoint-4000/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": [
5
+ 0
6
+ ],
7
+ "pad_token_id": 0,
8
+ "transformers_version": "4.57.1"
9
+ }
checkpoint-4000/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c72e520db34a52c14831395578ea693935bede2d06ca79e984a3d6a2ed094e43
3
+ size 324662984
checkpoint-4000/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80ca8af2d851f79d60271915dc5179db0faecf0c292a2c101e03fa2632e92925
3
+ size 649415674
checkpoint-4000/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48ee9b73399c28d7e668360bf1d5a4d11095c4738bf96c13f7bb6fbff59f8ccb
3
+ size 14244
checkpoint-4000/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56fa5a80e559ca2cf005811c174dd0e06c413e168d9276140a249e2cda1062e7
3
+ size 1064
checkpoint-4000/special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
checkpoint-4000/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-4000/tokenizer_config.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|padding|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "50254": {
23
+ "content": " ",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "50255": {
31
+ "content": " ",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": false
37
+ },
38
+ "50256": {
39
+ "content": " ",
40
+ "lstrip": false,
41
+ "normalized": true,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "50257": {
47
+ "content": " ",
48
+ "lstrip": false,
49
+ "normalized": true,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "50258": {
55
+ "content": " ",
56
+ "lstrip": false,
57
+ "normalized": true,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "50259": {
63
+ "content": " ",
64
+ "lstrip": false,
65
+ "normalized": true,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "50260": {
71
+ "content": " ",
72
+ "lstrip": false,
73
+ "normalized": true,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": false
77
+ },
78
+ "50261": {
79
+ "content": " ",
80
+ "lstrip": false,
81
+ "normalized": true,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": false
85
+ },
86
+ "50262": {
87
+ "content": " ",
88
+ "lstrip": false,
89
+ "normalized": true,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": false
93
+ },
94
+ "50263": {
95
+ "content": " ",
96
+ "lstrip": false,
97
+ "normalized": true,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": false
101
+ },
102
+ "50264": {
103
+ "content": " ",
104
+ "lstrip": false,
105
+ "normalized": true,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": false
109
+ },
110
+ "50265": {
111
+ "content": " ",
112
+ "lstrip": false,
113
+ "normalized": true,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": false
117
+ },
118
+ "50266": {
119
+ "content": " ",
120
+ "lstrip": false,
121
+ "normalized": true,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "50267": {
127
+ "content": " ",
128
+ "lstrip": false,
129
+ "normalized": true,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "50268": {
135
+ "content": " ",
136
+ "lstrip": false,
137
+ "normalized": true,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "50269": {
143
+ "content": " ",
144
+ "lstrip": false,
145
+ "normalized": true,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "50270": {
151
+ "content": " ",
152
+ "lstrip": false,
153
+ "normalized": true,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "50271": {
159
+ "content": " ",
160
+ "lstrip": false,
161
+ "normalized": true,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "50272": {
167
+ "content": " ",
168
+ "lstrip": false,
169
+ "normalized": true,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "50273": {
175
+ "content": " ",
176
+ "lstrip": false,
177
+ "normalized": true,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "50274": {
183
+ "content": " ",
184
+ "lstrip": false,
185
+ "normalized": true,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "50275": {
191
+ "content": " ",
192
+ "lstrip": false,
193
+ "normalized": true,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "50276": {
199
+ "content": " ",
200
+ "lstrip": false,
201
+ "normalized": true,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ }
206
+ },
207
+ "bos_token": "<|endoftext|>",
208
+ "clean_up_tokenization_spaces": true,
209
+ "eos_token": "<|endoftext|>",
210
+ "extra_special_tokens": {},
211
+ "model_max_length": 1000000000000000019884624838656,
212
+ "pad_token": "<|endoftext|>",
213
+ "tokenizer_class": "GPTNeoXTokenizer",
214
+ "unk_token": "<|endoftext|>"
215
+ }
checkpoint-4000/trainer_state.json ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.44912280701754387,
6
+ "eval_steps": 500,
7
+ "global_step": 4000,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.011228070175438596,
14
+ "grad_norm": 0.60546875,
15
+ "learning_rate": 0.00024749999999999994,
16
+ "loss": 8.5199,
17
+ "step": 100
18
+ },
19
+ {
20
+ "epoch": 0.02245614035087719,
21
+ "grad_norm": 0.55859375,
22
+ "learning_rate": 0.0002998664031981949,
23
+ "loss": 6.415,
24
+ "step": 200
25
+ },
26
+ {
27
+ "epoch": 0.03368421052631579,
28
+ "grad_norm": 0.48046875,
29
+ "learning_rate": 0.0002993145411731054,
30
+ "loss": 5.8846,
31
+ "step": 300
32
+ },
33
+ {
34
+ "epoch": 0.04491228070175438,
35
+ "grad_norm": 0.5,
36
+ "learning_rate": 0.00029833654740795074,
37
+ "loss": 5.5615,
38
+ "step": 400
39
+ },
40
+ {
41
+ "epoch": 0.056140350877192984,
42
+ "grad_norm": 0.63671875,
43
+ "learning_rate": 0.00029693521301859697,
44
+ "loss": 5.3436,
45
+ "step": 500
46
+ },
47
+ {
48
+ "epoch": 0.056140350877192984,
49
+ "eval_loss": 5.2718000411987305,
50
+ "eval_runtime": 296.6131,
51
+ "eval_samples_per_second": 50.571,
52
+ "eval_steps_per_second": 6.321,
53
+ "step": 500
54
+ },
55
+ {
56
+ "epoch": 0.06736842105263158,
57
+ "grad_norm": 0.484375,
58
+ "learning_rate": 0.00029511453730114126,
59
+ "loss": 5.1964,
60
+ "step": 600
61
+ },
62
+ {
63
+ "epoch": 0.07859649122807018,
64
+ "grad_norm": 0.45703125,
65
+ "learning_rate": 0.0002928797163182408,
66
+ "loss": 5.0532,
67
+ "step": 700
68
+ },
69
+ {
70
+ "epoch": 0.08982456140350877,
71
+ "grad_norm": 0.3984375,
72
+ "learning_rate": 0.00029023712806996646,
73
+ "loss": 4.9288,
74
+ "step": 800
75
+ },
76
+ {
77
+ "epoch": 0.10105263157894737,
78
+ "grad_norm": 0.408203125,
79
+ "learning_rate": 0.0002871943142915013,
80
+ "loss": 4.8118,
81
+ "step": 900
82
+ },
83
+ {
84
+ "epoch": 0.11228070175438597,
85
+ "grad_norm": 0.609375,
86
+ "learning_rate": 0.0002837599589296326,
87
+ "loss": 4.6787,
88
+ "step": 1000
89
+ },
90
+ {
91
+ "epoch": 0.11228070175438597,
92
+ "eval_loss": 4.601714134216309,
93
+ "eval_runtime": 296.6412,
94
+ "eval_samples_per_second": 50.566,
95
+ "eval_steps_per_second": 6.321,
96
+ "step": 1000
97
+ },
98
+ {
99
+ "epoch": 0.12350877192982457,
100
+ "grad_norm": 0.49609375,
101
+ "learning_rate": 0.00027994386335946324,
102
+ "loss": 4.5393,
103
+ "step": 1100
104
+ },
105
+ {
106
+ "epoch": 0.13473684210526315,
107
+ "grad_norm": 0.4375,
108
+ "learning_rate": 0.0002757569184120724,
109
+ "loss": 4.3818,
110
+ "step": 1200
111
+ },
112
+ {
113
+ "epoch": 0.14596491228070174,
114
+ "grad_norm": 0.431640625,
115
+ "learning_rate": 0.00027121107329295584,
116
+ "loss": 4.2778,
117
+ "step": 1300
118
+ },
119
+ {
120
+ "epoch": 0.15719298245614036,
121
+ "grad_norm": 0.380859375,
122
+ "learning_rate": 0.0002663193014799507,
123
+ "loss": 4.2072,
124
+ "step": 1400
125
+ },
126
+ {
127
+ "epoch": 0.16842105263157894,
128
+ "grad_norm": 0.462890625,
129
+ "learning_rate": 0.000261095563697969,
130
+ "loss": 4.1242,
131
+ "step": 1500
132
+ },
133
+ {
134
+ "epoch": 0.16842105263157894,
135
+ "eval_loss": 4.072988510131836,
136
+ "eval_runtime": 296.6152,
137
+ "eval_samples_per_second": 50.571,
138
+ "eval_steps_per_second": 6.321,
139
+ "step": 1500
140
+ },
141
+ {
142
+ "epoch": 0.17964912280701753,
143
+ "grad_norm": 0.40625,
144
+ "learning_rate": 0.0002555547680762069,
145
+ "loss": 4.0549,
146
+ "step": 1600
147
+ },
148
+ {
149
+ "epoch": 0.19087719298245615,
150
+ "grad_norm": 0.47265625,
151
+ "learning_rate": 0.00024971272760153834,
152
+ "loss": 4.0018,
153
+ "step": 1700
154
+ },
155
+ {
156
+ "epoch": 0.20210526315789473,
157
+ "grad_norm": 0.4453125,
158
+ "learning_rate": 0.00024358611498951694,
159
+ "loss": 3.9404,
160
+ "step": 1800
161
+ },
162
+ {
163
+ "epoch": 0.21333333333333335,
164
+ "grad_norm": 0.40234375,
165
+ "learning_rate": 0.0002371924151017814,
166
+ "loss": 3.9074,
167
+ "step": 1900
168
+ },
169
+ {
170
+ "epoch": 0.22456140350877193,
171
+ "grad_norm": 0.39453125,
172
+ "learning_rate": 0.00023054987504566113,
173
+ "loss": 3.8638,
174
+ "step": 2000
175
+ },
176
+ {
177
+ "epoch": 0.22456140350877193,
178
+ "eval_loss": 3.8390953540802,
179
+ "eval_runtime": 296.6249,
180
+ "eval_samples_per_second": 50.569,
181
+ "eval_steps_per_second": 6.321,
182
+ "step": 2000
183
+ },
184
+ {
185
+ "epoch": 0.23578947368421052,
186
+ "grad_norm": 0.40625,
187
+ "learning_rate": 0.0002236774520983933,
188
+ "loss": 3.8229,
189
+ "step": 2100
190
+ },
191
+ {
192
+ "epoch": 0.24701754385964914,
193
+ "grad_norm": 0.40625,
194
+ "learning_rate": 0.0002165947596045723,
195
+ "loss": 3.7931,
196
+ "step": 2200
197
+ },
198
+ {
199
+ "epoch": 0.2582456140350877,
200
+ "grad_norm": 0.408203125,
201
+ "learning_rate": 0.0002093220110012354,
202
+ "loss": 3.753,
203
+ "step": 2300
204
+ },
205
+ {
206
+ "epoch": 0.2694736842105263,
207
+ "grad_norm": 0.40234375,
208
+ "learning_rate": 0.00020187996213033227,
209
+ "loss": 3.6916,
210
+ "step": 2400
211
+ },
212
+ {
213
+ "epoch": 0.2807017543859649,
214
+ "grad_norm": 0.421875,
215
+ "learning_rate": 0.0001942898520032151,
216
+ "loss": 3.7182,
217
+ "step": 2500
218
+ },
219
+ {
220
+ "epoch": 0.2807017543859649,
221
+ "eval_loss": 3.7045886516571045,
222
+ "eval_runtime": 296.6142,
223
+ "eval_samples_per_second": 50.571,
224
+ "eval_steps_per_second": 6.321,
225
+ "step": 2500
226
+ },
227
+ {
228
+ "epoch": 0.2919298245614035,
229
+ "grad_norm": 0.3984375,
230
+ "learning_rate": 0.00018657334218620119,
231
+ "loss": 3.6917,
232
+ "step": 2600
233
+ },
234
+ {
235
+ "epoch": 0.3031578947368421,
236
+ "grad_norm": 0.39453125,
237
+ "learning_rate": 0.00017875245498019782,
238
+ "loss": 3.6778,
239
+ "step": 2700
240
+ },
241
+ {
242
+ "epoch": 0.3143859649122807,
243
+ "grad_norm": 0.361328125,
244
+ "learning_rate": 0.0001708495105708196,
245
+ "loss": 3.6465,
246
+ "step": 2800
247
+ },
248
+ {
249
+ "epoch": 0.3256140350877193,
250
+ "grad_norm": 0.380859375,
251
+ "learning_rate": 0.0001628870633283667,
252
+ "loss": 3.61,
253
+ "step": 2900
254
+ },
255
+ {
256
+ "epoch": 0.3368421052631579,
257
+ "grad_norm": 0.373046875,
258
+ "learning_rate": 0.00015488783743945845,
259
+ "loss": 3.6202,
260
+ "step": 3000
261
+ },
262
+ {
263
+ "epoch": 0.3368421052631579,
264
+ "eval_loss": 3.6153271198272705,
265
+ "eval_runtime": 296.6146,
266
+ "eval_samples_per_second": 50.571,
267
+ "eval_steps_per_second": 6.321,
268
+ "step": 3000
269
+ },
270
+ {
271
+ "epoch": 0.3480701754385965,
272
+ "grad_norm": 0.384765625,
273
+ "learning_rate": 0.00014687466205402512,
274
+ "loss": 3.6382,
275
+ "step": 3100
276
+ },
277
+ {
278
+ "epoch": 0.35929824561403506,
279
+ "grad_norm": 0.3828125,
280
+ "learning_rate": 0.00013887040613274276,
281
+ "loss": 3.6321,
282
+ "step": 3200
283
+ },
284
+ {
285
+ "epoch": 0.3705263157894737,
286
+ "grad_norm": 0.369140625,
287
+ "learning_rate": 0.00013089791318085124,
288
+ "loss": 3.5585,
289
+ "step": 3300
290
+ },
291
+ {
292
+ "epoch": 0.3817543859649123,
293
+ "grad_norm": 0.453125,
294
+ "learning_rate": 0.00012297993605461978,
295
+ "loss": 3.5688,
296
+ "step": 3400
297
+ },
298
+ {
299
+ "epoch": 0.3929824561403509,
300
+ "grad_norm": 0.380859375,
301
+ "learning_rate": 0.00011513907202651833,
302
+ "loss": 3.5655,
303
+ "step": 3500
304
+ },
305
+ {
306
+ "epoch": 0.3929824561403509,
307
+ "eval_loss": 3.5610458850860596,
308
+ "eval_runtime": 296.6199,
309
+ "eval_samples_per_second": 50.57,
310
+ "eval_steps_per_second": 6.321,
311
+ "step": 3500
312
+ },
313
+ {
314
+ "epoch": 0.40421052631578946,
315
+ "grad_norm": 0.392578125,
316
+ "learning_rate": 0.0001073976982944116,
317
+ "loss": 3.5872,
318
+ "step": 3600
319
+ },
320
+ {
321
+ "epoch": 0.41543859649122805,
322
+ "grad_norm": 0.5078125,
323
+ "learning_rate": 9.977790811882895e-05,
324
+ "loss": 3.5564,
325
+ "step": 3700
326
+ },
327
+ {
328
+ "epoch": 0.4266666666666667,
329
+ "grad_norm": 0.390625,
330
+ "learning_rate": 9.23014477705685e-05,
331
+ "loss": 3.5286,
332
+ "step": 3800
333
+ },
334
+ {
335
+ "epoch": 0.4378947368421053,
336
+ "grad_norm": 0.419921875,
337
+ "learning_rate": 8.498965446858242e-05,
338
+ "loss": 3.5338,
339
+ "step": 3900
340
+ },
341
+ {
342
+ "epoch": 0.44912280701754387,
343
+ "grad_norm": 0.36328125,
344
+ "learning_rate": 7.786339548526267e-05,
345
+ "loss": 3.522,
346
+ "step": 4000
347
+ },
348
+ {
349
+ "epoch": 0.44912280701754387,
350
+ "eval_loss": 3.527006149291992,
351
+ "eval_runtime": 296.6237,
352
+ "eval_samples_per_second": 50.569,
353
+ "eval_steps_per_second": 6.321,
354
+ "step": 4000
355
+ }
356
+ ],
357
+ "logging_steps": 100,
358
+ "max_steps": 6000,
359
+ "num_input_tokens_seen": 0,
360
+ "num_train_epochs": 1,
361
+ "save_steps": 2000,
362
+ "stateful_callbacks": {
363
+ "TrainerControl": {
364
+ "args": {
365
+ "should_epoch_stop": false,
366
+ "should_evaluate": false,
367
+ "should_log": false,
368
+ "should_save": true,
369
+ "should_training_stop": false
370
+ },
371
+ "attributes": {}
372
+ }
373
+ },
374
+ "total_flos": 1.94546717687808e+17,
375
+ "train_batch_size": 8,
376
+ "trial_name": null,
377
+ "trial_params": null
378
+ }
checkpoint-4000/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16bb5f9341aac44319789787905b9f8cd32fdefcafde13dd02317a8f825218ad
3
+ size 5432
checkpoint-6000/config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPTNeoXForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "config_custom.GPTNeoXConfig",
9
+ "AutoModel": "modeling_custom.GPTNeoXModel",
10
+ "AutoModelForCausalLM": "modeling_custom.GPTNeoXForCausalLM"
11
+ },
12
+ "bos_token_id": 0,
13
+ "classifier_dropout": 0.1,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 0,
16
+ "hidden_act": "gelu",
17
+ "hidden_dropout": 0.0,
18
+ "hidden_size": 768,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 3072,
21
+ "layer_norm_eps": 1e-05,
22
+ "max_position_embeddings": 2048,
23
+ "model_type": "gpt_neox",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "pad_token_id": 0,
27
+ "partial_rotary_factor": 0.25,
28
+ "rope_scaling": null,
29
+ "rope_theta": 10000,
30
+ "rotary_emb_base": 10000,
31
+ "rotary_pct": 0.25,
32
+ "tie_word_embeddings": false,
33
+ "transformers_version": "4.57.1",
34
+ "use_cache": true,
35
+ "use_parallel_residual": true,
36
+ "vocab_size": 50304
37
+ }
checkpoint-6000/config_custom.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """GPTNeoX model configuration"""
16
+
17
+ from transformers.configuration_utils import PretrainedConfig
18
+ from transformers.modeling_rope_utils import rope_config_validation
19
+ from transformers.utils import logging
20
+
21
+
22
+ logger = logging.get_logger(__name__)
23
+
24
+
25
+ class GPTNeoXConfig(PretrainedConfig):
26
+ r"""
27
+ This is the configuration class to store the configuration of a [`GPTNeoXModel`]. It is used to instantiate an
28
+ GPTNeoX model according to the specified arguments, defining the model architecture. Instantiating a configuration
29
+ with the defaults will yield a similar configuration to that of the GPTNeoX
30
+ [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) architecture.
31
+
32
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
33
+ documentation from [`PretrainedConfig`] for more information.
34
+
35
+
36
+ Args:
37
+ vocab_size (`int`, *optional*, defaults to 50432):
38
+ Vocabulary size of the GPTNeoX model. Defines the number of different tokens that can be represented by the
39
+ `inputs_ids` passed when calling [`GPTNeoXModel`].
40
+ hidden_size (`int`, *optional*, defaults to 6144):
41
+ Dimension of the encoder layers and the pooler layer.
42
+ num_hidden_layers (`int`, *optional*, defaults to 44):
43
+ Number of hidden layers in the Transformer encoder.
44
+ num_attention_heads (`int`, *optional*, defaults to 64):
45
+ Number of attention heads for each attention layer in the Transformer encoder.
46
+ intermediate_size (`int`, *optional*, defaults to 24576):
47
+ Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
48
+ hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
49
+ The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
50
+ `"relu"`, `"selu"` and `"gelu_new"` are supported.
51
+ rotary_pct (`float`, *optional*, defaults to 0.25):
52
+ percentage of hidden dimensions to allocate to rotary embeddings
53
+ rotary_emb_base (`int`, *optional*, defaults to 10000)
54
+ base for computing rotary embeddings frequency
55
+ attention_dropout (`float`, *optional*, defaults to 0.0):
56
+ The dropout ratio probability of the attention score.
57
+ hidden_dropout (`float`, *optional*, defaults to 0.0):
58
+ The dropout ratio of (1) the word embeddings, (2) the post-attention hidden states, and (3) the post-mlp
59
+ hidden states.
60
+ classifier_dropout (`float`, *optional*, defaults to 0.1):
61
+ Argument used when doing token classification, used in the model [`GPTNeoXForTokenClassification`].
62
+
63
+ The dropout ratio for the hidden layer.
64
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
65
+ The maximum sequence length that this model might ever be used with. Typically set this to something large
66
+ just in case (e.g., 512 or 1024 or 2048).
67
+ initializer_range (`float`, *optional*, defaults to 1e-5):
68
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
69
+ layer_norm_eps (`float`, *optional*, defaults to 1e-12):
70
+ The epsilon used by the layer normalization layers.
71
+ use_cache (`bool`, *optional*, defaults to `True`):
72
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
73
+ relevant if `config.is_decoder=True`.
74
+ use_parallel_residual (`bool`, *optional*, defaults to `True`):
75
+ Whether to use a "parallel" formulation in each Transformer layer, which can provide a slight training
76
+ speedup at large scales (e.g. 20B).
77
+ rope_scaling (`Dict`, *optional*):
78
+ Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
79
+ and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
80
+ accordingly.
81
+ Expected contents:
82
+ `rope_type` (`str`):
83
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
84
+ 'llama3'], with 'default' being the original RoPE implementation.
85
+ `factor` (`float`, *optional*):
86
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
87
+ most scaling types, a `factor` of x will enable the model to handle sequences of length x *
88
+ original maximum pre-trained length.
89
+ `original_max_position_embeddings` (`int`, *optional*):
90
+ Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
91
+ pretraining.
92
+ `attention_factor` (`float`, *optional*):
93
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
94
+ computation. If unspecified, it defaults to value recommended by the implementation, using the
95
+ `factor` field to infer the suggested value.
96
+ `beta_fast` (`float`, *optional*):
97
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
98
+ ramp function. If unspecified, it defaults to 32.
99
+ `beta_slow` (`float`, *optional*):
100
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
101
+ ramp function. If unspecified, it defaults to 1.
102
+ `short_factor` (`List[float]`, *optional*):
103
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<
104
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
105
+ size divided by the number of attention heads divided by 2
106
+ `long_factor` (`List[float]`, *optional*):
107
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<
108
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
109
+ size divided by the number of attention heads divided by 2
110
+ `low_freq_factor` (`float`, *optional*):
111
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
112
+ `high_freq_factor` (`float`, *optional*):
113
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
114
+ attention_bias (`bool`, *optional*, defaults to `True`):
115
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
116
+
117
+ Example:
118
+
119
+ ```python
120
+ >>> from transformers import GPTNeoXConfig, GPTNeoXModel
121
+
122
+ >>> # Initializing a GPTNeoX gpt-neox-20b style configuration
123
+ >>> configuration = GPTNeoXConfig()
124
+
125
+ >>> # Initializing a model (with random weights) from the gpt-neox-20b style configuration
126
+ >>> model = GPTNeoXModel(configuration) # doctest: +SKIP
127
+
128
+ >>> # Accessing the model configuration
129
+ >>> configuration = model.config # doctest: +SKIP
130
+ ```"""
131
+
132
+ model_type = "gpt_neox"
133
+ keys_to_ignore_at_inference = ["past_key_values"]
134
+
135
+ def __init__(
136
+ self,
137
+ vocab_size=50432,
138
+ hidden_size=6144,
139
+ num_hidden_layers=44,
140
+ num_attention_heads=64,
141
+ intermediate_size=24576,
142
+ hidden_act="gelu",
143
+ rotary_pct=0.25,
144
+ rotary_emb_base=10000,
145
+ attention_dropout=0.0,
146
+ hidden_dropout=0.0,
147
+ classifier_dropout=0.1,
148
+ max_position_embeddings=2048,
149
+ initializer_range=0.02,
150
+ layer_norm_eps=1e-5,
151
+ use_cache=True,
152
+ bos_token_id=0,
153
+ eos_token_id=2,
154
+ tie_word_embeddings=False,
155
+ use_parallel_residual=True,
156
+ rope_scaling=None,
157
+ attention_bias=True,
158
+ **kwargs,
159
+ ):
160
+ super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
161
+ self.vocab_size = vocab_size
162
+ self.max_position_embeddings = max_position_embeddings
163
+ self.hidden_size = hidden_size
164
+ self.num_hidden_layers = num_hidden_layers
165
+ self.num_attention_heads = num_attention_heads
166
+ self.intermediate_size = intermediate_size
167
+ self.hidden_act = hidden_act
168
+ self.rotary_pct = rotary_pct
169
+ self.partial_rotary_factor = rotary_pct
170
+ self.rotary_emb_base = rotary_emb_base
171
+ self.rope_theta = rotary_emb_base
172
+ self.attention_dropout = attention_dropout
173
+ self.hidden_dropout = hidden_dropout
174
+ self.classifier_dropout = classifier_dropout
175
+ self.initializer_range = initializer_range
176
+ self.layer_norm_eps = layer_norm_eps
177
+ self.use_cache = use_cache
178
+ self.tie_word_embeddings = tie_word_embeddings
179
+ self.use_parallel_residual = use_parallel_residual
180
+ self.rope_scaling = rope_scaling
181
+ self.attention_bias = attention_bias
182
+ # Validate the correctness of rotary position embeddings parameters
183
+ # BC: if there is a 'type' field, move it to 'rope_type'.
184
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
185
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
186
+ rope_config_validation(self)
187
+
188
+ if self.hidden_size % self.num_attention_heads != 0:
189
+ raise ValueError(
190
+ "The hidden size is not divisble by the number of attention heads! Make sure to update them!"
191
+ )
checkpoint-6000/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": [
5
+ 0
6
+ ],
7
+ "pad_token_id": 0,
8
+ "transformers_version": "4.57.1"
9
+ }
checkpoint-6000/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12cf23aa91dfe30303a07a4ede45ad60f365fc53154800212398b79607d1ee86
3
+ size 324662984
checkpoint-6000/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ab91ad685edbd6bd5c188a4dd7cc2e907e4205d3ab9145f31282a8e2ca7feca
3
+ size 649415674
checkpoint-6000/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7682299c566684ea51cf26f0c86b6ffaa3c0bc63cbdf84674b29a2c62ac72143
3
+ size 14244
checkpoint-6000/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db8a93f8f45b05f221c35faddb5e530d4068160ebb91e51e12090a0d7eefafa9
3
+ size 1064
checkpoint-6000/special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
checkpoint-6000/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-6000/tokenizer_config.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|padding|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "50254": {
23
+ "content": " ",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "50255": {
31
+ "content": " ",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": false
37
+ },
38
+ "50256": {
39
+ "content": " ",
40
+ "lstrip": false,
41
+ "normalized": true,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "50257": {
47
+ "content": " ",
48
+ "lstrip": false,
49
+ "normalized": true,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "50258": {
55
+ "content": " ",
56
+ "lstrip": false,
57
+ "normalized": true,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "50259": {
63
+ "content": " ",
64
+ "lstrip": false,
65
+ "normalized": true,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "50260": {
71
+ "content": " ",
72
+ "lstrip": false,
73
+ "normalized": true,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": false
77
+ },
78
+ "50261": {
79
+ "content": " ",
80
+ "lstrip": false,
81
+ "normalized": true,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": false
85
+ },
86
+ "50262": {
87
+ "content": " ",
88
+ "lstrip": false,
89
+ "normalized": true,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": false
93
+ },
94
+ "50263": {
95
+ "content": " ",
96
+ "lstrip": false,
97
+ "normalized": true,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": false
101
+ },
102
+ "50264": {
103
+ "content": " ",
104
+ "lstrip": false,
105
+ "normalized": true,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": false
109
+ },
110
+ "50265": {
111
+ "content": " ",
112
+ "lstrip": false,
113
+ "normalized": true,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": false
117
+ },
118
+ "50266": {
119
+ "content": " ",
120
+ "lstrip": false,
121
+ "normalized": true,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "50267": {
127
+ "content": " ",
128
+ "lstrip": false,
129
+ "normalized": true,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "50268": {
135
+ "content": " ",
136
+ "lstrip": false,
137
+ "normalized": true,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "50269": {
143
+ "content": " ",
144
+ "lstrip": false,
145
+ "normalized": true,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "50270": {
151
+ "content": " ",
152
+ "lstrip": false,
153
+ "normalized": true,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "50271": {
159
+ "content": " ",
160
+ "lstrip": false,
161
+ "normalized": true,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "50272": {
167
+ "content": " ",
168
+ "lstrip": false,
169
+ "normalized": true,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "50273": {
175
+ "content": " ",
176
+ "lstrip": false,
177
+ "normalized": true,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "50274": {
183
+ "content": " ",
184
+ "lstrip": false,
185
+ "normalized": true,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "50275": {
191
+ "content": " ",
192
+ "lstrip": false,
193
+ "normalized": true,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "50276": {
199
+ "content": " ",
200
+ "lstrip": false,
201
+ "normalized": true,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ }
206
+ },
207
+ "bos_token": "<|endoftext|>",
208
+ "clean_up_tokenization_spaces": true,
209
+ "eos_token": "<|endoftext|>",
210
+ "extra_special_tokens": {},
211
+ "model_max_length": 1000000000000000019884624838656,
212
+ "pad_token": "<|endoftext|>",
213
+ "tokenizer_class": "GPTNeoXTokenizer",
214
+ "unk_token": "<|endoftext|>"
215
+ }
checkpoint-6000/trainer_state.json ADDED
@@ -0,0 +1,550 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.6736842105263158,
6
+ "eval_steps": 500,
7
+ "global_step": 6000,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.011228070175438596,
14
+ "grad_norm": 0.60546875,
15
+ "learning_rate": 0.00024749999999999994,
16
+ "loss": 8.5199,
17
+ "step": 100
18
+ },
19
+ {
20
+ "epoch": 0.02245614035087719,
21
+ "grad_norm": 0.55859375,
22
+ "learning_rate": 0.0002998664031981949,
23
+ "loss": 6.415,
24
+ "step": 200
25
+ },
26
+ {
27
+ "epoch": 0.03368421052631579,
28
+ "grad_norm": 0.48046875,
29
+ "learning_rate": 0.0002993145411731054,
30
+ "loss": 5.8846,
31
+ "step": 300
32
+ },
33
+ {
34
+ "epoch": 0.04491228070175438,
35
+ "grad_norm": 0.5,
36
+ "learning_rate": 0.00029833654740795074,
37
+ "loss": 5.5615,
38
+ "step": 400
39
+ },
40
+ {
41
+ "epoch": 0.056140350877192984,
42
+ "grad_norm": 0.63671875,
43
+ "learning_rate": 0.00029693521301859697,
44
+ "loss": 5.3436,
45
+ "step": 500
46
+ },
47
+ {
48
+ "epoch": 0.056140350877192984,
49
+ "eval_loss": 5.2718000411987305,
50
+ "eval_runtime": 296.6131,
51
+ "eval_samples_per_second": 50.571,
52
+ "eval_steps_per_second": 6.321,
53
+ "step": 500
54
+ },
55
+ {
56
+ "epoch": 0.06736842105263158,
57
+ "grad_norm": 0.484375,
58
+ "learning_rate": 0.00029511453730114126,
59
+ "loss": 5.1964,
60
+ "step": 600
61
+ },
62
+ {
63
+ "epoch": 0.07859649122807018,
64
+ "grad_norm": 0.45703125,
65
+ "learning_rate": 0.0002928797163182408,
66
+ "loss": 5.0532,
67
+ "step": 700
68
+ },
69
+ {
70
+ "epoch": 0.08982456140350877,
71
+ "grad_norm": 0.3984375,
72
+ "learning_rate": 0.00029023712806996646,
73
+ "loss": 4.9288,
74
+ "step": 800
75
+ },
76
+ {
77
+ "epoch": 0.10105263157894737,
78
+ "grad_norm": 0.408203125,
79
+ "learning_rate": 0.0002871943142915013,
80
+ "loss": 4.8118,
81
+ "step": 900
82
+ },
83
+ {
84
+ "epoch": 0.11228070175438597,
85
+ "grad_norm": 0.609375,
86
+ "learning_rate": 0.0002837599589296326,
87
+ "loss": 4.6787,
88
+ "step": 1000
89
+ },
90
+ {
91
+ "epoch": 0.11228070175438597,
92
+ "eval_loss": 4.601714134216309,
93
+ "eval_runtime": 296.6412,
94
+ "eval_samples_per_second": 50.566,
95
+ "eval_steps_per_second": 6.321,
96
+ "step": 1000
97
+ },
98
+ {
99
+ "epoch": 0.12350877192982457,
100
+ "grad_norm": 0.49609375,
101
+ "learning_rate": 0.00027994386335946324,
102
+ "loss": 4.5393,
103
+ "step": 1100
104
+ },
105
+ {
106
+ "epoch": 0.13473684210526315,
107
+ "grad_norm": 0.4375,
108
+ "learning_rate": 0.0002757569184120724,
109
+ "loss": 4.3818,
110
+ "step": 1200
111
+ },
112
+ {
113
+ "epoch": 0.14596491228070174,
114
+ "grad_norm": 0.431640625,
115
+ "learning_rate": 0.00027121107329295584,
116
+ "loss": 4.2778,
117
+ "step": 1300
118
+ },
119
+ {
120
+ "epoch": 0.15719298245614036,
121
+ "grad_norm": 0.380859375,
122
+ "learning_rate": 0.0002663193014799507,
123
+ "loss": 4.2072,
124
+ "step": 1400
125
+ },
126
+ {
127
+ "epoch": 0.16842105263157894,
128
+ "grad_norm": 0.462890625,
129
+ "learning_rate": 0.000261095563697969,
130
+ "loss": 4.1242,
131
+ "step": 1500
132
+ },
133
+ {
134
+ "epoch": 0.16842105263157894,
135
+ "eval_loss": 4.072988510131836,
136
+ "eval_runtime": 296.6152,
137
+ "eval_samples_per_second": 50.571,
138
+ "eval_steps_per_second": 6.321,
139
+ "step": 1500
140
+ },
141
+ {
142
+ "epoch": 0.17964912280701753,
143
+ "grad_norm": 0.40625,
144
+ "learning_rate": 0.0002555547680762069,
145
+ "loss": 4.0549,
146
+ "step": 1600
147
+ },
148
+ {
149
+ "epoch": 0.19087719298245615,
150
+ "grad_norm": 0.47265625,
151
+ "learning_rate": 0.00024971272760153834,
152
+ "loss": 4.0018,
153
+ "step": 1700
154
+ },
155
+ {
156
+ "epoch": 0.20210526315789473,
157
+ "grad_norm": 0.4453125,
158
+ "learning_rate": 0.00024358611498951694,
159
+ "loss": 3.9404,
160
+ "step": 1800
161
+ },
162
+ {
163
+ "epoch": 0.21333333333333335,
164
+ "grad_norm": 0.40234375,
165
+ "learning_rate": 0.0002371924151017814,
166
+ "loss": 3.9074,
167
+ "step": 1900
168
+ },
169
+ {
170
+ "epoch": 0.22456140350877193,
171
+ "grad_norm": 0.39453125,
172
+ "learning_rate": 0.00023054987504566113,
173
+ "loss": 3.8638,
174
+ "step": 2000
175
+ },
176
+ {
177
+ "epoch": 0.22456140350877193,
178
+ "eval_loss": 3.8390953540802,
179
+ "eval_runtime": 296.6249,
180
+ "eval_samples_per_second": 50.569,
181
+ "eval_steps_per_second": 6.321,
182
+ "step": 2000
183
+ },
184
+ {
185
+ "epoch": 0.23578947368421052,
186
+ "grad_norm": 0.40625,
187
+ "learning_rate": 0.0002236774520983933,
188
+ "loss": 3.8229,
189
+ "step": 2100
190
+ },
191
+ {
192
+ "epoch": 0.24701754385964914,
193
+ "grad_norm": 0.40625,
194
+ "learning_rate": 0.0002165947596045723,
195
+ "loss": 3.7931,
196
+ "step": 2200
197
+ },
198
+ {
199
+ "epoch": 0.2582456140350877,
200
+ "grad_norm": 0.408203125,
201
+ "learning_rate": 0.0002093220110012354,
202
+ "loss": 3.753,
203
+ "step": 2300
204
+ },
205
+ {
206
+ "epoch": 0.2694736842105263,
207
+ "grad_norm": 0.40234375,
208
+ "learning_rate": 0.00020187996213033227,
209
+ "loss": 3.6916,
210
+ "step": 2400
211
+ },
212
+ {
213
+ "epoch": 0.2807017543859649,
214
+ "grad_norm": 0.421875,
215
+ "learning_rate": 0.0001942898520032151,
216
+ "loss": 3.7182,
217
+ "step": 2500
218
+ },
219
+ {
220
+ "epoch": 0.2807017543859649,
221
+ "eval_loss": 3.7045886516571045,
222
+ "eval_runtime": 296.6142,
223
+ "eval_samples_per_second": 50.571,
224
+ "eval_steps_per_second": 6.321,
225
+ "step": 2500
226
+ },
227
+ {
228
+ "epoch": 0.2919298245614035,
229
+ "grad_norm": 0.3984375,
230
+ "learning_rate": 0.00018657334218620119,
231
+ "loss": 3.6917,
232
+ "step": 2600
233
+ },
234
+ {
235
+ "epoch": 0.3031578947368421,
236
+ "grad_norm": 0.39453125,
237
+ "learning_rate": 0.00017875245498019782,
238
+ "loss": 3.6778,
239
+ "step": 2700
240
+ },
241
+ {
242
+ "epoch": 0.3143859649122807,
243
+ "grad_norm": 0.361328125,
244
+ "learning_rate": 0.0001708495105708196,
245
+ "loss": 3.6465,
246
+ "step": 2800
247
+ },
248
+ {
249
+ "epoch": 0.3256140350877193,
250
+ "grad_norm": 0.380859375,
251
+ "learning_rate": 0.0001628870633283667,
252
+ "loss": 3.61,
253
+ "step": 2900
254
+ },
255
+ {
256
+ "epoch": 0.3368421052631579,
257
+ "grad_norm": 0.373046875,
258
+ "learning_rate": 0.00015488783743945845,
259
+ "loss": 3.6202,
260
+ "step": 3000
261
+ },
262
+ {
263
+ "epoch": 0.3368421052631579,
264
+ "eval_loss": 3.6153271198272705,
265
+ "eval_runtime": 296.6146,
266
+ "eval_samples_per_second": 50.571,
267
+ "eval_steps_per_second": 6.321,
268
+ "step": 3000
269
+ },
270
+ {
271
+ "epoch": 0.3480701754385965,
272
+ "grad_norm": 0.384765625,
273
+ "learning_rate": 0.00014687466205402512,
274
+ "loss": 3.6382,
275
+ "step": 3100
276
+ },
277
+ {
278
+ "epoch": 0.35929824561403506,
279
+ "grad_norm": 0.3828125,
280
+ "learning_rate": 0.00013887040613274276,
281
+ "loss": 3.6321,
282
+ "step": 3200
283
+ },
284
+ {
285
+ "epoch": 0.3705263157894737,
286
+ "grad_norm": 0.369140625,
287
+ "learning_rate": 0.00013089791318085124,
288
+ "loss": 3.5585,
289
+ "step": 3300
290
+ },
291
+ {
292
+ "epoch": 0.3817543859649123,
293
+ "grad_norm": 0.453125,
294
+ "learning_rate": 0.00012297993605461978,
295
+ "loss": 3.5688,
296
+ "step": 3400
297
+ },
298
+ {
299
+ "epoch": 0.3929824561403509,
300
+ "grad_norm": 0.380859375,
301
+ "learning_rate": 0.00011513907202651833,
302
+ "loss": 3.5655,
303
+ "step": 3500
304
+ },
305
+ {
306
+ "epoch": 0.3929824561403509,
307
+ "eval_loss": 3.5610458850860596,
308
+ "eval_runtime": 296.6199,
309
+ "eval_samples_per_second": 50.57,
310
+ "eval_steps_per_second": 6.321,
311
+ "step": 3500
312
+ },
313
+ {
314
+ "epoch": 0.40421052631578946,
315
+ "grad_norm": 0.392578125,
316
+ "learning_rate": 0.0001073976982944116,
317
+ "loss": 3.5872,
318
+ "step": 3600
319
+ },
320
+ {
321
+ "epoch": 0.41543859649122805,
322
+ "grad_norm": 0.5078125,
323
+ "learning_rate": 9.977790811882895e-05,
324
+ "loss": 3.5564,
325
+ "step": 3700
326
+ },
327
+ {
328
+ "epoch": 0.4266666666666667,
329
+ "grad_norm": 0.390625,
330
+ "learning_rate": 9.23014477705685e-05,
331
+ "loss": 3.5286,
332
+ "step": 3800
333
+ },
334
+ {
335
+ "epoch": 0.4378947368421053,
336
+ "grad_norm": 0.419921875,
337
+ "learning_rate": 8.498965446858242e-05,
338
+ "loss": 3.5338,
339
+ "step": 3900
340
+ },
341
+ {
342
+ "epoch": 0.44912280701754387,
343
+ "grad_norm": 0.36328125,
344
+ "learning_rate": 7.786339548526267e-05,
345
+ "loss": 3.522,
346
+ "step": 4000
347
+ },
348
+ {
349
+ "epoch": 0.44912280701754387,
350
+ "eval_loss": 3.527006149291992,
351
+ "eval_runtime": 296.6237,
352
+ "eval_samples_per_second": 50.569,
353
+ "eval_steps_per_second": 6.321,
354
+ "step": 4000
355
+ },
356
+ {
357
+ "epoch": 0.46035087719298246,
358
+ "grad_norm": 0.365234375,
359
+ "learning_rate": 7.094300859291779e-05,
360
+ "loss": 3.5287,
361
+ "step": 4100
362
+ },
363
+ {
364
+ "epoch": 0.47157894736842104,
365
+ "grad_norm": 0.36328125,
366
+ "learning_rate": 6.424824402139943e-05,
367
+ "loss": 3.5926,
368
+ "step": 4200
369
+ },
370
+ {
371
+ "epoch": 0.48280701754385963,
372
+ "grad_norm": 0.384765625,
373
+ "learning_rate": 5.779820809252842e-05,
374
+ "loss": 3.5062,
375
+ "step": 4300
376
+ },
377
+ {
378
+ "epoch": 0.49403508771929827,
379
+ "grad_norm": 0.38671875,
380
+ "learning_rate": 5.161130869218288e-05,
381
+ "loss": 3.4921,
382
+ "step": 4400
383
+ },
384
+ {
385
+ "epoch": 0.5052631578947369,
386
+ "grad_norm": 0.375,
387
+ "learning_rate": 4.5705202735666346e-05,
388
+ "loss": 3.5462,
389
+ "step": 4500
390
+ },
391
+ {
392
+ "epoch": 0.5052631578947369,
393
+ "eval_loss": 3.5098726749420166,
394
+ "eval_runtime": 296.5947,
395
+ "eval_samples_per_second": 50.574,
396
+ "eval_steps_per_second": 6.322,
397
+ "step": 4500
398
+ },
399
+ {
400
+ "epoch": 0.5164912280701754,
401
+ "grad_norm": 0.380859375,
402
+ "learning_rate": 4.0096745776285776e-05,
403
+ "loss": 3.5366,
404
+ "step": 4600
405
+ },
406
+ {
407
+ "epoch": 0.527719298245614,
408
+ "grad_norm": 0.37890625,
409
+ "learning_rate": 3.4801943900952816e-05,
410
+ "loss": 3.4956,
411
+ "step": 4700
412
+ },
413
+ {
414
+ "epoch": 0.5389473684210526,
415
+ "grad_norm": 0.361328125,
416
+ "learning_rate": 2.9835908050093693e-05,
417
+ "loss": 3.4891,
418
+ "step": 4800
419
+ },
420
+ {
421
+ "epoch": 0.5501754385964912,
422
+ "grad_norm": 0.357421875,
423
+ "learning_rate": 2.521281089223571e-05,
424
+ "loss": 3.5134,
425
+ "step": 4900
426
+ },
427
+ {
428
+ "epoch": 0.5614035087719298,
429
+ "grad_norm": 0.36328125,
430
+ "learning_rate": 2.094584637634653e-05,
431
+ "loss": 3.5214,
432
+ "step": 5000
433
+ },
434
+ {
435
+ "epoch": 0.5614035087719298,
436
+ "eval_loss": 3.503505229949951,
437
+ "eval_runtime": 296.6246,
438
+ "eval_samples_per_second": 50.569,
439
+ "eval_steps_per_second": 6.321,
440
+ "step": 5000
441
+ },
442
+ {
443
+ "epoch": 0.5726315789473684,
444
+ "grad_norm": 0.376953125,
445
+ "learning_rate": 1.7047192077360732e-05,
446
+ "loss": 3.4897,
447
+ "step": 5100
448
+ },
449
+ {
450
+ "epoch": 0.583859649122807,
451
+ "grad_norm": 0.35546875,
452
+ "learning_rate": 1.352797444235626e-05,
453
+ "loss": 3.4981,
454
+ "step": 5200
455
+ },
456
+ {
457
+ "epoch": 0.5950877192982457,
458
+ "grad_norm": 0.3515625,
459
+ "learning_rate": 1.0398237036565915e-05,
460
+ "loss": 3.5027,
461
+ "step": 5300
462
+ },
463
+ {
464
+ "epoch": 0.6063157894736843,
465
+ "grad_norm": 0.349609375,
466
+ "learning_rate": 7.66691187984656e-06,
467
+ "loss": 3.5306,
468
+ "step": 5400
469
+ },
470
+ {
471
+ "epoch": 0.6175438596491228,
472
+ "grad_norm": 0.361328125,
473
+ "learning_rate": 5.341793955409951e-06,
474
+ "loss": 3.4939,
475
+ "step": 5500
476
+ },
477
+ {
478
+ "epoch": 0.6175438596491228,
479
+ "eval_loss": 3.502210855484009,
480
+ "eval_runtime": 296.5914,
481
+ "eval_samples_per_second": 50.575,
482
+ "eval_steps_per_second": 6.322,
483
+ "step": 5500
484
+ },
485
+ {
486
+ "epoch": 0.6287719298245614,
487
+ "grad_norm": 0.359375,
488
+ "learning_rate": 3.42951896356507e-06,
489
+ "loss": 3.5079,
490
+ "step": 5600
491
+ },
492
+ {
493
+ "epoch": 0.64,
494
+ "grad_norm": 0.373046875,
495
+ "learning_rate": 1.9355443839609632e-06,
496
+ "loss": 3.5295,
497
+ "step": 5700
498
+ },
499
+ {
500
+ "epoch": 0.6512280701754386,
501
+ "grad_norm": 0.353515625,
502
+ "learning_rate": 8.64133900376951e-07,
503
+ "loss": 3.5329,
504
+ "step": 5800
505
+ },
506
+ {
507
+ "epoch": 0.6624561403508772,
508
+ "grad_norm": 0.38671875,
509
+ "learning_rate": 2.1834523251072488e-07,
510
+ "loss": 3.5276,
511
+ "step": 5900
512
+ },
513
+ {
514
+ "epoch": 0.6736842105263158,
515
+ "grad_norm": 0.373046875,
516
+ "learning_rate": 2.1409491196555663e-11,
517
+ "loss": 3.483,
518
+ "step": 6000
519
+ },
520
+ {
521
+ "epoch": 0.6736842105263158,
522
+ "eval_loss": 3.5021510124206543,
523
+ "eval_runtime": 296.6149,
524
+ "eval_samples_per_second": 50.571,
525
+ "eval_steps_per_second": 6.321,
526
+ "step": 6000
527
+ }
528
+ ],
529
+ "logging_steps": 100,
530
+ "max_steps": 6000,
531
+ "num_input_tokens_seen": 0,
532
+ "num_train_epochs": 1,
533
+ "save_steps": 2000,
534
+ "stateful_callbacks": {
535
+ "TrainerControl": {
536
+ "args": {
537
+ "should_epoch_stop": false,
538
+ "should_evaluate": false,
539
+ "should_log": false,
540
+ "should_save": true,
541
+ "should_training_stop": true
542
+ },
543
+ "attributes": {}
544
+ }
545
+ },
546
+ "total_flos": 2.91820076531712e+17,
547
+ "train_batch_size": 8,
548
+ "trial_name": null,
549
+ "trial_params": null
550
+ }
checkpoint-6000/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16bb5f9341aac44319789787905b9f8cd32fdefcafde13dd02317a8f825218ad
3
+ size 5432
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPTNeoXForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "config_custom.GPTNeoXConfig",
9
+ "AutoModel": "modeling_custom.GPTNeoXModel",
10
+ "AutoModelForCausalLM": "modeling_custom.GPTNeoXForCausalLM"
11
+ },
12
+ "bos_token_id": 0,
13
+ "classifier_dropout": 0.1,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 0,
16
+ "hidden_act": "gelu",
17
+ "hidden_dropout": 0.0,
18
+ "hidden_size": 768,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 3072,
21
+ "layer_norm_eps": 1e-05,
22
+ "max_position_embeddings": 2048,
23
+ "model_type": "gpt_neox",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "pad_token_id": 0,
27
+ "partial_rotary_factor": 0.25,
28
+ "rope_scaling": null,
29
+ "rope_theta": 10000,
30
+ "rotary_emb_base": 10000,
31
+ "rotary_pct": 0.25,
32
+ "tie_word_embeddings": false,
33
+ "transformers_version": "4.57.1",
34
+ "use_cache": true,
35
+ "use_parallel_residual": true,
36
+ "vocab_size": 50304
37
+ }
config_custom.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """GPTNeoX model configuration"""
16
+
17
+ from transformers.configuration_utils import PretrainedConfig
18
+ from transformers.modeling_rope_utils import rope_config_validation
19
+ from transformers.utils import logging
20
+
21
+
22
+ logger = logging.get_logger(__name__)
23
+
24
+
25
+ class GPTNeoXConfig(PretrainedConfig):
26
+ r"""
27
+ This is the configuration class to store the configuration of a [`GPTNeoXModel`]. It is used to instantiate an
28
+ GPTNeoX model according to the specified arguments, defining the model architecture. Instantiating a configuration
29
+ with the defaults will yield a similar configuration to that of the GPTNeoX
30
+ [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) architecture.
31
+
32
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
33
+ documentation from [`PretrainedConfig`] for more information.
34
+
35
+
36
+ Args:
37
+ vocab_size (`int`, *optional*, defaults to 50432):
38
+ Vocabulary size of the GPTNeoX model. Defines the number of different tokens that can be represented by the
39
+ `inputs_ids` passed when calling [`GPTNeoXModel`].
40
+ hidden_size (`int`, *optional*, defaults to 6144):
41
+ Dimension of the encoder layers and the pooler layer.
42
+ num_hidden_layers (`int`, *optional*, defaults to 44):
43
+ Number of hidden layers in the Transformer encoder.
44
+ num_attention_heads (`int`, *optional*, defaults to 64):
45
+ Number of attention heads for each attention layer in the Transformer encoder.
46
+ intermediate_size (`int`, *optional*, defaults to 24576):
47
+ Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
48
+ hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
49
+ The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
50
+ `"relu"`, `"selu"` and `"gelu_new"` are supported.
51
+ rotary_pct (`float`, *optional*, defaults to 0.25):
52
+ percentage of hidden dimensions to allocate to rotary embeddings
53
+ rotary_emb_base (`int`, *optional*, defaults to 10000)
54
+ base for computing rotary embeddings frequency
55
+ attention_dropout (`float`, *optional*, defaults to 0.0):
56
+ The dropout ratio probability of the attention score.
57
+ hidden_dropout (`float`, *optional*, defaults to 0.0):
58
+ The dropout ratio of (1) the word embeddings, (2) the post-attention hidden states, and (3) the post-mlp
59
+ hidden states.
60
+ classifier_dropout (`float`, *optional*, defaults to 0.1):
61
+ Argument used when doing token classification, used in the model [`GPTNeoXForTokenClassification`].
62
+
63
+ The dropout ratio for the hidden layer.
64
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
65
+ The maximum sequence length that this model might ever be used with. Typically set this to something large
66
+ just in case (e.g., 512 or 1024 or 2048).
67
+ initializer_range (`float`, *optional*, defaults to 1e-5):
68
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
69
+ layer_norm_eps (`float`, *optional*, defaults to 1e-12):
70
+ The epsilon used by the layer normalization layers.
71
+ use_cache (`bool`, *optional*, defaults to `True`):
72
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
73
+ relevant if `config.is_decoder=True`.
74
+ use_parallel_residual (`bool`, *optional*, defaults to `True`):
75
+ Whether to use a "parallel" formulation in each Transformer layer, which can provide a slight training
76
+ speedup at large scales (e.g. 20B).
77
+ rope_scaling (`Dict`, *optional*):
78
+ Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
79
+ and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
80
+ accordingly.
81
+ Expected contents:
82
+ `rope_type` (`str`):
83
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
84
+ 'llama3'], with 'default' being the original RoPE implementation.
85
+ `factor` (`float`, *optional*):
86
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
87
+ most scaling types, a `factor` of x will enable the model to handle sequences of length x *
88
+ original maximum pre-trained length.
89
+ `original_max_position_embeddings` (`int`, *optional*):
90
+ Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
91
+ pretraining.
92
+ `attention_factor` (`float`, *optional*):
93
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
94
+ computation. If unspecified, it defaults to value recommended by the implementation, using the
95
+ `factor` field to infer the suggested value.
96
+ `beta_fast` (`float`, *optional*):
97
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
98
+ ramp function. If unspecified, it defaults to 32.
99
+ `beta_slow` (`float`, *optional*):
100
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
101
+ ramp function. If unspecified, it defaults to 1.
102
+ `short_factor` (`List[float]`, *optional*):
103
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<
104
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
105
+ size divided by the number of attention heads divided by 2
106
+ `long_factor` (`List[float]`, *optional*):
107
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<
108
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
109
+ size divided by the number of attention heads divided by 2
110
+ `low_freq_factor` (`float`, *optional*):
111
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
112
+ `high_freq_factor` (`float`, *optional*):
113
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
114
+ attention_bias (`bool`, *optional*, defaults to `True`):
115
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
116
+
117
+ Example:
118
+
119
+ ```python
120
+ >>> from transformers import GPTNeoXConfig, GPTNeoXModel
121
+
122
+ >>> # Initializing a GPTNeoX gpt-neox-20b style configuration
123
+ >>> configuration = GPTNeoXConfig()
124
+
125
+ >>> # Initializing a model (with random weights) from the gpt-neox-20b style configuration
126
+ >>> model = GPTNeoXModel(configuration) # doctest: +SKIP
127
+
128
+ >>> # Accessing the model configuration
129
+ >>> configuration = model.config # doctest: +SKIP
130
+ ```"""
131
+
132
+ model_type = "gpt_neox"
133
+ keys_to_ignore_at_inference = ["past_key_values"]
134
+
135
+ def __init__(
136
+ self,
137
+ vocab_size=50432,
138
+ hidden_size=6144,
139
+ num_hidden_layers=44,
140
+ num_attention_heads=64,
141
+ intermediate_size=24576,
142
+ hidden_act="gelu",
143
+ rotary_pct=0.25,
144
+ rotary_emb_base=10000,
145
+ attention_dropout=0.0,
146
+ hidden_dropout=0.0,
147
+ classifier_dropout=0.1,
148
+ max_position_embeddings=2048,
149
+ initializer_range=0.02,
150
+ layer_norm_eps=1e-5,
151
+ use_cache=True,
152
+ bos_token_id=0,
153
+ eos_token_id=2,
154
+ tie_word_embeddings=False,
155
+ use_parallel_residual=True,
156
+ rope_scaling=None,
157
+ attention_bias=True,
158
+ **kwargs,
159
+ ):
160
+ super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
161
+ self.vocab_size = vocab_size
162
+ self.max_position_embeddings = max_position_embeddings
163
+ self.hidden_size = hidden_size
164
+ self.num_hidden_layers = num_hidden_layers
165
+ self.num_attention_heads = num_attention_heads
166
+ self.intermediate_size = intermediate_size
167
+ self.hidden_act = hidden_act
168
+ self.rotary_pct = rotary_pct
169
+ self.partial_rotary_factor = rotary_pct
170
+ self.rotary_emb_base = rotary_emb_base
171
+ self.rope_theta = rotary_emb_base
172
+ self.attention_dropout = attention_dropout
173
+ self.hidden_dropout = hidden_dropout
174
+ self.classifier_dropout = classifier_dropout
175
+ self.initializer_range = initializer_range
176
+ self.layer_norm_eps = layer_norm_eps
177
+ self.use_cache = use_cache
178
+ self.tie_word_embeddings = tie_word_embeddings
179
+ self.use_parallel_residual = use_parallel_residual
180
+ self.rope_scaling = rope_scaling
181
+ self.attention_bias = attention_bias
182
+ # Validate the correctness of rotary position embeddings parameters
183
+ # BC: if there is a 'type' field, move it to 'rope_type'.
184
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
185
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
186
+ rope_config_validation(self)
187
+
188
+ if self.hidden_size % self.num_attention_heads != 0:
189
+ raise ValueError(
190
+ "The hidden size is not divisble by the number of attention heads! Make sure to update them!"
191
+ )
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": [
5
+ 0
6
+ ],
7
+ "pad_token_id": 0,
8
+ "transformers_version": "4.57.1"
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12cf23aa91dfe30303a07a4ede45ad60f365fc53154800212398b79607d1ee86
3
+ size 324662984
modeling_custom.py ADDED
@@ -0,0 +1,1569 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 EleutherAI The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """PyTorch GPTNeoX model."""
16
+
17
+ from typing import Optional, Tuple, Union
18
+
19
+ import einops
20
+ import torch
21
+ import torch.utils.checkpoint
22
+ from packaging import version
23
+ from torch import nn
24
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
25
+
26
+ from transformers.activations import ACT2FN
27
+ from transformers.cache_utils import Cache, DynamicCache, StaticCache
28
+ from transformers.file_utils import (
29
+ add_code_sample_docstrings,
30
+ add_start_docstrings,
31
+ add_start_docstrings_to_model_forward,
32
+ replace_return_docstrings,
33
+ )
34
+ from transformers.generation import GenerationMixin
35
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
36
+ from transformers.modeling_outputs import (
37
+ BaseModelOutputWithPast,
38
+ CausalLMOutputWithPast,
39
+ QuestionAnsweringModelOutput,
40
+ SequenceClassifierOutputWithPast,
41
+ TokenClassifierOutput,
42
+ )
43
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS
44
+ from transformers.modeling_utils import PreTrainedModel
45
+ from transformers.utils import (
46
+ get_torch_version,
47
+ is_flash_attn_2_available,
48
+ is_flash_attn_greater_or_equal_2_10,
49
+ logging,
50
+ )
51
+ from einops import rearrange
52
+ from .config_custom import GPTNeoXConfig
53
+
54
+
55
+ if is_flash_attn_2_available():
56
+ from transformers.modeling_flash_attention_utils import _flash_attention_forward
57
+
58
+ logger = logging.get_logger(__name__)
59
+
60
+ _CHECKPOINT_FOR_DOC = "trl-internal-testing/tiny-random-GPTNeoXForCausalLM"
61
+ _REAL_CHECKPOINT_FOR_DOC = "EleutherAI/gpt-neox-20b"
62
+ _CONFIG_FOR_DOC = "GPTNeoXConfig"
63
+
64
+
65
+ # Copied from transformers.models.llama.modeling_llama._prepare_4d_causal_attention_mask_with_cache_position
66
+ def _prepare_4d_causal_attention_mask_with_cache_position(
67
+ attention_mask: torch.Tensor,
68
+ sequence_length: int,
69
+ target_length: int,
70
+ dtype: torch.dtype,
71
+ device: torch.device,
72
+ min_dtype: float,
73
+ cache_position: torch.Tensor,
74
+ batch_size: int,
75
+ ):
76
+ """
77
+ Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
78
+ `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.
79
+
80
+ Args:
81
+ attention_mask (`torch.Tensor`):
82
+ A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape `(batch_size, 1, query_length, key_value_length)`.
83
+ sequence_length (`int`):
84
+ The sequence length being processed.
85
+ target_length (`int`):
86
+ The target length: when generating with static cache, the mask should be as long as the static cache, to account for the 0 padding, the part of the cache that is not filled yet.
87
+ dtype (`torch.dtype`):
88
+ The dtype to use for the 4D attention mask.
89
+ device (`torch.device`):
90
+ The device to plcae the 4D attention mask on.
91
+ min_dtype (`float`):
92
+ The minimum value representable with the dtype `dtype`.
93
+ cache_position (`torch.Tensor`):
94
+ Indices depicting the position of the input sequence tokens in the sequence.
95
+ batch_size (`torch.Tensor`):
96
+ Batch size.
97
+ """
98
+ if attention_mask is not None and attention_mask.dim() == 4:
99
+ # In this case we assume that the mask comes already in inverted form and requires no inversion or slicing.
100
+ causal_mask = attention_mask
101
+ else:
102
+ causal_mask = torch.full((sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=device)
103
+ if sequence_length != 1:
104
+ causal_mask = torch.triu(causal_mask, diagonal=1)
105
+ causal_mask *= torch.arange(target_length, device=device) > cache_position.reshape(-1, 1)
106
+ causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
107
+ if attention_mask is not None:
108
+ causal_mask = causal_mask.clone() # copy to contiguous memory for in-place edit
109
+ mask_length = attention_mask.shape[-1]
110
+ padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :]
111
+ padding_mask = padding_mask == 0
112
+ causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
113
+ padding_mask, min_dtype
114
+ )
115
+
116
+ return causal_mask
117
+
118
+
119
+ class GPTNeoXPreTrainedModel(PreTrainedModel):
120
+ """
121
+ An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
122
+ models.
123
+ """
124
+
125
+ config_class = GPTNeoXConfig
126
+ base_model_prefix = "gpt_neox"
127
+ supports_gradient_checkpointing = True
128
+ _no_split_modules = ["GPTNeoXLayer"]
129
+ _skip_keys_device_placement = "past_key_values"
130
+ _supports_flash_attn_2 = True
131
+ _supports_cache_class = True
132
+ _supports_quantized_cache = True
133
+ _supports_static_cache = True
134
+ _supports_sdpa = True
135
+
136
+ def _init_weights(self, module):
137
+ """Initialize the weights"""
138
+ if isinstance(module, nn.Linear):
139
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
140
+ if module.bias is not None:
141
+ module.bias.data.zero_()
142
+ elif isinstance(module, nn.Embedding):
143
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
144
+ if module.padding_idx is not None:
145
+ module.weight.data[module.padding_idx].zero_()
146
+ elif isinstance(module, nn.LayerNorm):
147
+ module.bias.data.zero_()
148
+ module.weight.data.fill_(1.0)
149
+
150
+
151
+ class GPTNeoXAttention(nn.Module):
152
+ def __init__(self, config, layer_idx=None):
153
+ super().__init__()
154
+ self.config = config
155
+ self.num_attention_heads = config.num_attention_heads
156
+ self.hidden_size = config.hidden_size
157
+ if self.hidden_size % self.num_attention_heads != 0:
158
+ raise ValueError(
159
+ "The hidden size is not divisble by the number of attention heads! Make sure to update them"
160
+ )
161
+ self.head_size = self.hidden_size // self.num_attention_heads
162
+ self.rotary_ndims = int(self.head_size * config.rotary_pct)
163
+ self.rope_theta = config.rotary_emb_base
164
+ self._init_bias(config.max_position_embeddings)
165
+
166
+ self.register_buffer("masked_bias", torch.tensor(-1e9), persistent=False)
167
+ self.rotary_emb = GPTNeoXRotaryEmbedding(config=self.config)
168
+
169
+ if layer_idx is None:
170
+ logger.warning_once(
171
+ f"Instantiating {self.__class__.__name__} without passing a `layer_idx` is not recommended and will "
172
+ "lead to errors during the forward call if caching is used. Please make sure to provide a `layer_idx` "
173
+ "when creating this class."
174
+ )
175
+ self.norm_factor = self.head_size**-0.5
176
+ self.query_key_value = nn.Linear(config.hidden_size, 3 * config.hidden_size, bias=config.attention_bias)
177
+ self.dense = nn.Linear(config.hidden_size, config.hidden_size, bias=config.attention_bias)
178
+ self.attention_dropout = nn.Dropout(config.attention_dropout)
179
+ self.is_causal = True
180
+ self.layer_idx = layer_idx
181
+
182
+ def _init_bias(self, max_positions, device=None):
183
+ self.register_buffer(
184
+ "bias",
185
+ torch.tril(torch.ones((max_positions, max_positions), dtype=torch.bool)).view(
186
+ 1, 1, max_positions, max_positions
187
+ ),
188
+ persistent=False,
189
+ )
190
+ if device is not None:
191
+ self.bias = self.bias.to(device)
192
+
193
+ def forward(
194
+ self,
195
+ hidden_states: torch.FloatTensor,
196
+ attention_mask: torch.FloatTensor,
197
+ position_ids: torch.LongTensor,
198
+ head_mask: Optional[torch.FloatTensor] = None,
199
+ layer_past: Optional[Cache] = None,
200
+ use_cache: Optional[bool] = False,
201
+ output_attentions: Optional[bool] = False,
202
+ padding_mask: Optional[torch.Tensor] = None,
203
+ cache_position: Optional[torch.LongTensor] = None,
204
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
205
+ ):
206
+ # Apply attention-specific projections and rope
207
+ query, key, value, present = self._attn_projections_and_rope(
208
+ hidden_states=hidden_states,
209
+ position_ids=position_ids,
210
+ layer_past=layer_past,
211
+ use_cache=use_cache,
212
+ position_embeddings=position_embeddings,
213
+ )
214
+
215
+ # Compute attention
216
+ attn_output, attn_weights = self._attn(query, key, value, attention_mask, head_mask)
217
+
218
+ # Reshape outputs
219
+ attn_output = self._merge_heads(attn_output, self.num_attention_heads, self.head_size)
220
+ attn_output = self.dense(attn_output)
221
+
222
+ outputs = (attn_output, present)
223
+ if output_attentions:
224
+ outputs += (attn_weights,)
225
+
226
+ return outputs
227
+
228
+ @classmethod
229
+ def _split_heads(cls, tensor, num_attention_heads, attn_head_size):
230
+ """
231
+ Splits hidden dim into attn_head_size and num_attention_heads
232
+ """
233
+ # tensor: [bs, seq_len, hidden_size]
234
+ new_shape = tensor.size()[:-1] + (num_attention_heads, attn_head_size)
235
+ # -> [bs, seq_len, num_attention_heads, attn_head_size]
236
+ tensor = tensor.view(new_shape)
237
+ # -> [bs, num_attention_heads, seq_len, attn_head_size]
238
+ tensor = tensor.permute(0, 2, 1, 3)
239
+ return tensor
240
+
241
+ @classmethod
242
+ def _merge_heads(cls, tensor, num_attention_heads, attn_head_size):
243
+ """
244
+ Merges attn_head_size dim and num_attn_heads dim into hidden dim
245
+ """
246
+ # tensor [bs, num_attention_heads, seq_len, attn_head_size]
247
+ tensor = tensor.permute(0, 2, 1, 3).contiguous()
248
+ # -> [bs, seq_len, num_attention_heads, attn_head_size]
249
+ tensor = tensor.view(tensor.size(0), tensor.size(1), num_attention_heads * attn_head_size)
250
+ # -> [bs, seq_len, hidden_size]
251
+ return tensor
252
+
253
+ def _attn_projections_and_rope(
254
+ self,
255
+ hidden_states: torch.FloatTensor,
256
+ position_ids: torch.LongTensor,
257
+ layer_past: Optional[Tuple[torch.Tensor]] = None,
258
+ use_cache: Optional[bool] = False,
259
+ cache_position: Optional[torch.LongTensor] = None,
260
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
261
+ ):
262
+ # Compute QKV
263
+ # Attention heads [batch, seq_len, hidden_size]
264
+ # --> [batch, seq_len, (np * 3 * head_size)]
265
+ qkv = self.query_key_value(hidden_states)
266
+
267
+ # [batch, seq_len, (num_heads * 3 * head_size)]
268
+ # --> [batch, seq_len, num_heads, 3 * head_size]
269
+ new_qkv_shape = qkv.size()[:-1] + (self.num_attention_heads, 3 * self.head_size)
270
+ qkv = qkv.view(*new_qkv_shape)
271
+
272
+ # [batch, seq_len, num_attention_heads, 3 * head_size] --> 3 [batch, num_attention_heads, seq_len, head_size]
273
+ query = qkv[..., : self.head_size].permute(0, 2, 1, 3)
274
+ key = qkv[..., self.head_size : 2 * self.head_size].permute(0, 2, 1, 3)
275
+ value = qkv[..., 2 * self.head_size :].permute(0, 2, 1, 3)
276
+
277
+ # Compute rotary embeddings on rotary_ndims
278
+ query_rot = query[..., : self.rotary_ndims]
279
+ query_pass = query[..., self.rotary_ndims :]
280
+ key_rot = key[..., : self.rotary_ndims]
281
+ key_pass = key[..., self.rotary_ndims :]
282
+
283
+ if position_embeddings is None:
284
+ logger.warning_once(
285
+ "The attention layers in this model are transitioning from computing the RoPE embeddings internally "
286
+ "through `position_ids` (2D tensor with the indexes of the tokens), to using externally computed "
287
+ "`position_embeddings` (Tuple of tensors, containing cos and sin). In v4.46 `position_ids` will be "
288
+ "removed and `position_embeddings` will be mandatory."
289
+ )
290
+ cos, sin = self.rotary_emb(value, position_ids)
291
+ else:
292
+ cos, sin = position_embeddings
293
+ query, key = apply_rotary_pos_emb(query_rot, key_rot, cos, sin)
294
+ query = torch.cat((query, query_pass), dim=-1)
295
+ key = torch.cat((key, key_pass), dim=-1)
296
+
297
+ # Cache QKV values
298
+ if layer_past is not None:
299
+ cache_kwargs = {
300
+ "sin": sin,
301
+ "cos": cos,
302
+ "partial_rotation_size": self.rotary_ndims,
303
+ "cache_position": cache_position,
304
+ }
305
+ key, value = layer_past.update(key, value, self.layer_idx, cache_kwargs)
306
+
307
+ return query, key, value, layer_past
308
+
309
+ def _attn(self, query, key, value, attention_mask=None, head_mask=None):
310
+ # q, k, v: [bs, num_attention_heads, seq_len, attn_head_size]
311
+ # compute causal mask from causal mask buffer
312
+ batch_size, num_attention_heads, query_length, attn_head_size = query.size()
313
+ key_length = key.size(-2)
314
+
315
+ # dynamically increase the causal mask with the key length, if needed.
316
+ if key_length > self.bias.shape[-1]:
317
+ self._init_bias(key_length, device=key.device)
318
+ causal_mask = self.bias[:, :, key_length - query_length : key_length, :key_length]
319
+
320
+ query = query.view(batch_size * num_attention_heads, query_length, attn_head_size)
321
+ key = key.view(batch_size * num_attention_heads, key_length, attn_head_size)
322
+ attn_scores = torch.zeros(
323
+ batch_size * num_attention_heads,
324
+ query_length,
325
+ key_length,
326
+ dtype=query.dtype,
327
+ device=key.device,
328
+ )
329
+ attn_scores = torch.baddbmm(
330
+ attn_scores,
331
+ query,
332
+ key.transpose(1, 2),
333
+ beta=1.0,
334
+ alpha=self.norm_factor,
335
+ )
336
+ attn_scores = attn_scores.view(batch_size, num_attention_heads, query_length, key_length)
337
+
338
+ mask_value = torch.finfo(attn_scores.dtype).min
339
+ # Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
340
+ # Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same device`
341
+ mask_value = torch.tensor(mask_value, dtype=attn_scores.dtype).to(attn_scores.device)
342
+ attn_scores = torch.where(causal_mask, attn_scores, mask_value)
343
+
344
+ if attention_mask is not None: # no matter the length, we just slice it
345
+ causal_mask = attention_mask[:, :, :, : key.shape[-2]]
346
+ attn_scores = attn_scores + causal_mask
347
+
348
+ attn_weights = nn.functional.softmax(attn_scores, dim=-1)
349
+ attn_weights = attn_weights.to(value.dtype)
350
+
351
+ # Mask heads if we want to
352
+ if head_mask is not None:
353
+ attn_weights = attn_weights * head_mask
354
+
355
+ attn_weights = self.attention_dropout(attn_weights)
356
+
357
+ attn_output = torch.matmul(attn_weights, value)
358
+ return attn_output, attn_weights
359
+
360
+
361
+ class GPTNeoXFlashAttention2(GPTNeoXAttention):
362
+ """
363
+ GPTNeoX flash attention module. This module inherits from `GPTNeoXAttention` as the weights of the module stays
364
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
365
+ flash attention and deal with padding tokens in case the input contains any of them.
366
+ """
367
+
368
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2.__init__
369
+ def __init__(self, *args, **kwargs):
370
+ super().__init__(*args, **kwargs)
371
+
372
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
373
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
374
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
375
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
376
+
377
+ def forward(
378
+ self,
379
+ hidden_states: torch.FloatTensor,
380
+ attention_mask: torch.FloatTensor,
381
+ position_ids: torch.LongTensor,
382
+ head_mask: Optional[torch.FloatTensor] = None,
383
+ layer_past: Optional[Cache] = None,
384
+ use_cache: Optional[bool] = False,
385
+ output_attentions: Optional[bool] = False,
386
+ cache_position: Optional[torch.LongTensor] = None,
387
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
388
+ ):
389
+ # Apply attention-specific projections and rope
390
+ query, key, value, present = self._attn_projections_and_rope(
391
+ hidden_states=hidden_states,
392
+ position_ids=position_ids,
393
+ layer_past=layer_past,
394
+ use_cache=use_cache,
395
+ cache_position=cache_position,
396
+ position_embeddings=position_embeddings,
397
+ )
398
+
399
+ query_length = query.shape[-2]
400
+
401
+ # GPT-neo-X casts query and key in fp32 to apply rotary embedding in full precision
402
+ target_dtype = value.dtype
403
+ if query.dtype != target_dtype:
404
+ query = query.to(target_dtype)
405
+ if key.dtype != target_dtype:
406
+ key = key.to(target_dtype)
407
+
408
+ #TODO: Permute to get the expected shape for Flash Attention
409
+ # [batch, num_attention_heads, seq_len, head_size]
410
+ query = einops.rearrange(query, "b n s h -> b s n h")
411
+ key = einops.rearrange(key, "b n s h -> b s n h")
412
+ value = einops.rearrange(value, "b n s h -> b s n h")
413
+
414
+ attention_dropout = self.config.attention_dropout if self.training else 0.0
415
+
416
+ #TODO: Compute attention with _flash_attention_forward
417
+ attn_output = _flash_attention_forward(query_states=query, key_states=key, value_states=value, query_length=query_length,
418
+ attention_mask=attention_mask, is_causal=True, attention_dropout=attention_dropout)
419
+
420
+ #TODO: Reshape outputs before projection
421
+ bsz, q_len, _ = hidden_states.size()
422
+ attn_output = einops.rearrange(attn_output, "b s n h -> b s (n h)")
423
+ # attn_output = attn_weights.view(attn_weights.size(0), -1)
424
+ # print(attn_output.shape)
425
+ attn_output = self.dense(attn_output)
426
+
427
+ outputs = (attn_output, present)
428
+ if output_attentions:
429
+ outputs += (None, )
430
+
431
+ return outputs
432
+
433
+
434
+ class GPTNeoXSdpaAttention(GPTNeoXAttention):
435
+ """
436
+ GPTNeoX attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
437
+ `GPTNeoXAttention` as the weights of the module stays untouched. The only changes are on the forward pass
438
+ to adapt to the SDPA API.
439
+ """
440
+
441
+ def __init__(self, config, layer_idx=None):
442
+ super().__init__(config, layer_idx=layer_idx)
443
+
444
+ # SDPA with memory-efficient backend is broken in torch==2.1.2 when using non-contiguous inputs and a custom
445
+ # attn_mask, so we need to call `.contiguous()`. This was fixed in torch==2.2.0.
446
+ # Reference: https://github.com/pytorch/pytorch/issues/112577
447
+ self.require_contiguous_qkv = version.parse(get_torch_version()) < version.parse("2.2.0")
448
+
449
+ def forward(
450
+ self,
451
+ hidden_states: torch.FloatTensor,
452
+ attention_mask: torch.FloatTensor,
453
+ position_ids: torch.LongTensor,
454
+ head_mask: Optional[torch.FloatTensor] = None,
455
+ layer_past: Optional[Tuple[torch.Tensor]] = None,
456
+ use_cache: Optional[bool] = False,
457
+ output_attentions: Optional[bool] = False,
458
+ cache_position: Optional[torch.LongTensor] = None,
459
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
460
+ ):
461
+ if output_attentions or head_mask is not None:
462
+ logger.warning_once(
463
+ "`GPTNeoXSdpaAttention` is used but `torch.nn.functional.scaled_dot_product_attention` does not support "
464
+ "`output_attentions=True` or `head_mask`. Falling back to the manual attention implementation, but "
465
+ "specifying the manual implementation will be required from Transformers version v5.0.0 onwards. "
466
+ 'This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
467
+ )
468
+ return super().forward(
469
+ hidden_states=hidden_states,
470
+ attention_mask=attention_mask,
471
+ position_ids=position_ids,
472
+ head_mask=head_mask,
473
+ layer_past=layer_past,
474
+ use_cache=use_cache,
475
+ output_attentions=output_attentions,
476
+ cache_position=cache_position,
477
+ )
478
+
479
+ bsz, q_len, _ = hidden_states.size()
480
+
481
+ # Apply attention-specific projections and rope
482
+ query, key, value, present = self._attn_projections_and_rope(
483
+ hidden_states=hidden_states,
484
+ position_ids=position_ids,
485
+ layer_past=layer_past,
486
+ use_cache=use_cache,
487
+ cache_position=cache_position,
488
+ position_embeddings=position_embeddings,
489
+ )
490
+
491
+ causal_mask = attention_mask
492
+ if attention_mask is not None:
493
+ causal_mask = causal_mask[:, :, :, : key.shape[-2]]
494
+
495
+ # GPT-neo-X casts query and key in fp32 to apply rotary embedding in full precision
496
+ target_dtype = value.dtype
497
+ if query.dtype != target_dtype:
498
+ query = query.to(target_dtype)
499
+ if key.dtype != target_dtype:
500
+ key = key.to(target_dtype)
501
+
502
+ # Avoid torch==2.1.2 specific bug for the memory-efficient backend in SDPA
503
+ if self.require_contiguous_qkv and query.device.type == "cuda" and attention_mask is not None:
504
+ query = query.contiguous()
505
+ key = key.contiguous()
506
+ value = value.contiguous()
507
+
508
+ # We dispatch to SDPA's Flash Attention or Efficient kernels via this `is_causal` if statement instead of an inline conditional assignment
509
+ # in SDPA to support both torch.compile's dynamic shapes and full graph options. An inline conditional prevents dynamic shapes from compiling.
510
+ is_causal = True if causal_mask is None and q_len > 1 else False
511
+
512
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
513
+ query=query,
514
+ key=key,
515
+ value=value,
516
+ attn_mask=causal_mask,
517
+ dropout_p=self.attention_dropout.p if self.training else 0.0,
518
+ is_causal=is_causal,
519
+ )
520
+
521
+ # Reshape outputs
522
+ attn_output = attn_output.transpose(1, 2).contiguous()
523
+ attn_output = attn_output.view(bsz, q_len, self.hidden_size)
524
+
525
+ attn_output = self.dense(attn_output)
526
+
527
+ return attn_output, present, None
528
+
529
+
530
+ def attention_mask_func(attention_scores, ltor_mask):
531
+ attention_scores.masked_fill_(~ltor_mask, torch.finfo(attention_scores.dtype).min)
532
+ return attention_scores
533
+
534
+
535
+ # Copied from transformers.models.llama.modeling_llama.LlamaRotaryEmbedding with Llama->GPTNeoX
536
+ class GPTNeoXRotaryEmbedding(nn.Module):
537
+ def __init__(
538
+ self,
539
+ dim=None,
540
+ max_position_embeddings=2048,
541
+ base=10000,
542
+ device=None,
543
+ scaling_factor=1.0,
544
+ rope_type="default",
545
+ config: Optional[GPTNeoXConfig] = None,
546
+ ):
547
+ super().__init__()
548
+ # TODO (joao): remove the `if` below, only used for BC
549
+ self.rope_kwargs = {}
550
+ if config is None:
551
+ logger.warning_once(
552
+ "`GPTNeoXRotaryEmbedding` can now be fully parameterized by passing the model config through the "
553
+ "`config` argument. All other arguments will be removed in v4.46"
554
+ )
555
+ self.rope_kwargs = {
556
+ "rope_type": rope_type,
557
+ "factor": scaling_factor,
558
+ "dim": dim,
559
+ "base": base,
560
+ "max_position_embeddings": max_position_embeddings,
561
+ }
562
+ self.rope_type = rope_type
563
+ self.max_seq_len_cached = max_position_embeddings
564
+ self.original_max_seq_len = max_position_embeddings
565
+ else:
566
+ # BC: "rope_type" was originally "type"
567
+ if config.rope_scaling is not None:
568
+ self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
569
+ else:
570
+ self.rope_type = "default"
571
+ self.max_seq_len_cached = config.max_position_embeddings
572
+ self.original_max_seq_len = config.max_position_embeddings
573
+
574
+ self.config = config
575
+ self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
576
+
577
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device, **self.rope_kwargs)
578
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
579
+ self.original_inv_freq = self.inv_freq
580
+
581
+ def _dynamic_frequency_update(self, position_ids, device):
582
+ """
583
+ dynamic RoPE layers should recompute `inv_freq` in the following situations:
584
+ 1 - growing beyond the cached sequence length (allow scaling)
585
+ 2 - the current sequence length is in the original scale (avoid losing precision with small sequences)
586
+ """
587
+ seq_len = torch.max(position_ids) + 1
588
+ if seq_len > self.max_seq_len_cached: # growth
589
+ inv_freq, self.attention_scaling = self.rope_init_fn(
590
+ self.config, device, seq_len=seq_len, **self.rope_kwargs
591
+ )
592
+ self.register_buffer("inv_freq", inv_freq, persistent=False) # TODO joao: may break with compilation
593
+ self.max_seq_len_cached = seq_len
594
+
595
+ if seq_len < self.original_max_seq_len and self.max_seq_len_cached > self.original_max_seq_len: # reset
596
+ self.register_buffer("inv_freq", self.original_inv_freq, persistent=False)
597
+ self.max_seq_len_cached = self.original_max_seq_len
598
+
599
+ @torch.no_grad()
600
+ def forward(self, x, position_ids):
601
+ if "dynamic" in self.rope_type:
602
+ self._dynamic_frequency_update(position_ids, device=x.device)
603
+
604
+ # Core RoPE block
605
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
606
+ position_ids_expanded = position_ids[:, None, :].float()
607
+ # Force float32 (see https://github.com/huggingface/transformers/pull/29285)
608
+ device_type = x.device.type
609
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
610
+ with torch.autocast(device_type=device_type, enabled=False):
611
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
612
+ emb = torch.cat((freqs, freqs), dim=-1)
613
+ cos = emb.cos()
614
+ sin = emb.sin()
615
+
616
+ # Advanced RoPE types (e.g. yarn) apply a post-processing scaling factor, equivalent to scaling attention
617
+ cos = cos * self.attention_scaling
618
+ sin = sin * self.attention_scaling
619
+
620
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
621
+
622
+
623
+ # Copied from transformers.models.llama.modeling_llama.LlamaLinearScalingRotaryEmbedding with Llama->GPTNeoX
624
+ class GPTNeoXLinearScalingRotaryEmbedding(GPTNeoXRotaryEmbedding):
625
+ """GPTNeoXRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
626
+
627
+ def __init__(self, *args, **kwargs):
628
+ logger.warning_once(
629
+ "`GPTNeoXLinearScalingRotaryEmbedding` is deprecated an will be removed in v4.46. Please use "
630
+ "`GPTNeoXRotaryEmbedding`, which now also does linear scaling (simply pass the model config to __init__)."
631
+ )
632
+ kwargs["rope_type"] = "linear"
633
+ super().__init__(*args, **kwargs)
634
+
635
+
636
+ # Copied from transformers.models.llama.modeling_llama.LlamaDynamicNTKScalingRotaryEmbedding with Llama->GPTNeoX
637
+ class GPTNeoXDynamicNTKScalingRotaryEmbedding(GPTNeoXRotaryEmbedding):
638
+ """GPTNeoXRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
639
+
640
+ def __init__(self, *args, **kwargs):
641
+ logger.warning_once(
642
+ "`GPTNeoXDynamicNTKScalingRotaryEmbedding` is deprecated an will be removed in v4.46. Please use "
643
+ "`GPTNeoXRotaryEmbedding`, which now also does dynamic ntk scaling (simply pass the model config to "
644
+ "__init__)."
645
+ )
646
+ kwargs["rope_type"] = "dynamic"
647
+ super().__init__(*args, **kwargs)
648
+
649
+
650
+ def rotate_half(x):
651
+ """Rotates half the hidden dims of the input."""
652
+ x1 = x[..., : x.shape[-1] // 2]
653
+ x2 = x[..., x.shape[-1] // 2 :]
654
+ return torch.cat((-x2, x1), dim=-1)
655
+
656
+
657
+ # Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
658
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
659
+ """Applies Rotary Position Embedding to the query and key tensors.
660
+
661
+ Args:
662
+ q (`torch.Tensor`): The query tensor.
663
+ k (`torch.Tensor`): The key tensor.
664
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
665
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
666
+ position_ids (`torch.Tensor`, *optional*):
667
+ Deprecated and unused.
668
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
669
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
670
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
671
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
672
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
673
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
674
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
675
+ Returns:
676
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
677
+ """
678
+ cos = cos.unsqueeze(unsqueeze_dim)
679
+ sin = sin.unsqueeze(unsqueeze_dim)
680
+ q_embed = (q * cos) + (rotate_half(q) * sin)
681
+ k_embed = (k * cos) + (rotate_half(k) * sin)
682
+ return q_embed, k_embed
683
+
684
+
685
+ class GPTNeoXMLP(nn.Module):
686
+ def __init__(self, config):
687
+ super().__init__()
688
+ self.dense_h_to_4h = nn.Linear(config.hidden_size, config.intermediate_size)
689
+ self.dense_4h_to_h = nn.Linear(config.intermediate_size, config.hidden_size)
690
+ self.act = ACT2FN[config.hidden_act]
691
+
692
+ def forward(self, hidden_states):
693
+ hidden_states = self.dense_h_to_4h(hidden_states)
694
+ hidden_states = self.act(hidden_states)
695
+ hidden_states = self.dense_4h_to_h(hidden_states)
696
+ return hidden_states
697
+
698
+
699
+ GPT_NEOX_ATTENTION_CLASSES = {
700
+ "eager": GPTNeoXAttention,
701
+ "flash_attention_2": GPTNeoXFlashAttention2,
702
+ "sdpa": GPTNeoXSdpaAttention,
703
+ }
704
+
705
+
706
+ class GPTNeoXLayer(nn.Module):
707
+ def __init__(self, config, layer_idx):
708
+ super().__init__()
709
+ self.use_parallel_residual = config.use_parallel_residual
710
+ self.input_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
711
+ self.post_attention_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
712
+ self.post_attention_dropout = nn.Dropout(config.hidden_dropout)
713
+ self.post_mlp_dropout = nn.Dropout(config.hidden_dropout)
714
+ self.attention = GPT_NEOX_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx)
715
+ self.mlp = GPTNeoXMLP(config)
716
+
717
+ def forward(
718
+ self,
719
+ hidden_states: Optional[torch.FloatTensor],
720
+ attention_mask: Optional[torch.FloatTensor] = None,
721
+ position_ids: Optional[torch.LongTensor] = None,
722
+ head_mask: Optional[torch.FloatTensor] = None,
723
+ use_cache: Optional[bool] = False,
724
+ layer_past: Optional[Cache] = None,
725
+ output_attentions: Optional[bool] = False,
726
+ cache_position: Optional[torch.LongTensor] = None,
727
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
728
+ ):
729
+ attention_layer_outputs = self.attention(
730
+ self.input_layernorm(hidden_states),
731
+ attention_mask=attention_mask,
732
+ position_ids=position_ids,
733
+ layer_past=layer_past,
734
+ head_mask=head_mask,
735
+ use_cache=use_cache,
736
+ output_attentions=output_attentions,
737
+ cache_position=cache_position,
738
+ position_embeddings=position_embeddings,
739
+ )
740
+ attn_output = attention_layer_outputs[0] # output_attn: attn_output, present, (attn_weights)
741
+ attn_output = self.post_attention_dropout(attn_output)
742
+ outputs = attention_layer_outputs[1:]
743
+
744
+ if self.use_parallel_residual:
745
+ # pseudocode:
746
+ # x = x + attn(ln1(x)) + mlp(ln2(x))
747
+ mlp_output = self.mlp(self.post_attention_layernorm(hidden_states))
748
+ mlp_output = self.post_mlp_dropout(mlp_output)
749
+ hidden_states = mlp_output + attn_output + hidden_states
750
+ else:
751
+ # pseudocode:
752
+ # x = x + attn(ln1(x))
753
+ # x = x + mlp(ln2(x))
754
+ attn_output = attn_output + hidden_states
755
+ mlp_output = self.mlp(self.post_attention_layernorm(attn_output))
756
+ mlp_output = self.post_mlp_dropout(mlp_output)
757
+ hidden_states = mlp_output + attn_output
758
+
759
+ if use_cache:
760
+ outputs = (hidden_states,) + outputs # hidden_states, present, (attn_weights)
761
+ else:
762
+ outputs = (hidden_states,) + outputs[1:] # hidden_states, (attn_weights)
763
+
764
+ return outputs
765
+
766
+
767
+ GPT_NEOX_START_DOCSTRING = r"""
768
+ This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
769
+ it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
770
+ behavior.
771
+
772
+ Parameters:
773
+ config ([`~GPTNeoXConfig`]): Model configuration class with all the parameters of the model.
774
+ Initializing with a config file does not load the weights associated with the model, only the
775
+ configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
776
+ """
777
+
778
+ GPT_NEOX_INPUTS_DOCSTRING = r"""
779
+ Args:
780
+ input_ids (`torch.LongTensor` of shape `({0})`):
781
+ Indices of input sequence tokens in the vocabulary.
782
+
783
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
784
+ [`PreTrainedTokenizer.__call__`] for details.
785
+
786
+ [What are input IDs?](../glossary#input-ids)
787
+ attention_mask (`torch.FloatTensor` of shape `({0})`, *optional*):
788
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
789
+
790
+ - 1 for tokens that are **not masked**,
791
+ - 0 for tokens that are **masked**.
792
+
793
+ [What are attention masks?](../glossary#attention-mask)
794
+ position_ids (`torch.LongTensor` of shape `({0})`, *optional*):
795
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
796
+ config.n_positions - 1]`.
797
+
798
+ [What are position IDs?](../glossary#position-ids)
799
+ head_mask (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
800
+ Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:
801
+
802
+ - 1 indicates the head is **not masked**,
803
+ - 0 indicates the head is **masked**.
804
+
805
+ inputs_embeds (`torch.FloatTensor` of shape `({0}, hidden_size)`, *optional*):
806
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
807
+ is useful if you want more control over how to convert *input_ids* indices into associated vectors than the
808
+ model's internal embedding lookup matrix.
809
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
810
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
811
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
812
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
813
+
814
+ Two formats are allowed:
815
+ - a [`~cache_utils.Cache`] instance, see our
816
+ [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache);
817
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
818
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
819
+ cache format.
820
+
821
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
822
+ legacy cache format will be returned.
823
+
824
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
825
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
826
+ of shape `(batch_size, sequence_length)`.
827
+ output_attentions (`bool`, *optional*):
828
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
829
+ tensors for more detail.
830
+ output_hidden_states (`bool`, *optional*):
831
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
832
+ more detail.
833
+ return_dict (`bool`, *optional*):
834
+ Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.
835
+ cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
836
+ Indices depicting the position of the input sequence tokens in the sequence. Contrarily to `position_ids`,
837
+ this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
838
+ the complete sequence length.
839
+ """
840
+
841
+
842
+ @add_start_docstrings(
843
+ "The bare GPTNeoX Model transformer outputting raw hidden-states without any specific head on top.",
844
+ GPT_NEOX_START_DOCSTRING,
845
+ )
846
+ class GPTNeoXModel(GPTNeoXPreTrainedModel):
847
+ def __init__(self, config):
848
+ super().__init__(config)
849
+ self.config = config
850
+
851
+ self.embed_in = nn.Embedding(config.vocab_size, config.hidden_size)
852
+ self.emb_dropout = nn.Dropout(config.hidden_dropout)
853
+ self.layers = nn.ModuleList([GPTNeoXLayer(config, i) for i in range(config.num_hidden_layers)])
854
+ self.final_layer_norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
855
+ self.rotary_emb = GPTNeoXRotaryEmbedding(config=config)
856
+
857
+ self._attn_implementation = config._attn_implementation
858
+
859
+ self.gradient_checkpointing = False
860
+
861
+ # Initialize weights and apply final processing
862
+ self.post_init()
863
+
864
+ def get_input_embeddings(self):
865
+ return self.embed_in
866
+
867
+ def set_input_embeddings(self, value):
868
+ self.embed_in = value
869
+
870
+ @add_start_docstrings_to_model_forward(GPT_NEOX_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
871
+ @add_code_sample_docstrings(
872
+ checkpoint=_CHECKPOINT_FOR_DOC,
873
+ real_checkpoint=_REAL_CHECKPOINT_FOR_DOC,
874
+ output_type=BaseModelOutputWithPast,
875
+ config_class=_CONFIG_FOR_DOC,
876
+ )
877
+ def forward(
878
+ self,
879
+ input_ids: Optional[torch.LongTensor] = None,
880
+ attention_mask: Optional[torch.FloatTensor] = None,
881
+ position_ids: Optional[torch.LongTensor] = None,
882
+ head_mask: Optional[torch.FloatTensor] = None,
883
+ inputs_embeds: Optional[torch.FloatTensor] = None,
884
+ past_key_values: Optional[Union[Cache, Tuple[Tuple[torch.FloatTensor]]]] = None,
885
+ use_cache: Optional[bool] = None,
886
+ output_attentions: Optional[bool] = None,
887
+ output_hidden_states: Optional[bool] = None,
888
+ return_dict: Optional[bool] = None,
889
+ cache_position: Optional[torch.LongTensor] = None,
890
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
891
+ r"""
892
+ use_cache (`bool`, *optional*):
893
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
894
+ `past_key_values`).
895
+ """
896
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
897
+ output_hidden_states = (
898
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
899
+ )
900
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
901
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
902
+
903
+ if (input_ids is None) ^ (inputs_embeds is not None):
904
+ raise ValueError(
905
+ "You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
906
+ )
907
+
908
+ if self.gradient_checkpointing and self.training:
909
+ if use_cache:
910
+ logger.warning_once(
911
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
912
+ )
913
+ use_cache = False
914
+
915
+ if inputs_embeds is None:
916
+ inputs_embeds = self.embed_in(input_ids)
917
+
918
+ # kept for BC (non `Cache` `past_key_values` inputs)
919
+ return_legacy_cache = False
920
+ if use_cache and not isinstance(past_key_values, Cache):
921
+ return_legacy_cache = True
922
+ if past_key_values is None:
923
+ past_key_values = DynamicCache()
924
+ else:
925
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
926
+ logger.warning_once(
927
+ "We detected that you are passing `past_key_values` as a tuple of tuples. This is deprecated and "
928
+ "will be removed in v4.47. Please convert your cache or use an appropriate `Cache` class "
929
+ "(https://huggingface.co/docs/transformers/kv_cache#legacy-cache-format)"
930
+ )
931
+
932
+ seq_length = inputs_embeds.shape[1]
933
+ if cache_position is None:
934
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
935
+ cache_position = torch.arange(past_seen_tokens, past_seen_tokens + seq_length, device=inputs_embeds.device)
936
+
937
+ if position_ids is None:
938
+ position_ids = cache_position.unsqueeze(0)
939
+
940
+ causal_mask = self._update_causal_mask(
941
+ attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions
942
+ )
943
+
944
+ # Prepare head mask if needed
945
+ # 1.0 in head_mask indicate we keep the head
946
+ # attention_probs has shape bsz x n_heads x N x N
947
+ # input head_mask has shape [num_heads] or [num_hidden_layers x num_heads]
948
+ # and head_mask is converted to shape [num_hidden_layers x batch x num_heads x seq_length x seq_length]
949
+ head_mask = self.get_head_mask(head_mask, self.config.num_hidden_layers)
950
+ hidden_states = self.emb_dropout(inputs_embeds)
951
+
952
+ # create position embeddings to be shared across the decoder layers
953
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
954
+
955
+ next_decoder_cache = None
956
+ all_attentions = () if output_attentions else None
957
+ all_hidden_states = () if output_hidden_states else None
958
+ for i, layer in enumerate(
959
+ self.layers,
960
+ ):
961
+ if output_hidden_states:
962
+ all_hidden_states = all_hidden_states + (hidden_states,)
963
+
964
+ if self.gradient_checkpointing and self.training:
965
+ outputs = self._gradient_checkpointing_func(
966
+ layer.__call__,
967
+ hidden_states,
968
+ causal_mask,
969
+ position_ids,
970
+ head_mask[i],
971
+ use_cache,
972
+ None,
973
+ output_attentions,
974
+ cache_position,
975
+ position_embeddings,
976
+ )
977
+ else:
978
+ outputs = layer(
979
+ hidden_states,
980
+ attention_mask=causal_mask,
981
+ position_ids=position_ids,
982
+ head_mask=head_mask[i],
983
+ layer_past=past_key_values,
984
+ use_cache=use_cache,
985
+ output_attentions=output_attentions,
986
+ cache_position=cache_position,
987
+ position_embeddings=position_embeddings,
988
+ )
989
+ hidden_states = outputs[0]
990
+ if use_cache is True:
991
+ next_decoder_cache = outputs[1]
992
+ if output_attentions:
993
+ all_attentions = all_attentions + (outputs[2 if use_cache else 1],)
994
+
995
+ hidden_states = self.final_layer_norm(hidden_states)
996
+ # Add last hidden state
997
+ if output_hidden_states:
998
+ all_hidden_states = all_hidden_states + (hidden_states,)
999
+
1000
+ next_cache = next_decoder_cache if use_cache else None
1001
+ if return_legacy_cache:
1002
+ next_cache = next_cache.to_legacy_cache()
1003
+
1004
+ if not return_dict:
1005
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_attentions] if v is not None)
1006
+
1007
+ return BaseModelOutputWithPast(
1008
+ last_hidden_state=hidden_states,
1009
+ past_key_values=next_cache,
1010
+ hidden_states=all_hidden_states,
1011
+ attentions=all_attentions,
1012
+ )
1013
+
1014
+ # Copied from transformers.models.llama.modeling_llama.LlamaModel._update_causal_mask
1015
+ def _update_causal_mask(
1016
+ self,
1017
+ attention_mask: torch.Tensor,
1018
+ input_tensor: torch.Tensor,
1019
+ cache_position: torch.Tensor,
1020
+ past_key_values: Cache,
1021
+ output_attentions: bool,
1022
+ ):
1023
+ if self.config._attn_implementation == "flash_attention_2":
1024
+ if attention_mask is not None and 0.0 in attention_mask:
1025
+ return attention_mask
1026
+ return None
1027
+
1028
+ # For SDPA, when possible, we will rely on its `is_causal` argument instead of its `attn_mask` argument, in
1029
+ # order to dispatch on Flash Attention 2. This feature is not compatible with static cache, as SDPA will fail
1030
+ # to infer the attention mask.
1031
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
1032
+ using_static_cache = isinstance(past_key_values, StaticCache)
1033
+
1034
+ # When output attentions is True, sdpa implementation's forward method calls the eager implementation's forward
1035
+ if self.config._attn_implementation == "sdpa" and not using_static_cache and not output_attentions:
1036
+ if AttentionMaskConverter._ignore_causal_mask_sdpa(
1037
+ attention_mask,
1038
+ inputs_embeds=input_tensor,
1039
+ past_key_values_length=past_seen_tokens,
1040
+ is_training=self.training,
1041
+ ):
1042
+ return None
1043
+
1044
+ dtype, device = input_tensor.dtype, input_tensor.device
1045
+ min_dtype = torch.finfo(dtype).min
1046
+ sequence_length = input_tensor.shape[1]
1047
+ if using_static_cache:
1048
+ target_length = past_key_values.get_max_length()
1049
+ else:
1050
+ target_length = (
1051
+ attention_mask.shape[-1]
1052
+ if isinstance(attention_mask, torch.Tensor)
1053
+ else past_seen_tokens + sequence_length + 1
1054
+ )
1055
+
1056
+ # In case the provided `attention` mask is 2D, we generate a causal mask here (4D).
1057
+ causal_mask = _prepare_4d_causal_attention_mask_with_cache_position(
1058
+ attention_mask,
1059
+ sequence_length=sequence_length,
1060
+ target_length=target_length,
1061
+ dtype=dtype,
1062
+ device=device,
1063
+ min_dtype=min_dtype,
1064
+ cache_position=cache_position,
1065
+ batch_size=input_tensor.shape[0],
1066
+ )
1067
+
1068
+ if (
1069
+ self.config._attn_implementation == "sdpa"
1070
+ and attention_mask is not None
1071
+ and attention_mask.device.type == "cuda"
1072
+ and not output_attentions
1073
+ ):
1074
+ # Attend to all tokens in fully masked rows in the causal_mask, for example the relevant first rows when
1075
+ # using left padding. This is required by F.scaled_dot_product_attention memory-efficient attention path.
1076
+ # Details: https://github.com/pytorch/pytorch/issues/110213
1077
+ causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype)
1078
+
1079
+ return causal_mask
1080
+
1081
+
1082
+ @add_start_docstrings(
1083
+ """GPTNeoX Model with a `language modeling` head on top for CLM fine-tuning.""", GPT_NEOX_START_DOCSTRING
1084
+ )
1085
+ class GPTNeoXForCausalLM(GPTNeoXPreTrainedModel, GenerationMixin):
1086
+ _tied_weights_keys = ["embed_out.weight"]
1087
+
1088
+ def __init__(self, config):
1089
+ super().__init__(config)
1090
+
1091
+ self.gpt_neox = GPTNeoXModel(config)
1092
+ self.embed_out = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1093
+
1094
+ # Initialize weights and apply final processing
1095
+ self.post_init()
1096
+
1097
+ def get_output_embeddings(self):
1098
+ return self.embed_out
1099
+
1100
+ def set_output_embeddings(self, new_embeddings):
1101
+ self.embed_out = new_embeddings
1102
+
1103
+ @add_start_docstrings_to_model_forward(GPT_NEOX_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
1104
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1105
+ def forward(
1106
+ self,
1107
+ input_ids: Optional[torch.LongTensor] = None,
1108
+ attention_mask: Optional[torch.FloatTensor] = None,
1109
+ position_ids: Optional[torch.LongTensor] = None,
1110
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1111
+ head_mask: Optional[torch.FloatTensor] = None,
1112
+ past_key_values: Optional[Union[Cache, Tuple[Tuple[torch.FloatTensor]]]] = None,
1113
+ labels: Optional[torch.LongTensor] = None,
1114
+ use_cache: Optional[bool] = None,
1115
+ output_attentions: Optional[bool] = None,
1116
+ output_hidden_states: Optional[bool] = None,
1117
+ return_dict: Optional[bool] = None,
1118
+ cache_position: Optional[torch.LongTensor] = None,
1119
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1120
+ r"""
1121
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1122
+ Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
1123
+ `[-100, 0, ..., config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are
1124
+ ignored (masked), the loss is only computed for the tokens with labels n `[0, ..., config.vocab_size]`.
1125
+ use_cache (`bool`, *optional*):
1126
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
1127
+ `past_key_values`).
1128
+
1129
+ Returns:
1130
+
1131
+ Example:
1132
+
1133
+ ```python
1134
+ >>> from transformers import AutoTokenizer, GPTNeoXForCausalLM, GPTNeoXConfig
1135
+ >>> import torch
1136
+
1137
+ >>> tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
1138
+ >>> config = GPTNeoXConfig.from_pretrained("EleutherAI/gpt-neox-20b")
1139
+ >>> config.is_decoder = True
1140
+ >>> model = GPTNeoXForCausalLM.from_pretrained("EleutherAI/gpt-neox-20b", config=config)
1141
+
1142
+ >>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
1143
+ >>> outputs = model(**inputs)
1144
+
1145
+ >>> prediction_logits = outputs.logits
1146
+ ```"""
1147
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1148
+
1149
+ outputs = self.gpt_neox(
1150
+ input_ids,
1151
+ attention_mask=attention_mask,
1152
+ position_ids=position_ids,
1153
+ head_mask=head_mask,
1154
+ inputs_embeds=inputs_embeds,
1155
+ past_key_values=past_key_values,
1156
+ use_cache=use_cache,
1157
+ output_attentions=output_attentions,
1158
+ output_hidden_states=output_hidden_states,
1159
+ return_dict=return_dict,
1160
+ cache_position=cache_position,
1161
+ )
1162
+
1163
+ hidden_states = outputs[0]
1164
+ lm_logits = self.embed_out(hidden_states)
1165
+
1166
+ lm_loss = None
1167
+ if labels is not None:
1168
+ # move labels to correct device to enable model parallelism
1169
+ labels = labels.to(lm_logits.device)
1170
+ # we are doing next-token prediction; shift prediction scores and input ids by one
1171
+ shift_logits = lm_logits[:, :-1, :].contiguous()
1172
+ labels = labels[:, 1:].contiguous()
1173
+ loss_fct = CrossEntropyLoss()
1174
+ lm_loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), labels.view(-1))
1175
+
1176
+ if not return_dict:
1177
+ output = (lm_logits,) + outputs[1:]
1178
+ return ((lm_loss,) + output) if lm_loss is not None else output
1179
+
1180
+ return CausalLMOutputWithPast(
1181
+ loss=lm_loss,
1182
+ logits=lm_logits,
1183
+ past_key_values=outputs.past_key_values,
1184
+ hidden_states=outputs.hidden_states,
1185
+ attentions=outputs.attentions,
1186
+ )
1187
+
1188
+ # can't be copied from llama, gpt-neox has embed_out and not lm_head
1189
+ def prepare_inputs_for_generation(
1190
+ self,
1191
+ input_ids,
1192
+ past_key_values=None,
1193
+ attention_mask=None,
1194
+ inputs_embeds=None,
1195
+ cache_position=None,
1196
+ position_ids=None,
1197
+ use_cache=True,
1198
+ **kwargs,
1199
+ ):
1200
+ # If we have cache: let's slice `input_ids` through `cache_position`, to keep only the unprocessed tokens
1201
+ # Exception 1: when passing input_embeds, input_ids may be missing entries
1202
+ # Exception 2: some generation methods do special slicing of input_ids, so we don't need to do it here
1203
+ if past_key_values is not None:
1204
+ if inputs_embeds is not None: # Exception 1
1205
+ input_ids = input_ids[:, -cache_position.shape[0] :]
1206
+ elif input_ids.shape[1] != cache_position.shape[0]: # Default case (the "else", a no op, is Exception 2)
1207
+ input_ids = input_ids[:, cache_position]
1208
+
1209
+ if attention_mask is not None and position_ids is None:
1210
+ # create position_ids on the fly for batch generation
1211
+ position_ids = attention_mask.long().cumsum(-1) - 1
1212
+ position_ids.masked_fill_(attention_mask == 0, 1)
1213
+ if past_key_values:
1214
+ position_ids = position_ids[:, -input_ids.shape[1] :]
1215
+
1216
+ # This `clone` call is needed to avoid recapturing cuda graphs with `torch.compile`'s `mode="reduce-overhead`, as otherwise the input `position_ids` would have various stride during the decoding. Here, simply using `.contiguous()` is not sufficient as in the batch size = 1 case, `position_ids` is already contiguous but with varying stride which retriggers a capture.
1217
+ position_ids = position_ids.clone(memory_format=torch.contiguous_format)
1218
+
1219
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
1220
+ if inputs_embeds is not None and cache_position[0] == 0:
1221
+ model_inputs = {"inputs_embeds": inputs_embeds, "input_ids": None}
1222
+ else:
1223
+ # The clone here is for the same reason as for `position_ids`.
1224
+ model_inputs = {"input_ids": input_ids.clone(memory_format=torch.contiguous_format), "inputs_embeds": None}
1225
+
1226
+ if isinstance(past_key_values, StaticCache) and attention_mask.ndim == 2:
1227
+ if model_inputs["inputs_embeds"] is not None:
1228
+ batch_size, sequence_length, _ = model_inputs["inputs_embeds"].shape
1229
+ device = model_inputs["inputs_embeds"].device
1230
+ else:
1231
+ batch_size, sequence_length = model_inputs["input_ids"].shape
1232
+ device = model_inputs["input_ids"].device
1233
+
1234
+ dtype = self.embed_out.weight.dtype
1235
+ min_dtype = torch.finfo(dtype).min
1236
+
1237
+ attention_mask = _prepare_4d_causal_attention_mask_with_cache_position(
1238
+ attention_mask,
1239
+ sequence_length=sequence_length,
1240
+ target_length=past_key_values.get_max_length(),
1241
+ dtype=dtype,
1242
+ device=device,
1243
+ min_dtype=min_dtype,
1244
+ cache_position=cache_position,
1245
+ batch_size=batch_size,
1246
+ )
1247
+
1248
+ model_inputs.update(
1249
+ {
1250
+ "position_ids": position_ids,
1251
+ "cache_position": cache_position,
1252
+ "past_key_values": past_key_values,
1253
+ "use_cache": use_cache,
1254
+ "attention_mask": attention_mask,
1255
+ }
1256
+ )
1257
+ return model_inputs
1258
+
1259
+ def _reorder_cache(self, past_key_values, beam_idx):
1260
+ reordered_past = ()
1261
+ for layer_past in past_key_values:
1262
+ reordered_past += (
1263
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past[:2])
1264
+ + layer_past[2:],
1265
+ )
1266
+ return reordered_past
1267
+
1268
+
1269
+ @add_start_docstrings(
1270
+ """
1271
+ The GPTNeoX Model transformer with a sequence classification head on top (linear layer).
1272
+
1273
+ [`GPTNeoXForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1274
+ (e.g. GPT-1) do.
1275
+
1276
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1277
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1278
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1279
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1280
+ each row of the batch).
1281
+ """,
1282
+ GPT_NEOX_START_DOCSTRING,
1283
+ )
1284
+ class GPTNeoXForSequenceClassification(GPTNeoXPreTrainedModel):
1285
+ def __init__(self, config):
1286
+ super().__init__(config)
1287
+ self.num_labels = config.num_labels
1288
+ self.gpt_neox = GPTNeoXModel(config)
1289
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1290
+
1291
+ # Initialize weights and apply final processing
1292
+ self.post_init()
1293
+
1294
+ @add_start_docstrings_to_model_forward(GPT_NEOX_INPUTS_DOCSTRING)
1295
+ @add_code_sample_docstrings(
1296
+ checkpoint=_CHECKPOINT_FOR_DOC,
1297
+ output_type=SequenceClassifierOutputWithPast,
1298
+ config_class=_CONFIG_FOR_DOC,
1299
+ )
1300
+ def forward(
1301
+ self,
1302
+ input_ids: Optional[torch.LongTensor] = None,
1303
+ attention_mask: Optional[torch.FloatTensor] = None,
1304
+ position_ids: Optional[torch.LongTensor] = None,
1305
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1306
+ head_mask: Optional[torch.FloatTensor] = None,
1307
+ past_key_values: Optional[Union[Cache, Tuple[Tuple[torch.FloatTensor]]]] = None,
1308
+ labels: Optional[torch.LongTensor] = None,
1309
+ use_cache: Optional[bool] = None,
1310
+ output_attentions: Optional[bool] = None,
1311
+ output_hidden_states: Optional[bool] = None,
1312
+ return_dict: Optional[bool] = None,
1313
+ ) -> Union[Tuple[torch.Tensor], SequenceClassifierOutputWithPast]:
1314
+ r"""
1315
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1316
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1317
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1318
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1319
+ """
1320
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1321
+
1322
+ outputs = self.gpt_neox(
1323
+ input_ids,
1324
+ attention_mask=attention_mask,
1325
+ position_ids=position_ids,
1326
+ head_mask=head_mask,
1327
+ inputs_embeds=inputs_embeds,
1328
+ past_key_values=past_key_values,
1329
+ use_cache=use_cache,
1330
+ output_attentions=output_attentions,
1331
+ output_hidden_states=output_hidden_states,
1332
+ return_dict=return_dict,
1333
+ )
1334
+ hidden_states = outputs[0]
1335
+ logits = self.score(hidden_states)
1336
+
1337
+ if input_ids is not None:
1338
+ batch_size, sequence_length = input_ids.shape[:2]
1339
+ else:
1340
+ batch_size, sequence_length = inputs_embeds.shape[:2]
1341
+
1342
+ if self.config.pad_token_id is None and batch_size != 1:
1343
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1344
+ if self.config.pad_token_id is None:
1345
+ sequence_lengths = -1
1346
+ else:
1347
+ if input_ids is not None:
1348
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1349
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1350
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1351
+ sequence_lengths = sequence_lengths.to(logits.device)
1352
+ else:
1353
+ sequence_lengths = -1
1354
+ logger.warning_once(
1355
+ f"{self.__class__.__name__} will not detect padding tokens in `inputs_embeds`. Results may be "
1356
+ "unexpected if using padding tokens in conjunction with `inputs_embeds.`"
1357
+ )
1358
+
1359
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1360
+
1361
+ loss = None
1362
+ if labels is not None:
1363
+ labels = labels.to(logits.device)
1364
+ if self.config.problem_type is None:
1365
+ if self.num_labels == 1:
1366
+ self.config.problem_type = "regression"
1367
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1368
+ self.config.problem_type = "single_label_classification"
1369
+ else:
1370
+ self.config.problem_type = "multi_label_classification"
1371
+
1372
+ if self.config.problem_type == "regression":
1373
+ loss_fct = MSELoss()
1374
+ if self.num_labels == 1:
1375
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1376
+ else:
1377
+ loss = loss_fct(pooled_logits, labels)
1378
+ elif self.config.problem_type == "single_label_classification":
1379
+ loss_fct = CrossEntropyLoss()
1380
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1381
+ elif self.config.problem_type == "multi_label_classification":
1382
+ loss_fct = BCEWithLogitsLoss()
1383
+ loss = loss_fct(pooled_logits, labels)
1384
+ if not return_dict:
1385
+ output = (pooled_logits,) + outputs[1:]
1386
+ return ((loss,) + output) if loss is not None else output
1387
+
1388
+ return SequenceClassifierOutputWithPast(
1389
+ loss=loss,
1390
+ logits=pooled_logits,
1391
+ past_key_values=outputs.past_key_values,
1392
+ hidden_states=outputs.hidden_states,
1393
+ attentions=outputs.attentions,
1394
+ )
1395
+
1396
+
1397
+ class GPTNeoXForTokenClassification(GPTNeoXPreTrainedModel):
1398
+ def __init__(self, config):
1399
+ super().__init__(config)
1400
+ self.num_labels = config.num_labels
1401
+
1402
+ self.gpt_neox = GPTNeoXModel(config)
1403
+ self.dropout = nn.Dropout(config.classifier_dropout)
1404
+ self.classifier = nn.Linear(config.hidden_size, config.num_labels)
1405
+
1406
+ # Initialize weights and apply final processing
1407
+ self.post_init()
1408
+
1409
+ @add_start_docstrings_to_model_forward(GPT_NEOX_INPUTS_DOCSTRING)
1410
+ @add_code_sample_docstrings(
1411
+ checkpoint="LarsJonasson/pythia-410m-deduped-sft-swedish",
1412
+ output_type=TokenClassifierOutput,
1413
+ config_class=_CONFIG_FOR_DOC,
1414
+ expected_loss=0.25,
1415
+ )
1416
+ def forward(
1417
+ self,
1418
+ input_ids: Optional[torch.LongTensor] = None,
1419
+ past_key_values: Optional[Union[Cache, Tuple[Tuple[torch.Tensor]]]] = None,
1420
+ attention_mask: Optional[torch.FloatTensor] = None,
1421
+ token_type_ids: Optional[torch.LongTensor] = None,
1422
+ position_ids: Optional[torch.LongTensor] = None,
1423
+ head_mask: Optional[torch.FloatTensor] = None,
1424
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1425
+ labels: Optional[torch.LongTensor] = None,
1426
+ use_cache: Optional[bool] = None,
1427
+ output_attentions: Optional[bool] = None,
1428
+ output_hidden_states: Optional[bool] = None,
1429
+ return_dict: Optional[bool] = None,
1430
+ ) -> Union[Tuple, TokenClassifierOutput]:
1431
+ r"""
1432
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1433
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1434
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1435
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1436
+ """
1437
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1438
+
1439
+ outputs = self.gpt_neox(
1440
+ input_ids,
1441
+ past_key_values=past_key_values,
1442
+ attention_mask=attention_mask,
1443
+ position_ids=position_ids,
1444
+ head_mask=head_mask,
1445
+ inputs_embeds=inputs_embeds,
1446
+ use_cache=use_cache,
1447
+ output_attentions=output_attentions,
1448
+ output_hidden_states=output_hidden_states,
1449
+ return_dict=return_dict,
1450
+ )
1451
+
1452
+ hidden_states = outputs[0]
1453
+ hidden_states = self.dropout(hidden_states)
1454
+ logits = self.classifier(hidden_states)
1455
+
1456
+ loss = None
1457
+ if labels is not None:
1458
+ labels = labels.to(logits.device)
1459
+ loss_fct = CrossEntropyLoss()
1460
+ loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
1461
+
1462
+ if not return_dict:
1463
+ output = (logits,) + outputs[2:]
1464
+ return ((loss,) + output) if loss is not None else output
1465
+
1466
+ return TokenClassifierOutput(
1467
+ loss=loss,
1468
+ logits=logits,
1469
+ hidden_states=outputs.hidden_states,
1470
+ attentions=outputs.attentions,
1471
+ )
1472
+
1473
+
1474
+ @add_start_docstrings(
1475
+ """
1476
+ The GPT-NeoX Model transformer with a span classification head on top for extractive question-answering tasks like
1477
+ SQuAD (a linear layer on top of the hidden-states output to compute `span start logits` and `span end logits`).
1478
+ """,
1479
+ GPT_NEOX_START_DOCSTRING,
1480
+ )
1481
+ class GPTNeoXForQuestionAnswering(GPTNeoXPreTrainedModel):
1482
+ def __init__(self, config):
1483
+ super().__init__(config)
1484
+ self.num_labels = config.num_labels
1485
+ self.gpt_neox = GPTNeoXModel(config)
1486
+ self.qa_outputs = nn.Linear(config.hidden_size, 2)
1487
+
1488
+ # Initialize weights and apply final processing
1489
+ self.post_init()
1490
+
1491
+ @add_start_docstrings_to_model_forward(GPT_NEOX_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
1492
+ @add_code_sample_docstrings(
1493
+ checkpoint=_CHECKPOINT_FOR_DOC,
1494
+ output_type=QuestionAnsweringModelOutput,
1495
+ config_class=_CONFIG_FOR_DOC,
1496
+ real_checkpoint=_REAL_CHECKPOINT_FOR_DOC,
1497
+ )
1498
+ def forward(
1499
+ self,
1500
+ input_ids: Optional[torch.LongTensor] = None,
1501
+ attention_mask: Optional[torch.FloatTensor] = None,
1502
+ token_type_ids: Optional[torch.LongTensor] = None,
1503
+ position_ids: Optional[torch.LongTensor] = None,
1504
+ head_mask: Optional[torch.FloatTensor] = None,
1505
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1506
+ start_positions: Optional[torch.LongTensor] = None,
1507
+ end_positions: Optional[torch.LongTensor] = None,
1508
+ output_attentions: Optional[bool] = None,
1509
+ output_hidden_states: Optional[bool] = None,
1510
+ return_dict: Optional[bool] = None,
1511
+ ) -> Union[Tuple, QuestionAnsweringModelOutput]:
1512
+ r"""
1513
+ start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1514
+ Labels for position (index) of the start of the labelled span for computing the token classification loss.
1515
+ Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
1516
+ are not taken into account for computing the loss.
1517
+ end_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1518
+ Labels for position (index) of the end of the labelled span for computing the token classification loss.
1519
+ Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
1520
+ are not taken into account for computing the loss.
1521
+ """
1522
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1523
+
1524
+ outputs = self.gpt_neox(
1525
+ input_ids,
1526
+ attention_mask=attention_mask,
1527
+ position_ids=position_ids,
1528
+ head_mask=head_mask,
1529
+ inputs_embeds=inputs_embeds,
1530
+ output_attentions=output_attentions,
1531
+ output_hidden_states=output_hidden_states,
1532
+ return_dict=return_dict,
1533
+ )
1534
+
1535
+ sequence_output = outputs[0]
1536
+
1537
+ logits = self.qa_outputs(sequence_output)
1538
+ start_logits, end_logits = logits.split(1, dim=-1)
1539
+ start_logits = start_logits.squeeze(-1).contiguous()
1540
+ end_logits = end_logits.squeeze(-1).contiguous()
1541
+
1542
+ total_loss = None
1543
+ if start_positions is not None and end_positions is not None:
1544
+ # If we are on multi-GPU, split add a dimension
1545
+ if len(start_positions.size()) > 1:
1546
+ start_positions = start_positions.squeeze(-1).to(start_logits.device)
1547
+ if len(end_positions.size()) > 1:
1548
+ end_positions = end_positions.squeeze(-1).to(end_logits.device)
1549
+ # sometimes the start/end positions are outside our model inputs, we ignore these terms
1550
+ ignored_index = start_logits.size(1)
1551
+ start_positions = start_positions.clamp(0, ignored_index)
1552
+ end_positions = end_positions.clamp(0, ignored_index)
1553
+
1554
+ loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
1555
+ start_loss = loss_fct(start_logits, start_positions)
1556
+ end_loss = loss_fct(end_logits, end_positions)
1557
+ total_loss = (start_loss + end_loss) / 2
1558
+
1559
+ if not return_dict:
1560
+ output = (start_logits, end_logits) + outputs[2:]
1561
+ return ((total_loss,) + output) if total_loss is not None else output
1562
+
1563
+ return QuestionAnsweringModelOutput(
1564
+ loss=total_loss,
1565
+ start_logits=start_logits,
1566
+ end_logits=end_logits,
1567
+ hidden_states=outputs.hidden_states,
1568
+ attentions=outputs.attentions,
1569
+ )
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|padding|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "50254": {
23
+ "content": " ",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "50255": {
31
+ "content": " ",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": false
37
+ },
38
+ "50256": {
39
+ "content": " ",
40
+ "lstrip": false,
41
+ "normalized": true,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "50257": {
47
+ "content": " ",
48
+ "lstrip": false,
49
+ "normalized": true,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "50258": {
55
+ "content": " ",
56
+ "lstrip": false,
57
+ "normalized": true,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "50259": {
63
+ "content": " ",
64
+ "lstrip": false,
65
+ "normalized": true,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "50260": {
71
+ "content": " ",
72
+ "lstrip": false,
73
+ "normalized": true,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": false
77
+ },
78
+ "50261": {
79
+ "content": " ",
80
+ "lstrip": false,
81
+ "normalized": true,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": false
85
+ },
86
+ "50262": {
87
+ "content": " ",
88
+ "lstrip": false,
89
+ "normalized": true,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": false
93
+ },
94
+ "50263": {
95
+ "content": " ",
96
+ "lstrip": false,
97
+ "normalized": true,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": false
101
+ },
102
+ "50264": {
103
+ "content": " ",
104
+ "lstrip": false,
105
+ "normalized": true,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": false
109
+ },
110
+ "50265": {
111
+ "content": " ",
112
+ "lstrip": false,
113
+ "normalized": true,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": false
117
+ },
118
+ "50266": {
119
+ "content": " ",
120
+ "lstrip": false,
121
+ "normalized": true,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "50267": {
127
+ "content": " ",
128
+ "lstrip": false,
129
+ "normalized": true,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "50268": {
135
+ "content": " ",
136
+ "lstrip": false,
137
+ "normalized": true,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "50269": {
143
+ "content": " ",
144
+ "lstrip": false,
145
+ "normalized": true,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "50270": {
151
+ "content": " ",
152
+ "lstrip": false,
153
+ "normalized": true,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "50271": {
159
+ "content": " ",
160
+ "lstrip": false,
161
+ "normalized": true,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "50272": {
167
+ "content": " ",
168
+ "lstrip": false,
169
+ "normalized": true,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "50273": {
175
+ "content": " ",
176
+ "lstrip": false,
177
+ "normalized": true,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "50274": {
183
+ "content": " ",
184
+ "lstrip": false,
185
+ "normalized": true,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "50275": {
191
+ "content": " ",
192
+ "lstrip": false,
193
+ "normalized": true,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "50276": {
199
+ "content": " ",
200
+ "lstrip": false,
201
+ "normalized": true,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ }
206
+ },
207
+ "bos_token": "<|endoftext|>",
208
+ "clean_up_tokenization_spaces": true,
209
+ "eos_token": "<|endoftext|>",
210
+ "extra_special_tokens": {},
211
+ "model_max_length": 1000000000000000019884624838656,
212
+ "pad_token": "<|endoftext|>",
213
+ "tokenizer_class": "GPTNeoXTokenizer",
214
+ "unk_token": "<|endoftext|>"
215
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16bb5f9341aac44319789787905b9f8cd32fdefcafde13dd02317a8f825218ad
3
+ size 5432