BraylonDash commited on
Commit
38cf547
1 Parent(s): 0caa5c2

End of training

Browse files
Files changed (3) hide show
  1. README.md +5 -2
  2. config.json +34 -0
  3. configuration_phi.py +194 -0
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
  library_name: peft
3
  tags:
 
 
4
  - trl
5
  - dpo
6
- - generated_from_trainer
7
  base_model: DUAL-GPO/phi-2-ipo-chatml-merged
 
 
8
  model-index:
9
  - name: phi-2-ipo-chatml-lora-20k-40k-i1
10
  results: []
@@ -15,7 +18,7 @@ should probably proofread and complete it, then remove this comment. -->
15
 
16
  # phi-2-ipo-chatml-lora-20k-40k-i1
17
 
18
- This model was trained from scratch on the None dataset.
19
 
20
  ## Model description
21
 
 
1
  ---
2
  library_name: peft
3
  tags:
4
+ - alignment-handbook
5
+ - generated_from_trainer
6
  - trl
7
  - dpo
 
8
  base_model: DUAL-GPO/phi-2-ipo-chatml-merged
9
+ datasets:
10
+ - HuggingFaceH4/ultrafeedback_binarized
11
  model-index:
12
  - name: phi-2-ipo-chatml-lora-20k-40k-i1
13
  results: []
 
18
 
19
  # phi-2-ipo-chatml-lora-20k-40k-i1
20
 
21
+ This model is a fine-tuned version of [DUAL-GPO/phi-2-ipo-chatml-merged](https://huggingface.co/DUAL-GPO/phi-2-ipo-chatml-merged) on the HuggingFaceH4/ultrafeedback_binarized dataset.
22
 
23
  ## Model description
24
 
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "DUAL-GPO/phi-2-ipo-chatml-merged",
3
+ "architectures": [
4
+ "PhiForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_phi.PhiConfig",
9
+ "AutoModelForCausalLM": "DUAL-GPO/phi-2-sft-lora-ultrachat-merged--modeling_phi.PhiForCausalLM"
10
+ },
11
+ "bos_token_id": 50256,
12
+ "embd_pdrop": 0.0,
13
+ "eos_token_id": 50256,
14
+ "hidden_act": "gelu_new",
15
+ "hidden_size": 2560,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 10240,
18
+ "layer_norm_eps": 1e-05,
19
+ "max_position_embeddings": 2048,
20
+ "model_type": "phi",
21
+ "num_attention_heads": 32,
22
+ "num_hidden_layers": 32,
23
+ "num_key_value_heads": 32,
24
+ "partial_rotary_factor": 0.4,
25
+ "qk_layernorm": false,
26
+ "resid_pdrop": 0.1,
27
+ "rope_scaling": null,
28
+ "rope_theta": 10000.0,
29
+ "tie_word_embeddings": false,
30
+ "torch_dtype": "bfloat16",
31
+ "transformers_version": "4.36.2",
32
+ "use_cache": true,
33
+ "vocab_size": 51200
34
+ }
configuration_phi.py ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 Microsoft 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
+
16
+ """ Phi model configuration"""
17
+
18
+
19
+ from transformers.configuration_utils import PretrainedConfig
20
+ from transformers.utils import logging
21
+
22
+
23
+ logger = logging.get_logger(__name__)
24
+
25
+ PHI_PRETRAINED_CONFIG_ARCHIVE_MAP = {
26
+ "microsoft/phi-2": "https://huggingface.co/microsoft/phi-2/resolve/main/config.json",
27
+ "DUAL-GPO/phi-2-sft-lora-ultrachat-merged" : "https://huggingface.co/DUAL-GPO/phi-2-sft-lora-ultrachat-merged/blob/main/config.json"
28
+ }
29
+
30
+
31
+ class PhiConfig(PretrainedConfig):
32
+ r"""
33
+ This is the configuration class to store the configuration of a [`PhiModel`]. It is used to instantiate an Phi
34
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
35
+ defaults will yield a similar configuration to that of the Phi
36
+ [microsoft/phi-1](https://huggingface.co/microsoft/phi-1).
37
+
38
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
39
+ documentation from [`PretrainedConfig`] for more information.
40
+
41
+ Args:
42
+ vocab_size (`int`, *optional*, defaults to 51200):
43
+ Vocabulary size of the Phi model. Defines the number of different tokens that can be represented by the
44
+ `inputs_ids` passed when calling [`PhiModel`].
45
+ hidden_size (`int`, *optional*, defaults to 2048):
46
+ Dimension of the hidden representations.
47
+ intermediate_size (`int`, *optional*, defaults to 8192):
48
+ Dimension of the MLP representations.
49
+ num_hidden_layers (`int`, *optional*, defaults to 24):
50
+ Number of hidden layers in the Transformer decoder.
51
+ num_attention_heads (`int`, *optional*, defaults to 32):
52
+ Number of attention heads for each attention layer in the Transformer decoder.
53
+ num_key_value_heads (`int`, *optional*):
54
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
55
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
56
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
57
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
58
+ by meanpooling all the original heads within that group. For more details checkout [this
59
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
60
+ `num_attention_heads`.
61
+ resid_pdrop (`float`, *optional*, defaults to 0.0):
62
+ Dropout probability for mlp outputs.
63
+ embd_pdrop (`int`, *optional*, defaults to 0.0):
64
+ The dropout ratio for the embeddings.
65
+ attention_dropout (`float`, *optional*, defaults to 0.0):
66
+ The dropout ratio after computing the attention scores.
67
+ hidden_act (`str` or `function`, *optional*, defaults to `"gelu_new"`):
68
+ The non-linear activation function (function or string) in the decoder.
69
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
70
+ The maximum sequence length that this model might ever be used with. Phi-1 and Phi-1.5 supports up to 2048
71
+ tokens.
72
+ initializer_range (`float`, *optional*, defaults to 0.02):
73
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
74
+ layer_norm_eps (`float`, *optional*, defaults to 1e-05):
75
+ The epsilon used by the rms normalization layers.
76
+ use_cache (`bool`, *optional*, defaults to `True`):
77
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
78
+ relevant if `config.is_decoder=True`. Whether to tie weight embeddings or not.
79
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
80
+ Whether to tie weight embeddings
81
+ rope_theta (`float`, *optional*, defaults to 10000.0):
82
+ The base period of the RoPE embeddings.
83
+ rope_scaling (`Dict`, *optional*):
84
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
85
+ strategies: linear and dynamic. Their scaling factor must be an float greater than 1. The expected format
86
+ is `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
87
+ `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
88
+ these scaling strategies behave:
89
+ https://www.reddit.com/r/LocalPersimmon/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This
90
+ is an experimental feature, subject to breaking API changes in future versions.
91
+ partial_rotary_factor (`float`, *optional*, defaults to 0.5):
92
+ Percentage of the query and keys which will have rotary embedding.
93
+ qk_layernorm (`bool`, *optional*, defaults to `False`):
94
+ Whether or not to normalize the Queries and Keys after projecting the hidden states.
95
+ bos_token_id (`int`, *optional*, defaults to 1):
96
+ Denotes beginning of sequences token id.
97
+ eos_token_id (`int`, *optional*, defaults to 2):
98
+ Denotes end of sequences token id.
99
+
100
+ Example:
101
+
102
+ ```python
103
+ >>> from transformers import PhiModel, PhiConfig
104
+
105
+ >>> # Initializing a Phi-1 style configuration
106
+ >>> configuration = PhiConfig.from_pretrained("microsoft/phi-1")
107
+
108
+ >>> # Initializing a model from the configuration
109
+ >>> model = PhiModel(configuration)
110
+
111
+ >>> # Accessing the model configuration
112
+ >>> configuration = model.config
113
+ ```"""
114
+
115
+ model_type = "phi"
116
+ keys_to_ignore_at_inference = ["past_key_values"]
117
+
118
+ def __init__(
119
+ self,
120
+ vocab_size=51200,
121
+ hidden_size=2048,
122
+ intermediate_size=8192,
123
+ num_hidden_layers=24,
124
+ num_attention_heads=32,
125
+ num_key_value_heads=None,
126
+ resid_pdrop=0.0,
127
+ embd_pdrop=0.0,
128
+ attention_dropout=0.0,
129
+ hidden_act="gelu_new",
130
+ max_position_embeddings=2048,
131
+ initializer_range=0.02,
132
+ layer_norm_eps=1e-5,
133
+ use_cache=True,
134
+ tie_word_embeddings=False,
135
+ rope_theta=10000.0,
136
+ rope_scaling=None,
137
+ partial_rotary_factor=0.5,
138
+ qk_layernorm=False,
139
+ bos_token_id=1,
140
+ eos_token_id=2,
141
+ **kwargs,
142
+ ):
143
+ self.vocab_size = vocab_size
144
+ self.hidden_size = hidden_size
145
+ self.intermediate_size = intermediate_size
146
+ self.num_hidden_layers = num_hidden_layers
147
+ self.num_attention_heads = num_attention_heads
148
+
149
+ if num_key_value_heads is None:
150
+ num_key_value_heads = num_attention_heads
151
+
152
+ self.num_key_value_heads = num_key_value_heads
153
+ self.resid_pdrop = resid_pdrop
154
+ self.embd_pdrop = embd_pdrop
155
+ self.attention_dropout = attention_dropout
156
+ self.hidden_act = hidden_act
157
+ self.max_position_embeddings = max_position_embeddings
158
+ self.initializer_range = initializer_range
159
+ self.layer_norm_eps = layer_norm_eps
160
+ self.use_cache = use_cache
161
+ self.rope_theta = rope_theta
162
+ self.rope_scaling = rope_scaling
163
+ self.partial_rotary_factor = partial_rotary_factor
164
+ self.qk_layernorm = qk_layernorm
165
+ self._rope_scaling_validation()
166
+
167
+ super().__init__(
168
+ bos_token_id=bos_token_id,
169
+ eos_token_id=eos_token_id,
170
+ tie_word_embeddings=tie_word_embeddings,
171
+ **kwargs,
172
+ )
173
+
174
+ # Copied from transformers.models.llama.configuration_llama.LlamaConfig._rope_scaling_validation
175
+ def _rope_scaling_validation(self):
176
+ """
177
+ Validate the `rope_scaling` configuration.
178
+ """
179
+ if self.rope_scaling is None:
180
+ return
181
+
182
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
183
+ raise ValueError(
184
+ "`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, "
185
+ f"got {self.rope_scaling}"
186
+ )
187
+ rope_scaling_type = self.rope_scaling.get("type", None)
188
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
189
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
190
+ raise ValueError(
191
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
192
+ )
193
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
194
+ raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")