Upload folder using huggingface_hub
Browse files- README.md +10 -10
- config.json +6 -65
- generation_config.json +2 -2
- merges.txt +0 -1
README.md
CHANGED
@@ -65,8 +65,8 @@ To construct this dataset, we propose an efficient data construction pipeline. S
|
|
65 |
|
66 |
- **For samples with clear ground truths:**
|
67 |
the model is prompted to first provide the reasoning process and then give the final answer in the format like `Final Answer: ***`.
|
68 |
-
Responses matching the ground truth answer constitute the positive set
|
69 |
-
Given these responses labeled as positive or negative, we build the preference pairs by selecting a chosen response
|
70 |
|
71 |
- **For samples without clear ground truths:**
|
72 |
we propose a simple yet effective method: Dropout Next-Token Prediction (Dropout NTP).
|
@@ -85,16 +85,16 @@ The data construction pipeline is open-sourced, see more details in our [documen
|
|
85 |
### Mixed Preference Optimization
|
86 |
|
87 |
The key insight behind MPO is that *an effective PO process should enable the model to learn the relative preference between pairs of responses, the absolute quality of individual responses, and the process for generating preferred responses.* We define the training objective as a combination of
|
88 |
-
preference loss
|
89 |
-
quality loss
|
90 |
-
and generation loss
|
91 |
referred to as Mixed Preference Optimization:
|
92 |
|
93 |
$$
|
94 |
\mathcal{L}=w_{p}\cdot\mathcal{L}_{\text{p}} + w_{q}\cdot\mathcal{L}_{\text{q}} + w_{g}\cdot\mathcal{L}_{\text{g}},
|
95 |
$$
|
96 |
|
97 |
-
where
|
98 |
In this work, we empirically compare different variants of preference loss.
|
99 |
Based on the experimental results, we use DPO as our preference loss and BCO as our quality loss.
|
100 |
|
@@ -106,8 +106,8 @@ $$
|
|
106 |
\mathcal{L}_{\text{p}}=-\log \sigma\left(\beta \log \frac{\pi_\theta\left(y_c \mid x\right)}{\pi_0\left(y_c \mid x\right)}-\beta \log \frac{\pi_\theta\left(y_r \mid x\right)}{\pi_0\left(y_r \mid x\right)}\right),
|
107 |
$$
|
108 |
|
109 |
-
where
|
110 |
-
The policy model
|
111 |
|
112 |
Additionally, the BCO loss is employed as the quality loss, which helps the model to understand the absolute quality of individual responses.
|
113 |
The loss function is defined as:
|
@@ -116,7 +116,7 @@ $$
|
|
116 |
\mathcal{L}_{\text{q}}=\mathcal{L}_{\text{q}}^+ + \mathcal{L}_{\text{q}}^-,
|
117 |
$$
|
118 |
|
119 |
-
where
|
120 |
Each response type's loss is calculated independently, requiring the model to differentiate the absolute quality of individual responses. The loss terms are given by:
|
121 |
|
122 |
$$
|
@@ -127,7 +127,7 @@ $$
|
|
127 |
\mathcal{L}_{\text{q}}^-=-\log \sigma\left(-\left(\beta \log \frac{\pi_\theta\left(y_r \mid x\right)}{\pi_0\left(y_r \mid x\right)} - \delta\right) \right),
|
128 |
$$
|
129 |
|
130 |
-
where
|
131 |
|
132 |
Finally, the SFT loss is used as the generation loss to help the model learn the generation process of preferred responses.
|
133 |
The loss function is defined as:
|
|
|
65 |
|
66 |
- **For samples with clear ground truths:**
|
67 |
the model is prompted to first provide the reasoning process and then give the final answer in the format like `Final Answer: ***`.
|
68 |
+
Responses matching the ground truth answer constitute the positive set \\(mathcal{Y}_p\\), while those that do not match make up the negative set \\(\mathcal{Y}_n\\). Additionally, responses that fail to provide a clear final answer are also merged into \\(\mathcal{Y}_n\\).
|
69 |
+
Given these responses labeled as positive or negative, we build the preference pairs by selecting a chosen response \\(y_c\\) from \\(\mathcal{Y}_p\\) and a negative response \\(y_r\\) from \\(\mathcal{Y}_n\\).
|
70 |
|
71 |
- **For samples without clear ground truths:**
|
72 |
we propose a simple yet effective method: Dropout Next-Token Prediction (Dropout NTP).
|
|
|
85 |
### Mixed Preference Optimization
|
86 |
|
87 |
The key insight behind MPO is that *an effective PO process should enable the model to learn the relative preference between pairs of responses, the absolute quality of individual responses, and the process for generating preferred responses.* We define the training objective as a combination of
|
88 |
+
preference loss \\(\mathcal{L}_{\text{p}}\\),
|
89 |
+
quality loss \\(\mathcal{L}_{\text{q}}\\),
|
90 |
+
and generation loss \\(\mathcal{L}_{\text{g}}\\),
|
91 |
referred to as Mixed Preference Optimization:
|
92 |
|
93 |
$$
|
94 |
\mathcal{L}=w_{p}\cdot\mathcal{L}_{\text{p}} + w_{q}\cdot\mathcal{L}_{\text{q}} + w_{g}\cdot\mathcal{L}_{\text{g}},
|
95 |
$$
|
96 |
|
97 |
+
where \\(w_{*}\\) represents the weight assigned to each loss component.
|
98 |
In this work, we empirically compare different variants of preference loss.
|
99 |
Based on the experimental results, we use DPO as our preference loss and BCO as our quality loss.
|
100 |
|
|
|
106 |
\mathcal{L}_{\text{p}}=-\log \sigma\left(\beta \log \frac{\pi_\theta\left(y_c \mid x\right)}{\pi_0\left(y_c \mid x\right)}-\beta \log \frac{\pi_\theta\left(y_r \mid x\right)}{\pi_0\left(y_r \mid x\right)}\right),
|
107 |
$$
|
108 |
|
109 |
+
where \\(\beta\\) is the KL penalty coefficient, and \\(x\\), \\(y_c\\), and \\(y_r\\) are user query, chosen response, and rejected response, respectively.
|
110 |
+
The policy model \\(\pi_\theta\\) is initialized from model \\(\pi_0\\).
|
111 |
|
112 |
Additionally, the BCO loss is employed as the quality loss, which helps the model to understand the absolute quality of individual responses.
|
113 |
The loss function is defined as:
|
|
|
116 |
\mathcal{L}_{\text{q}}=\mathcal{L}_{\text{q}}^+ + \mathcal{L}_{\text{q}}^-,
|
117 |
$$
|
118 |
|
119 |
+
where \\(\mathcal{L}_{\text{q}}^{+}\\) and \\(\mathcal{L}_{\text{q}}^{+}\\) represent the loss for chosen and rejected responses, respectively.
|
120 |
Each response type's loss is calculated independently, requiring the model to differentiate the absolute quality of individual responses. The loss terms are given by:
|
121 |
|
122 |
$$
|
|
|
127 |
\mathcal{L}_{\text{q}}^-=-\log \sigma\left(-\left(\beta \log \frac{\pi_\theta\left(y_r \mid x\right)}{\pi_0\left(y_r \mid x\right)} - \delta\right) \right),
|
128 |
$$
|
129 |
|
130 |
+
where \\(\delta\\) represents the reward shift, calculated as the moving average of previous rewards to stabilize training.
|
131 |
|
132 |
Finally, the SFT loss is used as the generation loss to help the model learn the generation process of preferred responses.
|
133 |
The loss function is defined as:
|
config.json
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
{
|
2 |
"_commit_hash": null,
|
3 |
-
"_name_or_path": "/mnt/petrelfs/share_data/wangweiyun/share_internvl/InternVL2_5-38B",
|
4 |
"architectures": [
|
5 |
"InternVLChatModel"
|
6 |
],
|
@@ -12,13 +11,13 @@
|
|
12 |
"downsample_ratio": 0.5,
|
13 |
"dynamic_image_size": true,
|
14 |
"force_image_size": 448,
|
15 |
-
"hidden_size": 5120,
|
16 |
"llm_config": {
|
17 |
"_name_or_path": "Qwen/Qwen2.5-32B-Instruct",
|
18 |
"add_cross_attention": false,
|
19 |
"architectures": [
|
20 |
"Qwen2ForCausalLM"
|
21 |
],
|
|
|
22 |
"attention_dropout": 0.0,
|
23 |
"bad_words_ids": null,
|
24 |
"begin_suppress_tokens": null,
|
@@ -74,10 +73,9 @@
|
|
74 |
"return_dict": true,
|
75 |
"return_dict_in_generate": false,
|
76 |
"rms_norm_eps": 1e-06,
|
77 |
-
"rope_scaling": null,
|
78 |
"rope_theta": 1000000.0,
|
79 |
"sep_token_id": null,
|
80 |
-
"sliding_window":
|
81 |
"suppress_tokens": null,
|
82 |
"task_specific_params": null,
|
83 |
"temperature": 1.0,
|
@@ -89,107 +87,50 @@
|
|
89 |
"top_p": 1.0,
|
90 |
"torch_dtype": "bfloat16",
|
91 |
"torchscript": false,
|
92 |
-
"transformers_version": "4.
|
93 |
"typical_p": 1.0,
|
94 |
"use_bfloat16": true,
|
95 |
-
"use_cache":
|
96 |
"use_sliding_window": false,
|
97 |
"vocab_size": 151674
|
98 |
},
|
99 |
"max_dynamic_patch": 12,
|
100 |
"min_dynamic_patch": 1,
|
101 |
"model_type": "internvl_chat",
|
102 |
-
"pad2square": false,
|
103 |
"ps_version": "v2",
|
104 |
"select_layer": -1,
|
105 |
"template": "internvl2_5",
|
106 |
-
"tie_word_embeddings": false,
|
107 |
"torch_dtype": "bfloat16",
|
108 |
-
"transformers_version": null,
|
109 |
"use_backbone_lora": 0,
|
110 |
"use_llm_lora": 0,
|
111 |
"use_thumbnail": true,
|
112 |
"vision_config": {
|
113 |
-
"_name_or_path": "",
|
114 |
-
"add_cross_attention": false,
|
115 |
"architectures": [
|
116 |
"InternVisionModel"
|
117 |
],
|
118 |
"attention_dropout": 0.0,
|
119 |
-
"
|
120 |
-
"begin_suppress_tokens": null,
|
121 |
-
"bos_token_id": null,
|
122 |
-
"chunk_size_feed_forward": 0,
|
123 |
-
"cross_attention_hidden_size": null,
|
124 |
-
"decoder_start_token_id": null,
|
125 |
-
"diversity_penalty": 0.0,
|
126 |
-
"do_sample": false,
|
127 |
-
"drop_path_rate": 0.4,
|
128 |
"dropout": 0.0,
|
129 |
-
"early_stopping": false,
|
130 |
-
"encoder_no_repeat_ngram_size": 0,
|
131 |
-
"eos_token_id": null,
|
132 |
-
"exponential_decay_length_penalty": null,
|
133 |
-
"finetuning_task": null,
|
134 |
-
"forced_bos_token_id": null,
|
135 |
-
"forced_eos_token_id": null,
|
136 |
"hidden_act": "gelu",
|
137 |
"hidden_size": 3200,
|
138 |
-
"id2label": {
|
139 |
-
"0": "LABEL_0",
|
140 |
-
"1": "LABEL_1"
|
141 |
-
},
|
142 |
"image_size": 448,
|
143 |
"initializer_factor": 0.1,
|
144 |
"initializer_range": 1e-10,
|
145 |
"intermediate_size": 12800,
|
146 |
-
"is_decoder": false,
|
147 |
-
"is_encoder_decoder": false,
|
148 |
-
"label2id": {
|
149 |
-
"LABEL_0": 0,
|
150 |
-
"LABEL_1": 1
|
151 |
-
},
|
152 |
"layer_norm_eps": 1e-06,
|
153 |
-
"length_penalty": 1.0,
|
154 |
-
"max_length": 20,
|
155 |
-
"min_length": 0,
|
156 |
"model_type": "intern_vit_6b",
|
157 |
-
"no_repeat_ngram_size": 0,
|
158 |
"norm_type": "rms_norm",
|
159 |
"num_attention_heads": 25,
|
160 |
-
"num_beam_groups": 1,
|
161 |
-
"num_beams": 1,
|
162 |
"num_channels": 3,
|
163 |
"num_hidden_layers": 45,
|
164 |
-
"num_return_sequences": 1,
|
165 |
"output_attentions": false,
|
166 |
"output_hidden_states": false,
|
167 |
-
"output_scores": false,
|
168 |
-
"pad_token_id": null,
|
169 |
"patch_size": 14,
|
170 |
-
"prefix": null,
|
171 |
-
"problem_type": null,
|
172 |
-
"pruned_heads": {},
|
173 |
"qk_normalization": true,
|
174 |
"qkv_bias": false,
|
175 |
-
"remove_invalid_values": false,
|
176 |
-
"repetition_penalty": 1.0,
|
177 |
"return_dict": true,
|
178 |
-
"return_dict_in_generate": false,
|
179 |
-
"sep_token_id": null,
|
180 |
-
"suppress_tokens": null,
|
181 |
-
"task_specific_params": null,
|
182 |
-
"temperature": 1.0,
|
183 |
-
"tf_legacy_loss": false,
|
184 |
-
"tie_encoder_decoder": false,
|
185 |
-
"tie_word_embeddings": true,
|
186 |
-
"tokenizer_class": null,
|
187 |
-
"top_k": 50,
|
188 |
-
"top_p": 1.0,
|
189 |
"torch_dtype": "bfloat16",
|
190 |
-
"
|
191 |
-
"transformers_version": "4.45.1",
|
192 |
-
"typical_p": 1.0,
|
193 |
"use_bfloat16": true,
|
194 |
"use_flash_attn": true
|
195 |
}
|
|
|
1 |
{
|
2 |
"_commit_hash": null,
|
|
|
3 |
"architectures": [
|
4 |
"InternVLChatModel"
|
5 |
],
|
|
|
11 |
"downsample_ratio": 0.5,
|
12 |
"dynamic_image_size": true,
|
13 |
"force_image_size": 448,
|
|
|
14 |
"llm_config": {
|
15 |
"_name_or_path": "Qwen/Qwen2.5-32B-Instruct",
|
16 |
"add_cross_attention": false,
|
17 |
"architectures": [
|
18 |
"Qwen2ForCausalLM"
|
19 |
],
|
20 |
+
"_attn_implementation": "flash_attention_2",
|
21 |
"attention_dropout": 0.0,
|
22 |
"bad_words_ids": null,
|
23 |
"begin_suppress_tokens": null,
|
|
|
73 |
"return_dict": true,
|
74 |
"return_dict_in_generate": false,
|
75 |
"rms_norm_eps": 1e-06,
|
|
|
76 |
"rope_theta": 1000000.0,
|
77 |
"sep_token_id": null,
|
78 |
+
"sliding_window": 131072,
|
79 |
"suppress_tokens": null,
|
80 |
"task_specific_params": null,
|
81 |
"temperature": 1.0,
|
|
|
87 |
"top_p": 1.0,
|
88 |
"torch_dtype": "bfloat16",
|
89 |
"torchscript": false,
|
90 |
+
"transformers_version": "4.37.2",
|
91 |
"typical_p": 1.0,
|
92 |
"use_bfloat16": true,
|
93 |
+
"use_cache": true,
|
94 |
"use_sliding_window": false,
|
95 |
"vocab_size": 151674
|
96 |
},
|
97 |
"max_dynamic_patch": 12,
|
98 |
"min_dynamic_patch": 1,
|
99 |
"model_type": "internvl_chat",
|
|
|
100 |
"ps_version": "v2",
|
101 |
"select_layer": -1,
|
102 |
"template": "internvl2_5",
|
|
|
103 |
"torch_dtype": "bfloat16",
|
|
|
104 |
"use_backbone_lora": 0,
|
105 |
"use_llm_lora": 0,
|
106 |
"use_thumbnail": true,
|
107 |
"vision_config": {
|
|
|
|
|
108 |
"architectures": [
|
109 |
"InternVisionModel"
|
110 |
],
|
111 |
"attention_dropout": 0.0,
|
112 |
+
"drop_path_rate": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
"dropout": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
"hidden_act": "gelu",
|
115 |
"hidden_size": 3200,
|
|
|
|
|
|
|
|
|
116 |
"image_size": 448,
|
117 |
"initializer_factor": 0.1,
|
118 |
"initializer_range": 1e-10,
|
119 |
"intermediate_size": 12800,
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
"layer_norm_eps": 1e-06,
|
|
|
|
|
|
|
121 |
"model_type": "intern_vit_6b",
|
|
|
122 |
"norm_type": "rms_norm",
|
123 |
"num_attention_heads": 25,
|
|
|
|
|
124 |
"num_channels": 3,
|
125 |
"num_hidden_layers": 45,
|
|
|
126 |
"output_attentions": false,
|
127 |
"output_hidden_states": false,
|
|
|
|
|
128 |
"patch_size": 14,
|
|
|
|
|
|
|
129 |
"qk_normalization": true,
|
130 |
"qkv_bias": false,
|
|
|
|
|
131 |
"return_dict": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
"torch_dtype": "bfloat16",
|
133 |
+
"transformers_version": "4.37.2",
|
|
|
|
|
134 |
"use_bfloat16": true,
|
135 |
"use_flash_attn": true
|
136 |
}
|
generation_config.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"_from_model_config": true,
|
|
|
3 |
"eos_token_id": [
|
4 |
151644,
|
5 |
151645
|
6 |
-
]
|
7 |
-
"transformers_version": "4.45.1"
|
8 |
}
|
|
|
1 |
{
|
2 |
"_from_model_config": true,
|
3 |
+
"transformers_version": "4.45.1",
|
4 |
"eos_token_id": [
|
5 |
151644,
|
6 |
151645
|
7 |
+
]
|
|
|
8 |
}
|
merges.txt
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
#version: 0.2
|
2 |
Ġ Ġ
|
3 |
ĠĠ ĠĠ
|
4 |
i n
|
|
|
|
|
1 |
Ġ Ġ
|
2 |
ĠĠ ĠĠ
|
3 |
i n
|