Upload folder using huggingface_hub
Browse files- README.md +10 -10
- config.json +4 -63
- generation_config.json +2 -2
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-26B",
|
| 4 |
"architectures": [
|
| 5 |
"InternVLChatModel"
|
| 6 |
],
|
|
@@ -12,7 +11,6 @@
|
|
| 12 |
"downsample_ratio": 0.5,
|
| 13 |
"dynamic_image_size": true,
|
| 14 |
"force_image_size": 448,
|
| 15 |
-
"hidden_size": 6144,
|
| 16 |
"llm_config": {
|
| 17 |
"_name_or_path": "internlm/internlm2_5-20b-chat",
|
| 18 |
"add_cross_attention": false,
|
|
@@ -98,106 +96,49 @@
|
|
| 98 |
"top_p": 1.0,
|
| 99 |
"torch_dtype": "bfloat16",
|
| 100 |
"torchscript": false,
|
| 101 |
-
"transformers_version": "4.
|
| 102 |
"typical_p": 1.0,
|
| 103 |
"use_bfloat16": true,
|
| 104 |
-
"use_cache":
|
| 105 |
"vocab_size": 92553
|
| 106 |
},
|
| 107 |
"max_dynamic_patch": 12,
|
| 108 |
"min_dynamic_patch": 1,
|
| 109 |
"model_type": "internvl_chat",
|
| 110 |
-
"pad2square": false,
|
| 111 |
"ps_version": "v2",
|
| 112 |
"select_layer": -1,
|
| 113 |
"template": "internvl2_5",
|
| 114 |
-
"tie_word_embeddings": false,
|
| 115 |
"torch_dtype": "bfloat16",
|
| 116 |
-
"transformers_version": null,
|
| 117 |
"use_backbone_lora": 0,
|
| 118 |
"use_llm_lora": 0,
|
| 119 |
"use_thumbnail": true,
|
| 120 |
"vision_config": {
|
| 121 |
-
"_name_or_path": "",
|
| 122 |
-
"add_cross_attention": false,
|
| 123 |
"architectures": [
|
| 124 |
"InternVisionModel"
|
| 125 |
],
|
| 126 |
"attention_dropout": 0.0,
|
| 127 |
-
"
|
| 128 |
-
"begin_suppress_tokens": null,
|
| 129 |
-
"bos_token_id": null,
|
| 130 |
-
"chunk_size_feed_forward": 0,
|
| 131 |
-
"cross_attention_hidden_size": null,
|
| 132 |
-
"decoder_start_token_id": null,
|
| 133 |
-
"diversity_penalty": 0.0,
|
| 134 |
-
"do_sample": false,
|
| 135 |
-
"drop_path_rate": 0.4,
|
| 136 |
"dropout": 0.0,
|
| 137 |
-
"early_stopping": false,
|
| 138 |
-
"encoder_no_repeat_ngram_size": 0,
|
| 139 |
-
"eos_token_id": null,
|
| 140 |
-
"exponential_decay_length_penalty": null,
|
| 141 |
-
"finetuning_task": null,
|
| 142 |
-
"forced_bos_token_id": null,
|
| 143 |
-
"forced_eos_token_id": null,
|
| 144 |
"hidden_act": "gelu",
|
| 145 |
"hidden_size": 3200,
|
| 146 |
-
"id2label": {
|
| 147 |
-
"0": "LABEL_0",
|
| 148 |
-
"1": "LABEL_1"
|
| 149 |
-
},
|
| 150 |
"image_size": 448,
|
| 151 |
"initializer_factor": 0.1,
|
| 152 |
"initializer_range": 1e-10,
|
| 153 |
"intermediate_size": 12800,
|
| 154 |
-
"is_decoder": false,
|
| 155 |
-
"is_encoder_decoder": false,
|
| 156 |
-
"label2id": {
|
| 157 |
-
"LABEL_0": 0,
|
| 158 |
-
"LABEL_1": 1
|
| 159 |
-
},
|
| 160 |
"layer_norm_eps": 1e-06,
|
| 161 |
-
"length_penalty": 1.0,
|
| 162 |
-
"max_length": 20,
|
| 163 |
-
"min_length": 0,
|
| 164 |
"model_type": "intern_vit_6b",
|
| 165 |
-
"no_repeat_ngram_size": 0,
|
| 166 |
"norm_type": "rms_norm",
|
| 167 |
"num_attention_heads": 25,
|
| 168 |
-
"num_beam_groups": 1,
|
| 169 |
-
"num_beams": 1,
|
| 170 |
"num_channels": 3,
|
| 171 |
"num_hidden_layers": 45,
|
| 172 |
-
"num_return_sequences": 1,
|
| 173 |
"output_attentions": false,
|
| 174 |
"output_hidden_states": false,
|
| 175 |
-
"output_scores": false,
|
| 176 |
-
"pad_token_id": null,
|
| 177 |
"patch_size": 14,
|
| 178 |
-
"prefix": null,
|
| 179 |
-
"problem_type": null,
|
| 180 |
-
"pruned_heads": {},
|
| 181 |
"qk_normalization": true,
|
| 182 |
"qkv_bias": false,
|
| 183 |
-
"remove_invalid_values": false,
|
| 184 |
-
"repetition_penalty": 1.0,
|
| 185 |
"return_dict": true,
|
| 186 |
-
"return_dict_in_generate": false,
|
| 187 |
-
"sep_token_id": null,
|
| 188 |
-
"suppress_tokens": null,
|
| 189 |
-
"task_specific_params": null,
|
| 190 |
-
"temperature": 1.0,
|
| 191 |
-
"tf_legacy_loss": false,
|
| 192 |
-
"tie_encoder_decoder": false,
|
| 193 |
-
"tie_word_embeddings": true,
|
| 194 |
-
"tokenizer_class": null,
|
| 195 |
-
"top_k": 50,
|
| 196 |
-
"top_p": 1.0,
|
| 197 |
"torch_dtype": "bfloat16",
|
| 198 |
-
"
|
| 199 |
-
"transformers_version": "4.45.1",
|
| 200 |
-
"typical_p": 1.0,
|
| 201 |
"use_bfloat16": true,
|
| 202 |
"use_flash_attn": true
|
| 203 |
}
|
|
|
|
| 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": "internlm/internlm2_5-20b-chat",
|
| 16 |
"add_cross_attention": false,
|
|
|
|
| 96 |
"top_p": 1.0,
|
| 97 |
"torch_dtype": "bfloat16",
|
| 98 |
"torchscript": false,
|
| 99 |
+
"transformers_version": "4.37.2",
|
| 100 |
"typical_p": 1.0,
|
| 101 |
"use_bfloat16": true,
|
| 102 |
+
"use_cache": true,
|
| 103 |
"vocab_size": 92553
|
| 104 |
},
|
| 105 |
"max_dynamic_patch": 12,
|
| 106 |
"min_dynamic_patch": 1,
|
| 107 |
"model_type": "internvl_chat",
|
|
|
|
| 108 |
"ps_version": "v2",
|
| 109 |
"select_layer": -1,
|
| 110 |
"template": "internvl2_5",
|
|
|
|
| 111 |
"torch_dtype": "bfloat16",
|
|
|
|
| 112 |
"use_backbone_lora": 0,
|
| 113 |
"use_llm_lora": 0,
|
| 114 |
"use_thumbnail": true,
|
| 115 |
"vision_config": {
|
|
|
|
|
|
|
| 116 |
"architectures": [
|
| 117 |
"InternVisionModel"
|
| 118 |
],
|
| 119 |
"attention_dropout": 0.0,
|
| 120 |
+
"drop_path_rate": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
"dropout": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
"hidden_act": "gelu",
|
| 123 |
"hidden_size": 3200,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
"image_size": 448,
|
| 125 |
"initializer_factor": 0.1,
|
| 126 |
"initializer_range": 1e-10,
|
| 127 |
"intermediate_size": 12800,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
"layer_norm_eps": 1e-06,
|
|
|
|
|
|
|
|
|
|
| 129 |
"model_type": "intern_vit_6b",
|
|
|
|
| 130 |
"norm_type": "rms_norm",
|
| 131 |
"num_attention_heads": 25,
|
|
|
|
|
|
|
| 132 |
"num_channels": 3,
|
| 133 |
"num_hidden_layers": 45,
|
|
|
|
| 134 |
"output_attentions": false,
|
| 135 |
"output_hidden_states": false,
|
|
|
|
|
|
|
| 136 |
"patch_size": 14,
|
|
|
|
|
|
|
|
|
|
| 137 |
"qk_normalization": true,
|
| 138 |
"qkv_bias": false,
|
|
|
|
|
|
|
| 139 |
"return_dict": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
"torch_dtype": "bfloat16",
|
| 141 |
+
"transformers_version": "4.37.2",
|
|
|
|
|
|
|
| 142 |
"use_bfloat16": true,
|
| 143 |
"use_flash_attn": true
|
| 144 |
}
|
generation_config.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
|
|
|
| 3 |
"eos_token_id": [
|
| 4 |
92542,
|
| 5 |
92543
|
| 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 |
92542,
|
| 6 |
92543
|
| 7 |
+
]
|
|
|
|
| 8 |
}
|