Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- action_head--35000_checkpoint.pt +3 -0
- config.json +308 -0
- config.json.back.20250921_145013 +308 -0
- config.json.back.20250921_182648 +308 -0
- config.json.back.20250921_183706 +308 -0
- config.json.back.20250922_064615 +308 -0
- config.json.back.20250922_073803 +308 -0
- configuration_prismatic.py +142 -0
- dataset_statistics.json +133 -0
- lora_adapter/README.md +202 -0
- lora_adapter/adapter_config.json +45 -0
- lora_adapter/adapter_model.safetensors +3 -0
- modeling_prismatic.py +1556 -0
- modeling_prismatic.py.back.20250921_182648 +1552 -0
- modeling_prismatic.py.back.20250921_183706 +1553 -0
- preprocessor_config.json +110 -0
- special_tokens_map.json +32 -0
- tokenizer.json +3 -0
- tokenizer_config.json +2084 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
action_head--35000_checkpoint.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b3cec4d149ab1e2105f4350ec2d63ed2c52d8b27ace1201d2b0fa0245fcb6090
|
| 3 |
+
size 18984846
|
config.json
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"norm_stats": {
|
| 3 |
+
"libero_spatial_no_noops": {
|
| 4 |
+
"action": {
|
| 5 |
+
"mean": [
|
| 6 |
+
0.15312479436397552,
|
| 7 |
+
0.13707277178764343,
|
| 8 |
+
-0.15526802837848663,
|
| 9 |
+
-0.005176450591534376,
|
| 10 |
+
-0.01120874285697937,
|
| 11 |
+
-0.020194264128804207,
|
| 12 |
+
0.4578818082809448
|
| 13 |
+
],
|
| 14 |
+
"std": [
|
| 15 |
+
0.41272708773612976,
|
| 16 |
+
0.34724321961402893,
|
| 17 |
+
0.50869220495224,
|
| 18 |
+
0.037266165018081665,
|
| 19 |
+
0.07244449853897095,
|
| 20 |
+
0.05762382969260216,
|
| 21 |
+
0.49827873706817627
|
| 22 |
+
],
|
| 23 |
+
"max": [
|
| 24 |
+
0.9375,
|
| 25 |
+
0.9375,
|
| 26 |
+
0.9375,
|
| 27 |
+
0.1971428543329239,
|
| 28 |
+
0.33642858266830444,
|
| 29 |
+
0.375,
|
| 30 |
+
1.0
|
| 31 |
+
],
|
| 32 |
+
"min": [
|
| 33 |
+
-0.9375,
|
| 34 |
+
-0.9375,
|
| 35 |
+
-0.9375,
|
| 36 |
+
-0.1875,
|
| 37 |
+
-0.3675000071525574,
|
| 38 |
+
-0.36000001430511475,
|
| 39 |
+
0.0
|
| 40 |
+
],
|
| 41 |
+
"q01": [
|
| 42 |
+
-0.7454732114076613,
|
| 43 |
+
-0.6616071462631226,
|
| 44 |
+
-0.9375,
|
| 45 |
+
-0.1071428582072258,
|
| 46 |
+
-0.20678570866584778,
|
| 47 |
+
-0.1842857152223587,
|
| 48 |
+
0.0
|
| 49 |
+
],
|
| 50 |
+
"q99": [
|
| 51 |
+
0.9375,
|
| 52 |
+
0.8758928775787354,
|
| 53 |
+
0.9321428537368774,
|
| 54 |
+
0.1039285734295845,
|
| 55 |
+
0.17678570747375488,
|
| 56 |
+
0.14571428298950195,
|
| 57 |
+
1.0
|
| 58 |
+
],
|
| 59 |
+
"mask": [
|
| 60 |
+
true,
|
| 61 |
+
true,
|
| 62 |
+
true,
|
| 63 |
+
true,
|
| 64 |
+
true,
|
| 65 |
+
true,
|
| 66 |
+
false
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
"proprio": {
|
| 70 |
+
"mean": [
|
| 71 |
+
-0.024462558329105377,
|
| 72 |
+
0.106529600918293,
|
| 73 |
+
1.0580483675003052,
|
| 74 |
+
3.0628468990325928,
|
| 75 |
+
-0.10464039444923401,
|
| 76 |
+
0.08307311683893204,
|
| 77 |
+
0.01995457336306572,
|
| 78 |
+
-0.020162804052233696
|
| 79 |
+
],
|
| 80 |
+
"std": [
|
| 81 |
+
0.1101478561758995,
|
| 82 |
+
0.13784688711166382,
|
| 83 |
+
0.1044282391667366,
|
| 84 |
+
0.10451053828001022,
|
| 85 |
+
0.4112098217010498,
|
| 86 |
+
0.2176690548658371,
|
| 87 |
+
0.017260896041989326,
|
| 88 |
+
0.0171116404235363
|
| 89 |
+
],
|
| 90 |
+
"max": [
|
| 91 |
+
0.1759040206670761,
|
| 92 |
+
0.3904820382595062,
|
| 93 |
+
1.3290715217590332,
|
| 94 |
+
3.4566118717193604,
|
| 95 |
+
1.2268599271774292,
|
| 96 |
+
1.0429412126541138,
|
| 97 |
+
0.041053611785173416,
|
| 98 |
+
0.000775813648942858
|
| 99 |
+
],
|
| 100 |
+
"min": [
|
| 101 |
+
-0.3095473051071167,
|
| 102 |
+
-0.29250794649124146,
|
| 103 |
+
0.9095591306686401,
|
| 104 |
+
2.497488260269165,
|
| 105 |
+
-1.8006486892700195,
|
| 106 |
+
-0.7207611203193665,
|
| 107 |
+
-0.0004703797458205372,
|
| 108 |
+
-0.041536275297403336
|
| 109 |
+
],
|
| 110 |
+
"q01": [
|
| 111 |
+
-0.2727657300233841,
|
| 112 |
+
-0.23721413239836692,
|
| 113 |
+
0.9160063165426254,
|
| 114 |
+
2.77949666261673,
|
| 115 |
+
-1.3187511622905732,
|
| 116 |
+
-0.41989982962608335,
|
| 117 |
+
0.001503719249740243,
|
| 118 |
+
-0.03989770736545324
|
| 119 |
+
],
|
| 120 |
+
"q99": [
|
| 121 |
+
0.13529365032911292,
|
| 122 |
+
0.3629165390133857,
|
| 123 |
+
1.2862326657772063,
|
| 124 |
+
3.2829698753356933,
|
| 125 |
+
0.9332760351896285,
|
| 126 |
+
0.6325724506378171,
|
| 127 |
+
0.039933966137468815,
|
| 128 |
+
-0.001671919699292631
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
"num_transitions": 52970,
|
| 132 |
+
"num_trajectories": 432
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"n_action_bins": 256,
|
| 136 |
+
"vision_backbone_id": "dinosiglip-vit-so-224px",
|
| 137 |
+
"llm_backbone_id": "llama3.2-1b-pure",
|
| 138 |
+
"arch_specifier": "no-align+fused-gelu-mlp",
|
| 139 |
+
"output_projector_states": false,
|
| 140 |
+
"use_fused_vision_backbone": true,
|
| 141 |
+
"timm_model_ids": [
|
| 142 |
+
"vit_large_patch14_reg4_dinov2.lvd142m",
|
| 143 |
+
"vit_so400m_patch14_siglip_224"
|
| 144 |
+
],
|
| 145 |
+
"timm_override_act_layers": [
|
| 146 |
+
null,
|
| 147 |
+
null
|
| 148 |
+
],
|
| 149 |
+
"image_sizes": [
|
| 150 |
+
224,
|
| 151 |
+
224
|
| 152 |
+
],
|
| 153 |
+
"image_resize_strategy": "resize-naive",
|
| 154 |
+
"hf_llm_id": "meta-llama/Llama-3.2-1B",
|
| 155 |
+
"llm_max_length": 2048,
|
| 156 |
+
"pad_token_id": 128256,
|
| 157 |
+
"pad_to_multiple_of": 64,
|
| 158 |
+
"text_config": {
|
| 159 |
+
"vocab_size": 128320,
|
| 160 |
+
"max_position_embeddings": 131072,
|
| 161 |
+
"hidden_size": 2048,
|
| 162 |
+
"intermediate_size": 8192,
|
| 163 |
+
"num_hidden_layers": 16,
|
| 164 |
+
"num_attention_heads": 32,
|
| 165 |
+
"num_key_value_heads": 8,
|
| 166 |
+
"hidden_act": "silu",
|
| 167 |
+
"initializer_range": 0.02,
|
| 168 |
+
"rms_norm_eps": 1e-06,
|
| 169 |
+
"pretraining_tp": 1,
|
| 170 |
+
"use_cache": true,
|
| 171 |
+
"rope_theta": 500000.0,
|
| 172 |
+
"rope_scaling": null,
|
| 173 |
+
"attention_bias": false,
|
| 174 |
+
"attention_dropout": 0.0,
|
| 175 |
+
"mlp_bias": false,
|
| 176 |
+
"head_dim": 64,
|
| 177 |
+
"return_dict": true,
|
| 178 |
+
"output_hidden_states": false,
|
| 179 |
+
"output_attentions": false,
|
| 180 |
+
"torchscript": false,
|
| 181 |
+
"torch_dtype": "bfloat16",
|
| 182 |
+
"use_bfloat16": false,
|
| 183 |
+
"tf_legacy_loss": false,
|
| 184 |
+
"pruned_heads": {},
|
| 185 |
+
"tie_word_embeddings": false,
|
| 186 |
+
"chunk_size_feed_forward": 0,
|
| 187 |
+
"is_encoder_decoder": false,
|
| 188 |
+
"is_decoder": false,
|
| 189 |
+
"cross_attention_hidden_size": null,
|
| 190 |
+
"add_cross_attention": false,
|
| 191 |
+
"tie_encoder_decoder": false,
|
| 192 |
+
"max_length": 20,
|
| 193 |
+
"min_length": 0,
|
| 194 |
+
"do_sample": false,
|
| 195 |
+
"early_stopping": false,
|
| 196 |
+
"num_beams": 1,
|
| 197 |
+
"num_beam_groups": 1,
|
| 198 |
+
"diversity_penalty": 0.0,
|
| 199 |
+
"temperature": 1.0,
|
| 200 |
+
"top_k": 50,
|
| 201 |
+
"top_p": 1.0,
|
| 202 |
+
"typical_p": 1.0,
|
| 203 |
+
"repetition_penalty": 1.0,
|
| 204 |
+
"length_penalty": 1.0,
|
| 205 |
+
"no_repeat_ngram_size": 0,
|
| 206 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 207 |
+
"bad_words_ids": null,
|
| 208 |
+
"num_return_sequences": 1,
|
| 209 |
+
"output_scores": false,
|
| 210 |
+
"return_dict_in_generate": false,
|
| 211 |
+
"forced_bos_token_id": null,
|
| 212 |
+
"forced_eos_token_id": null,
|
| 213 |
+
"remove_invalid_values": false,
|
| 214 |
+
"exponential_decay_length_penalty": null,
|
| 215 |
+
"suppress_tokens": null,
|
| 216 |
+
"begin_suppress_tokens": null,
|
| 217 |
+
"architectures": null,
|
| 218 |
+
"finetuning_task": null,
|
| 219 |
+
"id2label": {
|
| 220 |
+
"0": "LABEL_0",
|
| 221 |
+
"1": "LABEL_1"
|
| 222 |
+
},
|
| 223 |
+
"label2id": {
|
| 224 |
+
"LABEL_0": 0,
|
| 225 |
+
"LABEL_1": 1
|
| 226 |
+
},
|
| 227 |
+
"tokenizer_class": null,
|
| 228 |
+
"prefix": null,
|
| 229 |
+
"bos_token_id": 1,
|
| 230 |
+
"pad_token_id": 128256,
|
| 231 |
+
"eos_token_id": 2,
|
| 232 |
+
"sep_token_id": null,
|
| 233 |
+
"decoder_start_token_id": null,
|
| 234 |
+
"task_specific_params": null,
|
| 235 |
+
"problem_type": null,
|
| 236 |
+
"_name_or_path": "",
|
| 237 |
+
"_attn_implementation_autoset": false,
|
| 238 |
+
"model_type": "llama"
|
| 239 |
+
},
|
| 240 |
+
"return_dict": true,
|
| 241 |
+
"output_hidden_states": false,
|
| 242 |
+
"output_attentions": false,
|
| 243 |
+
"torchscript": false,
|
| 244 |
+
"torch_dtype": "bfloat16",
|
| 245 |
+
"use_bfloat16": false,
|
| 246 |
+
"tf_legacy_loss": false,
|
| 247 |
+
"pruned_heads": {},
|
| 248 |
+
"tie_word_embeddings": true,
|
| 249 |
+
"chunk_size_feed_forward": 0,
|
| 250 |
+
"is_encoder_decoder": false,
|
| 251 |
+
"is_decoder": false,
|
| 252 |
+
"cross_attention_hidden_size": null,
|
| 253 |
+
"add_cross_attention": false,
|
| 254 |
+
"tie_encoder_decoder": false,
|
| 255 |
+
"max_length": 20,
|
| 256 |
+
"min_length": 0,
|
| 257 |
+
"do_sample": false,
|
| 258 |
+
"early_stopping": false,
|
| 259 |
+
"num_beams": 1,
|
| 260 |
+
"num_beam_groups": 1,
|
| 261 |
+
"diversity_penalty": 0.0,
|
| 262 |
+
"temperature": 1.0,
|
| 263 |
+
"top_k": 50,
|
| 264 |
+
"top_p": 1.0,
|
| 265 |
+
"typical_p": 1.0,
|
| 266 |
+
"repetition_penalty": 1.0,
|
| 267 |
+
"length_penalty": 1.0,
|
| 268 |
+
"no_repeat_ngram_size": 0,
|
| 269 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 270 |
+
"bad_words_ids": null,
|
| 271 |
+
"num_return_sequences": 1,
|
| 272 |
+
"output_scores": false,
|
| 273 |
+
"return_dict_in_generate": false,
|
| 274 |
+
"forced_bos_token_id": null,
|
| 275 |
+
"forced_eos_token_id": null,
|
| 276 |
+
"remove_invalid_values": false,
|
| 277 |
+
"exponential_decay_length_penalty": null,
|
| 278 |
+
"suppress_tokens": null,
|
| 279 |
+
"begin_suppress_tokens": null,
|
| 280 |
+
"architectures": [
|
| 281 |
+
"PrismaticForConditionalGeneration"
|
| 282 |
+
],
|
| 283 |
+
"finetuning_task": null,
|
| 284 |
+
"id2label": {
|
| 285 |
+
"0": "LABEL_0",
|
| 286 |
+
"1": "LABEL_1"
|
| 287 |
+
},
|
| 288 |
+
"label2id": {
|
| 289 |
+
"LABEL_0": 0,
|
| 290 |
+
"LABEL_1": 1
|
| 291 |
+
},
|
| 292 |
+
"tokenizer_class": null,
|
| 293 |
+
"prefix": null,
|
| 294 |
+
"bos_token_id": null,
|
| 295 |
+
"eos_token_id": null,
|
| 296 |
+
"sep_token_id": null,
|
| 297 |
+
"decoder_start_token_id": null,
|
| 298 |
+
"task_specific_params": null,
|
| 299 |
+
"problem_type": null,
|
| 300 |
+
"_name_or_path": "/home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm",
|
| 301 |
+
"_attn_implementation_autoset": true,
|
| 302 |
+
"transformers_version": "4.51.0",
|
| 303 |
+
"model_type": "openvla",
|
| 304 |
+
"auto_map": {
|
| 305 |
+
"AutoConfig": "configuration_prismatic.OpenVLAConfig",
|
| 306 |
+
"AutoModelForVision2Seq": "modeling_prismatic.OpenVLAForActionPrediction"
|
| 307 |
+
}
|
| 308 |
+
}
|
config.json.back.20250921_145013
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"norm_stats": {
|
| 3 |
+
"libero_spatial_no_noops": {
|
| 4 |
+
"action": {
|
| 5 |
+
"mean": [
|
| 6 |
+
0.15312479436397552,
|
| 7 |
+
0.13707277178764343,
|
| 8 |
+
-0.15526802837848663,
|
| 9 |
+
-0.005176450591534376,
|
| 10 |
+
-0.01120874285697937,
|
| 11 |
+
-0.020194264128804207,
|
| 12 |
+
0.4578818082809448
|
| 13 |
+
],
|
| 14 |
+
"std": [
|
| 15 |
+
0.41272708773612976,
|
| 16 |
+
0.34724321961402893,
|
| 17 |
+
0.50869220495224,
|
| 18 |
+
0.037266165018081665,
|
| 19 |
+
0.07244449853897095,
|
| 20 |
+
0.05762382969260216,
|
| 21 |
+
0.49827873706817627
|
| 22 |
+
],
|
| 23 |
+
"max": [
|
| 24 |
+
0.9375,
|
| 25 |
+
0.9375,
|
| 26 |
+
0.9375,
|
| 27 |
+
0.1971428543329239,
|
| 28 |
+
0.33642858266830444,
|
| 29 |
+
0.375,
|
| 30 |
+
1.0
|
| 31 |
+
],
|
| 32 |
+
"min": [
|
| 33 |
+
-0.9375,
|
| 34 |
+
-0.9375,
|
| 35 |
+
-0.9375,
|
| 36 |
+
-0.1875,
|
| 37 |
+
-0.3675000071525574,
|
| 38 |
+
-0.36000001430511475,
|
| 39 |
+
0.0
|
| 40 |
+
],
|
| 41 |
+
"q01": [
|
| 42 |
+
-0.7454732114076613,
|
| 43 |
+
-0.6616071462631226,
|
| 44 |
+
-0.9375,
|
| 45 |
+
-0.1071428582072258,
|
| 46 |
+
-0.20678570866584778,
|
| 47 |
+
-0.1842857152223587,
|
| 48 |
+
0.0
|
| 49 |
+
],
|
| 50 |
+
"q99": [
|
| 51 |
+
0.9375,
|
| 52 |
+
0.8758928775787354,
|
| 53 |
+
0.9321428537368774,
|
| 54 |
+
0.1039285734295845,
|
| 55 |
+
0.17678570747375488,
|
| 56 |
+
0.14571428298950195,
|
| 57 |
+
1.0
|
| 58 |
+
],
|
| 59 |
+
"mask": [
|
| 60 |
+
true,
|
| 61 |
+
true,
|
| 62 |
+
true,
|
| 63 |
+
true,
|
| 64 |
+
true,
|
| 65 |
+
true,
|
| 66 |
+
false
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
"proprio": {
|
| 70 |
+
"mean": [
|
| 71 |
+
-0.024462558329105377,
|
| 72 |
+
0.106529600918293,
|
| 73 |
+
1.0580483675003052,
|
| 74 |
+
3.0628468990325928,
|
| 75 |
+
-0.10464039444923401,
|
| 76 |
+
0.08307311683893204,
|
| 77 |
+
0.01995457336306572,
|
| 78 |
+
-0.020162804052233696
|
| 79 |
+
],
|
| 80 |
+
"std": [
|
| 81 |
+
0.1101478561758995,
|
| 82 |
+
0.13784688711166382,
|
| 83 |
+
0.1044282391667366,
|
| 84 |
+
0.10451053828001022,
|
| 85 |
+
0.4112098217010498,
|
| 86 |
+
0.2176690548658371,
|
| 87 |
+
0.017260896041989326,
|
| 88 |
+
0.0171116404235363
|
| 89 |
+
],
|
| 90 |
+
"max": [
|
| 91 |
+
0.1759040206670761,
|
| 92 |
+
0.3904820382595062,
|
| 93 |
+
1.3290715217590332,
|
| 94 |
+
3.4566118717193604,
|
| 95 |
+
1.2268599271774292,
|
| 96 |
+
1.0429412126541138,
|
| 97 |
+
0.041053611785173416,
|
| 98 |
+
0.000775813648942858
|
| 99 |
+
],
|
| 100 |
+
"min": [
|
| 101 |
+
-0.3095473051071167,
|
| 102 |
+
-0.29250794649124146,
|
| 103 |
+
0.9095591306686401,
|
| 104 |
+
2.497488260269165,
|
| 105 |
+
-1.8006486892700195,
|
| 106 |
+
-0.7207611203193665,
|
| 107 |
+
-0.0004703797458205372,
|
| 108 |
+
-0.041536275297403336
|
| 109 |
+
],
|
| 110 |
+
"q01": [
|
| 111 |
+
-0.2727657300233841,
|
| 112 |
+
-0.23721413239836692,
|
| 113 |
+
0.9160063165426254,
|
| 114 |
+
2.77949666261673,
|
| 115 |
+
-1.3187511622905732,
|
| 116 |
+
-0.41989982962608335,
|
| 117 |
+
0.001503719249740243,
|
| 118 |
+
-0.03989770736545324
|
| 119 |
+
],
|
| 120 |
+
"q99": [
|
| 121 |
+
0.13529365032911292,
|
| 122 |
+
0.3629165390133857,
|
| 123 |
+
1.2862326657772063,
|
| 124 |
+
3.2829698753356933,
|
| 125 |
+
0.9332760351896285,
|
| 126 |
+
0.6325724506378171,
|
| 127 |
+
0.039933966137468815,
|
| 128 |
+
-0.001671919699292631
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
"num_transitions": 52970,
|
| 132 |
+
"num_trajectories": 432
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"n_action_bins": 256,
|
| 136 |
+
"vision_backbone_id": "dinosiglip-vit-so-224px",
|
| 137 |
+
"llm_backbone_id": "llama3.2-1b-pure",
|
| 138 |
+
"arch_specifier": "no-align+fused-gelu-mlp",
|
| 139 |
+
"output_projector_states": false,
|
| 140 |
+
"use_fused_vision_backbone": true,
|
| 141 |
+
"timm_model_ids": [
|
| 142 |
+
"vit_large_patch14_reg4_dinov2.lvd142m",
|
| 143 |
+
"vit_so400m_patch14_siglip_224"
|
| 144 |
+
],
|
| 145 |
+
"timm_override_act_layers": [
|
| 146 |
+
null,
|
| 147 |
+
null
|
| 148 |
+
],
|
| 149 |
+
"image_sizes": [
|
| 150 |
+
224,
|
| 151 |
+
224
|
| 152 |
+
],
|
| 153 |
+
"image_resize_strategy": "resize-naive",
|
| 154 |
+
"hf_llm_id": "meta-llama/Llama-3.2-1B",
|
| 155 |
+
"llm_max_length": 2048,
|
| 156 |
+
"pad_token_id": 128256,
|
| 157 |
+
"pad_to_multiple_of": 64,
|
| 158 |
+
"text_config": {
|
| 159 |
+
"vocab_size": 128320,
|
| 160 |
+
"max_position_embeddings": 131072,
|
| 161 |
+
"hidden_size": 2048,
|
| 162 |
+
"intermediate_size": 8192,
|
| 163 |
+
"num_hidden_layers": 16,
|
| 164 |
+
"num_attention_heads": 32,
|
| 165 |
+
"num_key_value_heads": 8,
|
| 166 |
+
"hidden_act": "silu",
|
| 167 |
+
"initializer_range": 0.02,
|
| 168 |
+
"rms_norm_eps": 1e-06,
|
| 169 |
+
"pretraining_tp": 1,
|
| 170 |
+
"use_cache": true,
|
| 171 |
+
"rope_theta": 500000.0,
|
| 172 |
+
"rope_scaling": null,
|
| 173 |
+
"attention_bias": false,
|
| 174 |
+
"attention_dropout": 0.0,
|
| 175 |
+
"mlp_bias": false,
|
| 176 |
+
"head_dim": 64,
|
| 177 |
+
"return_dict": true,
|
| 178 |
+
"output_hidden_states": false,
|
| 179 |
+
"output_attentions": false,
|
| 180 |
+
"torchscript": false,
|
| 181 |
+
"torch_dtype": "bfloat16",
|
| 182 |
+
"use_bfloat16": false,
|
| 183 |
+
"tf_legacy_loss": false,
|
| 184 |
+
"pruned_heads": {},
|
| 185 |
+
"tie_word_embeddings": false,
|
| 186 |
+
"chunk_size_feed_forward": 0,
|
| 187 |
+
"is_encoder_decoder": false,
|
| 188 |
+
"is_decoder": false,
|
| 189 |
+
"cross_attention_hidden_size": null,
|
| 190 |
+
"add_cross_attention": false,
|
| 191 |
+
"tie_encoder_decoder": false,
|
| 192 |
+
"max_length": 20,
|
| 193 |
+
"min_length": 0,
|
| 194 |
+
"do_sample": false,
|
| 195 |
+
"early_stopping": false,
|
| 196 |
+
"num_beams": 1,
|
| 197 |
+
"num_beam_groups": 1,
|
| 198 |
+
"diversity_penalty": 0.0,
|
| 199 |
+
"temperature": 1.0,
|
| 200 |
+
"top_k": 50,
|
| 201 |
+
"top_p": 1.0,
|
| 202 |
+
"typical_p": 1.0,
|
| 203 |
+
"repetition_penalty": 1.0,
|
| 204 |
+
"length_penalty": 1.0,
|
| 205 |
+
"no_repeat_ngram_size": 0,
|
| 206 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 207 |
+
"bad_words_ids": null,
|
| 208 |
+
"num_return_sequences": 1,
|
| 209 |
+
"output_scores": false,
|
| 210 |
+
"return_dict_in_generate": false,
|
| 211 |
+
"forced_bos_token_id": null,
|
| 212 |
+
"forced_eos_token_id": null,
|
| 213 |
+
"remove_invalid_values": false,
|
| 214 |
+
"exponential_decay_length_penalty": null,
|
| 215 |
+
"suppress_tokens": null,
|
| 216 |
+
"begin_suppress_tokens": null,
|
| 217 |
+
"architectures": null,
|
| 218 |
+
"finetuning_task": null,
|
| 219 |
+
"id2label": {
|
| 220 |
+
"0": "LABEL_0",
|
| 221 |
+
"1": "LABEL_1"
|
| 222 |
+
},
|
| 223 |
+
"label2id": {
|
| 224 |
+
"LABEL_0": 0,
|
| 225 |
+
"LABEL_1": 1
|
| 226 |
+
},
|
| 227 |
+
"tokenizer_class": null,
|
| 228 |
+
"prefix": null,
|
| 229 |
+
"bos_token_id": 1,
|
| 230 |
+
"pad_token_id": 128256,
|
| 231 |
+
"eos_token_id": 2,
|
| 232 |
+
"sep_token_id": null,
|
| 233 |
+
"decoder_start_token_id": null,
|
| 234 |
+
"task_specific_params": null,
|
| 235 |
+
"problem_type": null,
|
| 236 |
+
"_name_or_path": "",
|
| 237 |
+
"_attn_implementation_autoset": false,
|
| 238 |
+
"model_type": "llama"
|
| 239 |
+
},
|
| 240 |
+
"return_dict": true,
|
| 241 |
+
"output_hidden_states": false,
|
| 242 |
+
"output_attentions": false,
|
| 243 |
+
"torchscript": false,
|
| 244 |
+
"torch_dtype": "bfloat16",
|
| 245 |
+
"use_bfloat16": false,
|
| 246 |
+
"tf_legacy_loss": false,
|
| 247 |
+
"pruned_heads": {},
|
| 248 |
+
"tie_word_embeddings": true,
|
| 249 |
+
"chunk_size_feed_forward": 0,
|
| 250 |
+
"is_encoder_decoder": false,
|
| 251 |
+
"is_decoder": false,
|
| 252 |
+
"cross_attention_hidden_size": null,
|
| 253 |
+
"add_cross_attention": false,
|
| 254 |
+
"tie_encoder_decoder": false,
|
| 255 |
+
"max_length": 20,
|
| 256 |
+
"min_length": 0,
|
| 257 |
+
"do_sample": false,
|
| 258 |
+
"early_stopping": false,
|
| 259 |
+
"num_beams": 1,
|
| 260 |
+
"num_beam_groups": 1,
|
| 261 |
+
"diversity_penalty": 0.0,
|
| 262 |
+
"temperature": 1.0,
|
| 263 |
+
"top_k": 50,
|
| 264 |
+
"top_p": 1.0,
|
| 265 |
+
"typical_p": 1.0,
|
| 266 |
+
"repetition_penalty": 1.0,
|
| 267 |
+
"length_penalty": 1.0,
|
| 268 |
+
"no_repeat_ngram_size": 0,
|
| 269 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 270 |
+
"bad_words_ids": null,
|
| 271 |
+
"num_return_sequences": 1,
|
| 272 |
+
"output_scores": false,
|
| 273 |
+
"return_dict_in_generate": false,
|
| 274 |
+
"forced_bos_token_id": null,
|
| 275 |
+
"forced_eos_token_id": null,
|
| 276 |
+
"remove_invalid_values": false,
|
| 277 |
+
"exponential_decay_length_penalty": null,
|
| 278 |
+
"suppress_tokens": null,
|
| 279 |
+
"begin_suppress_tokens": null,
|
| 280 |
+
"architectures": [
|
| 281 |
+
"PrismaticForConditionalGeneration"
|
| 282 |
+
],
|
| 283 |
+
"finetuning_task": null,
|
| 284 |
+
"id2label": {
|
| 285 |
+
"0": "LABEL_0",
|
| 286 |
+
"1": "LABEL_1"
|
| 287 |
+
},
|
| 288 |
+
"label2id": {
|
| 289 |
+
"LABEL_0": 0,
|
| 290 |
+
"LABEL_1": 1
|
| 291 |
+
},
|
| 292 |
+
"tokenizer_class": null,
|
| 293 |
+
"prefix": null,
|
| 294 |
+
"bos_token_id": null,
|
| 295 |
+
"eos_token_id": null,
|
| 296 |
+
"sep_token_id": null,
|
| 297 |
+
"decoder_start_token_id": null,
|
| 298 |
+
"task_specific_params": null,
|
| 299 |
+
"problem_type": null,
|
| 300 |
+
"_name_or_path": "/home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm",
|
| 301 |
+
"_attn_implementation_autoset": true,
|
| 302 |
+
"transformers_version": "4.51.0",
|
| 303 |
+
"model_type": "openvla",
|
| 304 |
+
"auto_map": {
|
| 305 |
+
"AutoConfig": "configuration_prismatic.OpenVLAConfig",
|
| 306 |
+
"AutoModelForVision2Seq": "modeling_prismatic.OpenVLAForActionPrediction"
|
| 307 |
+
}
|
| 308 |
+
}
|
config.json.back.20250921_182648
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"norm_stats": {
|
| 3 |
+
"libero_spatial_no_noops": {
|
| 4 |
+
"action": {
|
| 5 |
+
"mean": [
|
| 6 |
+
0.15312479436397552,
|
| 7 |
+
0.13707277178764343,
|
| 8 |
+
-0.15526802837848663,
|
| 9 |
+
-0.005176450591534376,
|
| 10 |
+
-0.01120874285697937,
|
| 11 |
+
-0.020194264128804207,
|
| 12 |
+
0.4578818082809448
|
| 13 |
+
],
|
| 14 |
+
"std": [
|
| 15 |
+
0.41272708773612976,
|
| 16 |
+
0.34724321961402893,
|
| 17 |
+
0.50869220495224,
|
| 18 |
+
0.037266165018081665,
|
| 19 |
+
0.07244449853897095,
|
| 20 |
+
0.05762382969260216,
|
| 21 |
+
0.49827873706817627
|
| 22 |
+
],
|
| 23 |
+
"max": [
|
| 24 |
+
0.9375,
|
| 25 |
+
0.9375,
|
| 26 |
+
0.9375,
|
| 27 |
+
0.1971428543329239,
|
| 28 |
+
0.33642858266830444,
|
| 29 |
+
0.375,
|
| 30 |
+
1.0
|
| 31 |
+
],
|
| 32 |
+
"min": [
|
| 33 |
+
-0.9375,
|
| 34 |
+
-0.9375,
|
| 35 |
+
-0.9375,
|
| 36 |
+
-0.1875,
|
| 37 |
+
-0.3675000071525574,
|
| 38 |
+
-0.36000001430511475,
|
| 39 |
+
0.0
|
| 40 |
+
],
|
| 41 |
+
"q01": [
|
| 42 |
+
-0.7454732114076613,
|
| 43 |
+
-0.6616071462631226,
|
| 44 |
+
-0.9375,
|
| 45 |
+
-0.1071428582072258,
|
| 46 |
+
-0.20678570866584778,
|
| 47 |
+
-0.1842857152223587,
|
| 48 |
+
0.0
|
| 49 |
+
],
|
| 50 |
+
"q99": [
|
| 51 |
+
0.9375,
|
| 52 |
+
0.8758928775787354,
|
| 53 |
+
0.9321428537368774,
|
| 54 |
+
0.1039285734295845,
|
| 55 |
+
0.17678570747375488,
|
| 56 |
+
0.14571428298950195,
|
| 57 |
+
1.0
|
| 58 |
+
],
|
| 59 |
+
"mask": [
|
| 60 |
+
true,
|
| 61 |
+
true,
|
| 62 |
+
true,
|
| 63 |
+
true,
|
| 64 |
+
true,
|
| 65 |
+
true,
|
| 66 |
+
false
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
"proprio": {
|
| 70 |
+
"mean": [
|
| 71 |
+
-0.024462558329105377,
|
| 72 |
+
0.106529600918293,
|
| 73 |
+
1.0580483675003052,
|
| 74 |
+
3.0628468990325928,
|
| 75 |
+
-0.10464039444923401,
|
| 76 |
+
0.08307311683893204,
|
| 77 |
+
0.01995457336306572,
|
| 78 |
+
-0.020162804052233696
|
| 79 |
+
],
|
| 80 |
+
"std": [
|
| 81 |
+
0.1101478561758995,
|
| 82 |
+
0.13784688711166382,
|
| 83 |
+
0.1044282391667366,
|
| 84 |
+
0.10451053828001022,
|
| 85 |
+
0.4112098217010498,
|
| 86 |
+
0.2176690548658371,
|
| 87 |
+
0.017260896041989326,
|
| 88 |
+
0.0171116404235363
|
| 89 |
+
],
|
| 90 |
+
"max": [
|
| 91 |
+
0.1759040206670761,
|
| 92 |
+
0.3904820382595062,
|
| 93 |
+
1.3290715217590332,
|
| 94 |
+
3.4566118717193604,
|
| 95 |
+
1.2268599271774292,
|
| 96 |
+
1.0429412126541138,
|
| 97 |
+
0.041053611785173416,
|
| 98 |
+
0.000775813648942858
|
| 99 |
+
],
|
| 100 |
+
"min": [
|
| 101 |
+
-0.3095473051071167,
|
| 102 |
+
-0.29250794649124146,
|
| 103 |
+
0.9095591306686401,
|
| 104 |
+
2.497488260269165,
|
| 105 |
+
-1.8006486892700195,
|
| 106 |
+
-0.7207611203193665,
|
| 107 |
+
-0.0004703797458205372,
|
| 108 |
+
-0.041536275297403336
|
| 109 |
+
],
|
| 110 |
+
"q01": [
|
| 111 |
+
-0.2727657300233841,
|
| 112 |
+
-0.23721413239836692,
|
| 113 |
+
0.9160063165426254,
|
| 114 |
+
2.77949666261673,
|
| 115 |
+
-1.3187511622905732,
|
| 116 |
+
-0.41989982962608335,
|
| 117 |
+
0.001503719249740243,
|
| 118 |
+
-0.03989770736545324
|
| 119 |
+
],
|
| 120 |
+
"q99": [
|
| 121 |
+
0.13529365032911292,
|
| 122 |
+
0.3629165390133857,
|
| 123 |
+
1.2862326657772063,
|
| 124 |
+
3.2829698753356933,
|
| 125 |
+
0.9332760351896285,
|
| 126 |
+
0.6325724506378171,
|
| 127 |
+
0.039933966137468815,
|
| 128 |
+
-0.001671919699292631
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
"num_transitions": 52970,
|
| 132 |
+
"num_trajectories": 432
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"n_action_bins": 256,
|
| 136 |
+
"vision_backbone_id": "dinosiglip-vit-so-224px",
|
| 137 |
+
"llm_backbone_id": "llama3.2-1b-pure",
|
| 138 |
+
"arch_specifier": "no-align+fused-gelu-mlp",
|
| 139 |
+
"output_projector_states": false,
|
| 140 |
+
"use_fused_vision_backbone": true,
|
| 141 |
+
"timm_model_ids": [
|
| 142 |
+
"vit_large_patch14_reg4_dinov2.lvd142m",
|
| 143 |
+
"vit_so400m_patch14_siglip_224"
|
| 144 |
+
],
|
| 145 |
+
"timm_override_act_layers": [
|
| 146 |
+
null,
|
| 147 |
+
null
|
| 148 |
+
],
|
| 149 |
+
"image_sizes": [
|
| 150 |
+
224,
|
| 151 |
+
224
|
| 152 |
+
],
|
| 153 |
+
"image_resize_strategy": "resize-naive",
|
| 154 |
+
"hf_llm_id": "meta-llama/Llama-3.2-1B",
|
| 155 |
+
"llm_max_length": 2048,
|
| 156 |
+
"pad_token_id": 128256,
|
| 157 |
+
"pad_to_multiple_of": 64,
|
| 158 |
+
"text_config": {
|
| 159 |
+
"vocab_size": 128320,
|
| 160 |
+
"max_position_embeddings": 131072,
|
| 161 |
+
"hidden_size": 2048,
|
| 162 |
+
"intermediate_size": 8192,
|
| 163 |
+
"num_hidden_layers": 16,
|
| 164 |
+
"num_attention_heads": 32,
|
| 165 |
+
"num_key_value_heads": 8,
|
| 166 |
+
"hidden_act": "silu",
|
| 167 |
+
"initializer_range": 0.02,
|
| 168 |
+
"rms_norm_eps": 1e-06,
|
| 169 |
+
"pretraining_tp": 1,
|
| 170 |
+
"use_cache": true,
|
| 171 |
+
"rope_theta": 500000.0,
|
| 172 |
+
"rope_scaling": null,
|
| 173 |
+
"attention_bias": false,
|
| 174 |
+
"attention_dropout": 0.0,
|
| 175 |
+
"mlp_bias": false,
|
| 176 |
+
"head_dim": 64,
|
| 177 |
+
"return_dict": true,
|
| 178 |
+
"output_hidden_states": false,
|
| 179 |
+
"output_attentions": false,
|
| 180 |
+
"torchscript": false,
|
| 181 |
+
"torch_dtype": "bfloat16",
|
| 182 |
+
"use_bfloat16": false,
|
| 183 |
+
"tf_legacy_loss": false,
|
| 184 |
+
"pruned_heads": {},
|
| 185 |
+
"tie_word_embeddings": false,
|
| 186 |
+
"chunk_size_feed_forward": 0,
|
| 187 |
+
"is_encoder_decoder": false,
|
| 188 |
+
"is_decoder": false,
|
| 189 |
+
"cross_attention_hidden_size": null,
|
| 190 |
+
"add_cross_attention": false,
|
| 191 |
+
"tie_encoder_decoder": false,
|
| 192 |
+
"max_length": 20,
|
| 193 |
+
"min_length": 0,
|
| 194 |
+
"do_sample": false,
|
| 195 |
+
"early_stopping": false,
|
| 196 |
+
"num_beams": 1,
|
| 197 |
+
"num_beam_groups": 1,
|
| 198 |
+
"diversity_penalty": 0.0,
|
| 199 |
+
"temperature": 1.0,
|
| 200 |
+
"top_k": 50,
|
| 201 |
+
"top_p": 1.0,
|
| 202 |
+
"typical_p": 1.0,
|
| 203 |
+
"repetition_penalty": 1.0,
|
| 204 |
+
"length_penalty": 1.0,
|
| 205 |
+
"no_repeat_ngram_size": 0,
|
| 206 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 207 |
+
"bad_words_ids": null,
|
| 208 |
+
"num_return_sequences": 1,
|
| 209 |
+
"output_scores": false,
|
| 210 |
+
"return_dict_in_generate": false,
|
| 211 |
+
"forced_bos_token_id": null,
|
| 212 |
+
"forced_eos_token_id": null,
|
| 213 |
+
"remove_invalid_values": false,
|
| 214 |
+
"exponential_decay_length_penalty": null,
|
| 215 |
+
"suppress_tokens": null,
|
| 216 |
+
"begin_suppress_tokens": null,
|
| 217 |
+
"architectures": null,
|
| 218 |
+
"finetuning_task": null,
|
| 219 |
+
"id2label": {
|
| 220 |
+
"0": "LABEL_0",
|
| 221 |
+
"1": "LABEL_1"
|
| 222 |
+
},
|
| 223 |
+
"label2id": {
|
| 224 |
+
"LABEL_0": 0,
|
| 225 |
+
"LABEL_1": 1
|
| 226 |
+
},
|
| 227 |
+
"tokenizer_class": null,
|
| 228 |
+
"prefix": null,
|
| 229 |
+
"bos_token_id": 1,
|
| 230 |
+
"pad_token_id": 128256,
|
| 231 |
+
"eos_token_id": 2,
|
| 232 |
+
"sep_token_id": null,
|
| 233 |
+
"decoder_start_token_id": null,
|
| 234 |
+
"task_specific_params": null,
|
| 235 |
+
"problem_type": null,
|
| 236 |
+
"_name_or_path": "",
|
| 237 |
+
"_attn_implementation_autoset": false,
|
| 238 |
+
"model_type": "llama"
|
| 239 |
+
},
|
| 240 |
+
"return_dict": true,
|
| 241 |
+
"output_hidden_states": false,
|
| 242 |
+
"output_attentions": false,
|
| 243 |
+
"torchscript": false,
|
| 244 |
+
"torch_dtype": "bfloat16",
|
| 245 |
+
"use_bfloat16": false,
|
| 246 |
+
"tf_legacy_loss": false,
|
| 247 |
+
"pruned_heads": {},
|
| 248 |
+
"tie_word_embeddings": true,
|
| 249 |
+
"chunk_size_feed_forward": 0,
|
| 250 |
+
"is_encoder_decoder": false,
|
| 251 |
+
"is_decoder": false,
|
| 252 |
+
"cross_attention_hidden_size": null,
|
| 253 |
+
"add_cross_attention": false,
|
| 254 |
+
"tie_encoder_decoder": false,
|
| 255 |
+
"max_length": 20,
|
| 256 |
+
"min_length": 0,
|
| 257 |
+
"do_sample": false,
|
| 258 |
+
"early_stopping": false,
|
| 259 |
+
"num_beams": 1,
|
| 260 |
+
"num_beam_groups": 1,
|
| 261 |
+
"diversity_penalty": 0.0,
|
| 262 |
+
"temperature": 1.0,
|
| 263 |
+
"top_k": 50,
|
| 264 |
+
"top_p": 1.0,
|
| 265 |
+
"typical_p": 1.0,
|
| 266 |
+
"repetition_penalty": 1.0,
|
| 267 |
+
"length_penalty": 1.0,
|
| 268 |
+
"no_repeat_ngram_size": 0,
|
| 269 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 270 |
+
"bad_words_ids": null,
|
| 271 |
+
"num_return_sequences": 1,
|
| 272 |
+
"output_scores": false,
|
| 273 |
+
"return_dict_in_generate": false,
|
| 274 |
+
"forced_bos_token_id": null,
|
| 275 |
+
"forced_eos_token_id": null,
|
| 276 |
+
"remove_invalid_values": false,
|
| 277 |
+
"exponential_decay_length_penalty": null,
|
| 278 |
+
"suppress_tokens": null,
|
| 279 |
+
"begin_suppress_tokens": null,
|
| 280 |
+
"architectures": [
|
| 281 |
+
"PrismaticForConditionalGeneration"
|
| 282 |
+
],
|
| 283 |
+
"finetuning_task": null,
|
| 284 |
+
"id2label": {
|
| 285 |
+
"0": "LABEL_0",
|
| 286 |
+
"1": "LABEL_1"
|
| 287 |
+
},
|
| 288 |
+
"label2id": {
|
| 289 |
+
"LABEL_0": 0,
|
| 290 |
+
"LABEL_1": 1
|
| 291 |
+
},
|
| 292 |
+
"tokenizer_class": null,
|
| 293 |
+
"prefix": null,
|
| 294 |
+
"bos_token_id": null,
|
| 295 |
+
"eos_token_id": null,
|
| 296 |
+
"sep_token_id": null,
|
| 297 |
+
"decoder_start_token_id": null,
|
| 298 |
+
"task_specific_params": null,
|
| 299 |
+
"problem_type": null,
|
| 300 |
+
"_name_or_path": "/home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm",
|
| 301 |
+
"_attn_implementation_autoset": true,
|
| 302 |
+
"transformers_version": "4.51.0",
|
| 303 |
+
"model_type": "openvla",
|
| 304 |
+
"auto_map": {
|
| 305 |
+
"AutoConfig": "configuration_prismatic.OpenVLAConfig",
|
| 306 |
+
"AutoModelForVision2Seq": "modeling_prismatic.OpenVLAForActionPrediction"
|
| 307 |
+
}
|
| 308 |
+
}
|
config.json.back.20250921_183706
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"norm_stats": {
|
| 3 |
+
"libero_spatial_no_noops": {
|
| 4 |
+
"action": {
|
| 5 |
+
"mean": [
|
| 6 |
+
0.15312479436397552,
|
| 7 |
+
0.13707277178764343,
|
| 8 |
+
-0.15526802837848663,
|
| 9 |
+
-0.005176450591534376,
|
| 10 |
+
-0.01120874285697937,
|
| 11 |
+
-0.020194264128804207,
|
| 12 |
+
0.4578818082809448
|
| 13 |
+
],
|
| 14 |
+
"std": [
|
| 15 |
+
0.41272708773612976,
|
| 16 |
+
0.34724321961402893,
|
| 17 |
+
0.50869220495224,
|
| 18 |
+
0.037266165018081665,
|
| 19 |
+
0.07244449853897095,
|
| 20 |
+
0.05762382969260216,
|
| 21 |
+
0.49827873706817627
|
| 22 |
+
],
|
| 23 |
+
"max": [
|
| 24 |
+
0.9375,
|
| 25 |
+
0.9375,
|
| 26 |
+
0.9375,
|
| 27 |
+
0.1971428543329239,
|
| 28 |
+
0.33642858266830444,
|
| 29 |
+
0.375,
|
| 30 |
+
1.0
|
| 31 |
+
],
|
| 32 |
+
"min": [
|
| 33 |
+
-0.9375,
|
| 34 |
+
-0.9375,
|
| 35 |
+
-0.9375,
|
| 36 |
+
-0.1875,
|
| 37 |
+
-0.3675000071525574,
|
| 38 |
+
-0.36000001430511475,
|
| 39 |
+
0.0
|
| 40 |
+
],
|
| 41 |
+
"q01": [
|
| 42 |
+
-0.7454732114076613,
|
| 43 |
+
-0.6616071462631226,
|
| 44 |
+
-0.9375,
|
| 45 |
+
-0.1071428582072258,
|
| 46 |
+
-0.20678570866584778,
|
| 47 |
+
-0.1842857152223587,
|
| 48 |
+
0.0
|
| 49 |
+
],
|
| 50 |
+
"q99": [
|
| 51 |
+
0.9375,
|
| 52 |
+
0.8758928775787354,
|
| 53 |
+
0.9321428537368774,
|
| 54 |
+
0.1039285734295845,
|
| 55 |
+
0.17678570747375488,
|
| 56 |
+
0.14571428298950195,
|
| 57 |
+
1.0
|
| 58 |
+
],
|
| 59 |
+
"mask": [
|
| 60 |
+
true,
|
| 61 |
+
true,
|
| 62 |
+
true,
|
| 63 |
+
true,
|
| 64 |
+
true,
|
| 65 |
+
true,
|
| 66 |
+
false
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
"proprio": {
|
| 70 |
+
"mean": [
|
| 71 |
+
-0.024462558329105377,
|
| 72 |
+
0.106529600918293,
|
| 73 |
+
1.0580483675003052,
|
| 74 |
+
3.0628468990325928,
|
| 75 |
+
-0.10464039444923401,
|
| 76 |
+
0.08307311683893204,
|
| 77 |
+
0.01995457336306572,
|
| 78 |
+
-0.020162804052233696
|
| 79 |
+
],
|
| 80 |
+
"std": [
|
| 81 |
+
0.1101478561758995,
|
| 82 |
+
0.13784688711166382,
|
| 83 |
+
0.1044282391667366,
|
| 84 |
+
0.10451053828001022,
|
| 85 |
+
0.4112098217010498,
|
| 86 |
+
0.2176690548658371,
|
| 87 |
+
0.017260896041989326,
|
| 88 |
+
0.0171116404235363
|
| 89 |
+
],
|
| 90 |
+
"max": [
|
| 91 |
+
0.1759040206670761,
|
| 92 |
+
0.3904820382595062,
|
| 93 |
+
1.3290715217590332,
|
| 94 |
+
3.4566118717193604,
|
| 95 |
+
1.2268599271774292,
|
| 96 |
+
1.0429412126541138,
|
| 97 |
+
0.041053611785173416,
|
| 98 |
+
0.000775813648942858
|
| 99 |
+
],
|
| 100 |
+
"min": [
|
| 101 |
+
-0.3095473051071167,
|
| 102 |
+
-0.29250794649124146,
|
| 103 |
+
0.9095591306686401,
|
| 104 |
+
2.497488260269165,
|
| 105 |
+
-1.8006486892700195,
|
| 106 |
+
-0.7207611203193665,
|
| 107 |
+
-0.0004703797458205372,
|
| 108 |
+
-0.041536275297403336
|
| 109 |
+
],
|
| 110 |
+
"q01": [
|
| 111 |
+
-0.2727657300233841,
|
| 112 |
+
-0.23721413239836692,
|
| 113 |
+
0.9160063165426254,
|
| 114 |
+
2.77949666261673,
|
| 115 |
+
-1.3187511622905732,
|
| 116 |
+
-0.41989982962608335,
|
| 117 |
+
0.001503719249740243,
|
| 118 |
+
-0.03989770736545324
|
| 119 |
+
],
|
| 120 |
+
"q99": [
|
| 121 |
+
0.13529365032911292,
|
| 122 |
+
0.3629165390133857,
|
| 123 |
+
1.2862326657772063,
|
| 124 |
+
3.2829698753356933,
|
| 125 |
+
0.9332760351896285,
|
| 126 |
+
0.6325724506378171,
|
| 127 |
+
0.039933966137468815,
|
| 128 |
+
-0.001671919699292631
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
"num_transitions": 52970,
|
| 132 |
+
"num_trajectories": 432
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"n_action_bins": 256,
|
| 136 |
+
"vision_backbone_id": "dinosiglip-vit-so-224px",
|
| 137 |
+
"llm_backbone_id": "llama3.2-1b-pure",
|
| 138 |
+
"arch_specifier": "no-align+fused-gelu-mlp",
|
| 139 |
+
"output_projector_states": false,
|
| 140 |
+
"use_fused_vision_backbone": true,
|
| 141 |
+
"timm_model_ids": [
|
| 142 |
+
"vit_large_patch14_reg4_dinov2.lvd142m",
|
| 143 |
+
"vit_so400m_patch14_siglip_224"
|
| 144 |
+
],
|
| 145 |
+
"timm_override_act_layers": [
|
| 146 |
+
null,
|
| 147 |
+
null
|
| 148 |
+
],
|
| 149 |
+
"image_sizes": [
|
| 150 |
+
224,
|
| 151 |
+
224
|
| 152 |
+
],
|
| 153 |
+
"image_resize_strategy": "resize-naive",
|
| 154 |
+
"hf_llm_id": "meta-llama/Llama-3.2-1B",
|
| 155 |
+
"llm_max_length": 2048,
|
| 156 |
+
"pad_token_id": 128256,
|
| 157 |
+
"pad_to_multiple_of": 64,
|
| 158 |
+
"text_config": {
|
| 159 |
+
"vocab_size": 128320,
|
| 160 |
+
"max_position_embeddings": 131072,
|
| 161 |
+
"hidden_size": 2048,
|
| 162 |
+
"intermediate_size": 8192,
|
| 163 |
+
"num_hidden_layers": 16,
|
| 164 |
+
"num_attention_heads": 32,
|
| 165 |
+
"num_key_value_heads": 8,
|
| 166 |
+
"hidden_act": "silu",
|
| 167 |
+
"initializer_range": 0.02,
|
| 168 |
+
"rms_norm_eps": 1e-06,
|
| 169 |
+
"pretraining_tp": 1,
|
| 170 |
+
"use_cache": true,
|
| 171 |
+
"rope_theta": 500000.0,
|
| 172 |
+
"rope_scaling": null,
|
| 173 |
+
"attention_bias": false,
|
| 174 |
+
"attention_dropout": 0.0,
|
| 175 |
+
"mlp_bias": false,
|
| 176 |
+
"head_dim": 64,
|
| 177 |
+
"return_dict": true,
|
| 178 |
+
"output_hidden_states": false,
|
| 179 |
+
"output_attentions": false,
|
| 180 |
+
"torchscript": false,
|
| 181 |
+
"torch_dtype": "bfloat16",
|
| 182 |
+
"use_bfloat16": false,
|
| 183 |
+
"tf_legacy_loss": false,
|
| 184 |
+
"pruned_heads": {},
|
| 185 |
+
"tie_word_embeddings": false,
|
| 186 |
+
"chunk_size_feed_forward": 0,
|
| 187 |
+
"is_encoder_decoder": false,
|
| 188 |
+
"is_decoder": false,
|
| 189 |
+
"cross_attention_hidden_size": null,
|
| 190 |
+
"add_cross_attention": false,
|
| 191 |
+
"tie_encoder_decoder": false,
|
| 192 |
+
"max_length": 20,
|
| 193 |
+
"min_length": 0,
|
| 194 |
+
"do_sample": false,
|
| 195 |
+
"early_stopping": false,
|
| 196 |
+
"num_beams": 1,
|
| 197 |
+
"num_beam_groups": 1,
|
| 198 |
+
"diversity_penalty": 0.0,
|
| 199 |
+
"temperature": 1.0,
|
| 200 |
+
"top_k": 50,
|
| 201 |
+
"top_p": 1.0,
|
| 202 |
+
"typical_p": 1.0,
|
| 203 |
+
"repetition_penalty": 1.0,
|
| 204 |
+
"length_penalty": 1.0,
|
| 205 |
+
"no_repeat_ngram_size": 0,
|
| 206 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 207 |
+
"bad_words_ids": null,
|
| 208 |
+
"num_return_sequences": 1,
|
| 209 |
+
"output_scores": false,
|
| 210 |
+
"return_dict_in_generate": false,
|
| 211 |
+
"forced_bos_token_id": null,
|
| 212 |
+
"forced_eos_token_id": null,
|
| 213 |
+
"remove_invalid_values": false,
|
| 214 |
+
"exponential_decay_length_penalty": null,
|
| 215 |
+
"suppress_tokens": null,
|
| 216 |
+
"begin_suppress_tokens": null,
|
| 217 |
+
"architectures": null,
|
| 218 |
+
"finetuning_task": null,
|
| 219 |
+
"id2label": {
|
| 220 |
+
"0": "LABEL_0",
|
| 221 |
+
"1": "LABEL_1"
|
| 222 |
+
},
|
| 223 |
+
"label2id": {
|
| 224 |
+
"LABEL_0": 0,
|
| 225 |
+
"LABEL_1": 1
|
| 226 |
+
},
|
| 227 |
+
"tokenizer_class": null,
|
| 228 |
+
"prefix": null,
|
| 229 |
+
"bos_token_id": 1,
|
| 230 |
+
"pad_token_id": 128256,
|
| 231 |
+
"eos_token_id": 2,
|
| 232 |
+
"sep_token_id": null,
|
| 233 |
+
"decoder_start_token_id": null,
|
| 234 |
+
"task_specific_params": null,
|
| 235 |
+
"problem_type": null,
|
| 236 |
+
"_name_or_path": "",
|
| 237 |
+
"_attn_implementation_autoset": false,
|
| 238 |
+
"model_type": "llama"
|
| 239 |
+
},
|
| 240 |
+
"return_dict": true,
|
| 241 |
+
"output_hidden_states": false,
|
| 242 |
+
"output_attentions": false,
|
| 243 |
+
"torchscript": false,
|
| 244 |
+
"torch_dtype": "bfloat16",
|
| 245 |
+
"use_bfloat16": false,
|
| 246 |
+
"tf_legacy_loss": false,
|
| 247 |
+
"pruned_heads": {},
|
| 248 |
+
"tie_word_embeddings": true,
|
| 249 |
+
"chunk_size_feed_forward": 0,
|
| 250 |
+
"is_encoder_decoder": false,
|
| 251 |
+
"is_decoder": false,
|
| 252 |
+
"cross_attention_hidden_size": null,
|
| 253 |
+
"add_cross_attention": false,
|
| 254 |
+
"tie_encoder_decoder": false,
|
| 255 |
+
"max_length": 20,
|
| 256 |
+
"min_length": 0,
|
| 257 |
+
"do_sample": false,
|
| 258 |
+
"early_stopping": false,
|
| 259 |
+
"num_beams": 1,
|
| 260 |
+
"num_beam_groups": 1,
|
| 261 |
+
"diversity_penalty": 0.0,
|
| 262 |
+
"temperature": 1.0,
|
| 263 |
+
"top_k": 50,
|
| 264 |
+
"top_p": 1.0,
|
| 265 |
+
"typical_p": 1.0,
|
| 266 |
+
"repetition_penalty": 1.0,
|
| 267 |
+
"length_penalty": 1.0,
|
| 268 |
+
"no_repeat_ngram_size": 0,
|
| 269 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 270 |
+
"bad_words_ids": null,
|
| 271 |
+
"num_return_sequences": 1,
|
| 272 |
+
"output_scores": false,
|
| 273 |
+
"return_dict_in_generate": false,
|
| 274 |
+
"forced_bos_token_id": null,
|
| 275 |
+
"forced_eos_token_id": null,
|
| 276 |
+
"remove_invalid_values": false,
|
| 277 |
+
"exponential_decay_length_penalty": null,
|
| 278 |
+
"suppress_tokens": null,
|
| 279 |
+
"begin_suppress_tokens": null,
|
| 280 |
+
"architectures": [
|
| 281 |
+
"PrismaticForConditionalGeneration"
|
| 282 |
+
],
|
| 283 |
+
"finetuning_task": null,
|
| 284 |
+
"id2label": {
|
| 285 |
+
"0": "LABEL_0",
|
| 286 |
+
"1": "LABEL_1"
|
| 287 |
+
},
|
| 288 |
+
"label2id": {
|
| 289 |
+
"LABEL_0": 0,
|
| 290 |
+
"LABEL_1": 1
|
| 291 |
+
},
|
| 292 |
+
"tokenizer_class": null,
|
| 293 |
+
"prefix": null,
|
| 294 |
+
"bos_token_id": null,
|
| 295 |
+
"eos_token_id": null,
|
| 296 |
+
"sep_token_id": null,
|
| 297 |
+
"decoder_start_token_id": null,
|
| 298 |
+
"task_specific_params": null,
|
| 299 |
+
"problem_type": null,
|
| 300 |
+
"_name_or_path": "/home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm",
|
| 301 |
+
"_attn_implementation_autoset": true,
|
| 302 |
+
"transformers_version": "4.51.0",
|
| 303 |
+
"model_type": "openvla",
|
| 304 |
+
"auto_map": {
|
| 305 |
+
"AutoConfig": "configuration_prismatic.OpenVLAConfig",
|
| 306 |
+
"AutoModelForVision2Seq": "modeling_prismatic.OpenVLAForActionPrediction"
|
| 307 |
+
}
|
| 308 |
+
}
|
config.json.back.20250922_064615
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"norm_stats": {
|
| 3 |
+
"libero_spatial_no_noops": {
|
| 4 |
+
"action": {
|
| 5 |
+
"mean": [
|
| 6 |
+
0.15312479436397552,
|
| 7 |
+
0.13707277178764343,
|
| 8 |
+
-0.15526802837848663,
|
| 9 |
+
-0.005176450591534376,
|
| 10 |
+
-0.01120874285697937,
|
| 11 |
+
-0.020194264128804207,
|
| 12 |
+
0.4578818082809448
|
| 13 |
+
],
|
| 14 |
+
"std": [
|
| 15 |
+
0.41272708773612976,
|
| 16 |
+
0.34724321961402893,
|
| 17 |
+
0.50869220495224,
|
| 18 |
+
0.037266165018081665,
|
| 19 |
+
0.07244449853897095,
|
| 20 |
+
0.05762382969260216,
|
| 21 |
+
0.49827873706817627
|
| 22 |
+
],
|
| 23 |
+
"max": [
|
| 24 |
+
0.9375,
|
| 25 |
+
0.9375,
|
| 26 |
+
0.9375,
|
| 27 |
+
0.1971428543329239,
|
| 28 |
+
0.33642858266830444,
|
| 29 |
+
0.375,
|
| 30 |
+
1.0
|
| 31 |
+
],
|
| 32 |
+
"min": [
|
| 33 |
+
-0.9375,
|
| 34 |
+
-0.9375,
|
| 35 |
+
-0.9375,
|
| 36 |
+
-0.1875,
|
| 37 |
+
-0.3675000071525574,
|
| 38 |
+
-0.36000001430511475,
|
| 39 |
+
0.0
|
| 40 |
+
],
|
| 41 |
+
"q01": [
|
| 42 |
+
-0.7454732114076613,
|
| 43 |
+
-0.6616071462631226,
|
| 44 |
+
-0.9375,
|
| 45 |
+
-0.1071428582072258,
|
| 46 |
+
-0.20678570866584778,
|
| 47 |
+
-0.1842857152223587,
|
| 48 |
+
0.0
|
| 49 |
+
],
|
| 50 |
+
"q99": [
|
| 51 |
+
0.9375,
|
| 52 |
+
0.8758928775787354,
|
| 53 |
+
0.9321428537368774,
|
| 54 |
+
0.1039285734295845,
|
| 55 |
+
0.17678570747375488,
|
| 56 |
+
0.14571428298950195,
|
| 57 |
+
1.0
|
| 58 |
+
],
|
| 59 |
+
"mask": [
|
| 60 |
+
true,
|
| 61 |
+
true,
|
| 62 |
+
true,
|
| 63 |
+
true,
|
| 64 |
+
true,
|
| 65 |
+
true,
|
| 66 |
+
false
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
"proprio": {
|
| 70 |
+
"mean": [
|
| 71 |
+
-0.024462558329105377,
|
| 72 |
+
0.106529600918293,
|
| 73 |
+
1.0580483675003052,
|
| 74 |
+
3.0628468990325928,
|
| 75 |
+
-0.10464039444923401,
|
| 76 |
+
0.08307311683893204,
|
| 77 |
+
0.01995457336306572,
|
| 78 |
+
-0.020162804052233696
|
| 79 |
+
],
|
| 80 |
+
"std": [
|
| 81 |
+
0.1101478561758995,
|
| 82 |
+
0.13784688711166382,
|
| 83 |
+
0.1044282391667366,
|
| 84 |
+
0.10451053828001022,
|
| 85 |
+
0.4112098217010498,
|
| 86 |
+
0.2176690548658371,
|
| 87 |
+
0.017260896041989326,
|
| 88 |
+
0.0171116404235363
|
| 89 |
+
],
|
| 90 |
+
"max": [
|
| 91 |
+
0.1759040206670761,
|
| 92 |
+
0.3904820382595062,
|
| 93 |
+
1.3290715217590332,
|
| 94 |
+
3.4566118717193604,
|
| 95 |
+
1.2268599271774292,
|
| 96 |
+
1.0429412126541138,
|
| 97 |
+
0.041053611785173416,
|
| 98 |
+
0.000775813648942858
|
| 99 |
+
],
|
| 100 |
+
"min": [
|
| 101 |
+
-0.3095473051071167,
|
| 102 |
+
-0.29250794649124146,
|
| 103 |
+
0.9095591306686401,
|
| 104 |
+
2.497488260269165,
|
| 105 |
+
-1.8006486892700195,
|
| 106 |
+
-0.7207611203193665,
|
| 107 |
+
-0.0004703797458205372,
|
| 108 |
+
-0.041536275297403336
|
| 109 |
+
],
|
| 110 |
+
"q01": [
|
| 111 |
+
-0.2727657300233841,
|
| 112 |
+
-0.23721413239836692,
|
| 113 |
+
0.9160063165426254,
|
| 114 |
+
2.77949666261673,
|
| 115 |
+
-1.3187511622905732,
|
| 116 |
+
-0.41989982962608335,
|
| 117 |
+
0.001503719249740243,
|
| 118 |
+
-0.03989770736545324
|
| 119 |
+
],
|
| 120 |
+
"q99": [
|
| 121 |
+
0.13529365032911292,
|
| 122 |
+
0.3629165390133857,
|
| 123 |
+
1.2862326657772063,
|
| 124 |
+
3.2829698753356933,
|
| 125 |
+
0.9332760351896285,
|
| 126 |
+
0.6325724506378171,
|
| 127 |
+
0.039933966137468815,
|
| 128 |
+
-0.001671919699292631
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
"num_transitions": 52970,
|
| 132 |
+
"num_trajectories": 432
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"n_action_bins": 256,
|
| 136 |
+
"vision_backbone_id": "dinosiglip-vit-so-224px",
|
| 137 |
+
"llm_backbone_id": "llama3.2-1b-pure",
|
| 138 |
+
"arch_specifier": "no-align+fused-gelu-mlp",
|
| 139 |
+
"output_projector_states": false,
|
| 140 |
+
"use_fused_vision_backbone": true,
|
| 141 |
+
"timm_model_ids": [
|
| 142 |
+
"vit_large_patch14_reg4_dinov2.lvd142m",
|
| 143 |
+
"vit_so400m_patch14_siglip_224"
|
| 144 |
+
],
|
| 145 |
+
"timm_override_act_layers": [
|
| 146 |
+
null,
|
| 147 |
+
null
|
| 148 |
+
],
|
| 149 |
+
"image_sizes": [
|
| 150 |
+
224,
|
| 151 |
+
224
|
| 152 |
+
],
|
| 153 |
+
"image_resize_strategy": "resize-naive",
|
| 154 |
+
"hf_llm_id": "meta-llama/Llama-3.2-1B",
|
| 155 |
+
"llm_max_length": 2048,
|
| 156 |
+
"pad_token_id": 128256,
|
| 157 |
+
"pad_to_multiple_of": 64,
|
| 158 |
+
"text_config": {
|
| 159 |
+
"vocab_size": 128320,
|
| 160 |
+
"max_position_embeddings": 131072,
|
| 161 |
+
"hidden_size": 2048,
|
| 162 |
+
"intermediate_size": 8192,
|
| 163 |
+
"num_hidden_layers": 16,
|
| 164 |
+
"num_attention_heads": 32,
|
| 165 |
+
"num_key_value_heads": 8,
|
| 166 |
+
"hidden_act": "silu",
|
| 167 |
+
"initializer_range": 0.02,
|
| 168 |
+
"rms_norm_eps": 1e-06,
|
| 169 |
+
"pretraining_tp": 1,
|
| 170 |
+
"use_cache": true,
|
| 171 |
+
"rope_theta": 500000.0,
|
| 172 |
+
"rope_scaling": null,
|
| 173 |
+
"attention_bias": false,
|
| 174 |
+
"attention_dropout": 0.0,
|
| 175 |
+
"mlp_bias": false,
|
| 176 |
+
"head_dim": 64,
|
| 177 |
+
"return_dict": true,
|
| 178 |
+
"output_hidden_states": false,
|
| 179 |
+
"output_attentions": false,
|
| 180 |
+
"torchscript": false,
|
| 181 |
+
"torch_dtype": "bfloat16",
|
| 182 |
+
"use_bfloat16": false,
|
| 183 |
+
"tf_legacy_loss": false,
|
| 184 |
+
"pruned_heads": {},
|
| 185 |
+
"tie_word_embeddings": false,
|
| 186 |
+
"chunk_size_feed_forward": 0,
|
| 187 |
+
"is_encoder_decoder": false,
|
| 188 |
+
"is_decoder": false,
|
| 189 |
+
"cross_attention_hidden_size": null,
|
| 190 |
+
"add_cross_attention": false,
|
| 191 |
+
"tie_encoder_decoder": false,
|
| 192 |
+
"max_length": 20,
|
| 193 |
+
"min_length": 0,
|
| 194 |
+
"do_sample": false,
|
| 195 |
+
"early_stopping": false,
|
| 196 |
+
"num_beams": 1,
|
| 197 |
+
"num_beam_groups": 1,
|
| 198 |
+
"diversity_penalty": 0.0,
|
| 199 |
+
"temperature": 1.0,
|
| 200 |
+
"top_k": 50,
|
| 201 |
+
"top_p": 1.0,
|
| 202 |
+
"typical_p": 1.0,
|
| 203 |
+
"repetition_penalty": 1.0,
|
| 204 |
+
"length_penalty": 1.0,
|
| 205 |
+
"no_repeat_ngram_size": 0,
|
| 206 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 207 |
+
"bad_words_ids": null,
|
| 208 |
+
"num_return_sequences": 1,
|
| 209 |
+
"output_scores": false,
|
| 210 |
+
"return_dict_in_generate": false,
|
| 211 |
+
"forced_bos_token_id": null,
|
| 212 |
+
"forced_eos_token_id": null,
|
| 213 |
+
"remove_invalid_values": false,
|
| 214 |
+
"exponential_decay_length_penalty": null,
|
| 215 |
+
"suppress_tokens": null,
|
| 216 |
+
"begin_suppress_tokens": null,
|
| 217 |
+
"architectures": null,
|
| 218 |
+
"finetuning_task": null,
|
| 219 |
+
"id2label": {
|
| 220 |
+
"0": "LABEL_0",
|
| 221 |
+
"1": "LABEL_1"
|
| 222 |
+
},
|
| 223 |
+
"label2id": {
|
| 224 |
+
"LABEL_0": 0,
|
| 225 |
+
"LABEL_1": 1
|
| 226 |
+
},
|
| 227 |
+
"tokenizer_class": null,
|
| 228 |
+
"prefix": null,
|
| 229 |
+
"bos_token_id": 1,
|
| 230 |
+
"pad_token_id": 128256,
|
| 231 |
+
"eos_token_id": 2,
|
| 232 |
+
"sep_token_id": null,
|
| 233 |
+
"decoder_start_token_id": null,
|
| 234 |
+
"task_specific_params": null,
|
| 235 |
+
"problem_type": null,
|
| 236 |
+
"_name_or_path": "",
|
| 237 |
+
"_attn_implementation_autoset": false,
|
| 238 |
+
"model_type": "llama"
|
| 239 |
+
},
|
| 240 |
+
"return_dict": true,
|
| 241 |
+
"output_hidden_states": false,
|
| 242 |
+
"output_attentions": false,
|
| 243 |
+
"torchscript": false,
|
| 244 |
+
"torch_dtype": "bfloat16",
|
| 245 |
+
"use_bfloat16": false,
|
| 246 |
+
"tf_legacy_loss": false,
|
| 247 |
+
"pruned_heads": {},
|
| 248 |
+
"tie_word_embeddings": true,
|
| 249 |
+
"chunk_size_feed_forward": 0,
|
| 250 |
+
"is_encoder_decoder": false,
|
| 251 |
+
"is_decoder": false,
|
| 252 |
+
"cross_attention_hidden_size": null,
|
| 253 |
+
"add_cross_attention": false,
|
| 254 |
+
"tie_encoder_decoder": false,
|
| 255 |
+
"max_length": 20,
|
| 256 |
+
"min_length": 0,
|
| 257 |
+
"do_sample": false,
|
| 258 |
+
"early_stopping": false,
|
| 259 |
+
"num_beams": 1,
|
| 260 |
+
"num_beam_groups": 1,
|
| 261 |
+
"diversity_penalty": 0.0,
|
| 262 |
+
"temperature": 1.0,
|
| 263 |
+
"top_k": 50,
|
| 264 |
+
"top_p": 1.0,
|
| 265 |
+
"typical_p": 1.0,
|
| 266 |
+
"repetition_penalty": 1.0,
|
| 267 |
+
"length_penalty": 1.0,
|
| 268 |
+
"no_repeat_ngram_size": 0,
|
| 269 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 270 |
+
"bad_words_ids": null,
|
| 271 |
+
"num_return_sequences": 1,
|
| 272 |
+
"output_scores": false,
|
| 273 |
+
"return_dict_in_generate": false,
|
| 274 |
+
"forced_bos_token_id": null,
|
| 275 |
+
"forced_eos_token_id": null,
|
| 276 |
+
"remove_invalid_values": false,
|
| 277 |
+
"exponential_decay_length_penalty": null,
|
| 278 |
+
"suppress_tokens": null,
|
| 279 |
+
"begin_suppress_tokens": null,
|
| 280 |
+
"architectures": [
|
| 281 |
+
"PrismaticForConditionalGeneration"
|
| 282 |
+
],
|
| 283 |
+
"finetuning_task": null,
|
| 284 |
+
"id2label": {
|
| 285 |
+
"0": "LABEL_0",
|
| 286 |
+
"1": "LABEL_1"
|
| 287 |
+
},
|
| 288 |
+
"label2id": {
|
| 289 |
+
"LABEL_0": 0,
|
| 290 |
+
"LABEL_1": 1
|
| 291 |
+
},
|
| 292 |
+
"tokenizer_class": null,
|
| 293 |
+
"prefix": null,
|
| 294 |
+
"bos_token_id": null,
|
| 295 |
+
"eos_token_id": null,
|
| 296 |
+
"sep_token_id": null,
|
| 297 |
+
"decoder_start_token_id": null,
|
| 298 |
+
"task_specific_params": null,
|
| 299 |
+
"problem_type": null,
|
| 300 |
+
"_name_or_path": "/home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm",
|
| 301 |
+
"_attn_implementation_autoset": true,
|
| 302 |
+
"transformers_version": "4.51.0",
|
| 303 |
+
"model_type": "openvla",
|
| 304 |
+
"auto_map": {
|
| 305 |
+
"AutoConfig": "configuration_prismatic.OpenVLAConfig",
|
| 306 |
+
"AutoModelForVision2Seq": "modeling_prismatic.OpenVLAForActionPrediction"
|
| 307 |
+
}
|
| 308 |
+
}
|
config.json.back.20250922_073803
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"norm_stats": {
|
| 3 |
+
"libero_spatial_no_noops": {
|
| 4 |
+
"action": {
|
| 5 |
+
"mean": [
|
| 6 |
+
0.15312479436397552,
|
| 7 |
+
0.13707277178764343,
|
| 8 |
+
-0.15526802837848663,
|
| 9 |
+
-0.005176450591534376,
|
| 10 |
+
-0.01120874285697937,
|
| 11 |
+
-0.020194264128804207,
|
| 12 |
+
0.4578818082809448
|
| 13 |
+
],
|
| 14 |
+
"std": [
|
| 15 |
+
0.41272708773612976,
|
| 16 |
+
0.34724321961402893,
|
| 17 |
+
0.50869220495224,
|
| 18 |
+
0.037266165018081665,
|
| 19 |
+
0.07244449853897095,
|
| 20 |
+
0.05762382969260216,
|
| 21 |
+
0.49827873706817627
|
| 22 |
+
],
|
| 23 |
+
"max": [
|
| 24 |
+
0.9375,
|
| 25 |
+
0.9375,
|
| 26 |
+
0.9375,
|
| 27 |
+
0.1971428543329239,
|
| 28 |
+
0.33642858266830444,
|
| 29 |
+
0.375,
|
| 30 |
+
1.0
|
| 31 |
+
],
|
| 32 |
+
"min": [
|
| 33 |
+
-0.9375,
|
| 34 |
+
-0.9375,
|
| 35 |
+
-0.9375,
|
| 36 |
+
-0.1875,
|
| 37 |
+
-0.3675000071525574,
|
| 38 |
+
-0.36000001430511475,
|
| 39 |
+
0.0
|
| 40 |
+
],
|
| 41 |
+
"q01": [
|
| 42 |
+
-0.7454732114076613,
|
| 43 |
+
-0.6616071462631226,
|
| 44 |
+
-0.9375,
|
| 45 |
+
-0.1071428582072258,
|
| 46 |
+
-0.20678570866584778,
|
| 47 |
+
-0.1842857152223587,
|
| 48 |
+
0.0
|
| 49 |
+
],
|
| 50 |
+
"q99": [
|
| 51 |
+
0.9375,
|
| 52 |
+
0.8758928775787354,
|
| 53 |
+
0.9321428537368774,
|
| 54 |
+
0.1039285734295845,
|
| 55 |
+
0.17678570747375488,
|
| 56 |
+
0.14571428298950195,
|
| 57 |
+
1.0
|
| 58 |
+
],
|
| 59 |
+
"mask": [
|
| 60 |
+
true,
|
| 61 |
+
true,
|
| 62 |
+
true,
|
| 63 |
+
true,
|
| 64 |
+
true,
|
| 65 |
+
true,
|
| 66 |
+
false
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
"proprio": {
|
| 70 |
+
"mean": [
|
| 71 |
+
-0.024462558329105377,
|
| 72 |
+
0.106529600918293,
|
| 73 |
+
1.0580483675003052,
|
| 74 |
+
3.0628468990325928,
|
| 75 |
+
-0.10464039444923401,
|
| 76 |
+
0.08307311683893204,
|
| 77 |
+
0.01995457336306572,
|
| 78 |
+
-0.020162804052233696
|
| 79 |
+
],
|
| 80 |
+
"std": [
|
| 81 |
+
0.1101478561758995,
|
| 82 |
+
0.13784688711166382,
|
| 83 |
+
0.1044282391667366,
|
| 84 |
+
0.10451053828001022,
|
| 85 |
+
0.4112098217010498,
|
| 86 |
+
0.2176690548658371,
|
| 87 |
+
0.017260896041989326,
|
| 88 |
+
0.0171116404235363
|
| 89 |
+
],
|
| 90 |
+
"max": [
|
| 91 |
+
0.1759040206670761,
|
| 92 |
+
0.3904820382595062,
|
| 93 |
+
1.3290715217590332,
|
| 94 |
+
3.4566118717193604,
|
| 95 |
+
1.2268599271774292,
|
| 96 |
+
1.0429412126541138,
|
| 97 |
+
0.041053611785173416,
|
| 98 |
+
0.000775813648942858
|
| 99 |
+
],
|
| 100 |
+
"min": [
|
| 101 |
+
-0.3095473051071167,
|
| 102 |
+
-0.29250794649124146,
|
| 103 |
+
0.9095591306686401,
|
| 104 |
+
2.497488260269165,
|
| 105 |
+
-1.8006486892700195,
|
| 106 |
+
-0.7207611203193665,
|
| 107 |
+
-0.0004703797458205372,
|
| 108 |
+
-0.041536275297403336
|
| 109 |
+
],
|
| 110 |
+
"q01": [
|
| 111 |
+
-0.2727657300233841,
|
| 112 |
+
-0.23721413239836692,
|
| 113 |
+
0.9160063165426254,
|
| 114 |
+
2.77949666261673,
|
| 115 |
+
-1.3187511622905732,
|
| 116 |
+
-0.41989982962608335,
|
| 117 |
+
0.001503719249740243,
|
| 118 |
+
-0.03989770736545324
|
| 119 |
+
],
|
| 120 |
+
"q99": [
|
| 121 |
+
0.13529365032911292,
|
| 122 |
+
0.3629165390133857,
|
| 123 |
+
1.2862326657772063,
|
| 124 |
+
3.2829698753356933,
|
| 125 |
+
0.9332760351896285,
|
| 126 |
+
0.6325724506378171,
|
| 127 |
+
0.039933966137468815,
|
| 128 |
+
-0.001671919699292631
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
"num_transitions": 52970,
|
| 132 |
+
"num_trajectories": 432
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"n_action_bins": 256,
|
| 136 |
+
"vision_backbone_id": "dinosiglip-vit-so-224px",
|
| 137 |
+
"llm_backbone_id": "llama3.2-1b-pure",
|
| 138 |
+
"arch_specifier": "no-align+fused-gelu-mlp",
|
| 139 |
+
"output_projector_states": false,
|
| 140 |
+
"use_fused_vision_backbone": true,
|
| 141 |
+
"timm_model_ids": [
|
| 142 |
+
"vit_large_patch14_reg4_dinov2.lvd142m",
|
| 143 |
+
"vit_so400m_patch14_siglip_224"
|
| 144 |
+
],
|
| 145 |
+
"timm_override_act_layers": [
|
| 146 |
+
null,
|
| 147 |
+
null
|
| 148 |
+
],
|
| 149 |
+
"image_sizes": [
|
| 150 |
+
224,
|
| 151 |
+
224
|
| 152 |
+
],
|
| 153 |
+
"image_resize_strategy": "resize-naive",
|
| 154 |
+
"hf_llm_id": "meta-llama/Llama-3.2-1B",
|
| 155 |
+
"llm_max_length": 2048,
|
| 156 |
+
"pad_token_id": 128256,
|
| 157 |
+
"pad_to_multiple_of": 64,
|
| 158 |
+
"text_config": {
|
| 159 |
+
"vocab_size": 128320,
|
| 160 |
+
"max_position_embeddings": 131072,
|
| 161 |
+
"hidden_size": 2048,
|
| 162 |
+
"intermediate_size": 8192,
|
| 163 |
+
"num_hidden_layers": 16,
|
| 164 |
+
"num_attention_heads": 32,
|
| 165 |
+
"num_key_value_heads": 8,
|
| 166 |
+
"hidden_act": "silu",
|
| 167 |
+
"initializer_range": 0.02,
|
| 168 |
+
"rms_norm_eps": 1e-06,
|
| 169 |
+
"pretraining_tp": 1,
|
| 170 |
+
"use_cache": true,
|
| 171 |
+
"rope_theta": 500000.0,
|
| 172 |
+
"rope_scaling": null,
|
| 173 |
+
"attention_bias": false,
|
| 174 |
+
"attention_dropout": 0.0,
|
| 175 |
+
"mlp_bias": false,
|
| 176 |
+
"head_dim": 64,
|
| 177 |
+
"return_dict": true,
|
| 178 |
+
"output_hidden_states": false,
|
| 179 |
+
"output_attentions": false,
|
| 180 |
+
"torchscript": false,
|
| 181 |
+
"torch_dtype": "bfloat16",
|
| 182 |
+
"use_bfloat16": false,
|
| 183 |
+
"tf_legacy_loss": false,
|
| 184 |
+
"pruned_heads": {},
|
| 185 |
+
"tie_word_embeddings": false,
|
| 186 |
+
"chunk_size_feed_forward": 0,
|
| 187 |
+
"is_encoder_decoder": false,
|
| 188 |
+
"is_decoder": false,
|
| 189 |
+
"cross_attention_hidden_size": null,
|
| 190 |
+
"add_cross_attention": false,
|
| 191 |
+
"tie_encoder_decoder": false,
|
| 192 |
+
"max_length": 20,
|
| 193 |
+
"min_length": 0,
|
| 194 |
+
"do_sample": false,
|
| 195 |
+
"early_stopping": false,
|
| 196 |
+
"num_beams": 1,
|
| 197 |
+
"num_beam_groups": 1,
|
| 198 |
+
"diversity_penalty": 0.0,
|
| 199 |
+
"temperature": 1.0,
|
| 200 |
+
"top_k": 50,
|
| 201 |
+
"top_p": 1.0,
|
| 202 |
+
"typical_p": 1.0,
|
| 203 |
+
"repetition_penalty": 1.0,
|
| 204 |
+
"length_penalty": 1.0,
|
| 205 |
+
"no_repeat_ngram_size": 0,
|
| 206 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 207 |
+
"bad_words_ids": null,
|
| 208 |
+
"num_return_sequences": 1,
|
| 209 |
+
"output_scores": false,
|
| 210 |
+
"return_dict_in_generate": false,
|
| 211 |
+
"forced_bos_token_id": null,
|
| 212 |
+
"forced_eos_token_id": null,
|
| 213 |
+
"remove_invalid_values": false,
|
| 214 |
+
"exponential_decay_length_penalty": null,
|
| 215 |
+
"suppress_tokens": null,
|
| 216 |
+
"begin_suppress_tokens": null,
|
| 217 |
+
"architectures": null,
|
| 218 |
+
"finetuning_task": null,
|
| 219 |
+
"id2label": {
|
| 220 |
+
"0": "LABEL_0",
|
| 221 |
+
"1": "LABEL_1"
|
| 222 |
+
},
|
| 223 |
+
"label2id": {
|
| 224 |
+
"LABEL_0": 0,
|
| 225 |
+
"LABEL_1": 1
|
| 226 |
+
},
|
| 227 |
+
"tokenizer_class": null,
|
| 228 |
+
"prefix": null,
|
| 229 |
+
"bos_token_id": 1,
|
| 230 |
+
"pad_token_id": 128256,
|
| 231 |
+
"eos_token_id": 2,
|
| 232 |
+
"sep_token_id": null,
|
| 233 |
+
"decoder_start_token_id": null,
|
| 234 |
+
"task_specific_params": null,
|
| 235 |
+
"problem_type": null,
|
| 236 |
+
"_name_or_path": "",
|
| 237 |
+
"_attn_implementation_autoset": false,
|
| 238 |
+
"model_type": "llama"
|
| 239 |
+
},
|
| 240 |
+
"return_dict": true,
|
| 241 |
+
"output_hidden_states": false,
|
| 242 |
+
"output_attentions": false,
|
| 243 |
+
"torchscript": false,
|
| 244 |
+
"torch_dtype": "bfloat16",
|
| 245 |
+
"use_bfloat16": false,
|
| 246 |
+
"tf_legacy_loss": false,
|
| 247 |
+
"pruned_heads": {},
|
| 248 |
+
"tie_word_embeddings": true,
|
| 249 |
+
"chunk_size_feed_forward": 0,
|
| 250 |
+
"is_encoder_decoder": false,
|
| 251 |
+
"is_decoder": false,
|
| 252 |
+
"cross_attention_hidden_size": null,
|
| 253 |
+
"add_cross_attention": false,
|
| 254 |
+
"tie_encoder_decoder": false,
|
| 255 |
+
"max_length": 20,
|
| 256 |
+
"min_length": 0,
|
| 257 |
+
"do_sample": false,
|
| 258 |
+
"early_stopping": false,
|
| 259 |
+
"num_beams": 1,
|
| 260 |
+
"num_beam_groups": 1,
|
| 261 |
+
"diversity_penalty": 0.0,
|
| 262 |
+
"temperature": 1.0,
|
| 263 |
+
"top_k": 50,
|
| 264 |
+
"top_p": 1.0,
|
| 265 |
+
"typical_p": 1.0,
|
| 266 |
+
"repetition_penalty": 1.0,
|
| 267 |
+
"length_penalty": 1.0,
|
| 268 |
+
"no_repeat_ngram_size": 0,
|
| 269 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 270 |
+
"bad_words_ids": null,
|
| 271 |
+
"num_return_sequences": 1,
|
| 272 |
+
"output_scores": false,
|
| 273 |
+
"return_dict_in_generate": false,
|
| 274 |
+
"forced_bos_token_id": null,
|
| 275 |
+
"forced_eos_token_id": null,
|
| 276 |
+
"remove_invalid_values": false,
|
| 277 |
+
"exponential_decay_length_penalty": null,
|
| 278 |
+
"suppress_tokens": null,
|
| 279 |
+
"begin_suppress_tokens": null,
|
| 280 |
+
"architectures": [
|
| 281 |
+
"PrismaticForConditionalGeneration"
|
| 282 |
+
],
|
| 283 |
+
"finetuning_task": null,
|
| 284 |
+
"id2label": {
|
| 285 |
+
"0": "LABEL_0",
|
| 286 |
+
"1": "LABEL_1"
|
| 287 |
+
},
|
| 288 |
+
"label2id": {
|
| 289 |
+
"LABEL_0": 0,
|
| 290 |
+
"LABEL_1": 1
|
| 291 |
+
},
|
| 292 |
+
"tokenizer_class": null,
|
| 293 |
+
"prefix": null,
|
| 294 |
+
"bos_token_id": null,
|
| 295 |
+
"eos_token_id": null,
|
| 296 |
+
"sep_token_id": null,
|
| 297 |
+
"decoder_start_token_id": null,
|
| 298 |
+
"task_specific_params": null,
|
| 299 |
+
"problem_type": null,
|
| 300 |
+
"_name_or_path": "/home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm",
|
| 301 |
+
"_attn_implementation_autoset": true,
|
| 302 |
+
"transformers_version": "4.51.0",
|
| 303 |
+
"model_type": "openvla",
|
| 304 |
+
"auto_map": {
|
| 305 |
+
"AutoConfig": "configuration_prismatic.OpenVLAConfig",
|
| 306 |
+
"AutoModelForVision2Seq": "modeling_prismatic.OpenVLAForActionPrediction"
|
| 307 |
+
}
|
| 308 |
+
}
|
configuration_prismatic.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
configuration_prismatic.py
|
| 3 |
+
|
| 4 |
+
HuggingFace-style configuration definition for Prismatic VLMs, inheriting from `transformers.PretrainedConfig`.
|
| 5 |
+
Default configuration specifies `siglip-224px+7b`.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from typing import Any, Dict, List, Optional
|
| 9 |
+
|
| 10 |
+
from transformers import PretrainedConfig
|
| 11 |
+
from transformers.models.auto import CONFIG_MAPPING
|
| 12 |
+
|
| 13 |
+
# === Utilities for Mapping Prismatic names to HF names ===
|
| 14 |
+
# fmt: off
|
| 15 |
+
VISION_BACKBONE_TO_RESOLUTION: Dict[str, List[int]] = {
|
| 16 |
+
"clip-vit-l": [224], "siglip-vit-so400m": [224], "dinov2-vit-l": [224], "in1k-vit-l": [224],
|
| 17 |
+
|
| 18 |
+
"clip-vit-l-336px": [336],
|
| 19 |
+
"siglip-vit-so400m-384px": [384],
|
| 20 |
+
|
| 21 |
+
"dinoclip-vit-l-336px": [336, 336],
|
| 22 |
+
"dinosiglip-vit-so-224px": [224, 224],
|
| 23 |
+
"dinosiglip-vit-so-384px": [384, 384],
|
| 24 |
+
}
|
| 25 |
+
VISION_BACKBONE_TO_TIMM_ID: Dict[str, List[str]] = {
|
| 26 |
+
"clip-vit-l": ["vit_large_patch14_clip_224.openai"],
|
| 27 |
+
"clip-vit-l-336px": ["vit_large_patch14_clip_336.openai"],
|
| 28 |
+
|
| 29 |
+
"dinov2-vit-l": ["vit_large_patch14_reg4_dinov2.lvd142m"],
|
| 30 |
+
"in1k-vit-l": ["vit_large_patch16_224.augreg_in21k_ft_in1k"],
|
| 31 |
+
|
| 32 |
+
"siglip-vit-so400m": ["vit_so400m_patch14_siglip_224"],
|
| 33 |
+
"siglip-vit-so400m-384px": ["vit_so400m_patch14_siglip_384"],
|
| 34 |
+
|
| 35 |
+
"dinoclip-vit-l-336px": ["vit_large_patch14_reg4_dinov2.lvd142m", "vit_large_patch14_clip_336.openai"],
|
| 36 |
+
"dinosiglip-vit-so-224px": ["vit_large_patch14_reg4_dinov2.lvd142m", "vit_so400m_patch14_siglip_224"],
|
| 37 |
+
"dinosiglip-vit-so-384px": ["vit_large_patch14_reg4_dinov2.lvd142m", "vit_so400m_patch14_siglip_384"],
|
| 38 |
+
}
|
| 39 |
+
TIMM_OVERRIDE_ACT_LAYER: Dict[str, List[Optional[str]]] = {
|
| 40 |
+
"clip-vit-l": ["quick_gelu"], "clip-vit-l-336px": ["quick_gelu"],
|
| 41 |
+
"dinov2-vit-l": [None], "in1k-vit-l": [None],
|
| 42 |
+
"siglip-vit-so400m": [None], "siglip-vit-so400m-384px": [None],
|
| 43 |
+
"dinoclip-vit-l-336px": [None, "quick_gelu"],
|
| 44 |
+
"dinosiglip-vit-so-224px": [None, None], "dinosiglip-vit-so-384px": [None, None]
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
LLM_BACKBONE_TO_HF_PATH = {
|
| 48 |
+
"llama2-7b-pure": "meta-llama/Llama-2-7b-hf", "llama2-13b-pure": "meta-llama/Llama-2-13b-hf",
|
| 49 |
+
"llama2-7b-chat": "meta-llama/Llama-2-7b-chat-hf", "llama2-13b-chat": "meta-llama/Llama-2-13b-chat-hf",
|
| 50 |
+
|
| 51 |
+
"vicuna-v15-7b": "lmsys/vicuna-7b-v1.5", "vicuna-v15-13b": "lmsys/vicuna-13b-v1.5",
|
| 52 |
+
|
| 53 |
+
"mistral-v0.1-7b-pure": "mistralai/Mistral-7B-v0.1",
|
| 54 |
+
"mistral-v0.1-7b-instruct": "mistralai/Mistral-7B-Instruct-v0.1",
|
| 55 |
+
|
| 56 |
+
"phi-2-3b": "microsoft/phi-2",
|
| 57 |
+
"llama3.2-1b-pure": "meta-llama/Llama-3.2-1B",
|
| 58 |
+
}
|
| 59 |
+
LLM_BACKBONE_TO_HF_METACLASS = {
|
| 60 |
+
"llama2-7b-pure": "llama", "llama2-13b-pure": "llama", "llama2-7b-chat": "llama", "llama2-13b-chat": "llama",
|
| 61 |
+
"vicuna-v15-7b": "llama", "vicuna-v15-13b": "llama",
|
| 62 |
+
|
| 63 |
+
"mistral-v0.1-7b-pure": "mistral", "mistral-v0.1-7b-instruct": "mistral",
|
| 64 |
+
|
| 65 |
+
"phi-2-3b": "phi",
|
| 66 |
+
"llama3.2-1b-pure": "llama",
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
VALID_VISION_BACKBONES = set(VISION_BACKBONE_TO_RESOLUTION.keys())
|
| 70 |
+
VALID_LLM_BACKBONES = set(LLM_BACKBONE_TO_HF_PATH)
|
| 71 |
+
# fmt: on
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class PrismaticConfig(PretrainedConfig):
|
| 75 |
+
model_type: str = "prismatic"
|
| 76 |
+
is_composition: bool = False
|
| 77 |
+
|
| 78 |
+
def __init__(
|
| 79 |
+
self,
|
| 80 |
+
vision_backbone_id: str = "siglip-vit-so400m",
|
| 81 |
+
llm_backbone_id: str = "vicuna-v15-7b",
|
| 82 |
+
arch_specifier: str = "no-align+gelu-mlp",
|
| 83 |
+
use_fused_vision_backbone: Optional[bool] = None,
|
| 84 |
+
image_resize_strategy: str = "letterbox",
|
| 85 |
+
text_config: Optional[Dict[str, Any]] = None,
|
| 86 |
+
llm_max_length: int = 2048,
|
| 87 |
+
pad_token_id: int = 32000,
|
| 88 |
+
pad_to_multiple_of: int = 64,
|
| 89 |
+
output_projector_states: bool = False,
|
| 90 |
+
**kwargs: str,
|
| 91 |
+
) -> None:
|
| 92 |
+
if vision_backbone_id not in VALID_VISION_BACKBONES:
|
| 93 |
+
raise ValueError(f"Vision backbone `{vision_backbone_id}` not in {VALID_VISION_BACKBONES = }")
|
| 94 |
+
|
| 95 |
+
if llm_backbone_id not in VALID_LLM_BACKBONES:
|
| 96 |
+
raise ValueError(f"LLM backbone `{llm_backbone_id}` not in {VALID_LLM_BACKBONES = }")
|
| 97 |
+
|
| 98 |
+
# Set Prismatic Configuration Fields
|
| 99 |
+
self.vision_backbone_id = vision_backbone_id
|
| 100 |
+
self.llm_backbone_id = llm_backbone_id
|
| 101 |
+
self.arch_specifier = arch_specifier
|
| 102 |
+
self.output_projector_states = output_projector_states
|
| 103 |
+
|
| 104 |
+
# [Contract] All vision backbone parameters are lists =>> supports fused backbones with different preprocessing
|
| 105 |
+
self.use_fused_vision_backbone = (
|
| 106 |
+
use_fused_vision_backbone
|
| 107 |
+
if use_fused_vision_backbone is not None
|
| 108 |
+
else any(self.vision_backbone_id.startswith(v) for v in ["dinoclip", "dinosiglip"])
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
self.timm_model_ids = VISION_BACKBONE_TO_TIMM_ID[self.vision_backbone_id]
|
| 112 |
+
self.timm_override_act_layers = TIMM_OVERRIDE_ACT_LAYER[self.vision_backbone_id]
|
| 113 |
+
self.image_sizes = VISION_BACKBONE_TO_RESOLUTION[self.vision_backbone_id]
|
| 114 |
+
self.image_resize_strategy = image_resize_strategy
|
| 115 |
+
|
| 116 |
+
self.hf_llm_id = LLM_BACKBONE_TO_HF_PATH[self.llm_backbone_id]
|
| 117 |
+
self.llm_max_length = llm_max_length
|
| 118 |
+
self.pad_token_id, self.pad_to_multiple_of = pad_token_id, pad_to_multiple_of
|
| 119 |
+
|
| 120 |
+
# [IMPORTANT] HF Utilities actually look for a `text_config` field... we need to use that specific naming!
|
| 121 |
+
self.text_config = (
|
| 122 |
+
CONFIG_MAPPING[LLM_BACKBONE_TO_HF_METACLASS[self.llm_backbone_id]](**text_config)
|
| 123 |
+
if text_config is not None
|
| 124 |
+
else CONFIG_MAPPING[LLM_BACKBONE_TO_HF_METACLASS[self.llm_backbone_id]]()
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
# Dispatch **kwargs to super() =>> note that `pad_token_id` collides, so we pass it in here as well...
|
| 128 |
+
super().__init__(pad_token_id=pad_token_id, **kwargs)
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
class OpenVLAConfig(PrismaticConfig):
|
| 132 |
+
model_type: str = "openvla"
|
| 133 |
+
|
| 134 |
+
def __init__(
|
| 135 |
+
self,
|
| 136 |
+
norm_stats: Optional[Dict[str, Dict[str, Dict[str, Dict[str, List[float]]]]]] = None,
|
| 137 |
+
n_action_bins: int = 256,
|
| 138 |
+
**kwargs: str,
|
| 139 |
+
) -> None:
|
| 140 |
+
self.norm_stats, self.n_action_bins = norm_stats, n_action_bins
|
| 141 |
+
|
| 142 |
+
super().__init__(**kwargs)
|
dataset_statistics.json
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"libero_spatial_no_noops": {
|
| 3 |
+
"action": {
|
| 4 |
+
"mean": [
|
| 5 |
+
0.15312479436397552,
|
| 6 |
+
0.13707277178764343,
|
| 7 |
+
-0.15526802837848663,
|
| 8 |
+
-0.005176450591534376,
|
| 9 |
+
-0.01120874285697937,
|
| 10 |
+
-0.020194264128804207,
|
| 11 |
+
0.4578818082809448
|
| 12 |
+
],
|
| 13 |
+
"std": [
|
| 14 |
+
0.41272708773612976,
|
| 15 |
+
0.34724321961402893,
|
| 16 |
+
0.50869220495224,
|
| 17 |
+
0.037266165018081665,
|
| 18 |
+
0.07244449853897095,
|
| 19 |
+
0.05762382969260216,
|
| 20 |
+
0.49827873706817627
|
| 21 |
+
],
|
| 22 |
+
"max": [
|
| 23 |
+
0.9375,
|
| 24 |
+
0.9375,
|
| 25 |
+
0.9375,
|
| 26 |
+
0.1971428543329239,
|
| 27 |
+
0.33642858266830444,
|
| 28 |
+
0.375,
|
| 29 |
+
1.0
|
| 30 |
+
],
|
| 31 |
+
"min": [
|
| 32 |
+
-0.9375,
|
| 33 |
+
-0.9375,
|
| 34 |
+
-0.9375,
|
| 35 |
+
-0.1875,
|
| 36 |
+
-0.3675000071525574,
|
| 37 |
+
-0.36000001430511475,
|
| 38 |
+
0.0
|
| 39 |
+
],
|
| 40 |
+
"q01": [
|
| 41 |
+
-0.7454732114076613,
|
| 42 |
+
-0.6616071462631226,
|
| 43 |
+
-0.9375,
|
| 44 |
+
-0.1071428582072258,
|
| 45 |
+
-0.20678570866584778,
|
| 46 |
+
-0.1842857152223587,
|
| 47 |
+
0.0
|
| 48 |
+
],
|
| 49 |
+
"q99": [
|
| 50 |
+
0.9375,
|
| 51 |
+
0.8758928775787354,
|
| 52 |
+
0.9321428537368774,
|
| 53 |
+
0.1039285734295845,
|
| 54 |
+
0.17678570747375488,
|
| 55 |
+
0.14571428298950195,
|
| 56 |
+
1.0
|
| 57 |
+
],
|
| 58 |
+
"mask": [
|
| 59 |
+
true,
|
| 60 |
+
true,
|
| 61 |
+
true,
|
| 62 |
+
true,
|
| 63 |
+
true,
|
| 64 |
+
true,
|
| 65 |
+
false
|
| 66 |
+
]
|
| 67 |
+
},
|
| 68 |
+
"proprio": {
|
| 69 |
+
"mean": [
|
| 70 |
+
-0.024462558329105377,
|
| 71 |
+
0.106529600918293,
|
| 72 |
+
1.0580483675003052,
|
| 73 |
+
3.0628468990325928,
|
| 74 |
+
-0.10464039444923401,
|
| 75 |
+
0.08307311683893204,
|
| 76 |
+
0.01995457336306572,
|
| 77 |
+
-0.020162804052233696
|
| 78 |
+
],
|
| 79 |
+
"std": [
|
| 80 |
+
0.1101478561758995,
|
| 81 |
+
0.13784688711166382,
|
| 82 |
+
0.1044282391667366,
|
| 83 |
+
0.10451053828001022,
|
| 84 |
+
0.4112098217010498,
|
| 85 |
+
0.2176690548658371,
|
| 86 |
+
0.017260896041989326,
|
| 87 |
+
0.0171116404235363
|
| 88 |
+
],
|
| 89 |
+
"max": [
|
| 90 |
+
0.1759040206670761,
|
| 91 |
+
0.3904820382595062,
|
| 92 |
+
1.3290715217590332,
|
| 93 |
+
3.4566118717193604,
|
| 94 |
+
1.2268599271774292,
|
| 95 |
+
1.0429412126541138,
|
| 96 |
+
0.041053611785173416,
|
| 97 |
+
0.000775813648942858
|
| 98 |
+
],
|
| 99 |
+
"min": [
|
| 100 |
+
-0.3095473051071167,
|
| 101 |
+
-0.29250794649124146,
|
| 102 |
+
0.9095591306686401,
|
| 103 |
+
2.497488260269165,
|
| 104 |
+
-1.8006486892700195,
|
| 105 |
+
-0.7207611203193665,
|
| 106 |
+
-0.0004703797458205372,
|
| 107 |
+
-0.041536275297403336
|
| 108 |
+
],
|
| 109 |
+
"q01": [
|
| 110 |
+
-0.2727657300233841,
|
| 111 |
+
-0.23721413239836692,
|
| 112 |
+
0.9160063165426254,
|
| 113 |
+
2.77949666261673,
|
| 114 |
+
-1.3187511622905732,
|
| 115 |
+
-0.41989982962608335,
|
| 116 |
+
0.001503719249740243,
|
| 117 |
+
-0.03989770736545324
|
| 118 |
+
],
|
| 119 |
+
"q99": [
|
| 120 |
+
0.13529365032911292,
|
| 121 |
+
0.3629165390133857,
|
| 122 |
+
1.2862326657772063,
|
| 123 |
+
3.2829698753356933,
|
| 124 |
+
0.9332760351896285,
|
| 125 |
+
0.6325724506378171,
|
| 126 |
+
0.039933966137468815,
|
| 127 |
+
-0.001671919699292631
|
| 128 |
+
]
|
| 129 |
+
},
|
| 130 |
+
"num_transitions": 52970,
|
| 131 |
+
"num_trajectories": 432
|
| 132 |
+
}
|
| 133 |
+
}
|
lora_adapter/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: /home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm
|
| 3 |
+
library_name: peft
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Model Card for Model ID
|
| 7 |
+
|
| 8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
## Model Details
|
| 13 |
+
|
| 14 |
+
### Model Description
|
| 15 |
+
|
| 16 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
- **Developed by:** [More Information Needed]
|
| 21 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
+
- **Model type:** [More Information Needed]
|
| 24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
+
- **License:** [More Information Needed]
|
| 26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
+
|
| 28 |
+
### Model Sources [optional]
|
| 29 |
+
|
| 30 |
+
<!-- Provide the basic links for the model. -->
|
| 31 |
+
|
| 32 |
+
- **Repository:** [More Information Needed]
|
| 33 |
+
- **Paper [optional]:** [More Information Needed]
|
| 34 |
+
- **Demo [optional]:** [More Information Needed]
|
| 35 |
+
|
| 36 |
+
## Uses
|
| 37 |
+
|
| 38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
+
|
| 40 |
+
### Direct Use
|
| 41 |
+
|
| 42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
+
|
| 44 |
+
[More Information Needed]
|
| 45 |
+
|
| 46 |
+
### Downstream Use [optional]
|
| 47 |
+
|
| 48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
+
|
| 50 |
+
[More Information Needed]
|
| 51 |
+
|
| 52 |
+
### Out-of-Scope Use
|
| 53 |
+
|
| 54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
+
|
| 56 |
+
[More Information Needed]
|
| 57 |
+
|
| 58 |
+
## Bias, Risks, and Limitations
|
| 59 |
+
|
| 60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
+
|
| 62 |
+
[More Information Needed]
|
| 63 |
+
|
| 64 |
+
### Recommendations
|
| 65 |
+
|
| 66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
+
|
| 68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
+
|
| 70 |
+
## How to Get Started with the Model
|
| 71 |
+
|
| 72 |
+
Use the code below to get started with the model.
|
| 73 |
+
|
| 74 |
+
[More Information Needed]
|
| 75 |
+
|
| 76 |
+
## Training Details
|
| 77 |
+
|
| 78 |
+
### Training Data
|
| 79 |
+
|
| 80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
+
|
| 82 |
+
[More Information Needed]
|
| 83 |
+
|
| 84 |
+
### Training Procedure
|
| 85 |
+
|
| 86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
+
|
| 88 |
+
#### Preprocessing [optional]
|
| 89 |
+
|
| 90 |
+
[More Information Needed]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
#### Training Hyperparameters
|
| 94 |
+
|
| 95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
+
|
| 97 |
+
#### Speeds, Sizes, Times [optional]
|
| 98 |
+
|
| 99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
+
|
| 101 |
+
[More Information Needed]
|
| 102 |
+
|
| 103 |
+
## Evaluation
|
| 104 |
+
|
| 105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
+
|
| 107 |
+
### Testing Data, Factors & Metrics
|
| 108 |
+
|
| 109 |
+
#### Testing Data
|
| 110 |
+
|
| 111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
+
|
| 113 |
+
[More Information Needed]
|
| 114 |
+
|
| 115 |
+
#### Factors
|
| 116 |
+
|
| 117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
+
|
| 119 |
+
[More Information Needed]
|
| 120 |
+
|
| 121 |
+
#### Metrics
|
| 122 |
+
|
| 123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
+
|
| 125 |
+
[More Information Needed]
|
| 126 |
+
|
| 127 |
+
### Results
|
| 128 |
+
|
| 129 |
+
[More Information Needed]
|
| 130 |
+
|
| 131 |
+
#### Summary
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
## Model Examination [optional]
|
| 136 |
+
|
| 137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
+
|
| 139 |
+
[More Information Needed]
|
| 140 |
+
|
| 141 |
+
## Environmental Impact
|
| 142 |
+
|
| 143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
+
|
| 145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
+
|
| 147 |
+
- **Hardware Type:** [More Information Needed]
|
| 148 |
+
- **Hours used:** [More Information Needed]
|
| 149 |
+
- **Cloud Provider:** [More Information Needed]
|
| 150 |
+
- **Compute Region:** [More Information Needed]
|
| 151 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
+
|
| 153 |
+
## Technical Specifications [optional]
|
| 154 |
+
|
| 155 |
+
### Model Architecture and Objective
|
| 156 |
+
|
| 157 |
+
[More Information Needed]
|
| 158 |
+
|
| 159 |
+
### Compute Infrastructure
|
| 160 |
+
|
| 161 |
+
[More Information Needed]
|
| 162 |
+
|
| 163 |
+
#### Hardware
|
| 164 |
+
|
| 165 |
+
[More Information Needed]
|
| 166 |
+
|
| 167 |
+
#### Software
|
| 168 |
+
|
| 169 |
+
[More Information Needed]
|
| 170 |
+
|
| 171 |
+
## Citation [optional]
|
| 172 |
+
|
| 173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
+
|
| 175 |
+
**BibTeX:**
|
| 176 |
+
|
| 177 |
+
[More Information Needed]
|
| 178 |
+
|
| 179 |
+
**APA:**
|
| 180 |
+
|
| 181 |
+
[More Information Needed]
|
| 182 |
+
|
| 183 |
+
## Glossary [optional]
|
| 184 |
+
|
| 185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
+
|
| 187 |
+
[More Information Needed]
|
| 188 |
+
|
| 189 |
+
## More Information [optional]
|
| 190 |
+
|
| 191 |
+
[More Information Needed]
|
| 192 |
+
|
| 193 |
+
## Model Card Authors [optional]
|
| 194 |
+
|
| 195 |
+
[More Information Needed]
|
| 196 |
+
|
| 197 |
+
## Model Card Contact
|
| 198 |
+
|
| 199 |
+
[More Information Needed]
|
| 200 |
+
### Framework versions
|
| 201 |
+
|
| 202 |
+
- PEFT 0.11.1
|
lora_adapter/adapter_config.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": {
|
| 4 |
+
"base_model_class": "OpenVLAForActionPrediction",
|
| 5 |
+
"parent_library": "transformers_modules.prismatic-llama3.2-dinosiglip-224px-1b-vlm.modeling_prismatic"
|
| 6 |
+
},
|
| 7 |
+
"base_model_name_or_path": "/home/user1/workspace/juyi/lisaopenvla/hf-convert/prismatic-llama3.2-dinosiglip-224px-1b-vlm",
|
| 8 |
+
"bias": "none",
|
| 9 |
+
"fan_in_fan_out": false,
|
| 10 |
+
"inference_mode": true,
|
| 11 |
+
"init_lora_weights": "gaussian",
|
| 12 |
+
"layer_replication": null,
|
| 13 |
+
"layers_pattern": null,
|
| 14 |
+
"layers_to_transform": null,
|
| 15 |
+
"loftq_config": {},
|
| 16 |
+
"lora_alpha": 16,
|
| 17 |
+
"lora_dropout": 0.0,
|
| 18 |
+
"megatron_config": null,
|
| 19 |
+
"megatron_core": "megatron.core",
|
| 20 |
+
"modules_to_save": null,
|
| 21 |
+
"peft_type": "LORA",
|
| 22 |
+
"r": 32,
|
| 23 |
+
"rank_pattern": {},
|
| 24 |
+
"revision": null,
|
| 25 |
+
"target_modules": [
|
| 26 |
+
"k_proj",
|
| 27 |
+
"v_proj",
|
| 28 |
+
"q",
|
| 29 |
+
"lm_head",
|
| 30 |
+
"fc1",
|
| 31 |
+
"qkv",
|
| 32 |
+
"kv",
|
| 33 |
+
"fc3",
|
| 34 |
+
"fc2",
|
| 35 |
+
"o_proj",
|
| 36 |
+
"up_proj",
|
| 37 |
+
"q_proj",
|
| 38 |
+
"gate_proj",
|
| 39 |
+
"proj",
|
| 40 |
+
"down_proj"
|
| 41 |
+
],
|
| 42 |
+
"task_type": null,
|
| 43 |
+
"use_dora": false,
|
| 44 |
+
"use_rslora": false
|
| 45 |
+
}
|
lora_adapter/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:914179b95993ea021e03d3d3f62cc0528f2adc3ded5086e5df998cb80759c68a
|
| 3 |
+
size 638172008
|
modeling_prismatic.py
ADDED
|
@@ -0,0 +1,1556 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
modeling_prismatic.py
|
| 3 |
+
|
| 4 |
+
Core HuggingFace-style PrismaticPreTrainedModel and PrismaticForConditionalGeneration class definitions.
|
| 5 |
+
Inherits from the default `transformers.PretrainedModel`. Meant to be standalone and self-contained,
|
| 6 |
+
but exactly replicate the logic in `prismatic.models.vlms.prismatic.py`.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import logging
|
| 10 |
+
from dataclasses import dataclass
|
| 11 |
+
from functools import partial
|
| 12 |
+
from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple, Union
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
import timm
|
| 16 |
+
import tokenizers
|
| 17 |
+
import torch
|
| 18 |
+
import torch.nn as nn
|
| 19 |
+
import transformers
|
| 20 |
+
from timm.models.vision_transformer import LayerScale
|
| 21 |
+
from transformers import AutoModelForCausalLM, PretrainedConfig, PreTrainedModel
|
| 22 |
+
from transformers.modeling_outputs import ModelOutput
|
| 23 |
+
from prismatic.models.action_heads import L1RegressionActionHead, DiTActionHead, FlowMatchingActionHead
|
| 24 |
+
from prismatic.training.train_utils import (
|
| 25 |
+
get_current_action_mask,
|
| 26 |
+
get_next_actions_mask,
|
| 27 |
+
)
|
| 28 |
+
from prismatic.vla.constants import (
|
| 29 |
+
ACTION_DIM,
|
| 30 |
+
ACTION_PROPRIO_NORMALIZATION_TYPE,
|
| 31 |
+
IGNORE_INDEX,
|
| 32 |
+
NUM_ACTIONS_CHUNK,
|
| 33 |
+
ACTION_TOKEN_IDX,
|
| 34 |
+
NormalizationType,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
from .configuration_prismatic import OpenVLAConfig, PrismaticConfig
|
| 38 |
+
|
| 39 |
+
# Set up logger
|
| 40 |
+
logger = logging.getLogger(__name__)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# === Utility Functions for Monkey-Patching ===
|
| 44 |
+
def unpack_tuple(fn: Callable[[Any], Tuple[Any]]) -> Callable[[Any], Any]:
|
| 45 |
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
| 46 |
+
result = fn(*args, **kwargs)
|
| 47 |
+
return result[0] if isinstance(result, tuple) else result
|
| 48 |
+
|
| 49 |
+
return wrapper
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
# HF Transformers overwrites parameters with names containing `gamma`; we're going to patch VisionBackbone.LayerScale.
|
| 53 |
+
# =>> TIMM :: https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/vision_transformer.py#L109
|
| 54 |
+
# =>> Transformers :: https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3960
|
| 55 |
+
def _ls_new_forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 56 |
+
return x.mul_(self.scale_factor) if self.inplace else x * self.scale_factor
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def ls_apply_patch(ls_module: LayerScale):
|
| 60 |
+
ls_module.scale_factor = nn.Parameter(ls_module.gamma.clone())
|
| 61 |
+
ls_module.forward = _ls_new_forward.__get__(ls_module, LayerScale)
|
| 62 |
+
del ls_module.gamma
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# === Prismatic Vision Backbone (nn.Module) Definitions (w/ Fused Backbone Support) ===
|
| 66 |
+
class PrismaticVisionBackbone(nn.Module):
|
| 67 |
+
"""
|
| 68 |
+
Vision backbone for Prismatic models that handles image feature extraction.
|
| 69 |
+
|
| 70 |
+
Supports both single backbone (e.g., SigLIP) and fused backbone (e.g., SigLIP + DINOv2) configurations.
|
| 71 |
+
For fused backbones, features from both models are concatenated along the feature dimension.
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
def __init__(
|
| 75 |
+
self,
|
| 76 |
+
use_fused_vision_backbone: bool,
|
| 77 |
+
image_sizes: List[int],
|
| 78 |
+
timm_model_ids: List[str],
|
| 79 |
+
timm_override_act_layers: List[Optional[str]],
|
| 80 |
+
) -> None:
|
| 81 |
+
"""
|
| 82 |
+
Initialize the vision backbone.
|
| 83 |
+
|
| 84 |
+
Args:
|
| 85 |
+
use_fused_vision_backbone: Whether to use two backbones and fuse their features
|
| 86 |
+
image_sizes: List of image sizes for each backbone
|
| 87 |
+
timm_model_ids: List of TIMM model IDs to use for each backbone
|
| 88 |
+
timm_override_act_layers: List of activation layer overrides for each backbone
|
| 89 |
+
"""
|
| 90 |
+
super().__init__()
|
| 91 |
+
self.use_fused_vision_backbone = use_fused_vision_backbone
|
| 92 |
+
self.num_images_in_input = 1 # Default value, can be overridden later
|
| 93 |
+
|
| 94 |
+
# Validate number of (fused) vision backbones
|
| 95 |
+
if len(timm_model_ids) > 2:
|
| 96 |
+
raise ValueError("Prismatic models only support up to 2 (fused) vision backbones!")
|
| 97 |
+
|
| 98 |
+
# Create primary featurizer
|
| 99 |
+
self.featurizer = self._create_featurizer(
|
| 100 |
+
model_id=timm_model_ids[0], img_size=image_sizes[0], act_layer=timm_override_act_layers[0]
|
| 101 |
+
)
|
| 102 |
+
self.embed_dim = self.featurizer.embed_dim
|
| 103 |
+
|
| 104 |
+
# Create secondary featurizer if using fused backbone
|
| 105 |
+
if self.use_fused_vision_backbone:
|
| 106 |
+
self.fused_featurizer = self._create_featurizer(
|
| 107 |
+
model_id=timm_model_ids[1], img_size=image_sizes[1], act_layer=timm_override_act_layers[1]
|
| 108 |
+
)
|
| 109 |
+
self.embed_dim += self.fused_featurizer.embed_dim
|
| 110 |
+
|
| 111 |
+
# Patch LayerScale modules for HF compatibility
|
| 112 |
+
self._patch_layer_scales()
|
| 113 |
+
|
| 114 |
+
def _create_featurizer(self, model_id: str, img_size: int, act_layer: Optional[str]) -> nn.Module:
|
| 115 |
+
"""
|
| 116 |
+
Create a TIMM-based featurizer model with appropriate configurations.
|
| 117 |
+
|
| 118 |
+
Args:
|
| 119 |
+
model_id: The TIMM model ID to load
|
| 120 |
+
img_size: Input image size for the model
|
| 121 |
+
act_layer: Override for the activation layer type
|
| 122 |
+
|
| 123 |
+
Returns:
|
| 124 |
+
A configured featurizer model
|
| 125 |
+
"""
|
| 126 |
+
featurizer = timm.create_model(
|
| 127 |
+
model_id,
|
| 128 |
+
pretrained=False,
|
| 129 |
+
num_classes=0,
|
| 130 |
+
img_size=img_size,
|
| 131 |
+
act_layer=act_layer,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# Monkey-patch the forward function to extract the second-to-last layer features
|
| 135 |
+
num_blocks = len(featurizer.blocks)
|
| 136 |
+
featurizer.forward = unpack_tuple(partial(featurizer.get_intermediate_layers, n={num_blocks - 2}))
|
| 137 |
+
|
| 138 |
+
return featurizer
|
| 139 |
+
|
| 140 |
+
def _patch_layer_scales(self) -> None:
|
| 141 |
+
"""
|
| 142 |
+
Patch all LayerScale modules to be compatible with HF's parameter naming.
|
| 143 |
+
|
| 144 |
+
HF Transformers overwrites parameters with names containing 'gamma',
|
| 145 |
+
so we need to rename and modify the forward method.
|
| 146 |
+
"""
|
| 147 |
+
# Patch primary featurizer
|
| 148 |
+
for module in self.featurizer.modules():
|
| 149 |
+
if isinstance(module, LayerScale):
|
| 150 |
+
ls_apply_patch(module)
|
| 151 |
+
|
| 152 |
+
# Patch secondary featurizer if it exists
|
| 153 |
+
if self.use_fused_vision_backbone:
|
| 154 |
+
for module in self.fused_featurizer.modules():
|
| 155 |
+
if isinstance(module, LayerScale):
|
| 156 |
+
ls_apply_patch(module)
|
| 157 |
+
|
| 158 |
+
def get_num_patches(self) -> int:
|
| 159 |
+
"""
|
| 160 |
+
Returns the number of vision patches output by the vision backbone.
|
| 161 |
+
|
| 162 |
+
Returns:
|
| 163 |
+
Number of patches per image
|
| 164 |
+
"""
|
| 165 |
+
return self.featurizer.patch_embed.num_patches
|
| 166 |
+
|
| 167 |
+
def get_num_images_in_input(self) -> int:
|
| 168 |
+
"""
|
| 169 |
+
Returns the number of input images for the vision backbone.
|
| 170 |
+
|
| 171 |
+
Returns:
|
| 172 |
+
Number of images expected in the input
|
| 173 |
+
"""
|
| 174 |
+
return self.num_images_in_input
|
| 175 |
+
|
| 176 |
+
def set_num_images_in_input(self, num_images_in_input: int) -> None:
|
| 177 |
+
"""
|
| 178 |
+
Sets the number of input images for the vision backbone.
|
| 179 |
+
|
| 180 |
+
Args:
|
| 181 |
+
num_images_in_input: Number of images to expect in the input
|
| 182 |
+
"""
|
| 183 |
+
self.num_images_in_input = num_images_in_input
|
| 184 |
+
|
| 185 |
+
def forward(self, pixel_values: torch.Tensor) -> torch.Tensor:
|
| 186 |
+
"""
|
| 187 |
+
Implements the forward pass for the vision backbone.
|
| 188 |
+
|
| 189 |
+
If `self.use_fused_vision_backbone == True`, uses both SigLIP and DINOv2 transformers to extract visual features
|
| 190 |
+
(otherwise uses SigLIP only). Allows multi-image inputs (but only for fused vision backbone).
|
| 191 |
+
|
| 192 |
+
Args:
|
| 193 |
+
pixel_values (torch.Tensor): Pixels for input image(s), (B, C, H, W).
|
| 194 |
+
"""
|
| 195 |
+
if self.num_images_in_input == 1:
|
| 196 |
+
if not self.use_fused_vision_backbone:
|
| 197 |
+
return self.featurizer(pixel_values)
|
| 198 |
+
|
| 199 |
+
# Split `pixel_values :: [bsz, 2 * 3, resolution, resolution]` =>> featurize =>> channel stack
|
| 200 |
+
img, img_fused = torch.split(pixel_values, [3, 3], dim=1)
|
| 201 |
+
patches, patches_fused = self.featurizer(img), self.fused_featurizer(img_fused)
|
| 202 |
+
|
| 203 |
+
return torch.cat([patches, patches_fused], dim=2)
|
| 204 |
+
|
| 205 |
+
else:
|
| 206 |
+
assert self.use_fused_vision_backbone, "Multi-image inputs require using fused backbone!"
|
| 207 |
+
|
| 208 |
+
# Split `pixel_values` into individual images (each with 6 channels: 3 for SigLIP + 3 for DINOv2)
|
| 209 |
+
images = torch.split(pixel_values, [6] * self.num_images_in_input, dim=1)
|
| 210 |
+
|
| 211 |
+
# Process each image and collect patches
|
| 212 |
+
all_patches = []
|
| 213 |
+
for img in images:
|
| 214 |
+
# Split each image further into two stacks of channels (each with 3 channels)
|
| 215 |
+
img_regular, img_fused = torch.split(img, [3, 3], dim=1)
|
| 216 |
+
|
| 217 |
+
# Get patches from both SigLIP and DINOv2 vision transformers
|
| 218 |
+
patches = self.featurizer(img_regular)
|
| 219 |
+
patches_fused = self.fused_featurizer(img_fused)
|
| 220 |
+
|
| 221 |
+
# Concatenate SigLIP and DINOv2 patches along the hidden dimension
|
| 222 |
+
combined_patches = torch.cat([patches, patches_fused], dim=2)
|
| 223 |
+
all_patches.append(combined_patches)
|
| 224 |
+
|
| 225 |
+
# Concatenate all patches along the patch dimension
|
| 226 |
+
return torch.cat(all_patches, dim=1)
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
# === Prismatic Projector (nn.Module) Definitions ===
|
| 230 |
+
class PrismaticProjector(nn.Module):
|
| 231 |
+
def __init__(self, use_fused_vision_backbone: bool, vision_dim: int, llm_dim: int) -> None:
|
| 232 |
+
super().__init__()
|
| 233 |
+
self.use_fused_vision_backbone = use_fused_vision_backbone
|
| 234 |
+
self.vision_dim, self.llm_dim = vision_dim, llm_dim
|
| 235 |
+
|
| 236 |
+
# Switch on `use_fused_vision_backbone` =>> use slightly different MLPs and projection factors!
|
| 237 |
+
if not self.use_fused_vision_backbone:
|
| 238 |
+
self.fc1 = nn.Linear(self.vision_dim, self.llm_dim, bias=True)
|
| 239 |
+
self.fc2 = nn.Linear(self.llm_dim, self.llm_dim, bias=True)
|
| 240 |
+
self.act_fn1 = nn.GELU()
|
| 241 |
+
else:
|
| 242 |
+
initial_projection_dim = 4 * vision_dim
|
| 243 |
+
self.fc1 = nn.Linear(self.vision_dim, initial_projection_dim, bias=True)
|
| 244 |
+
self.fc2 = nn.Linear(initial_projection_dim, self.llm_dim, bias=True)
|
| 245 |
+
self.fc3 = nn.Linear(self.llm_dim, self.llm_dim, bias=True)
|
| 246 |
+
self.act_fn1 = nn.GELU()
|
| 247 |
+
self.act_fn2 = nn.GELU()
|
| 248 |
+
|
| 249 |
+
def forward(self, img_patches: torch.Tensor) -> torch.Tensor:
|
| 250 |
+
if not self.use_fused_vision_backbone:
|
| 251 |
+
projected_features = self.fc1(img_patches)
|
| 252 |
+
projected_features = self.act_fn1(projected_features)
|
| 253 |
+
projected_features = self.fc2(projected_features)
|
| 254 |
+
else:
|
| 255 |
+
projected_features = self.fc1(img_patches)
|
| 256 |
+
projected_features = self.act_fn1(projected_features)
|
| 257 |
+
projected_features = self.fc2(projected_features)
|
| 258 |
+
projected_features = self.act_fn2(projected_features)
|
| 259 |
+
projected_features = self.fc3(projected_features)
|
| 260 |
+
|
| 261 |
+
return projected_features
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
# === Main HF Class Definitions ===
|
| 265 |
+
@dataclass
|
| 266 |
+
class PrismaticCausalLMOutputWithPast(ModelOutput):
|
| 267 |
+
"""Base class for Prismatic casual (visually-conditioned) language model outputs; also exposes visual features."""
|
| 268 |
+
|
| 269 |
+
loss: Optional[torch.FloatTensor] = None
|
| 270 |
+
logits: torch.FloatTensor = None
|
| 271 |
+
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None
|
| 272 |
+
hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
| 273 |
+
attentions: Optional[Tuple[torch.FloatTensor]] = None
|
| 274 |
+
|
| 275 |
+
# Additions for VLMs
|
| 276 |
+
projector_features: Optional[torch.FloatTensor] = None
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
class PrismaticPreTrainedModel(PreTrainedModel):
|
| 280 |
+
config_class: PretrainedConfig = PrismaticConfig
|
| 281 |
+
base_model_prefix: str = "model"
|
| 282 |
+
supports_gradient_checkpointing: bool = True
|
| 283 |
+
|
| 284 |
+
_no_split_modules: ClassVar[List[str]] = ["PrismaticProjector"]
|
| 285 |
+
_skip_keys_device_placement: str = "past_key_values"
|
| 286 |
+
_supports_flash_attn_2: bool = True
|
| 287 |
+
|
| 288 |
+
def _init_weights(self, module: nn.Module) -> None:
|
| 289 |
+
# Important :: this HF ported version is *not* meant for training from scratch; only inference and fine-tuning!
|
| 290 |
+
# => As such, this init_weights code is not correct; if training VLMs from scratch, use the main codebase at
|
| 291 |
+
# https://github.com/TRI-ML/prismatic-vlms
|
| 292 |
+
std = (
|
| 293 |
+
self.config.initializer_range
|
| 294 |
+
if hasattr(self.config, "initializer_range")
|
| 295 |
+
else self.config.text_config.initializer_range
|
| 296 |
+
)
|
| 297 |
+
|
| 298 |
+
if hasattr(module, "class_embedding"):
|
| 299 |
+
module.class_embedding.data.normal_(mean=0.0, std=std)
|
| 300 |
+
|
| 301 |
+
if isinstance(module, (nn.Linear, nn.Conv2d)):
|
| 302 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 303 |
+
if module.bias is not None:
|
| 304 |
+
module.bias.data.zero_()
|
| 305 |
+
elif isinstance(module, nn.Embedding):
|
| 306 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 307 |
+
if module.padding_idx is not None:
|
| 308 |
+
module.weight.data[module.padding_idx].zero_()
|
| 309 |
+
|
| 310 |
+
@property
|
| 311 |
+
def _supports_sdpa(self) -> bool:
|
| 312 |
+
"""Check LLM supports SDPA Attention"""
|
| 313 |
+
return self.language_model._supports_sdpa
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
class PrismaticForConditionalGeneration(PrismaticPreTrainedModel):
|
| 317 |
+
def __init__(self, config: PrismaticConfig) -> None:
|
| 318 |
+
super().__init__(config)
|
| 319 |
+
|
| 320 |
+
# [Validation] Lightweight Validate on `config` Fields + Dependency Versions
|
| 321 |
+
if config.use_fused_vision_backbone is None:
|
| 322 |
+
raise ValueError("Missing config field `use_fused_vision_backbone`")
|
| 323 |
+
|
| 324 |
+
if timm.__version__ not in {"0.9.10", "0.9.11", "0.9.12", "0.9.16"}:
|
| 325 |
+
raise NotImplementedError(
|
| 326 |
+
"TIMM Version must be >= 0.9.10 and < 1.0.0 (breaking); please raise a GitHub Issue "
|
| 327 |
+
"if you urgently need support for latest TIMM versions."
|
| 328 |
+
)
|
| 329 |
+
|
| 330 |
+
if (transformers.__version__ != "4.40.1") or (tokenizers.__version__ != "0.19.1"):
|
| 331 |
+
logger.warning(
|
| 332 |
+
f"Expected `transformers==4.40.1` and `tokenizers==0.19.1` but got "
|
| 333 |
+
f"`transformers=={transformers.__version__}` and `tokenizers=={tokenizers.__version__}`; "
|
| 334 |
+
f"there might be inference-time regressions due to dependency changes. If in doubt, please"
|
| 335 |
+
f"use the above versions."
|
| 336 |
+
)
|
| 337 |
+
|
| 338 |
+
# Instantiate PrismaticVisionBackbone (w/ Potential Fused Backbone)
|
| 339 |
+
self.vision_backbone = PrismaticVisionBackbone(
|
| 340 |
+
config.use_fused_vision_backbone, config.image_sizes, config.timm_model_ids, config.timm_override_act_layers
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
# Create Multimodal Projector
|
| 344 |
+
self.projector = PrismaticProjector(
|
| 345 |
+
config.use_fused_vision_backbone,
|
| 346 |
+
vision_dim=self.vision_backbone.embed_dim,
|
| 347 |
+
llm_dim=config.text_config.hidden_size,
|
| 348 |
+
)
|
| 349 |
+
|
| 350 |
+
# Instantiate LLM Backbone
|
| 351 |
+
self.language_model = AutoModelForCausalLM.from_config(
|
| 352 |
+
config.text_config, attn_implementation=config._attn_implementation
|
| 353 |
+
)
|
| 354 |
+
self.vocab_size = config.text_config.vocab_size
|
| 355 |
+
self.pad_token_id = config.pad_token_id
|
| 356 |
+
self.llm_dim = config.text_config.hidden_size
|
| 357 |
+
|
| 358 |
+
# HF Boilerplate =>> initializes weights via `_init_weights()` and sets gradient checkpointing
|
| 359 |
+
self.post_init()
|
| 360 |
+
|
| 361 |
+
# === `PreTrainedModel` Boilerplate ===
|
| 362 |
+
def get_input_embeddings(self) -> nn.Module:
|
| 363 |
+
return self.language_model.get_input_embeddings()
|
| 364 |
+
|
| 365 |
+
def set_input_embeddings(self, value: nn.Module) -> None:
|
| 366 |
+
self.language_model.set_input_embeddings(value)
|
| 367 |
+
|
| 368 |
+
def get_output_embeddings(self) -> nn.Module:
|
| 369 |
+
return self.language_model.get_output_embeddings()
|
| 370 |
+
|
| 371 |
+
def set_output_embeddings(self, new_embeddings: nn.Module) -> None:
|
| 372 |
+
self.language_model.set_output_embeddings(new_embeddings)
|
| 373 |
+
|
| 374 |
+
def get_decoder(self) -> nn.Module:
|
| 375 |
+
return self.language_model.get_decoder()
|
| 376 |
+
|
| 377 |
+
def set_decoder(self, decoder: nn.Module) -> None:
|
| 378 |
+
self.language_model.set_decoder(decoder)
|
| 379 |
+
|
| 380 |
+
def tie_weights(self) -> None:
|
| 381 |
+
self.language_model.tie_weights() # Note: `Llama-2` and `Mistral` don't tie weights (no-op)
|
| 382 |
+
|
| 383 |
+
def resize_token_embeddings(
|
| 384 |
+
self, new_num_tokens: Optional[int] = None, pad_to_multiple_of: Optional[int] = None
|
| 385 |
+
) -> nn.Embedding:
|
| 386 |
+
updated_embeddings = self.language_model.resize_token_embeddings(new_num_tokens, pad_to_multiple_of)
|
| 387 |
+
|
| 388 |
+
# Update config/instance variables
|
| 389 |
+
self.config.text_config.vocab_size = updated_embeddings.num_embeddings
|
| 390 |
+
self.vocab_size = updated_embeddings.num_embeddings
|
| 391 |
+
|
| 392 |
+
return updated_embeddings
|
| 393 |
+
|
| 394 |
+
def _replace_input_embeddings(self, input_embeddings, all_actions_mask, noisy_action_features):
|
| 395 |
+
"""
|
| 396 |
+
Replace embeddings in input_embeddings at positions where all_actions_mask is True
|
| 397 |
+
with embeddings from noisy_action_features, using vectorized operations.
|
| 398 |
+
|
| 399 |
+
Args:
|
| 400 |
+
input_embeddings: Tensor of shape (B, S, D)
|
| 401 |
+
all_actions_mask: Boolean tensor of shape (B, S)
|
| 402 |
+
noisy_action_features: Tensor of shape (B, K, D) where K is the number of True values in mask per sample
|
| 403 |
+
|
| 404 |
+
Returns:
|
| 405 |
+
Modified input_embeddings tensor
|
| 406 |
+
"""
|
| 407 |
+
# Clone input to avoid modifying the original tensor
|
| 408 |
+
new_input_embeddings = input_embeddings.clone()
|
| 409 |
+
|
| 410 |
+
# Create a tensor with the same shape of input_embeddings to hold the noisy action features
|
| 411 |
+
repositioned_noisy_action_features = torch.zeros_like(input_embeddings)
|
| 412 |
+
|
| 413 |
+
# Create batch indices for splicing
|
| 414 |
+
batch_indices = torch.arange(input_embeddings.shape[0], device=input_embeddings.device)
|
| 415 |
+
batch_indices = batch_indices.unsqueeze(1).expand(-1, noisy_action_features.shape[1])
|
| 416 |
+
|
| 417 |
+
# Get indices where mask is True for each sample
|
| 418 |
+
masked_indices = torch.stack([torch.where(mask)[0] for mask in all_actions_mask])
|
| 419 |
+
|
| 420 |
+
# Move the noisy action features into their correct positions
|
| 421 |
+
repositioned_noisy_action_features[batch_indices, masked_indices] = noisy_action_features
|
| 422 |
+
|
| 423 |
+
# Combine original input embeddings and noisy action embeddings using the mask
|
| 424 |
+
new_input_embeddings = torch.where(
|
| 425 |
+
all_actions_mask.unsqueeze(-1), repositioned_noisy_action_features, new_input_embeddings
|
| 426 |
+
)
|
| 427 |
+
|
| 428 |
+
return new_input_embeddings
|
| 429 |
+
|
| 430 |
+
def _process_action_masks(self, labels):
|
| 431 |
+
"""Helper to get action masks from labels"""
|
| 432 |
+
current_action_mask = get_current_action_mask(labels) # (B, seq_len)
|
| 433 |
+
next_actions_mask = get_next_actions_mask(labels) # (B, seq_len)
|
| 434 |
+
all_actions_mask = current_action_mask | next_actions_mask # (B, seq_len)
|
| 435 |
+
return all_actions_mask
|
| 436 |
+
|
| 437 |
+
def _process_vision_features(self, pixel_values):
|
| 438 |
+
"""Process vision features with optional FiLM conditioning"""
|
| 439 |
+
patch_features = self.vision_backbone(pixel_values) # (bsz, 256 * num_images, D)
|
| 440 |
+
|
| 441 |
+
# Project patch embeddings into language embedding space
|
| 442 |
+
return self.projector(patch_features)
|
| 443 |
+
|
| 444 |
+
def _process_proprio_features(self, projected_patch_embeddings, proprio, proprio_projector):
|
| 445 |
+
"""Process proprioceptive features and append to vision features"""
|
| 446 |
+
if proprio_projector is not None and proprio is not None:
|
| 447 |
+
# projected_patch_embeddings: (bsz, num_patches * num_images, llm_dim)
|
| 448 |
+
# proprio: (bsz, proprio_dim) or (propro_dim,)
|
| 449 |
+
proprio = proprio.reshape(projected_patch_embeddings.shape[0], -1) # (bsz, proprio_dim)
|
| 450 |
+
proprio_features = proprio_projector(proprio) # (bsz, llm_dim)
|
| 451 |
+
proprio_features = proprio_features.unsqueeze(dim=1) # (bsz, 1, llm_dim)
|
| 452 |
+
# For simplicity, just append proprio token to the end of projected vision patch tokens
|
| 453 |
+
return torch.cat((projected_patch_embeddings, proprio_features), dim=1)
|
| 454 |
+
return projected_patch_embeddings
|
| 455 |
+
|
| 456 |
+
def _build_multimodal_attention(self, input_embeddings, projected_patch_embeddings, attention_mask):
|
| 457 |
+
"""Build multimodal embeddings and attention mask"""
|
| 458 |
+
# juyi: Update attention mask 是不是要改成下三角? 不用, 因为generate会自动屏蔽
|
| 459 |
+
projected_patch_attention_mask = None
|
| 460 |
+
if attention_mask is not None:
|
| 461 |
+
projected_patch_attention_mask = torch.full(
|
| 462 |
+
(projected_patch_embeddings.shape[0], projected_patch_embeddings.shape[1]),
|
| 463 |
+
fill_value=True,
|
| 464 |
+
dtype=attention_mask.dtype,
|
| 465 |
+
device=attention_mask.device,
|
| 466 |
+
)
|
| 467 |
+
|
| 468 |
+
# Build multimodal embeddings & attention mask; insert embeddings after <BOS> token (1:)
|
| 469 |
+
multimodal_embeddings = torch.cat(
|
| 470 |
+
[input_embeddings[:, :1, :], projected_patch_embeddings, input_embeddings[:, 1:, :]], dim=1
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
multimodal_attention_mask = None
|
| 474 |
+
if attention_mask is not None:
|
| 475 |
+
multimodal_attention_mask = torch.cat(
|
| 476 |
+
[attention_mask[:, :1], projected_patch_attention_mask, attention_mask[:, 1:]], dim=1
|
| 477 |
+
)
|
| 478 |
+
|
| 479 |
+
return multimodal_embeddings, multimodal_attention_mask
|
| 480 |
+
|
| 481 |
+
def _build_multimodal_labels(self, labels, projected_patch_embeddings):
|
| 482 |
+
"""Build multimodal labels with IGNORE_INDEX for patch embeddings"""
|
| 483 |
+
if labels is not None:
|
| 484 |
+
projected_patch_labels = torch.full(
|
| 485 |
+
(projected_patch_embeddings.shape[0], projected_patch_embeddings.shape[1]),
|
| 486 |
+
fill_value=IGNORE_INDEX, # 这些位置不需要计算损失。
|
| 487 |
+
dtype=labels.dtype,
|
| 488 |
+
device=labels.device,
|
| 489 |
+
)
|
| 490 |
+
return torch.cat([labels[:, :1], projected_patch_labels, labels[:, 1:]], dim=1) # 第一个token是<BOS>
|
| 491 |
+
return None
|
| 492 |
+
|
| 493 |
+
# === Core Prismatic VLM `forward()` Logic ===
|
| 494 |
+
def forward(
|
| 495 |
+
self,
|
| 496 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 497 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 498 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 499 |
+
labels: Optional[torch.LongTensor] = None,
|
| 500 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 501 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 502 |
+
use_cache: Optional[bool] = None,
|
| 503 |
+
output_attentions: Optional[bool] = None,
|
| 504 |
+
output_hidden_states: Optional[bool] = None,
|
| 505 |
+
output_projector_features: Optional[bool] = None,
|
| 506 |
+
return_dict: Optional[bool] = None,
|
| 507 |
+
proprio=None,
|
| 508 |
+
proprio_projector=None,
|
| 509 |
+
noisy_actions=None,
|
| 510 |
+
noisy_action_projector=None,
|
| 511 |
+
diffusion_timestep_embeddings=None,
|
| 512 |
+
use_film: bool = False,
|
| 513 |
+
) -> Union[Tuple, PrismaticCausalLMOutputWithPast]:
|
| 514 |
+
"""Run a forward pass through the VLM, returning a PrismaticCausalLMOutputWithPast instance."""
|
| 515 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 516 |
+
output_hidden_states = (
|
| 517 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 518 |
+
)
|
| 519 |
+
output_projector_features = output_projector_features if output_projector_features is not None else False
|
| 520 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 521 |
+
|
| 522 |
+
# Respect `use_cache` only if not training (even if `gradient_checkpointing` is off)
|
| 523 |
+
use_cache = use_cache and not self.training
|
| 524 |
+
|
| 525 |
+
# Instantiate Placeholder for Projector Features
|
| 526 |
+
projected_patch_embeddings = None
|
| 527 |
+
|
| 528 |
+
# === Handle Generation with Cache (`input_ids.shape[1] == 1`) =>> requires `past_keys_values` ===
|
| 529 |
+
if input_ids.shape[1] == 1:
|
| 530 |
+
assert input_ids.shape[0] == 1, "Generation is only currently supported for batch size of 1!"
|
| 531 |
+
assert past_key_values is not None, "You must provide `past_key_values` during cached generation!"
|
| 532 |
+
assert labels is None, "Unexpected key `labels` provided during cached generation!"
|
| 533 |
+
|
| 534 |
+
language_model_output = self.language_model(
|
| 535 |
+
input_ids=input_ids,
|
| 536 |
+
attention_mask=None,
|
| 537 |
+
position_ids=None,
|
| 538 |
+
past_key_values=past_key_values,
|
| 539 |
+
inputs_embeds=None,
|
| 540 |
+
labels=None,
|
| 541 |
+
use_cache=use_cache,
|
| 542 |
+
output_attentions=output_attentions,
|
| 543 |
+
output_hidden_states=output_hidden_states,
|
| 544 |
+
return_dict=return_dict,
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
# === Handle Unimodal Forward ===
|
| 548 |
+
elif pixel_values is None:
|
| 549 |
+
assert (input_ids is not None) and (inputs_embeds is None), "Missing `input_ids` in language-only forward!"
|
| 550 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during language-only forward!"
|
| 551 |
+
|
| 552 |
+
language_model_output = self.language_model(
|
| 553 |
+
input_ids=input_ids,
|
| 554 |
+
attention_mask=attention_mask,
|
| 555 |
+
position_ids=None,
|
| 556 |
+
past_key_values=None,
|
| 557 |
+
inputs_embeds=None,
|
| 558 |
+
labels=labels,
|
| 559 |
+
use_cache=use_cache,
|
| 560 |
+
output_attentions=output_attentions,
|
| 561 |
+
output_hidden_states=output_hidden_states,
|
| 562 |
+
return_dict=return_dict,
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
# === Handle Multimodal Forward ===
|
| 566 |
+
elif (input_ids.shape[0] == pixel_values.shape[0]) or (inputs_embeds.shape[0] == pixel_values.shape[0]):
|
| 567 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during multimodal forward!"
|
| 568 |
+
|
| 569 |
+
# Get input embeddings (from language model embeddings)
|
| 570 |
+
input_embeddings = self.get_input_embeddings()(input_ids) # (B, seq_len, D)
|
| 571 |
+
|
| 572 |
+
# Extract action masks
|
| 573 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 574 |
+
|
| 575 |
+
# Extract the language portion of the input embeddings (i.e. remove the action tokens portion)
|
| 576 |
+
language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 577 |
+
input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 578 |
+
) # (B, lang_seq_len, llm_dim)
|
| 579 |
+
|
| 580 |
+
# Get visual features
|
| 581 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values, language_embeddings, use_film)
|
| 582 |
+
# bug: TypeError: PrismaticForConditionalGeneration._process_vision_features() takes 2 positional arguments but 4 were given
|
| 583 |
+
|
| 584 |
+
# Add proprioceptive state if provided
|
| 585 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 586 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 587 |
+
)
|
| 588 |
+
|
| 589 |
+
# [Diffusion] Add diffusion timestep embedding if provided
|
| 590 |
+
if diffusion_timestep_embeddings is not None:
|
| 591 |
+
# For simplicity, just append diffusion timestep embedding to the end of projected vision patch tokens
|
| 592 |
+
projected_patch_embeddings = torch.cat(
|
| 593 |
+
(projected_patch_embeddings, diffusion_timestep_embeddings), dim=1
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
# Process action embeddings
|
| 597 |
+
if noisy_actions is not None:
|
| 598 |
+
# Get mask corresponding to all action tokens
|
| 599 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 600 |
+
|
| 601 |
+
# Reshape noisy actions into individual action tokens
|
| 602 |
+
# noisy_actions: (B, chunk_len, action_dim) -> (B, chunk_len * action_dim, 1)
|
| 603 |
+
B = noisy_actions.shape[0]
|
| 604 |
+
noisy_actions = noisy_actions.reshape(B, -1).unsqueeze(-1)
|
| 605 |
+
|
| 606 |
+
# Project noisy action tokens into language model embedding space
|
| 607 |
+
noisy_action_features = noisy_action_projector(noisy_actions) # (B, chunk_len * action_dim, llm_dim)
|
| 608 |
+
|
| 609 |
+
# Replace embeddings of the action tokens with noisy action embeddings
|
| 610 |
+
input_embeddings = self._replace_input_embeddings(
|
| 611 |
+
input_embeddings, all_actions_mask, noisy_action_features
|
| 612 |
+
)
|
| 613 |
+
else:
|
| 614 |
+
# Replace the embeddings of the action tokens with zeros
|
| 615 |
+
# (Later on, the positional embeddings will be added to them)
|
| 616 |
+
all_actions_mask = all_actions_mask.unsqueeze(-1) # (B, seq_len, 1)
|
| 617 |
+
input_embeddings = input_embeddings * ~all_actions_mask
|
| 618 |
+
|
| 619 |
+
# Build multimodal embeddings & attention mask
|
| 620 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 621 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 622 |
+
)
|
| 623 |
+
|
| 624 |
+
# Build labels for multimodal sequence if needed
|
| 625 |
+
multimodal_labels = self._build_multimodal_labels(labels, projected_patch_embeddings)
|
| 626 |
+
|
| 627 |
+
# Dispatch to language model
|
| 628 |
+
language_model_output = self.language_model(
|
| 629 |
+
input_ids=None,
|
| 630 |
+
attention_mask=multimodal_attention_mask,
|
| 631 |
+
position_ids=None,
|
| 632 |
+
past_key_values=None,
|
| 633 |
+
inputs_embeds=multimodal_embeddings,
|
| 634 |
+
labels=multimodal_labels,
|
| 635 |
+
use_cache=use_cache,
|
| 636 |
+
output_attentions=output_attentions,
|
| 637 |
+
output_hidden_states=output_hidden_states,
|
| 638 |
+
return_dict=return_dict,
|
| 639 |
+
)
|
| 640 |
+
|
| 641 |
+
# === Otherwise =>> Assume Invalid! ===
|
| 642 |
+
elif (input_ids.shape[0] != pixel_values.shape[0]) or (inputs_embeds.shape[0] != pixel_values.shape[0]):
|
| 643 |
+
raise ValueError("Non-homogenous batch of (text, image) input -- forward() does not support mixed batches!")
|
| 644 |
+
|
| 645 |
+
else:
|
| 646 |
+
raise ValueError(
|
| 647 |
+
"Invalid PrismaticForConditionalGeneration `forward()` call with provided arguments:\n"
|
| 648 |
+
f"=> `input_ids` = {input_ids is not None}\n"
|
| 649 |
+
f"=> `attention_mask` = {attention_mask is not None}\n"
|
| 650 |
+
f"=> `pixel_values` = {pixel_values is not None}\n"
|
| 651 |
+
f"=> `labels` = {labels is not None}\n"
|
| 652 |
+
f"=> `input_embeds` = {inputs_embeds is not None}\n"
|
| 653 |
+
f"=> `past_key_values` = {past_key_values is not None}\n"
|
| 654 |
+
f"=> `use_cache` = {use_cache}"
|
| 655 |
+
)
|
| 656 |
+
|
| 657 |
+
# Unpack `language_model_output` and return PrismaticCausalLMOutputWithPast (or tuple if not `return_dict`)
|
| 658 |
+
if not return_dict:
|
| 659 |
+
if output_projector_features and (projected_patch_embeddings is not None):
|
| 660 |
+
return *language_model_output, projected_patch_embeddings
|
| 661 |
+
|
| 662 |
+
return language_model_output
|
| 663 |
+
|
| 664 |
+
return PrismaticCausalLMOutputWithPast(
|
| 665 |
+
loss=language_model_output.loss,
|
| 666 |
+
logits=language_model_output.logits,
|
| 667 |
+
past_key_values=language_model_output.past_key_values,
|
| 668 |
+
hidden_states=language_model_output.hidden_states,
|
| 669 |
+
attentions=language_model_output.attentions,
|
| 670 |
+
projector_features=projected_patch_embeddings,
|
| 671 |
+
)
|
| 672 |
+
|
| 673 |
+
# === GenerationMixin Methods ===
|
| 674 |
+
def prepare_inputs_for_generation(
|
| 675 |
+
self,
|
| 676 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 677 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 678 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 679 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 680 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 681 |
+
**kwargs: str,
|
| 682 |
+
) -> Dict[str, torch.Tensor]:
|
| 683 |
+
"""Borrowed from `LlamaForCausalLM` and simplified for batch size = 1; mirrors original PrismaticVLM logic."""
|
| 684 |
+
if ((input_ids is not None) and (input_ids.shape[0] > 1)) or (
|
| 685 |
+
(inputs_embeds is not None) and (inputs_embeds.shape[0] > 1)
|
| 686 |
+
):
|
| 687 |
+
raise ValueError("Generation with batch size > 1 is not currently supported!")
|
| 688 |
+
|
| 689 |
+
# Handle `past_key_values` (cache) =>> assume `input_ids` just has unprocessed tokens
|
| 690 |
+
if past_key_values is not None:
|
| 691 |
+
input_ids = input_ids[:, -1:]
|
| 692 |
+
|
| 693 |
+
# If `input_embeds` are passed, we only want to use them in the 1st generation step
|
| 694 |
+
if inputs_embeds is not None and past_key_values is None:
|
| 695 |
+
model_inputs = {"input_embeds": inputs_embeds}
|
| 696 |
+
else:
|
| 697 |
+
model_inputs = {"input_ids": input_ids}
|
| 698 |
+
|
| 699 |
+
# Make sure `pixel_values` are preserved in `model_inputs`
|
| 700 |
+
model_inputs.update(
|
| 701 |
+
{
|
| 702 |
+
"attention_mask": attention_mask,
|
| 703 |
+
"pixel_values": pixel_values,
|
| 704 |
+
"past_key_values": past_key_values,
|
| 705 |
+
"use_cache": kwargs.get("use_cache"),
|
| 706 |
+
}
|
| 707 |
+
)
|
| 708 |
+
|
| 709 |
+
return model_inputs
|
| 710 |
+
|
| 711 |
+
# Defer to Language Model (all handle this differently, with different return types)
|
| 712 |
+
def _reorder_cache(self, *args, **kwargs) -> Any:
|
| 713 |
+
return self.language_model._reorder_cache(*args, **kwargs)
|
| 714 |
+
|
| 715 |
+
|
| 716 |
+
class OpenVLAForActionPrediction(PrismaticForConditionalGeneration):
|
| 717 |
+
config_class: PretrainedConfig = OpenVLAConfig
|
| 718 |
+
|
| 719 |
+
def __init__(self, config: OpenVLAConfig) -> None:
|
| 720 |
+
super().__init__(config)
|
| 721 |
+
self.norm_stats = config.norm_stats
|
| 722 |
+
|
| 723 |
+
# Compute action bins
|
| 724 |
+
self.bins = np.linspace(-1, 1, config.n_action_bins)
|
| 725 |
+
self.bin_centers = (self.bins[:-1] + self.bins[1:]) / 2.0
|
| 726 |
+
|
| 727 |
+
# Compute vocab size for de-tokenization -- revert added "multiple of"
|
| 728 |
+
self.vocab_size = self.config.text_config.vocab_size - self.config.pad_to_multiple_of
|
| 729 |
+
|
| 730 |
+
def _prepare_input_for_action_prediction(self, input_ids, attention_mask):
|
| 731 |
+
# eval 会用到这里
|
| 732 |
+
"""Prepares input for action prediction by adding necessary tokens"""
|
| 733 |
+
# Add (ACTION_DIM * NUM_ACTIONS_CHUNK) placeholder tokens to input_ids to simulate action tokens
|
| 734 |
+
placeholder_action_token_ids = (
|
| 735 |
+
torch.ones((input_ids.shape[0], ACTION_DIM * NUM_ACTIONS_CHUNK)).to(input_ids.device).to(input_ids.dtype)
|
| 736 |
+
)
|
| 737 |
+
input_ids = torch.cat([input_ids, placeholder_action_token_ids], dim=-1) # torch.Size([1, 35 + 56= 91])
|
| 738 |
+
|
| 739 |
+
# Extend the attention mask to fit the new shape of input
|
| 740 |
+
# Note: Only batch size == 1 supported right now
|
| 741 |
+
mask_extension = (
|
| 742 |
+
torch.ones((attention_mask.shape[0], input_ids.shape[-1] - attention_mask.shape[-1]))
|
| 743 |
+
.to(attention_mask.device)
|
| 744 |
+
.to(attention_mask.dtype)
|
| 745 |
+
)
|
| 746 |
+
attention_mask = torch.cat([attention_mask, mask_extension], dim=-1)
|
| 747 |
+
|
| 748 |
+
return input_ids, attention_mask
|
| 749 |
+
|
| 750 |
+
def _prepare_labels_for_action_prediction(self, labels, input_ids):
|
| 751 |
+
"""Creates labels tensor for action prediction if not provided"""
|
| 752 |
+
# eval 会用到这里 ,
|
| 753 |
+
# Extends label tensors with fake action labels
|
| 754 |
+
# Adds stop tokens at the end of sequences
|
| 755 |
+
# Handles label preparation for action prediction tasks
|
| 756 |
+
# 他为啥可以随便一个? xuan说 你自定义一个值 ,然后一直指定这个 , PAD token可以吗?
|
| 757 |
+
#TODO: 这里是否要改? 感觉不需要改. 随便写就行了因为labels不重要只是要一个mask. 为什么需要这个函数? 确保 action 预测任务的标签(labels)符合模型的输入长度,并正确地处理序列终止
|
| 758 |
+
# Extend labels tensor with fake action labels
|
| 759 |
+
ARBITRARY_ACTION_TOKEN_IDX = ACTION_TOKEN_IDX # = 为了mask正确生成, action_tokens_only_mask = (labels == ACTION_TOKEN_IDX ), 所以这里也填上ACTION_TOKEN_IDX
|
| 760 |
+
labels_extension = (
|
| 761 |
+
torch.ones((labels.shape[0], input_ids.shape[-1] - labels.shape[-1])).to(labels.device).to(labels.dtype)
|
| 762 |
+
* ARBITRARY_ACTION_TOKEN_IDX
|
| 763 |
+
) #torch.Size([1, 57]),全是 ARBITRARY_ACTION_TOKEN_IDX
|
| 764 |
+
labels = torch.cat([labels, labels_extension], dim=-1)
|
| 765 |
+
|
| 766 |
+
return labels
|
| 767 |
+
|
| 768 |
+
def _unnormalize_actions(self, normalized_actions, unnorm_key=None):
|
| 769 |
+
"""Unnormalize actions using dataset statistics"""
|
| 770 |
+
action_norm_stats = self.get_action_stats(unnorm_key)
|
| 771 |
+
|
| 772 |
+
if ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS:
|
| 773 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["min"], dtype=bool))
|
| 774 |
+
action_high, action_low = np.array(action_norm_stats["max"]), np.array(action_norm_stats["min"])
|
| 775 |
+
elif ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS_Q99:
|
| 776 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["q01"], dtype=bool))
|
| 777 |
+
action_high, action_low = np.array(action_norm_stats["q99"]), np.array(action_norm_stats["q01"])
|
| 778 |
+
else:
|
| 779 |
+
raise ValueError("Unsupported action/proprio normalization type detected!")
|
| 780 |
+
|
| 781 |
+
actions = np.where(
|
| 782 |
+
mask,
|
| 783 |
+
0.5 * (normalized_actions + 1) * (action_high - action_low + 1e-8) + action_low,
|
| 784 |
+
normalized_actions,
|
| 785 |
+
)
|
| 786 |
+
|
| 787 |
+
return actions
|
| 788 |
+
|
| 789 |
+
|
| 790 |
+
def _normalize_actions(self, actions, norm_key=None):
|
| 791 |
+
"""Normalize actions to [-1, 1] using dataset statistics"""
|
| 792 |
+
action_norm_stats = self.get_action_stats(norm_key)
|
| 793 |
+
|
| 794 |
+
if ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS:
|
| 795 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["min"], dtype=bool))
|
| 796 |
+
action_high, action_low = np.array(action_norm_stats["max"]), np.array(action_norm_stats["min"])
|
| 797 |
+
elif ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS_Q99:
|
| 798 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["q01"], dtype=bool))
|
| 799 |
+
action_high, action_low = np.array(action_norm_stats["q99"]), np.array(action_norm_stats["q01"])
|
| 800 |
+
else:
|
| 801 |
+
raise ValueError("Unsupported action/proprio normalization type detected!")
|
| 802 |
+
|
| 803 |
+
normalized = np.where(
|
| 804 |
+
mask,
|
| 805 |
+
2 * (actions - action_low) / (action_high - action_low + 1e-8) - 1,
|
| 806 |
+
actions,
|
| 807 |
+
)
|
| 808 |
+
|
| 809 |
+
return normalized
|
| 810 |
+
|
| 811 |
+
def _run_diffusion_prediction(
|
| 812 |
+
self,
|
| 813 |
+
input_embeddings,
|
| 814 |
+
all_actions_mask,
|
| 815 |
+
noise,
|
| 816 |
+
action_head,
|
| 817 |
+
projected_patch_embeddings,
|
| 818 |
+
labels,
|
| 819 |
+
attention_mask,
|
| 820 |
+
NUM_PATCHES,
|
| 821 |
+
NUM_PROMPT_TOKENS,
|
| 822 |
+
noisy_action_projector,
|
| 823 |
+
):
|
| 824 |
+
"""Run diffusion-based action prediction"""
|
| 825 |
+
# Set diffusion timestep values
|
| 826 |
+
action_head.noise_scheduler.set_timesteps(action_head.num_diffusion_steps)
|
| 827 |
+
# Clone embedding for reuse in each timestep
|
| 828 |
+
orig_projected_patch_embeddings = projected_patch_embeddings.clone()
|
| 829 |
+
curr_noisy_actions = noise
|
| 830 |
+
|
| 831 |
+
# Reverse diffusion: Iteratively denoise to generate action prediction
|
| 832 |
+
for t in action_head.noise_scheduler.timesteps:
|
| 833 |
+
# Get diffusion model's noise prediction (conditioned on VLA latent embedding, current noisy action
|
| 834 |
+
# embedding, and diffusion timestep embedding)
|
| 835 |
+
timesteps = torch.Tensor([t]).to(labels.device)
|
| 836 |
+
diffusion_timestep_embeddings = (
|
| 837 |
+
action_head.time_encoder(timesteps).to(curr_noisy_actions.dtype).to(curr_noisy_actions.device)
|
| 838 |
+
) # (B, llm_dim)
|
| 839 |
+
diffusion_timestep_embeddings = diffusion_timestep_embeddings.unsqueeze(1) # (B, 1, llm_dim)
|
| 840 |
+
|
| 841 |
+
# [Diffusion] Replace the embeddings of the action tokens with noisy actions
|
| 842 |
+
# (Later on, the positional embeddings will be added to them)
|
| 843 |
+
|
| 844 |
+
# For simplicity, append diffusion timestep embedding to the end of projected vision tokens
|
| 845 |
+
projected_patch_embeddings = torch.cat(
|
| 846 |
+
(orig_projected_patch_embeddings, diffusion_timestep_embeddings), dim=1
|
| 847 |
+
)
|
| 848 |
+
|
| 849 |
+
# Reshape and project noisy actions into language embedding space
|
| 850 |
+
B = curr_noisy_actions.shape[0]
|
| 851 |
+
orig_curr_noisy_actions_shape = curr_noisy_actions.shape
|
| 852 |
+
curr_noisy_actions = curr_noisy_actions.reshape(B, -1).unsqueeze(-1)
|
| 853 |
+
noisy_action_features = noisy_action_projector(curr_noisy_actions)
|
| 854 |
+
curr_noisy_actions = curr_noisy_actions.reshape(orig_curr_noisy_actions_shape)
|
| 855 |
+
|
| 856 |
+
# Replace action token embeddings with noisy action embeddings
|
| 857 |
+
input_embeddings = self._replace_input_embeddings(
|
| 858 |
+
input_embeddings.clone(), all_actions_mask, noisy_action_features
|
| 859 |
+
)
|
| 860 |
+
|
| 861 |
+
# Build multimodal embeddings and attention mask
|
| 862 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 863 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 864 |
+
)
|
| 865 |
+
|
| 866 |
+
# Forward pass through language model
|
| 867 |
+
language_model_output = self.language_model(
|
| 868 |
+
input_ids=None,
|
| 869 |
+
attention_mask=multimodal_attention_mask,
|
| 870 |
+
position_ids=None,
|
| 871 |
+
past_key_values=None,
|
| 872 |
+
inputs_embeds=multimodal_embeddings,
|
| 873 |
+
labels=None,
|
| 874 |
+
use_cache=None,
|
| 875 |
+
output_attentions=False,
|
| 876 |
+
output_hidden_states=True,
|
| 877 |
+
return_dict=True,
|
| 878 |
+
)
|
| 879 |
+
|
| 880 |
+
# Extract hidden states for action portion of response
|
| 881 |
+
last_hidden_states = language_model_output.hidden_states[-1] # (B, seq_len, D)
|
| 882 |
+
actions_hidden_states = last_hidden_states[
|
| 883 |
+
:,
|
| 884 |
+
NUM_PATCHES + NUM_PROMPT_TOKENS : NUM_PATCHES + NUM_PROMPT_TOKENS + ACTION_DIM * NUM_ACTIONS_CHUNK,
|
| 885 |
+
:,
|
| 886 |
+
] # (B, act_chunk_len, D)
|
| 887 |
+
|
| 888 |
+
# Predict noise and update noisy actions: x_t -> x_{t-1}
|
| 889 |
+
noise_pred = action_head.predict_noise(actions_hidden_states)
|
| 890 |
+
curr_noisy_actions = action_head.noise_scheduler.step(noise_pred, t, curr_noisy_actions).prev_sample
|
| 891 |
+
|
| 892 |
+
curr_noisy_actions = curr_noisy_actions.reshape(NUM_ACTIONS_CHUNK, ACTION_DIM)
|
| 893 |
+
|
| 894 |
+
# Return final actions
|
| 895 |
+
return curr_noisy_actions.float().cpu().detach().numpy(), actions_hidden_states
|
| 896 |
+
|
| 897 |
+
def _regression_or_discrete_prediction(
|
| 898 |
+
self,
|
| 899 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 900 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 901 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 902 |
+
attention_mask: torch.BoolTensor,
|
| 903 |
+
labels: torch.LongTensor,
|
| 904 |
+
NUM_PATCHES: int,
|
| 905 |
+
NUM_PROMPT_TOKENS: int,
|
| 906 |
+
action_head: L1RegressionActionHead,
|
| 907 |
+
**kwargs,
|
| 908 |
+
):
|
| 909 |
+
"""Run L1 regression-based continuous action prediction or discrete action tokens prediction."""
|
| 910 |
+
# Extract hidden states for action tokens
|
| 911 |
+
# last_hidden_states = language_model_output.hidden_states[-1] # (B, seq_len, D)
|
| 912 |
+
|
| 913 |
+
# actions_hidden_states = last_hidden_states[:, NUM_PATCHES + NUM_PROMPT_TOKENS : NUM_PATCHES + NUM_PROMPT_TOKENS + NUM_ACTIONS_CHUNK * tokennum, :]# (B, act_chunk_len, D)
|
| 914 |
+
# 都不需要取了, 直接就给 token对应的hidden state了 ,太方便了.
|
| 915 |
+
# 为什么第一个是torch.Size([1, 535, 4096])? 我应该选哪个? https://discuss.huggingface.co/t/get-each-generated-token-last-layer-hidden-state/145921
|
| 916 |
+
# language_model_output.sequences tensor([[29871, 32001, 32001, 32001, 32001, 32001, 32001, 32001, 32001, 2]], device='cuda:0')
|
| 917 |
+
cfg = kwargs.pop("cfg", None)
|
| 918 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 919 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 920 |
+
)
|
| 921 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 922 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 923 |
+
# is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 924 |
+
hidden_states = language_model_output.hidden_states[0][-1]
|
| 925 |
+
actions_hidden_states = hidden_states[:, -NUM_ACTIONS_CHUNK:]
|
| 926 |
+
|
| 927 |
+
normalized_actions = action_head.predict_action(actions_hidden_states)
|
| 928 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 929 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 930 |
+
if cfg.mode == "mul":
|
| 931 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 932 |
+
token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 933 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 934 |
+
actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 935 |
+
|
| 936 |
+
actions_hidden_states_list = [actions_hidden_states0]
|
| 937 |
+
for i in range(1, token_num):
|
| 938 |
+
token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 939 |
+
actions_hidden_states_list.append(token_hidden_state)
|
| 940 |
+
# 将所有hidden states拼接起来
|
| 941 |
+
combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 942 |
+
actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 943 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 944 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 945 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 946 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 947 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 948 |
+
else:
|
| 949 |
+
raise NotImplementedError
|
| 950 |
+
else:
|
| 951 |
+
raise NotImplementedError
|
| 952 |
+
return normalized_actions, actions_hidden_states
|
| 953 |
+
|
| 954 |
+
def hist_predict_action(
|
| 955 |
+
self,
|
| 956 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 957 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 958 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 959 |
+
attention_mask: torch.BoolTensor,
|
| 960 |
+
action_head: L1RegressionActionHead,
|
| 961 |
+
**kwargs,
|
| 962 |
+
):
|
| 963 |
+
cfg = kwargs.get("cfg", None)
|
| 964 |
+
action_history = kwargs.get("action_history", None)
|
| 965 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 966 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 967 |
+
)
|
| 968 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 969 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 970 |
+
# the following is (num of tokens,)
|
| 971 |
+
if cfg.mode == "mul":
|
| 972 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 973 |
+
raise NotImplementedError
|
| 974 |
+
# token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 975 |
+
# language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 976 |
+
# actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 977 |
+
# actions_hidden_states_list = [actions_hidden_states0]
|
| 978 |
+
# for i in range(1, token_num):
|
| 979 |
+
# token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 980 |
+
# actions_hidden_states_list.append(token_hidden_state)
|
| 981 |
+
# combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 982 |
+
# actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 983 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 984 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 985 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 986 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 987 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 988 |
+
# 在中间加一个 1 维度
|
| 989 |
+
actions_hidden_states = actions_hidden_states.unsqueeze(1) # for match 3 dim
|
| 990 |
+
else:
|
| 991 |
+
raise NotImplementedError
|
| 992 |
+
else:
|
| 993 |
+
raise NotImplementedError
|
| 994 |
+
|
| 995 |
+
normalized_actions = action_head.predict_action(actions_hidden_states, action_history)
|
| 996 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 997 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 998 |
+
|
| 999 |
+
return normalized_actions, actions_hidden_states
|
| 1000 |
+
|
| 1001 |
+
def mul_regression_or_discrete_prediction(
|
| 1002 |
+
self,
|
| 1003 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 1004 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 1005 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 1006 |
+
attention_mask: torch.BoolTensor,
|
| 1007 |
+
labels: torch.LongTensor,
|
| 1008 |
+
NUM_PATCHES: int,
|
| 1009 |
+
NUM_PROMPT_TOKENS: int,
|
| 1010 |
+
action_head: L1RegressionActionHead,
|
| 1011 |
+
**kwargs,
|
| 1012 |
+
):
|
| 1013 |
+
cfg = kwargs.get("cfg", None)
|
| 1014 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1015 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1016 |
+
)
|
| 1017 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1018 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 1019 |
+
# the following is (num of tokens,)
|
| 1020 |
+
if cfg.mode == "mul":
|
| 1021 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 1022 |
+
token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 1023 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 1024 |
+
actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 1025 |
+
|
| 1026 |
+
actions_hidden_states_list = [actions_hidden_states0]
|
| 1027 |
+
for i in range(1, token_num):
|
| 1028 |
+
token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 1029 |
+
actions_hidden_states_list.append(token_hidden_state)
|
| 1030 |
+
combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 1031 |
+
actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 1032 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1033 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 1034 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1035 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 1036 |
+
else:
|
| 1037 |
+
raise NotImplementedError
|
| 1038 |
+
else:
|
| 1039 |
+
raise NotImplementedError
|
| 1040 |
+
|
| 1041 |
+
normalized_actions = action_head.predict_action(actions_hidden_states)
|
| 1042 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 1043 |
+
# print(f"*** normalized_actions[]: {normalized_actions} ***")
|
| 1044 |
+
if cfg.action_head_name == "medusa":
|
| 1045 |
+
normalized_actions[:, 6] = torch.sigmoid(normalized_actions[:, 6]) # without bs dim.
|
| 1046 |
+
# print(f"*** normalized_actions[]: {normalized_actions} ***")
|
| 1047 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 1048 |
+
|
| 1049 |
+
return normalized_actions, actions_hidden_states
|
| 1050 |
+
|
| 1051 |
+
def predict_action(
|
| 1052 |
+
self,
|
| 1053 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1054 |
+
unnorm_key: Optional[str] = None,
|
| 1055 |
+
proprio=None,
|
| 1056 |
+
proprio_projector=None,
|
| 1057 |
+
action_head=None,
|
| 1058 |
+
noisy_action_projector=None,
|
| 1059 |
+
use_film: bool = False,
|
| 1060 |
+
**kwargs: str,
|
| 1061 |
+
) -> np.ndarray:
|
| 1062 |
+
"""Predict actions from input sequence, with options for different prediction methods.
|
| 1063 |
+
|
| 1064 |
+
Args:
|
| 1065 |
+
input_ids: Input token ids
|
| 1066 |
+
unnorm_key: Key for unnormalization statistics
|
| 1067 |
+
proprio: Proprioceptive features
|
| 1068 |
+
proprio_projector: Projector for proprioceptive features
|
| 1069 |
+
action_head: Optional head for L1 regression or diffusion-based prediction
|
| 1070 |
+
noisy_action_projector: Projector for noisy actions in diffusion-based prediction
|
| 1071 |
+
use_film: Whether to use FiLM conditioning
|
| 1072 |
+
**kwargs: Additional arguments including pixel_values and attention_mask
|
| 1073 |
+
|
| 1074 |
+
Returns:
|
| 1075 |
+
Tuple of (unnormalized_actions, action_hidden_states)
|
| 1076 |
+
"""
|
| 1077 |
+
# If the special empty token ('') does not already appear after the colon (':') token in the prompt
|
| 1078 |
+
# (after "OUT:" or "ASSISTANT:"), insert it to match the inputs seen at training time
|
| 1079 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1080 |
+
input_ids = torch.cat(
|
| 1081 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1082 |
+
)
|
| 1083 |
+
|
| 1084 |
+
pixel_values = kwargs["pixel_values"]
|
| 1085 |
+
attention_mask = kwargs["attention_mask"]
|
| 1086 |
+
|
| 1087 |
+
# Create fake labels tensor (needed for action mask)
|
| 1088 |
+
labels = input_ids.clone()
|
| 1089 |
+
labels[:] = IGNORE_INDEX # 输入都ignore IGNORE_INDEX = -100
|
| 1090 |
+
|
| 1091 |
+
# Get number of tokens in prompt (excluding the start token)
|
| 1092 |
+
NUM_PROMPT_TOKENS = input_ids.shape[-1] - 1 # Subtract action tokens and stop token
|
| 1093 |
+
|
| 1094 |
+
# Prepare inputs by adding necessary tokens
|
| 1095 |
+
input_ids, attention_mask = self._prepare_input_for_action_prediction(input_ids, attention_mask)
|
| 1096 |
+
|
| 1097 |
+
# Update labels tensor for action mask computation later
|
| 1098 |
+
labels = self._prepare_labels_for_action_prediction(labels, input_ids)
|
| 1099 |
+
|
| 1100 |
+
# Get input embeddings and action masks
|
| 1101 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1102 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 1103 |
+
|
| 1104 |
+
# Extract language embeddings
|
| 1105 |
+
language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 1106 |
+
input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 1107 |
+
)
|
| 1108 |
+
|
| 1109 |
+
# Process vision features
|
| 1110 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values, language_embeddings, use_film)
|
| 1111 |
+
|
| 1112 |
+
# Add proprioceptive features if provided
|
| 1113 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1114 |
+
if use_proprio:
|
| 1115 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1116 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1117 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1118 |
+
)
|
| 1119 |
+
|
| 1120 |
+
# Use diffusion if provided, otherwise use regression or discrete prediction
|
| 1121 |
+
use_diffusion = noisy_action_projector is not None and hasattr(action_head, "noise_scheduler")
|
| 1122 |
+
|
| 1123 |
+
# Calculate number of patches (including proprio token and/or diffusion timestep embedding if present)
|
| 1124 |
+
NUM_PATCHES = self.vision_backbone.get_num_patches() * self.vision_backbone.get_num_images_in_input()
|
| 1125 |
+
if use_proprio:
|
| 1126 |
+
NUM_PATCHES += 1
|
| 1127 |
+
|
| 1128 |
+
normalized_actions, actions_hidden_states = self._regression_or_discrete_prediction(
|
| 1129 |
+
input_embeddings,
|
| 1130 |
+
all_actions_mask,
|
| 1131 |
+
projected_patch_embeddings,
|
| 1132 |
+
attention_mask,
|
| 1133 |
+
labels,
|
| 1134 |
+
NUM_PATCHES,
|
| 1135 |
+
NUM_PROMPT_TOKENS,
|
| 1136 |
+
action_head,
|
| 1137 |
+
)
|
| 1138 |
+
|
| 1139 |
+
# Unnormalize predicted actions
|
| 1140 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1141 |
+
|
| 1142 |
+
return actions, actions_hidden_states
|
| 1143 |
+
|
| 1144 |
+
@staticmethod
|
| 1145 |
+
def _check_unnorm_key(norm_stats: Dict[str, Dict[str, Any]], unnorm_key: Optional[str]) -> str:
|
| 1146 |
+
"""Validate and resolve the unnormalization key for action statistics"""
|
| 1147 |
+
if unnorm_key is None:
|
| 1148 |
+
assert len(norm_stats) == 1, (
|
| 1149 |
+
f"Your model was trained on more than one dataset, "
|
| 1150 |
+
f"please pass a `unnorm_key` from the following options to choose the statistics "
|
| 1151 |
+
f"used for un-normalizing actions: {norm_stats.keys()}"
|
| 1152 |
+
)
|
| 1153 |
+
unnorm_key = next(iter(norm_stats.keys()))
|
| 1154 |
+
# norm states没有加载libero, 为什么?
|
| 1155 |
+
assert unnorm_key in norm_stats, (
|
| 1156 |
+
f"The `unnorm_key` you chose is not in the set of available dataset statistics, "
|
| 1157 |
+
f"please choose from: {norm_stats.keys()}"
|
| 1158 |
+
)
|
| 1159 |
+
return unnorm_key
|
| 1160 |
+
|
| 1161 |
+
def get_action_dim(self, unnorm_key: Optional[str] = None) -> int:
|
| 1162 |
+
"""Get the dimensionality of the policy's action space."""
|
| 1163 |
+
unnorm_key = self._check_unnorm_key(self.norm_stats, unnorm_key)
|
| 1164 |
+
return len(self.norm_stats[unnorm_key]["action"]["min"])
|
| 1165 |
+
|
| 1166 |
+
def get_action_stats(self, unnorm_key: Optional[str] = None) -> Dict[str, Any]:
|
| 1167 |
+
"""Get all the logged statistics for the given dataset."""
|
| 1168 |
+
unnorm_key = self._check_unnorm_key(self.norm_stats, unnorm_key)
|
| 1169 |
+
return self.norm_stats[unnorm_key]["action"]
|
| 1170 |
+
|
| 1171 |
+
|
| 1172 |
+
def lisa_forward(
|
| 1173 |
+
self,
|
| 1174 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1175 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1176 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 1177 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1178 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1179 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1180 |
+
use_cache: Optional[bool] = None,
|
| 1181 |
+
output_attentions: Optional[bool] = None,
|
| 1182 |
+
output_hidden_states: Optional[bool] = None,
|
| 1183 |
+
output_projector_features: Optional[bool] = None,
|
| 1184 |
+
return_dict: Optional[bool] = None,
|
| 1185 |
+
proprio=None,
|
| 1186 |
+
proprio_projector=None,
|
| 1187 |
+
**kwargs
|
| 1188 |
+
) -> Union[Tuple, PrismaticCausalLMOutputWithPast]:
|
| 1189 |
+
"""Run a forward pass through the VLM, returning a PrismaticCausalLMOutputWithPast instance."""
|
| 1190 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1191 |
+
output_hidden_states = (
|
| 1192 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1193 |
+
)
|
| 1194 |
+
output_projector_features = output_projector_features if output_projector_features is not None else False
|
| 1195 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1196 |
+
|
| 1197 |
+
# Respect `use_cache` only if not training (even if `gradient_checkpointing` is off)
|
| 1198 |
+
use_cache = use_cache and not self.training
|
| 1199 |
+
|
| 1200 |
+
# Instantiate Placeholder for Projector Features
|
| 1201 |
+
projected_patch_embeddings = None
|
| 1202 |
+
|
| 1203 |
+
# === Handle Generation with Cache (`input_ids.shape[1] == 1`) =>> requires `past_keys_values` ===
|
| 1204 |
+
if input_ids.shape[1] == 1:
|
| 1205 |
+
assert input_ids.shape[0] == 1, "Generation is only currently supported for batch size of 1!"
|
| 1206 |
+
assert past_key_values is not None, "You must provide `past_key_values` during cached generation!"
|
| 1207 |
+
assert labels is None, "Unexpected key `labels` provided during cached generation!"
|
| 1208 |
+
|
| 1209 |
+
language_model_output = self.language_model(
|
| 1210 |
+
input_ids=input_ids,
|
| 1211 |
+
attention_mask=None,
|
| 1212 |
+
position_ids=None,
|
| 1213 |
+
past_key_values=past_key_values,
|
| 1214 |
+
inputs_embeds=None,
|
| 1215 |
+
labels=None,
|
| 1216 |
+
use_cache=use_cache,
|
| 1217 |
+
output_attentions=output_attentions,
|
| 1218 |
+
output_hidden_states=output_hidden_states,
|
| 1219 |
+
return_dict=return_dict,
|
| 1220 |
+
)
|
| 1221 |
+
|
| 1222 |
+
# === Handle Unimodal Forward ===
|
| 1223 |
+
elif pixel_values is None:
|
| 1224 |
+
raise NotImplementedError
|
| 1225 |
+
|
| 1226 |
+
# === Handle Multimodal Forward ===
|
| 1227 |
+
elif (input_ids.shape[0] == pixel_values.shape[0]) or (inputs_embeds.shape[0] == pixel_values.shape[0]):
|
| 1228 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during multimodal forward!"
|
| 1229 |
+
|
| 1230 |
+
# Get input embeddings (from language model embeddings)
|
| 1231 |
+
input_embeddings = self.get_input_embeddings()(input_ids) # (B, seq_len, D)
|
| 1232 |
+
# Extract the language portion of the input embeddings (i.e. remove the action tokens portion)
|
| 1233 |
+
# language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 1234 |
+
# input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 1235 |
+
# ) # (B, lang_seq_len, llm_dim) 这里就会把结尾的 stop index和padding 也算进去. 没问题吗? 没问题因为ignore了 我直接删了因为不用film
|
| 1236 |
+
# Get visual features
|
| 1237 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1238 |
+
|
| 1239 |
+
# Add proprioceptive state if provided
|
| 1240 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1241 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1242 |
+
)
|
| 1243 |
+
|
| 1244 |
+
all_actions_mask = (labels == ACTION_TOKEN_IDX) #和run forward pass不一样, run forward pass要手动算token number来找偏移.
|
| 1245 |
+
all_actions_mask = all_actions_mask.unsqueeze(-1) # (B, seq_len, 1)
|
| 1246 |
+
input_embeddings = input_embeddings * ~all_actions_mask
|
| 1247 |
+
|
| 1248 |
+
# Build multimodal embeddings & attention mask
|
| 1249 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1250 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1251 |
+
)
|
| 1252 |
+
|
| 1253 |
+
# Build labels for multimodal sequence if needed
|
| 1254 |
+
multimodal_labels = self._build_multimodal_labels(labels, projected_patch_embeddings)
|
| 1255 |
+
|
| 1256 |
+
# Dispatch to language model
|
| 1257 |
+
language_model_output = self.language_model(
|
| 1258 |
+
input_ids=None,
|
| 1259 |
+
attention_mask=multimodal_attention_mask,
|
| 1260 |
+
position_ids=None,
|
| 1261 |
+
past_key_values=None,
|
| 1262 |
+
inputs_embeds=multimodal_embeddings,
|
| 1263 |
+
labels=multimodal_labels,
|
| 1264 |
+
use_cache=use_cache,
|
| 1265 |
+
output_attentions=output_attentions,
|
| 1266 |
+
output_hidden_states=output_hidden_states,
|
| 1267 |
+
return_dict=return_dict,
|
| 1268 |
+
)
|
| 1269 |
+
|
| 1270 |
+
|
| 1271 |
+
# === Otherwise =>> Assume Invalid! ===
|
| 1272 |
+
elif (input_ids.shape[0] != pixel_values.shape[0]) or (inputs_embeds.shape[0] != pixel_values.shape[0]):
|
| 1273 |
+
raise ValueError("Non-homogenous batch of (text, image) input -- forward() does not support mixed batches!")
|
| 1274 |
+
|
| 1275 |
+
else:
|
| 1276 |
+
raise ValueError(
|
| 1277 |
+
"Invalid PrismaticForConditionalGeneration `forward()` call with provided arguments:\n"
|
| 1278 |
+
f"=> `input_ids` = {input_ids is not None}\n"
|
| 1279 |
+
f"=> `attention_mask` = {attention_mask is not None}\n"
|
| 1280 |
+
f"=> `pixel_values` = {pixel_values is not None}\n"
|
| 1281 |
+
f"=> `labels` = {labels is not None}\n"
|
| 1282 |
+
f"=> `input_embeds` = {inputs_embeds is not None}\n"
|
| 1283 |
+
f"=> `past_key_values` = {past_key_values is not None}\n"
|
| 1284 |
+
f"=> `use_cache` = {use_cache}"
|
| 1285 |
+
)
|
| 1286 |
+
|
| 1287 |
+
# Unpack `language_model_output` and return PrismaticCausalLMOutputWithPast (or tuple if not `return_dict`)
|
| 1288 |
+
if not return_dict:
|
| 1289 |
+
if output_projector_features and (projected_patch_embeddings is not None):
|
| 1290 |
+
return *language_model_output, projected_patch_embeddings
|
| 1291 |
+
|
| 1292 |
+
return language_model_output
|
| 1293 |
+
|
| 1294 |
+
return PrismaticCausalLMOutputWithPast(
|
| 1295 |
+
loss=language_model_output.loss,
|
| 1296 |
+
logits=language_model_output.logits,
|
| 1297 |
+
past_key_values=language_model_output.past_key_values,
|
| 1298 |
+
hidden_states=language_model_output.hidden_states,
|
| 1299 |
+
attentions=language_model_output.attentions,
|
| 1300 |
+
projector_features=projected_patch_embeddings,
|
| 1301 |
+
)
|
| 1302 |
+
|
| 1303 |
+
|
| 1304 |
+
|
| 1305 |
+
def mul_predict_action(
|
| 1306 |
+
self,
|
| 1307 |
+
input_ids: Optional[torch.LongTensor] = None, #就是 language instruction.
|
| 1308 |
+
unnorm_key: Optional[str] = None,
|
| 1309 |
+
proprio=None,
|
| 1310 |
+
proprio_projector=None,
|
| 1311 |
+
action_head:L1RegressionActionHead=None,
|
| 1312 |
+
noisy_action_projector=None,
|
| 1313 |
+
use_film: bool = False,
|
| 1314 |
+
**kwargs: str,
|
| 1315 |
+
) -> np.ndarray:
|
| 1316 |
+
# only use in evaluation.
|
| 1317 |
+
cfg = kwargs.get("cfg", None) # Extract cfg from kwargs
|
| 1318 |
+
action_history = kwargs.get("action_history", None)
|
| 1319 |
+
|
| 1320 |
+
emptytoken = 220 # for llama3.2
|
| 1321 |
+
# emptytoken = 29871 # for openvla oft
|
| 1322 |
+
|
| 1323 |
+
if not torch.all(input_ids[:, -1] == emptytoken):
|
| 1324 |
+
input_ids = torch.cat(
|
| 1325 |
+
(input_ids, torch.unsqueeze(torch.Tensor([emptytoken]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1326 |
+
)
|
| 1327 |
+
|
| 1328 |
+
|
| 1329 |
+
pixel_values = kwargs["pixel_values"]
|
| 1330 |
+
attention_mask = kwargs["attention_mask"]
|
| 1331 |
+
|
| 1332 |
+
# input id '<s> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1333 |
+
# import ipdb; ipdb.set_trace()
|
| 1334 |
+
|
| 1335 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1336 |
+
|
| 1337 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1338 |
+
|
| 1339 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1340 |
+
if use_proprio:
|
| 1341 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1342 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1343 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1344 |
+
)
|
| 1345 |
+
if cfg.action_head_name == "hist":
|
| 1346 |
+
normalized_actions, actions_hidden_states = self.hist_predict_action(
|
| 1347 |
+
input_embeddings,
|
| 1348 |
+
None,
|
| 1349 |
+
projected_patch_embeddings,
|
| 1350 |
+
attention_mask,
|
| 1351 |
+
action_head,
|
| 1352 |
+
cfg=cfg,
|
| 1353 |
+
action_history=action_history,
|
| 1354 |
+
)
|
| 1355 |
+
else:
|
| 1356 |
+
normalized_actions, actions_hidden_states = self.mul_regression_or_discrete_prediction(
|
| 1357 |
+
input_embeddings,
|
| 1358 |
+
None,
|
| 1359 |
+
projected_patch_embeddings,
|
| 1360 |
+
attention_mask,
|
| 1361 |
+
None, #推理不需要labels
|
| 1362 |
+
None, #推理不需要NUM_PATCHES
|
| 1363 |
+
None, #推理不需要NUM_PROMPT_TOKENS
|
| 1364 |
+
action_head,
|
| 1365 |
+
cfg=cfg,
|
| 1366 |
+
)
|
| 1367 |
+
|
| 1368 |
+
|
| 1369 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key) #在这里 unorm, 所以出来的已经是unorm的了. 所以我 history 也要记录 norm 的.
|
| 1370 |
+
|
| 1371 |
+
return actions, normalized_actions
|
| 1372 |
+
|
| 1373 |
+
|
| 1374 |
+
def flow_matching_predict_action(
|
| 1375 |
+
self,
|
| 1376 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1377 |
+
unnorm_key: Optional[str] = None,
|
| 1378 |
+
proprio=None,
|
| 1379 |
+
proprio_projector=None,
|
| 1380 |
+
action_head: FlowMatchingActionHead = None,
|
| 1381 |
+
noisy_action_projector=None,
|
| 1382 |
+
use_film: bool = False,
|
| 1383 |
+
**kwargs: str,
|
| 1384 |
+
) -> np.ndarray:
|
| 1385 |
+
"""Predict actions using Flow Matching"""
|
| 1386 |
+
cfg = kwargs.get("cfg", None)
|
| 1387 |
+
|
| 1388 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1389 |
+
input_ids = torch.cat(
|
| 1390 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1391 |
+
)
|
| 1392 |
+
|
| 1393 |
+
pixel_values = kwargs["pixel_values"]
|
| 1394 |
+
attention_mask = kwargs["attention_mask"]
|
| 1395 |
+
|
| 1396 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1397 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1398 |
+
|
| 1399 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1400 |
+
if use_proprio:
|
| 1401 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1402 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1403 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1404 |
+
)
|
| 1405 |
+
|
| 1406 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1407 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1408 |
+
)
|
| 1409 |
+
|
| 1410 |
+
if cfg.mode == "flow_matching":
|
| 1411 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1412 |
+
language_model_output = self.language_model.generate(
|
| 1413 |
+
inputs_embeds=multimodal_embeddings,
|
| 1414 |
+
max_new_tokens=1,
|
| 1415 |
+
output_hidden_states=True,
|
| 1416 |
+
return_dict_in_generate=True
|
| 1417 |
+
)
|
| 1418 |
+
|
| 1419 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1420 |
+
cognition_features = actions_hidden_states[:, -1]
|
| 1421 |
+
assert (cognition_features.shape[0], cognition_features.shape[1]) == (1, 4096), "Batch size must be 1 for action prediction"
|
| 1422 |
+
|
| 1423 |
+
model_dtype = next(action_head.net.parameters()).dtype
|
| 1424 |
+
cognition_features = cognition_features.unsqueeze(1).to(model_dtype)
|
| 1425 |
+
|
| 1426 |
+
# Sample actions using flow matching
|
| 1427 |
+
normalized_actions = action_head.sample_actions(
|
| 1428 |
+
cognition_features,
|
| 1429 |
+
num_steps=getattr(cfg, 'num_flow_steps', 20)
|
| 1430 |
+
)
|
| 1431 |
+
normalized_actions = normalized_actions[0].cpu().numpy()
|
| 1432 |
+
else:
|
| 1433 |
+
raise NotImplementedError("Multi-token flow matching not yet implemented")
|
| 1434 |
+
else:
|
| 1435 |
+
raise NotImplementedError
|
| 1436 |
+
|
| 1437 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1438 |
+
return actions, actions_hidden_states
|
| 1439 |
+
|
| 1440 |
+
def diffusion_predict_action(
|
| 1441 |
+
self,
|
| 1442 |
+
input_ids: Optional[torch.LongTensor] = None, #就是 language instruction.
|
| 1443 |
+
unnorm_key: Optional[str] = None,
|
| 1444 |
+
proprio=None,
|
| 1445 |
+
proprio_projector=None,
|
| 1446 |
+
action_head:DiTActionHead=None,
|
| 1447 |
+
noisy_action_projector=None,
|
| 1448 |
+
use_film: bool = False,
|
| 1449 |
+
**kwargs: str,
|
| 1450 |
+
) -> np.ndarray:
|
| 1451 |
+
cfg = kwargs.get("cfg", None) # Extract cfg from kwargs
|
| 1452 |
+
|
| 1453 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1454 |
+
input_ids = torch.cat(
|
| 1455 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1456 |
+
)
|
| 1457 |
+
|
| 1458 |
+
|
| 1459 |
+
pixel_values = kwargs["pixel_values"]
|
| 1460 |
+
attention_mask = kwargs["attention_mask"]
|
| 1461 |
+
|
| 1462 |
+
# input id '<s> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1463 |
+
|
| 1464 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1465 |
+
|
| 1466 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1467 |
+
|
| 1468 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1469 |
+
if use_proprio:
|
| 1470 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1471 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1472 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1473 |
+
)
|
| 1474 |
+
|
| 1475 |
+
# normalized_actions, actions_hidden_states = self.mul_regression_or_discrete_prediction(
|
| 1476 |
+
# input_embeddings,
|
| 1477 |
+
# None,
|
| 1478 |
+
# projected_patch_embeddings,
|
| 1479 |
+
# attention_mask,
|
| 1480 |
+
# None, #推理不需要labels
|
| 1481 |
+
# None, #推理不需要NUM_PATCHES
|
| 1482 |
+
# None, #推理不需要NUM_PROMPT_TOKENS
|
| 1483 |
+
# action_head,
|
| 1484 |
+
# cfg=cfg,
|
| 1485 |
+
# )
|
| 1486 |
+
|
| 1487 |
+
# cfg = kwargs.get("cfg", None)
|
| 1488 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1489 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1490 |
+
)
|
| 1491 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1492 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 1493 |
+
# the following is (num of tokens,)
|
| 1494 |
+
|
| 1495 |
+
if cfg.mode == "dit":
|
| 1496 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 1497 |
+
# token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 1498 |
+
# language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 1499 |
+
# actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 1500 |
+
|
| 1501 |
+
# actions_hidden_states_list = [actions_hidden_states0]
|
| 1502 |
+
# for i in range(1, token_num):
|
| 1503 |
+
# token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 1504 |
+
# actions_hidden_states_list.append(token_hidden_state)
|
| 1505 |
+
# combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 1506 |
+
# actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 1507 |
+
raise NotImplementedError
|
| 1508 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1509 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 1510 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 1511 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1512 |
+
cognition_features = actions_hidden_states[:, -1]
|
| 1513 |
+
assert (cognition_features.shape[0], cognition_features.shape[1]) == (1,4096), "Batch size must be 1 for action prediction"
|
| 1514 |
+
using_cfg = cfg.cfg_scale > 1.0
|
| 1515 |
+
|
| 1516 |
+
model_dtype = next(action_head.net.parameters()).dtype
|
| 1517 |
+
B = cognition_features.shape[0]
|
| 1518 |
+
|
| 1519 |
+
cognition_features = cognition_features.unsqueeze(1).to(model_dtype)
|
| 1520 |
+
|
| 1521 |
+
noise = torch.randn(B, cfg.num_actions_chunk, action_head.net.in_channels, device=cognition_features.device).to(model_dtype)
|
| 1522 |
+
|
| 1523 |
+
# TODO: Setup classifier-free guidance: now use cfg
|
| 1524 |
+
noise = torch.cat([noise, noise], 0) # noise.shape torch.Size([2, 16, 7])
|
| 1525 |
+
uncondition = action_head.net.z_embedder.uncondition # torch.Size([1, 4096])
|
| 1526 |
+
uncondition = uncondition.unsqueeze(0) #[1, D] # torch.Size([1, 1, 4096])
|
| 1527 |
+
uncondition = uncondition.expand(B, 1, -1) #[B, 1, D]
|
| 1528 |
+
z = torch.cat([cognition_features, uncondition], 0) # z shape torch.Size([2, 1, 4096])
|
| 1529 |
+
model_kwargs = dict(z=z, cfg_scale=cfg.cfg_scale)
|
| 1530 |
+
sample_fn = action_head.net.forward_with_cfg
|
| 1531 |
+
# default use ddim
|
| 1532 |
+
if action_head.ddim_diffusion is None:
|
| 1533 |
+
action_head.create_ddim(ddim_step=cfg.num_ddim_steps)
|
| 1534 |
+
samples = action_head.ddim_diffusion.ddim_sample_loop(sample_fn,
|
| 1535 |
+
noise.shape,
|
| 1536 |
+
noise,
|
| 1537 |
+
clip_denoised=False,
|
| 1538 |
+
model_kwargs=model_kwargs,
|
| 1539 |
+
progress=False,
|
| 1540 |
+
device=cognition_features.device,
|
| 1541 |
+
eta=0.0
|
| 1542 |
+
)
|
| 1543 |
+
if using_cfg:
|
| 1544 |
+
samples, _ = samples.chunk(2, dim=0) # Remove null class samples
|
| 1545 |
+
normalized_actions = samples[0].cpu().numpy()
|
| 1546 |
+
else:
|
| 1547 |
+
raise NotImplementedError
|
| 1548 |
+
else:
|
| 1549 |
+
raise NotImplementedError
|
| 1550 |
+
|
| 1551 |
+
|
| 1552 |
+
|
| 1553 |
+
# normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 1554 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1555 |
+
|
| 1556 |
+
return actions, actions_hidden_states
|
modeling_prismatic.py.back.20250921_182648
ADDED
|
@@ -0,0 +1,1552 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
modeling_prismatic.py
|
| 3 |
+
|
| 4 |
+
Core HuggingFace-style PrismaticPreTrainedModel and PrismaticForConditionalGeneration class definitions.
|
| 5 |
+
Inherits from the default `transformers.PretrainedModel`. Meant to be standalone and self-contained,
|
| 6 |
+
but exactly replicate the logic in `prismatic.models.vlms.prismatic.py`.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import logging
|
| 10 |
+
from dataclasses import dataclass
|
| 11 |
+
from functools import partial
|
| 12 |
+
from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple, Union
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
import timm
|
| 16 |
+
import tokenizers
|
| 17 |
+
import torch
|
| 18 |
+
import torch.nn as nn
|
| 19 |
+
import transformers
|
| 20 |
+
from timm.models.vision_transformer import LayerScale
|
| 21 |
+
from transformers import AutoModelForCausalLM, PretrainedConfig, PreTrainedModel
|
| 22 |
+
from transformers.modeling_outputs import ModelOutput
|
| 23 |
+
from prismatic.models.action_heads import L1RegressionActionHead, DiTActionHead, FlowMatchingActionHead
|
| 24 |
+
from prismatic.training.train_utils import (
|
| 25 |
+
get_current_action_mask,
|
| 26 |
+
get_next_actions_mask,
|
| 27 |
+
)
|
| 28 |
+
from prismatic.vla.constants import (
|
| 29 |
+
ACTION_DIM,
|
| 30 |
+
ACTION_PROPRIO_NORMALIZATION_TYPE,
|
| 31 |
+
IGNORE_INDEX,
|
| 32 |
+
NUM_ACTIONS_CHUNK,
|
| 33 |
+
ACTION_TOKEN_IDX,
|
| 34 |
+
NormalizationType,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
from .configuration_prismatic import OpenVLAConfig, PrismaticConfig
|
| 38 |
+
|
| 39 |
+
# Set up logger
|
| 40 |
+
logger = logging.getLogger(__name__)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# === Utility Functions for Monkey-Patching ===
|
| 44 |
+
def unpack_tuple(fn: Callable[[Any], Tuple[Any]]) -> Callable[[Any], Any]:
|
| 45 |
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
| 46 |
+
result = fn(*args, **kwargs)
|
| 47 |
+
return result[0] if isinstance(result, tuple) else result
|
| 48 |
+
|
| 49 |
+
return wrapper
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
# HF Transformers overwrites parameters with names containing `gamma`; we're going to patch VisionBackbone.LayerScale.
|
| 53 |
+
# =>> TIMM :: https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/vision_transformer.py#L109
|
| 54 |
+
# =>> Transformers :: https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3960
|
| 55 |
+
def _ls_new_forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 56 |
+
return x.mul_(self.scale_factor) if self.inplace else x * self.scale_factor
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def ls_apply_patch(ls_module: LayerScale):
|
| 60 |
+
ls_module.scale_factor = nn.Parameter(ls_module.gamma.clone())
|
| 61 |
+
ls_module.forward = _ls_new_forward.__get__(ls_module, LayerScale)
|
| 62 |
+
del ls_module.gamma
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# === Prismatic Vision Backbone (nn.Module) Definitions (w/ Fused Backbone Support) ===
|
| 66 |
+
class PrismaticVisionBackbone(nn.Module):
|
| 67 |
+
"""
|
| 68 |
+
Vision backbone for Prismatic models that handles image feature extraction.
|
| 69 |
+
|
| 70 |
+
Supports both single backbone (e.g., SigLIP) and fused backbone (e.g., SigLIP + DINOv2) configurations.
|
| 71 |
+
For fused backbones, features from both models are concatenated along the feature dimension.
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
def __init__(
|
| 75 |
+
self,
|
| 76 |
+
use_fused_vision_backbone: bool,
|
| 77 |
+
image_sizes: List[int],
|
| 78 |
+
timm_model_ids: List[str],
|
| 79 |
+
timm_override_act_layers: List[Optional[str]],
|
| 80 |
+
) -> None:
|
| 81 |
+
"""
|
| 82 |
+
Initialize the vision backbone.
|
| 83 |
+
|
| 84 |
+
Args:
|
| 85 |
+
use_fused_vision_backbone: Whether to use two backbones and fuse their features
|
| 86 |
+
image_sizes: List of image sizes for each backbone
|
| 87 |
+
timm_model_ids: List of TIMM model IDs to use for each backbone
|
| 88 |
+
timm_override_act_layers: List of activation layer overrides for each backbone
|
| 89 |
+
"""
|
| 90 |
+
super().__init__()
|
| 91 |
+
self.use_fused_vision_backbone = use_fused_vision_backbone
|
| 92 |
+
self.num_images_in_input = 1 # Default value, can be overridden later
|
| 93 |
+
|
| 94 |
+
# Validate number of (fused) vision backbones
|
| 95 |
+
if len(timm_model_ids) > 2:
|
| 96 |
+
raise ValueError("Prismatic models only support up to 2 (fused) vision backbones!")
|
| 97 |
+
|
| 98 |
+
# Create primary featurizer
|
| 99 |
+
self.featurizer = self._create_featurizer(
|
| 100 |
+
model_id=timm_model_ids[0], img_size=image_sizes[0], act_layer=timm_override_act_layers[0]
|
| 101 |
+
)
|
| 102 |
+
self.embed_dim = self.featurizer.embed_dim
|
| 103 |
+
|
| 104 |
+
# Create secondary featurizer if using fused backbone
|
| 105 |
+
if self.use_fused_vision_backbone:
|
| 106 |
+
self.fused_featurizer = self._create_featurizer(
|
| 107 |
+
model_id=timm_model_ids[1], img_size=image_sizes[1], act_layer=timm_override_act_layers[1]
|
| 108 |
+
)
|
| 109 |
+
self.embed_dim += self.fused_featurizer.embed_dim
|
| 110 |
+
|
| 111 |
+
# Patch LayerScale modules for HF compatibility
|
| 112 |
+
self._patch_layer_scales()
|
| 113 |
+
|
| 114 |
+
def _create_featurizer(self, model_id: str, img_size: int, act_layer: Optional[str]) -> nn.Module:
|
| 115 |
+
"""
|
| 116 |
+
Create a TIMM-based featurizer model with appropriate configurations.
|
| 117 |
+
|
| 118 |
+
Args:
|
| 119 |
+
model_id: The TIMM model ID to load
|
| 120 |
+
img_size: Input image size for the model
|
| 121 |
+
act_layer: Override for the activation layer type
|
| 122 |
+
|
| 123 |
+
Returns:
|
| 124 |
+
A configured featurizer model
|
| 125 |
+
"""
|
| 126 |
+
featurizer = timm.create_model(
|
| 127 |
+
model_id,
|
| 128 |
+
pretrained=False,
|
| 129 |
+
num_classes=0,
|
| 130 |
+
img_size=img_size,
|
| 131 |
+
act_layer=act_layer,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# Monkey-patch the forward function to extract the second-to-last layer features
|
| 135 |
+
num_blocks = len(featurizer.blocks)
|
| 136 |
+
featurizer.forward = unpack_tuple(partial(featurizer.get_intermediate_layers, n={num_blocks - 2}))
|
| 137 |
+
|
| 138 |
+
return featurizer
|
| 139 |
+
|
| 140 |
+
def _patch_layer_scales(self) -> None:
|
| 141 |
+
"""
|
| 142 |
+
Patch all LayerScale modules to be compatible with HF's parameter naming.
|
| 143 |
+
|
| 144 |
+
HF Transformers overwrites parameters with names containing 'gamma',
|
| 145 |
+
so we need to rename and modify the forward method.
|
| 146 |
+
"""
|
| 147 |
+
# Patch primary featurizer
|
| 148 |
+
for module in self.featurizer.modules():
|
| 149 |
+
if isinstance(module, LayerScale):
|
| 150 |
+
ls_apply_patch(module)
|
| 151 |
+
|
| 152 |
+
# Patch secondary featurizer if it exists
|
| 153 |
+
if self.use_fused_vision_backbone:
|
| 154 |
+
for module in self.fused_featurizer.modules():
|
| 155 |
+
if isinstance(module, LayerScale):
|
| 156 |
+
ls_apply_patch(module)
|
| 157 |
+
|
| 158 |
+
def get_num_patches(self) -> int:
|
| 159 |
+
"""
|
| 160 |
+
Returns the number of vision patches output by the vision backbone.
|
| 161 |
+
|
| 162 |
+
Returns:
|
| 163 |
+
Number of patches per image
|
| 164 |
+
"""
|
| 165 |
+
return self.featurizer.patch_embed.num_patches
|
| 166 |
+
|
| 167 |
+
def get_num_images_in_input(self) -> int:
|
| 168 |
+
"""
|
| 169 |
+
Returns the number of input images for the vision backbone.
|
| 170 |
+
|
| 171 |
+
Returns:
|
| 172 |
+
Number of images expected in the input
|
| 173 |
+
"""
|
| 174 |
+
return self.num_images_in_input
|
| 175 |
+
|
| 176 |
+
def set_num_images_in_input(self, num_images_in_input: int) -> None:
|
| 177 |
+
"""
|
| 178 |
+
Sets the number of input images for the vision backbone.
|
| 179 |
+
|
| 180 |
+
Args:
|
| 181 |
+
num_images_in_input: Number of images to expect in the input
|
| 182 |
+
"""
|
| 183 |
+
self.num_images_in_input = num_images_in_input
|
| 184 |
+
|
| 185 |
+
def forward(self, pixel_values: torch.Tensor) -> torch.Tensor:
|
| 186 |
+
"""
|
| 187 |
+
Implements the forward pass for the vision backbone.
|
| 188 |
+
|
| 189 |
+
If `self.use_fused_vision_backbone == True`, uses both SigLIP and DINOv2 transformers to extract visual features
|
| 190 |
+
(otherwise uses SigLIP only). Allows multi-image inputs (but only for fused vision backbone).
|
| 191 |
+
|
| 192 |
+
Args:
|
| 193 |
+
pixel_values (torch.Tensor): Pixels for input image(s), (B, C, H, W).
|
| 194 |
+
"""
|
| 195 |
+
if self.num_images_in_input == 1:
|
| 196 |
+
if not self.use_fused_vision_backbone:
|
| 197 |
+
return self.featurizer(pixel_values)
|
| 198 |
+
|
| 199 |
+
# Split `pixel_values :: [bsz, 2 * 3, resolution, resolution]` =>> featurize =>> channel stack
|
| 200 |
+
img, img_fused = torch.split(pixel_values, [3, 3], dim=1)
|
| 201 |
+
patches, patches_fused = self.featurizer(img), self.fused_featurizer(img_fused)
|
| 202 |
+
|
| 203 |
+
return torch.cat([patches, patches_fused], dim=2)
|
| 204 |
+
|
| 205 |
+
else:
|
| 206 |
+
assert self.use_fused_vision_backbone, "Multi-image inputs require using fused backbone!"
|
| 207 |
+
|
| 208 |
+
# Split `pixel_values` into individual images (each with 6 channels: 3 for SigLIP + 3 for DINOv2)
|
| 209 |
+
images = torch.split(pixel_values, [6] * self.num_images_in_input, dim=1)
|
| 210 |
+
|
| 211 |
+
# Process each image and collect patches
|
| 212 |
+
all_patches = []
|
| 213 |
+
for img in images:
|
| 214 |
+
# Split each image further into two stacks of channels (each with 3 channels)
|
| 215 |
+
img_regular, img_fused = torch.split(img, [3, 3], dim=1)
|
| 216 |
+
|
| 217 |
+
# Get patches from both SigLIP and DINOv2 vision transformers
|
| 218 |
+
patches = self.featurizer(img_regular)
|
| 219 |
+
patches_fused = self.fused_featurizer(img_fused)
|
| 220 |
+
|
| 221 |
+
# Concatenate SigLIP and DINOv2 patches along the hidden dimension
|
| 222 |
+
combined_patches = torch.cat([patches, patches_fused], dim=2)
|
| 223 |
+
all_patches.append(combined_patches)
|
| 224 |
+
|
| 225 |
+
# Concatenate all patches along the patch dimension
|
| 226 |
+
return torch.cat(all_patches, dim=1)
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
# === Prismatic Projector (nn.Module) Definitions ===
|
| 230 |
+
class PrismaticProjector(nn.Module):
|
| 231 |
+
def __init__(self, use_fused_vision_backbone: bool, vision_dim: int, llm_dim: int) -> None:
|
| 232 |
+
super().__init__()
|
| 233 |
+
self.use_fused_vision_backbone = use_fused_vision_backbone
|
| 234 |
+
self.vision_dim, self.llm_dim = vision_dim, llm_dim
|
| 235 |
+
|
| 236 |
+
# Switch on `use_fused_vision_backbone` =>> use slightly different MLPs and projection factors!
|
| 237 |
+
if not self.use_fused_vision_backbone:
|
| 238 |
+
self.fc1 = nn.Linear(self.vision_dim, self.llm_dim, bias=True)
|
| 239 |
+
self.fc2 = nn.Linear(self.llm_dim, self.llm_dim, bias=True)
|
| 240 |
+
self.act_fn1 = nn.GELU()
|
| 241 |
+
else:
|
| 242 |
+
initial_projection_dim = 4 * vision_dim
|
| 243 |
+
self.fc1 = nn.Linear(self.vision_dim, initial_projection_dim, bias=True)
|
| 244 |
+
self.fc2 = nn.Linear(initial_projection_dim, self.llm_dim, bias=True)
|
| 245 |
+
self.fc3 = nn.Linear(self.llm_dim, self.llm_dim, bias=True)
|
| 246 |
+
self.act_fn1 = nn.GELU()
|
| 247 |
+
self.act_fn2 = nn.GELU()
|
| 248 |
+
|
| 249 |
+
def forward(self, img_patches: torch.Tensor) -> torch.Tensor:
|
| 250 |
+
if not self.use_fused_vision_backbone:
|
| 251 |
+
projected_features = self.fc1(img_patches)
|
| 252 |
+
projected_features = self.act_fn1(projected_features)
|
| 253 |
+
projected_features = self.fc2(projected_features)
|
| 254 |
+
else:
|
| 255 |
+
projected_features = self.fc1(img_patches)
|
| 256 |
+
projected_features = self.act_fn1(projected_features)
|
| 257 |
+
projected_features = self.fc2(projected_features)
|
| 258 |
+
projected_features = self.act_fn2(projected_features)
|
| 259 |
+
projected_features = self.fc3(projected_features)
|
| 260 |
+
|
| 261 |
+
return projected_features
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
# === Main HF Class Definitions ===
|
| 265 |
+
@dataclass
|
| 266 |
+
class PrismaticCausalLMOutputWithPast(ModelOutput):
|
| 267 |
+
"""Base class for Prismatic casual (visually-conditioned) language model outputs; also exposes visual features."""
|
| 268 |
+
|
| 269 |
+
loss: Optional[torch.FloatTensor] = None
|
| 270 |
+
logits: torch.FloatTensor = None
|
| 271 |
+
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None
|
| 272 |
+
hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
| 273 |
+
attentions: Optional[Tuple[torch.FloatTensor]] = None
|
| 274 |
+
|
| 275 |
+
# Additions for VLMs
|
| 276 |
+
projector_features: Optional[torch.FloatTensor] = None
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
class PrismaticPreTrainedModel(PreTrainedModel):
|
| 280 |
+
config_class: PretrainedConfig = PrismaticConfig
|
| 281 |
+
base_model_prefix: str = "model"
|
| 282 |
+
supports_gradient_checkpointing: bool = True
|
| 283 |
+
|
| 284 |
+
_no_split_modules: ClassVar[List[str]] = ["PrismaticProjector"]
|
| 285 |
+
_skip_keys_device_placement: str = "past_key_values"
|
| 286 |
+
_supports_flash_attn_2: bool = True
|
| 287 |
+
|
| 288 |
+
def _init_weights(self, module: nn.Module) -> None:
|
| 289 |
+
# Important :: this HF ported version is *not* meant for training from scratch; only inference and fine-tuning!
|
| 290 |
+
# => As such, this init_weights code is not correct; if training VLMs from scratch, use the main codebase at
|
| 291 |
+
# https://github.com/TRI-ML/prismatic-vlms
|
| 292 |
+
std = (
|
| 293 |
+
self.config.initializer_range
|
| 294 |
+
if hasattr(self.config, "initializer_range")
|
| 295 |
+
else self.config.text_config.initializer_range
|
| 296 |
+
)
|
| 297 |
+
|
| 298 |
+
if hasattr(module, "class_embedding"):
|
| 299 |
+
module.class_embedding.data.normal_(mean=0.0, std=std)
|
| 300 |
+
|
| 301 |
+
if isinstance(module, (nn.Linear, nn.Conv2d)):
|
| 302 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 303 |
+
if module.bias is not None:
|
| 304 |
+
module.bias.data.zero_()
|
| 305 |
+
elif isinstance(module, nn.Embedding):
|
| 306 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 307 |
+
if module.padding_idx is not None:
|
| 308 |
+
module.weight.data[module.padding_idx].zero_()
|
| 309 |
+
|
| 310 |
+
@property
|
| 311 |
+
def _supports_sdpa(self) -> bool:
|
| 312 |
+
"""Check LLM supports SDPA Attention"""
|
| 313 |
+
return self.language_model._supports_sdpa
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
class PrismaticForConditionalGeneration(PrismaticPreTrainedModel):
|
| 317 |
+
def __init__(self, config: PrismaticConfig) -> None:
|
| 318 |
+
super().__init__(config)
|
| 319 |
+
|
| 320 |
+
# [Validation] Lightweight Validate on `config` Fields + Dependency Versions
|
| 321 |
+
if config.use_fused_vision_backbone is None:
|
| 322 |
+
raise ValueError("Missing config field `use_fused_vision_backbone`")
|
| 323 |
+
|
| 324 |
+
if timm.__version__ not in {"0.9.10", "0.9.11", "0.9.12", "0.9.16"}:
|
| 325 |
+
raise NotImplementedError(
|
| 326 |
+
"TIMM Version must be >= 0.9.10 and < 1.0.0 (breaking); please raise a GitHub Issue "
|
| 327 |
+
"if you urgently need support for latest TIMM versions."
|
| 328 |
+
)
|
| 329 |
+
|
| 330 |
+
if (transformers.__version__ != "4.40.1") or (tokenizers.__version__ != "0.19.1"):
|
| 331 |
+
logger.warning(
|
| 332 |
+
f"Expected `transformers==4.40.1` and `tokenizers==0.19.1` but got "
|
| 333 |
+
f"`transformers=={transformers.__version__}` and `tokenizers=={tokenizers.__version__}`; "
|
| 334 |
+
f"there might be inference-time regressions due to dependency changes. If in doubt, please"
|
| 335 |
+
f"use the above versions."
|
| 336 |
+
)
|
| 337 |
+
|
| 338 |
+
# Instantiate PrismaticVisionBackbone (w/ Potential Fused Backbone)
|
| 339 |
+
self.vision_backbone = PrismaticVisionBackbone(
|
| 340 |
+
config.use_fused_vision_backbone, config.image_sizes, config.timm_model_ids, config.timm_override_act_layers
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
# Create Multimodal Projector
|
| 344 |
+
self.projector = PrismaticProjector(
|
| 345 |
+
config.use_fused_vision_backbone,
|
| 346 |
+
vision_dim=self.vision_backbone.embed_dim,
|
| 347 |
+
llm_dim=config.text_config.hidden_size,
|
| 348 |
+
)
|
| 349 |
+
|
| 350 |
+
# Instantiate LLM Backbone
|
| 351 |
+
self.language_model = AutoModelForCausalLM.from_config(
|
| 352 |
+
config.text_config, attn_implementation=config._attn_implementation
|
| 353 |
+
)
|
| 354 |
+
self.vocab_size = config.text_config.vocab_size
|
| 355 |
+
self.pad_token_id = config.pad_token_id
|
| 356 |
+
self.llm_dim = config.text_config.hidden_size
|
| 357 |
+
|
| 358 |
+
# HF Boilerplate =>> initializes weights via `_init_weights()` and sets gradient checkpointing
|
| 359 |
+
self.post_init()
|
| 360 |
+
|
| 361 |
+
# === `PreTrainedModel` Boilerplate ===
|
| 362 |
+
def get_input_embeddings(self) -> nn.Module:
|
| 363 |
+
return self.language_model.get_input_embeddings()
|
| 364 |
+
|
| 365 |
+
def set_input_embeddings(self, value: nn.Module) -> None:
|
| 366 |
+
self.language_model.set_input_embeddings(value)
|
| 367 |
+
|
| 368 |
+
def get_output_embeddings(self) -> nn.Module:
|
| 369 |
+
return self.language_model.get_output_embeddings()
|
| 370 |
+
|
| 371 |
+
def set_output_embeddings(self, new_embeddings: nn.Module) -> None:
|
| 372 |
+
self.language_model.set_output_embeddings(new_embeddings)
|
| 373 |
+
|
| 374 |
+
def get_decoder(self) -> nn.Module:
|
| 375 |
+
return self.language_model.get_decoder()
|
| 376 |
+
|
| 377 |
+
def set_decoder(self, decoder: nn.Module) -> None:
|
| 378 |
+
self.language_model.set_decoder(decoder)
|
| 379 |
+
|
| 380 |
+
def tie_weights(self) -> None:
|
| 381 |
+
self.language_model.tie_weights() # Note: `Llama-2` and `Mistral` don't tie weights (no-op)
|
| 382 |
+
|
| 383 |
+
def resize_token_embeddings(
|
| 384 |
+
self, new_num_tokens: Optional[int] = None, pad_to_multiple_of: Optional[int] = None
|
| 385 |
+
) -> nn.Embedding:
|
| 386 |
+
updated_embeddings = self.language_model.resize_token_embeddings(new_num_tokens, pad_to_multiple_of)
|
| 387 |
+
|
| 388 |
+
# Update config/instance variables
|
| 389 |
+
self.config.text_config.vocab_size = updated_embeddings.num_embeddings
|
| 390 |
+
self.vocab_size = updated_embeddings.num_embeddings
|
| 391 |
+
|
| 392 |
+
return updated_embeddings
|
| 393 |
+
|
| 394 |
+
def _replace_input_embeddings(self, input_embeddings, all_actions_mask, noisy_action_features):
|
| 395 |
+
"""
|
| 396 |
+
Replace embeddings in input_embeddings at positions where all_actions_mask is True
|
| 397 |
+
with embeddings from noisy_action_features, using vectorized operations.
|
| 398 |
+
|
| 399 |
+
Args:
|
| 400 |
+
input_embeddings: Tensor of shape (B, S, D)
|
| 401 |
+
all_actions_mask: Boolean tensor of shape (B, S)
|
| 402 |
+
noisy_action_features: Tensor of shape (B, K, D) where K is the number of True values in mask per sample
|
| 403 |
+
|
| 404 |
+
Returns:
|
| 405 |
+
Modified input_embeddings tensor
|
| 406 |
+
"""
|
| 407 |
+
# Clone input to avoid modifying the original tensor
|
| 408 |
+
new_input_embeddings = input_embeddings.clone()
|
| 409 |
+
|
| 410 |
+
# Create a tensor with the same shape of input_embeddings to hold the noisy action features
|
| 411 |
+
repositioned_noisy_action_features = torch.zeros_like(input_embeddings)
|
| 412 |
+
|
| 413 |
+
# Create batch indices for splicing
|
| 414 |
+
batch_indices = torch.arange(input_embeddings.shape[0], device=input_embeddings.device)
|
| 415 |
+
batch_indices = batch_indices.unsqueeze(1).expand(-1, noisy_action_features.shape[1])
|
| 416 |
+
|
| 417 |
+
# Get indices where mask is True for each sample
|
| 418 |
+
masked_indices = torch.stack([torch.where(mask)[0] for mask in all_actions_mask])
|
| 419 |
+
|
| 420 |
+
# Move the noisy action features into their correct positions
|
| 421 |
+
repositioned_noisy_action_features[batch_indices, masked_indices] = noisy_action_features
|
| 422 |
+
|
| 423 |
+
# Combine original input embeddings and noisy action embeddings using the mask
|
| 424 |
+
new_input_embeddings = torch.where(
|
| 425 |
+
all_actions_mask.unsqueeze(-1), repositioned_noisy_action_features, new_input_embeddings
|
| 426 |
+
)
|
| 427 |
+
|
| 428 |
+
return new_input_embeddings
|
| 429 |
+
|
| 430 |
+
def _process_action_masks(self, labels):
|
| 431 |
+
"""Helper to get action masks from labels"""
|
| 432 |
+
current_action_mask = get_current_action_mask(labels) # (B, seq_len)
|
| 433 |
+
next_actions_mask = get_next_actions_mask(labels) # (B, seq_len)
|
| 434 |
+
all_actions_mask = current_action_mask | next_actions_mask # (B, seq_len)
|
| 435 |
+
return all_actions_mask
|
| 436 |
+
|
| 437 |
+
def _process_vision_features(self, pixel_values):
|
| 438 |
+
"""Process vision features with optional FiLM conditioning"""
|
| 439 |
+
patch_features = self.vision_backbone(pixel_values) # (bsz, 256 * num_images, D)
|
| 440 |
+
|
| 441 |
+
# Project patch embeddings into language embedding space
|
| 442 |
+
return self.projector(patch_features)
|
| 443 |
+
|
| 444 |
+
def _process_proprio_features(self, projected_patch_embeddings, proprio, proprio_projector):
|
| 445 |
+
"""Process proprioceptive features and append to vision features"""
|
| 446 |
+
if proprio_projector is not None and proprio is not None:
|
| 447 |
+
# projected_patch_embeddings: (bsz, num_patches * num_images, llm_dim)
|
| 448 |
+
# proprio: (bsz, proprio_dim) or (propro_dim,)
|
| 449 |
+
proprio = proprio.reshape(projected_patch_embeddings.shape[0], -1) # (bsz, proprio_dim)
|
| 450 |
+
proprio_features = proprio_projector(proprio) # (bsz, llm_dim)
|
| 451 |
+
proprio_features = proprio_features.unsqueeze(dim=1) # (bsz, 1, llm_dim)
|
| 452 |
+
# For simplicity, just append proprio token to the end of projected vision patch tokens
|
| 453 |
+
return torch.cat((projected_patch_embeddings, proprio_features), dim=1)
|
| 454 |
+
return projected_patch_embeddings
|
| 455 |
+
|
| 456 |
+
def _build_multimodal_attention(self, input_embeddings, projected_patch_embeddings, attention_mask):
|
| 457 |
+
"""Build multimodal embeddings and attention mask"""
|
| 458 |
+
# juyi: Update attention mask 是不是要改成下三角? 不用, 因为generate会自动屏蔽
|
| 459 |
+
projected_patch_attention_mask = None
|
| 460 |
+
if attention_mask is not None:
|
| 461 |
+
projected_patch_attention_mask = torch.full(
|
| 462 |
+
(projected_patch_embeddings.shape[0], projected_patch_embeddings.shape[1]),
|
| 463 |
+
fill_value=True,
|
| 464 |
+
dtype=attention_mask.dtype,
|
| 465 |
+
device=attention_mask.device,
|
| 466 |
+
)
|
| 467 |
+
|
| 468 |
+
# Build multimodal embeddings & attention mask; insert embeddings after <BOS> token (1:)
|
| 469 |
+
multimodal_embeddings = torch.cat(
|
| 470 |
+
[input_embeddings[:, :1, :], projected_patch_embeddings, input_embeddings[:, 1:, :]], dim=1
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
multimodal_attention_mask = None
|
| 474 |
+
if attention_mask is not None:
|
| 475 |
+
multimodal_attention_mask = torch.cat(
|
| 476 |
+
[attention_mask[:, :1], projected_patch_attention_mask, attention_mask[:, 1:]], dim=1
|
| 477 |
+
)
|
| 478 |
+
|
| 479 |
+
return multimodal_embeddings, multimodal_attention_mask
|
| 480 |
+
|
| 481 |
+
def _build_multimodal_labels(self, labels, projected_patch_embeddings):
|
| 482 |
+
"""Build multimodal labels with IGNORE_INDEX for patch embeddings"""
|
| 483 |
+
if labels is not None:
|
| 484 |
+
projected_patch_labels = torch.full(
|
| 485 |
+
(projected_patch_embeddings.shape[0], projected_patch_embeddings.shape[1]),
|
| 486 |
+
fill_value=IGNORE_INDEX, # 这些位置不需要计算损失。
|
| 487 |
+
dtype=labels.dtype,
|
| 488 |
+
device=labels.device,
|
| 489 |
+
)
|
| 490 |
+
return torch.cat([labels[:, :1], projected_patch_labels, labels[:, 1:]], dim=1) # 第一个token是<BOS>
|
| 491 |
+
return None
|
| 492 |
+
|
| 493 |
+
# === Core Prismatic VLM `forward()` Logic ===
|
| 494 |
+
def forward(
|
| 495 |
+
self,
|
| 496 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 497 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 498 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 499 |
+
labels: Optional[torch.LongTensor] = None,
|
| 500 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 501 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 502 |
+
use_cache: Optional[bool] = None,
|
| 503 |
+
output_attentions: Optional[bool] = None,
|
| 504 |
+
output_hidden_states: Optional[bool] = None,
|
| 505 |
+
output_projector_features: Optional[bool] = None,
|
| 506 |
+
return_dict: Optional[bool] = None,
|
| 507 |
+
proprio=None,
|
| 508 |
+
proprio_projector=None,
|
| 509 |
+
noisy_actions=None,
|
| 510 |
+
noisy_action_projector=None,
|
| 511 |
+
diffusion_timestep_embeddings=None,
|
| 512 |
+
use_film: bool = False,
|
| 513 |
+
) -> Union[Tuple, PrismaticCausalLMOutputWithPast]:
|
| 514 |
+
"""Run a forward pass through the VLM, returning a PrismaticCausalLMOutputWithPast instance."""
|
| 515 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 516 |
+
output_hidden_states = (
|
| 517 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 518 |
+
)
|
| 519 |
+
output_projector_features = output_projector_features if output_projector_features is not None else False
|
| 520 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 521 |
+
|
| 522 |
+
# Respect `use_cache` only if not training (even if `gradient_checkpointing` is off)
|
| 523 |
+
use_cache = use_cache and not self.training
|
| 524 |
+
|
| 525 |
+
# Instantiate Placeholder for Projector Features
|
| 526 |
+
projected_patch_embeddings = None
|
| 527 |
+
|
| 528 |
+
# === Handle Generation with Cache (`input_ids.shape[1] == 1`) =>> requires `past_keys_values` ===
|
| 529 |
+
if input_ids.shape[1] == 1:
|
| 530 |
+
assert input_ids.shape[0] == 1, "Generation is only currently supported for batch size of 1!"
|
| 531 |
+
assert past_key_values is not None, "You must provide `past_key_values` during cached generation!"
|
| 532 |
+
assert labels is None, "Unexpected key `labels` provided during cached generation!"
|
| 533 |
+
|
| 534 |
+
language_model_output = self.language_model(
|
| 535 |
+
input_ids=input_ids,
|
| 536 |
+
attention_mask=None,
|
| 537 |
+
position_ids=None,
|
| 538 |
+
past_key_values=past_key_values,
|
| 539 |
+
inputs_embeds=None,
|
| 540 |
+
labels=None,
|
| 541 |
+
use_cache=use_cache,
|
| 542 |
+
output_attentions=output_attentions,
|
| 543 |
+
output_hidden_states=output_hidden_states,
|
| 544 |
+
return_dict=return_dict,
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
# === Handle Unimodal Forward ===
|
| 548 |
+
elif pixel_values is None:
|
| 549 |
+
assert (input_ids is not None) and (inputs_embeds is None), "Missing `input_ids` in language-only forward!"
|
| 550 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during language-only forward!"
|
| 551 |
+
|
| 552 |
+
language_model_output = self.language_model(
|
| 553 |
+
input_ids=input_ids,
|
| 554 |
+
attention_mask=attention_mask,
|
| 555 |
+
position_ids=None,
|
| 556 |
+
past_key_values=None,
|
| 557 |
+
inputs_embeds=None,
|
| 558 |
+
labels=labels,
|
| 559 |
+
use_cache=use_cache,
|
| 560 |
+
output_attentions=output_attentions,
|
| 561 |
+
output_hidden_states=output_hidden_states,
|
| 562 |
+
return_dict=return_dict,
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
# === Handle Multimodal Forward ===
|
| 566 |
+
elif (input_ids.shape[0] == pixel_values.shape[0]) or (inputs_embeds.shape[0] == pixel_values.shape[0]):
|
| 567 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during multimodal forward!"
|
| 568 |
+
|
| 569 |
+
# Get input embeddings (from language model embeddings)
|
| 570 |
+
input_embeddings = self.get_input_embeddings()(input_ids) # (B, seq_len, D)
|
| 571 |
+
|
| 572 |
+
# Extract action masks
|
| 573 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 574 |
+
|
| 575 |
+
# Extract the language portion of the input embeddings (i.e. remove the action tokens portion)
|
| 576 |
+
language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 577 |
+
input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 578 |
+
) # (B, lang_seq_len, llm_dim)
|
| 579 |
+
|
| 580 |
+
# Get visual features
|
| 581 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values, language_embeddings, use_film)
|
| 582 |
+
# bug: TypeError: PrismaticForConditionalGeneration._process_vision_features() takes 2 positional arguments but 4 were given
|
| 583 |
+
|
| 584 |
+
# Add proprioceptive state if provided
|
| 585 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 586 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 587 |
+
)
|
| 588 |
+
|
| 589 |
+
# [Diffusion] Add diffusion timestep embedding if provided
|
| 590 |
+
if diffusion_timestep_embeddings is not None:
|
| 591 |
+
# For simplicity, just append diffusion timestep embedding to the end of projected vision patch tokens
|
| 592 |
+
projected_patch_embeddings = torch.cat(
|
| 593 |
+
(projected_patch_embeddings, diffusion_timestep_embeddings), dim=1
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
# Process action embeddings
|
| 597 |
+
if noisy_actions is not None:
|
| 598 |
+
# Get mask corresponding to all action tokens
|
| 599 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 600 |
+
|
| 601 |
+
# Reshape noisy actions into individual action tokens
|
| 602 |
+
# noisy_actions: (B, chunk_len, action_dim) -> (B, chunk_len * action_dim, 1)
|
| 603 |
+
B = noisy_actions.shape[0]
|
| 604 |
+
noisy_actions = noisy_actions.reshape(B, -1).unsqueeze(-1)
|
| 605 |
+
|
| 606 |
+
# Project noisy action tokens into language model embedding space
|
| 607 |
+
noisy_action_features = noisy_action_projector(noisy_actions) # (B, chunk_len * action_dim, llm_dim)
|
| 608 |
+
|
| 609 |
+
# Replace embeddings of the action tokens with noisy action embeddings
|
| 610 |
+
input_embeddings = self._replace_input_embeddings(
|
| 611 |
+
input_embeddings, all_actions_mask, noisy_action_features
|
| 612 |
+
)
|
| 613 |
+
else:
|
| 614 |
+
# Replace the embeddings of the action tokens with zeros
|
| 615 |
+
# (Later on, the positional embeddings will be added to them)
|
| 616 |
+
all_actions_mask = all_actions_mask.unsqueeze(-1) # (B, seq_len, 1)
|
| 617 |
+
input_embeddings = input_embeddings * ~all_actions_mask
|
| 618 |
+
|
| 619 |
+
# Build multimodal embeddings & attention mask
|
| 620 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 621 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 622 |
+
)
|
| 623 |
+
|
| 624 |
+
# Build labels for multimodal sequence if needed
|
| 625 |
+
multimodal_labels = self._build_multimodal_labels(labels, projected_patch_embeddings)
|
| 626 |
+
|
| 627 |
+
# Dispatch to language model
|
| 628 |
+
language_model_output = self.language_model(
|
| 629 |
+
input_ids=None,
|
| 630 |
+
attention_mask=multimodal_attention_mask,
|
| 631 |
+
position_ids=None,
|
| 632 |
+
past_key_values=None,
|
| 633 |
+
inputs_embeds=multimodal_embeddings,
|
| 634 |
+
labels=multimodal_labels,
|
| 635 |
+
use_cache=use_cache,
|
| 636 |
+
output_attentions=output_attentions,
|
| 637 |
+
output_hidden_states=output_hidden_states,
|
| 638 |
+
return_dict=return_dict,
|
| 639 |
+
)
|
| 640 |
+
|
| 641 |
+
# === Otherwise =>> Assume Invalid! ===
|
| 642 |
+
elif (input_ids.shape[0] != pixel_values.shape[0]) or (inputs_embeds.shape[0] != pixel_values.shape[0]):
|
| 643 |
+
raise ValueError("Non-homogenous batch of (text, image) input -- forward() does not support mixed batches!")
|
| 644 |
+
|
| 645 |
+
else:
|
| 646 |
+
raise ValueError(
|
| 647 |
+
"Invalid PrismaticForConditionalGeneration `forward()` call with provided arguments:\n"
|
| 648 |
+
f"=> `input_ids` = {input_ids is not None}\n"
|
| 649 |
+
f"=> `attention_mask` = {attention_mask is not None}\n"
|
| 650 |
+
f"=> `pixel_values` = {pixel_values is not None}\n"
|
| 651 |
+
f"=> `labels` = {labels is not None}\n"
|
| 652 |
+
f"=> `input_embeds` = {inputs_embeds is not None}\n"
|
| 653 |
+
f"=> `past_key_values` = {past_key_values is not None}\n"
|
| 654 |
+
f"=> `use_cache` = {use_cache}"
|
| 655 |
+
)
|
| 656 |
+
|
| 657 |
+
# Unpack `language_model_output` and return PrismaticCausalLMOutputWithPast (or tuple if not `return_dict`)
|
| 658 |
+
if not return_dict:
|
| 659 |
+
if output_projector_features and (projected_patch_embeddings is not None):
|
| 660 |
+
return *language_model_output, projected_patch_embeddings
|
| 661 |
+
|
| 662 |
+
return language_model_output
|
| 663 |
+
|
| 664 |
+
return PrismaticCausalLMOutputWithPast(
|
| 665 |
+
loss=language_model_output.loss,
|
| 666 |
+
logits=language_model_output.logits,
|
| 667 |
+
past_key_values=language_model_output.past_key_values,
|
| 668 |
+
hidden_states=language_model_output.hidden_states,
|
| 669 |
+
attentions=language_model_output.attentions,
|
| 670 |
+
projector_features=projected_patch_embeddings,
|
| 671 |
+
)
|
| 672 |
+
|
| 673 |
+
# === GenerationMixin Methods ===
|
| 674 |
+
def prepare_inputs_for_generation(
|
| 675 |
+
self,
|
| 676 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 677 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 678 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 679 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 680 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 681 |
+
**kwargs: str,
|
| 682 |
+
) -> Dict[str, torch.Tensor]:
|
| 683 |
+
"""Borrowed from `LlamaForCausalLM` and simplified for batch size = 1; mirrors original PrismaticVLM logic."""
|
| 684 |
+
if ((input_ids is not None) and (input_ids.shape[0] > 1)) or (
|
| 685 |
+
(inputs_embeds is not None) and (inputs_embeds.shape[0] > 1)
|
| 686 |
+
):
|
| 687 |
+
raise ValueError("Generation with batch size > 1 is not currently supported!")
|
| 688 |
+
|
| 689 |
+
# Handle `past_key_values` (cache) =>> assume `input_ids` just has unprocessed tokens
|
| 690 |
+
if past_key_values is not None:
|
| 691 |
+
input_ids = input_ids[:, -1:]
|
| 692 |
+
|
| 693 |
+
# If `input_embeds` are passed, we only want to use them in the 1st generation step
|
| 694 |
+
if inputs_embeds is not None and past_key_values is None:
|
| 695 |
+
model_inputs = {"input_embeds": inputs_embeds}
|
| 696 |
+
else:
|
| 697 |
+
model_inputs = {"input_ids": input_ids}
|
| 698 |
+
|
| 699 |
+
# Make sure `pixel_values` are preserved in `model_inputs`
|
| 700 |
+
model_inputs.update(
|
| 701 |
+
{
|
| 702 |
+
"attention_mask": attention_mask,
|
| 703 |
+
"pixel_values": pixel_values,
|
| 704 |
+
"past_key_values": past_key_values,
|
| 705 |
+
"use_cache": kwargs.get("use_cache"),
|
| 706 |
+
}
|
| 707 |
+
)
|
| 708 |
+
|
| 709 |
+
return model_inputs
|
| 710 |
+
|
| 711 |
+
# Defer to Language Model (all handle this differently, with different return types)
|
| 712 |
+
def _reorder_cache(self, *args, **kwargs) -> Any:
|
| 713 |
+
return self.language_model._reorder_cache(*args, **kwargs)
|
| 714 |
+
|
| 715 |
+
|
| 716 |
+
class OpenVLAForActionPrediction(PrismaticForConditionalGeneration):
|
| 717 |
+
config_class: PretrainedConfig = OpenVLAConfig
|
| 718 |
+
|
| 719 |
+
def __init__(self, config: OpenVLAConfig) -> None:
|
| 720 |
+
super().__init__(config)
|
| 721 |
+
self.norm_stats = config.norm_stats
|
| 722 |
+
|
| 723 |
+
# Compute action bins
|
| 724 |
+
self.bins = np.linspace(-1, 1, config.n_action_bins)
|
| 725 |
+
self.bin_centers = (self.bins[:-1] + self.bins[1:]) / 2.0
|
| 726 |
+
|
| 727 |
+
# Compute vocab size for de-tokenization -- revert added "multiple of"
|
| 728 |
+
self.vocab_size = self.config.text_config.vocab_size - self.config.pad_to_multiple_of
|
| 729 |
+
|
| 730 |
+
def _prepare_input_for_action_prediction(self, input_ids, attention_mask):
|
| 731 |
+
# eval 会用到这里
|
| 732 |
+
"""Prepares input for action prediction by adding necessary tokens"""
|
| 733 |
+
# Add (ACTION_DIM * NUM_ACTIONS_CHUNK) placeholder tokens to input_ids to simulate action tokens
|
| 734 |
+
placeholder_action_token_ids = (
|
| 735 |
+
torch.ones((input_ids.shape[0], ACTION_DIM * NUM_ACTIONS_CHUNK)).to(input_ids.device).to(input_ids.dtype)
|
| 736 |
+
)
|
| 737 |
+
input_ids = torch.cat([input_ids, placeholder_action_token_ids], dim=-1) # torch.Size([1, 35 + 56= 91])
|
| 738 |
+
|
| 739 |
+
# Extend the attention mask to fit the new shape of input
|
| 740 |
+
# Note: Only batch size == 1 supported right now
|
| 741 |
+
mask_extension = (
|
| 742 |
+
torch.ones((attention_mask.shape[0], input_ids.shape[-1] - attention_mask.shape[-1]))
|
| 743 |
+
.to(attention_mask.device)
|
| 744 |
+
.to(attention_mask.dtype)
|
| 745 |
+
)
|
| 746 |
+
attention_mask = torch.cat([attention_mask, mask_extension], dim=-1)
|
| 747 |
+
|
| 748 |
+
return input_ids, attention_mask
|
| 749 |
+
|
| 750 |
+
def _prepare_labels_for_action_prediction(self, labels, input_ids):
|
| 751 |
+
"""Creates labels tensor for action prediction if not provided"""
|
| 752 |
+
# eval 会用到这里 ,
|
| 753 |
+
# Extends label tensors with fake action labels
|
| 754 |
+
# Adds stop tokens at the end of sequences
|
| 755 |
+
# Handles label preparation for action prediction tasks
|
| 756 |
+
# 他为啥可以随便一个? xuan说 你自定义一个值 ,然后一直指定这个 , PAD token可以吗?
|
| 757 |
+
#TODO: 这里是否要改? 感觉不需要改. 随便写就行了因为labels不重要只是要一个mask. 为什么需要这个函数? 确保 action 预测任务的标签(labels)符合模型的输入长度,并正确地处理序列终止
|
| 758 |
+
# Extend labels tensor with fake action labels
|
| 759 |
+
ARBITRARY_ACTION_TOKEN_IDX = ACTION_TOKEN_IDX # = 为了mask正确生成, action_tokens_only_mask = (labels == ACTION_TOKEN_IDX ), 所以这里也填上ACTION_TOKEN_IDX
|
| 760 |
+
labels_extension = (
|
| 761 |
+
torch.ones((labels.shape[0], input_ids.shape[-1] - labels.shape[-1])).to(labels.device).to(labels.dtype)
|
| 762 |
+
* ARBITRARY_ACTION_TOKEN_IDX
|
| 763 |
+
) #torch.Size([1, 57]),全是 ARBITRARY_ACTION_TOKEN_IDX
|
| 764 |
+
labels = torch.cat([labels, labels_extension], dim=-1)
|
| 765 |
+
|
| 766 |
+
return labels
|
| 767 |
+
|
| 768 |
+
def _unnormalize_actions(self, normalized_actions, unnorm_key=None):
|
| 769 |
+
"""Unnormalize actions using dataset statistics"""
|
| 770 |
+
action_norm_stats = self.get_action_stats(unnorm_key)
|
| 771 |
+
|
| 772 |
+
if ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS:
|
| 773 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["min"], dtype=bool))
|
| 774 |
+
action_high, action_low = np.array(action_norm_stats["max"]), np.array(action_norm_stats["min"])
|
| 775 |
+
elif ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS_Q99:
|
| 776 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["q01"], dtype=bool))
|
| 777 |
+
action_high, action_low = np.array(action_norm_stats["q99"]), np.array(action_norm_stats["q01"])
|
| 778 |
+
else:
|
| 779 |
+
raise ValueError("Unsupported action/proprio normalization type detected!")
|
| 780 |
+
|
| 781 |
+
actions = np.where(
|
| 782 |
+
mask,
|
| 783 |
+
0.5 * (normalized_actions + 1) * (action_high - action_low + 1e-8) + action_low,
|
| 784 |
+
normalized_actions,
|
| 785 |
+
)
|
| 786 |
+
|
| 787 |
+
return actions
|
| 788 |
+
|
| 789 |
+
|
| 790 |
+
def _normalize_actions(self, actions, norm_key=None):
|
| 791 |
+
"""Normalize actions to [-1, 1] using dataset statistics"""
|
| 792 |
+
action_norm_stats = self.get_action_stats(norm_key)
|
| 793 |
+
|
| 794 |
+
if ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS:
|
| 795 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["min"], dtype=bool))
|
| 796 |
+
action_high, action_low = np.array(action_norm_stats["max"]), np.array(action_norm_stats["min"])
|
| 797 |
+
elif ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS_Q99:
|
| 798 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["q01"], dtype=bool))
|
| 799 |
+
action_high, action_low = np.array(action_norm_stats["q99"]), np.array(action_norm_stats["q01"])
|
| 800 |
+
else:
|
| 801 |
+
raise ValueError("Unsupported action/proprio normalization type detected!")
|
| 802 |
+
|
| 803 |
+
normalized = np.where(
|
| 804 |
+
mask,
|
| 805 |
+
2 * (actions - action_low) / (action_high - action_low + 1e-8) - 1,
|
| 806 |
+
actions,
|
| 807 |
+
)
|
| 808 |
+
|
| 809 |
+
return normalized
|
| 810 |
+
|
| 811 |
+
def _run_diffusion_prediction(
|
| 812 |
+
self,
|
| 813 |
+
input_embeddings,
|
| 814 |
+
all_actions_mask,
|
| 815 |
+
noise,
|
| 816 |
+
action_head,
|
| 817 |
+
projected_patch_embeddings,
|
| 818 |
+
labels,
|
| 819 |
+
attention_mask,
|
| 820 |
+
NUM_PATCHES,
|
| 821 |
+
NUM_PROMPT_TOKENS,
|
| 822 |
+
noisy_action_projector,
|
| 823 |
+
):
|
| 824 |
+
"""Run diffusion-based action prediction"""
|
| 825 |
+
# Set diffusion timestep values
|
| 826 |
+
action_head.noise_scheduler.set_timesteps(action_head.num_diffusion_steps)
|
| 827 |
+
# Clone embedding for reuse in each timestep
|
| 828 |
+
orig_projected_patch_embeddings = projected_patch_embeddings.clone()
|
| 829 |
+
curr_noisy_actions = noise
|
| 830 |
+
|
| 831 |
+
# Reverse diffusion: Iteratively denoise to generate action prediction
|
| 832 |
+
for t in action_head.noise_scheduler.timesteps:
|
| 833 |
+
# Get diffusion model's noise prediction (conditioned on VLA latent embedding, current noisy action
|
| 834 |
+
# embedding, and diffusion timestep embedding)
|
| 835 |
+
timesteps = torch.Tensor([t]).to(labels.device)
|
| 836 |
+
diffusion_timestep_embeddings = (
|
| 837 |
+
action_head.time_encoder(timesteps).to(curr_noisy_actions.dtype).to(curr_noisy_actions.device)
|
| 838 |
+
) # (B, llm_dim)
|
| 839 |
+
diffusion_timestep_embeddings = diffusion_timestep_embeddings.unsqueeze(1) # (B, 1, llm_dim)
|
| 840 |
+
|
| 841 |
+
# [Diffusion] Replace the embeddings of the action tokens with noisy actions
|
| 842 |
+
# (Later on, the positional embeddings will be added to them)
|
| 843 |
+
|
| 844 |
+
# For simplicity, append diffusion timestep embedding to the end of projected vision tokens
|
| 845 |
+
projected_patch_embeddings = torch.cat(
|
| 846 |
+
(orig_projected_patch_embeddings, diffusion_timestep_embeddings), dim=1
|
| 847 |
+
)
|
| 848 |
+
|
| 849 |
+
# Reshape and project noisy actions into language embedding space
|
| 850 |
+
B = curr_noisy_actions.shape[0]
|
| 851 |
+
orig_curr_noisy_actions_shape = curr_noisy_actions.shape
|
| 852 |
+
curr_noisy_actions = curr_noisy_actions.reshape(B, -1).unsqueeze(-1)
|
| 853 |
+
noisy_action_features = noisy_action_projector(curr_noisy_actions)
|
| 854 |
+
curr_noisy_actions = curr_noisy_actions.reshape(orig_curr_noisy_actions_shape)
|
| 855 |
+
|
| 856 |
+
# Replace action token embeddings with noisy action embeddings
|
| 857 |
+
input_embeddings = self._replace_input_embeddings(
|
| 858 |
+
input_embeddings.clone(), all_actions_mask, noisy_action_features
|
| 859 |
+
)
|
| 860 |
+
|
| 861 |
+
# Build multimodal embeddings and attention mask
|
| 862 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 863 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 864 |
+
)
|
| 865 |
+
|
| 866 |
+
# Forward pass through language model
|
| 867 |
+
language_model_output = self.language_model(
|
| 868 |
+
input_ids=None,
|
| 869 |
+
attention_mask=multimodal_attention_mask,
|
| 870 |
+
position_ids=None,
|
| 871 |
+
past_key_values=None,
|
| 872 |
+
inputs_embeds=multimodal_embeddings,
|
| 873 |
+
labels=None,
|
| 874 |
+
use_cache=None,
|
| 875 |
+
output_attentions=False,
|
| 876 |
+
output_hidden_states=True,
|
| 877 |
+
return_dict=True,
|
| 878 |
+
)
|
| 879 |
+
|
| 880 |
+
# Extract hidden states for action portion of response
|
| 881 |
+
last_hidden_states = language_model_output.hidden_states[-1] # (B, seq_len, D)
|
| 882 |
+
actions_hidden_states = last_hidden_states[
|
| 883 |
+
:,
|
| 884 |
+
NUM_PATCHES + NUM_PROMPT_TOKENS : NUM_PATCHES + NUM_PROMPT_TOKENS + ACTION_DIM * NUM_ACTIONS_CHUNK,
|
| 885 |
+
:,
|
| 886 |
+
] # (B, act_chunk_len, D)
|
| 887 |
+
|
| 888 |
+
# Predict noise and update noisy actions: x_t -> x_{t-1}
|
| 889 |
+
noise_pred = action_head.predict_noise(actions_hidden_states)
|
| 890 |
+
curr_noisy_actions = action_head.noise_scheduler.step(noise_pred, t, curr_noisy_actions).prev_sample
|
| 891 |
+
|
| 892 |
+
curr_noisy_actions = curr_noisy_actions.reshape(NUM_ACTIONS_CHUNK, ACTION_DIM)
|
| 893 |
+
|
| 894 |
+
# Return final actions
|
| 895 |
+
return curr_noisy_actions.float().cpu().detach().numpy(), actions_hidden_states
|
| 896 |
+
|
| 897 |
+
def _regression_or_discrete_prediction(
|
| 898 |
+
self,
|
| 899 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 900 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 901 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 902 |
+
attention_mask: torch.BoolTensor,
|
| 903 |
+
labels: torch.LongTensor,
|
| 904 |
+
NUM_PATCHES: int,
|
| 905 |
+
NUM_PROMPT_TOKENS: int,
|
| 906 |
+
action_head: L1RegressionActionHead,
|
| 907 |
+
**kwargs,
|
| 908 |
+
):
|
| 909 |
+
"""Run L1 regression-based continuous action prediction or discrete action tokens prediction."""
|
| 910 |
+
# Extract hidden states for action tokens
|
| 911 |
+
# last_hidden_states = language_model_output.hidden_states[-1] # (B, seq_len, D)
|
| 912 |
+
|
| 913 |
+
# actions_hidden_states = last_hidden_states[:, NUM_PATCHES + NUM_PROMPT_TOKENS : NUM_PATCHES + NUM_PROMPT_TOKENS + NUM_ACTIONS_CHUNK * tokennum, :]# (B, act_chunk_len, D)
|
| 914 |
+
# 都不需要取了, 直接就给 token对应的hidden state了 ,太方便了.
|
| 915 |
+
# 为什么第一个是torch.Size([1, 535, 4096])? 我应该选哪个? https://discuss.huggingface.co/t/get-each-generated-token-last-layer-hidden-state/145921
|
| 916 |
+
# language_model_output.sequences tensor([[29871, 32001, 32001, 32001, 32001, 32001, 32001, 32001, 32001, 2]], device='cuda:0')
|
| 917 |
+
cfg = kwargs.pop("cfg", None)
|
| 918 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 919 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 920 |
+
)
|
| 921 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 922 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 923 |
+
# is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 924 |
+
hidden_states = language_model_output.hidden_states[0][-1]
|
| 925 |
+
actions_hidden_states = hidden_states[:, -NUM_ACTIONS_CHUNK:]
|
| 926 |
+
|
| 927 |
+
normalized_actions = action_head.predict_action(actions_hidden_states)
|
| 928 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 929 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 930 |
+
if cfg.mode == "mul":
|
| 931 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 932 |
+
token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 933 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 934 |
+
actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 935 |
+
|
| 936 |
+
actions_hidden_states_list = [actions_hidden_states0]
|
| 937 |
+
for i in range(1, token_num):
|
| 938 |
+
token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 939 |
+
actions_hidden_states_list.append(token_hidden_state)
|
| 940 |
+
# 将所有hidden states拼接起来
|
| 941 |
+
combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 942 |
+
actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 943 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 944 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 945 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 946 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 947 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 948 |
+
else:
|
| 949 |
+
raise NotImplementedError
|
| 950 |
+
else:
|
| 951 |
+
raise NotImplementedError
|
| 952 |
+
return normalized_actions, actions_hidden_states
|
| 953 |
+
|
| 954 |
+
def hist_predict_action(
|
| 955 |
+
self,
|
| 956 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 957 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 958 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 959 |
+
attention_mask: torch.BoolTensor,
|
| 960 |
+
action_head: L1RegressionActionHead,
|
| 961 |
+
**kwargs,
|
| 962 |
+
):
|
| 963 |
+
cfg = kwargs.get("cfg", None)
|
| 964 |
+
action_history = kwargs.get("action_history", None)
|
| 965 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 966 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 967 |
+
)
|
| 968 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 969 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 970 |
+
# the following is (num of tokens,)
|
| 971 |
+
if cfg.mode == "mul":
|
| 972 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 973 |
+
raise NotImplementedError
|
| 974 |
+
# token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 975 |
+
# language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 976 |
+
# actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 977 |
+
# actions_hidden_states_list = [actions_hidden_states0]
|
| 978 |
+
# for i in range(1, token_num):
|
| 979 |
+
# token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 980 |
+
# actions_hidden_states_list.append(token_hidden_state)
|
| 981 |
+
# combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 982 |
+
# actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 983 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 984 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 985 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 986 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 987 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 988 |
+
# 在中间加一个 1 维度
|
| 989 |
+
actions_hidden_states = actions_hidden_states.unsqueeze(1) # for match 3 dim
|
| 990 |
+
else:
|
| 991 |
+
raise NotImplementedError
|
| 992 |
+
else:
|
| 993 |
+
raise NotImplementedError
|
| 994 |
+
|
| 995 |
+
normalized_actions = action_head.predict_action(actions_hidden_states, action_history)
|
| 996 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 997 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 998 |
+
|
| 999 |
+
return normalized_actions, actions_hidden_states
|
| 1000 |
+
|
| 1001 |
+
def mul_regression_or_discrete_prediction(
|
| 1002 |
+
self,
|
| 1003 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 1004 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 1005 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 1006 |
+
attention_mask: torch.BoolTensor,
|
| 1007 |
+
labels: torch.LongTensor,
|
| 1008 |
+
NUM_PATCHES: int,
|
| 1009 |
+
NUM_PROMPT_TOKENS: int,
|
| 1010 |
+
action_head: L1RegressionActionHead,
|
| 1011 |
+
**kwargs,
|
| 1012 |
+
):
|
| 1013 |
+
cfg = kwargs.get("cfg", None)
|
| 1014 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1015 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1016 |
+
)
|
| 1017 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1018 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 1019 |
+
# the following is (num of tokens,)
|
| 1020 |
+
if cfg.mode == "mul":
|
| 1021 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 1022 |
+
token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 1023 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 1024 |
+
actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 1025 |
+
|
| 1026 |
+
actions_hidden_states_list = [actions_hidden_states0]
|
| 1027 |
+
for i in range(1, token_num):
|
| 1028 |
+
token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 1029 |
+
actions_hidden_states_list.append(token_hidden_state)
|
| 1030 |
+
combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 1031 |
+
actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 1032 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1033 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 1034 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1035 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 1036 |
+
else:
|
| 1037 |
+
raise NotImplementedError
|
| 1038 |
+
else:
|
| 1039 |
+
raise NotImplementedError
|
| 1040 |
+
|
| 1041 |
+
normalized_actions = action_head.predict_action(actions_hidden_states)
|
| 1042 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 1043 |
+
# print(f"*** normalized_actions[]: {normalized_actions} ***")
|
| 1044 |
+
if cfg.action_head_name == "medusa":
|
| 1045 |
+
normalized_actions[:, 6] = torch.sigmoid(normalized_actions[:, 6]) # without bs dim.
|
| 1046 |
+
# print(f"*** normalized_actions[]: {normalized_actions} ***")
|
| 1047 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 1048 |
+
|
| 1049 |
+
return normalized_actions, actions_hidden_states
|
| 1050 |
+
|
| 1051 |
+
def predict_action(
|
| 1052 |
+
self,
|
| 1053 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1054 |
+
unnorm_key: Optional[str] = None,
|
| 1055 |
+
proprio=None,
|
| 1056 |
+
proprio_projector=None,
|
| 1057 |
+
action_head=None,
|
| 1058 |
+
noisy_action_projector=None,
|
| 1059 |
+
use_film: bool = False,
|
| 1060 |
+
**kwargs: str,
|
| 1061 |
+
) -> np.ndarray:
|
| 1062 |
+
"""Predict actions from input sequence, with options for different prediction methods.
|
| 1063 |
+
|
| 1064 |
+
Args:
|
| 1065 |
+
input_ids: Input token ids
|
| 1066 |
+
unnorm_key: Key for unnormalization statistics
|
| 1067 |
+
proprio: Proprioceptive features
|
| 1068 |
+
proprio_projector: Projector for proprioceptive features
|
| 1069 |
+
action_head: Optional head for L1 regression or diffusion-based prediction
|
| 1070 |
+
noisy_action_projector: Projector for noisy actions in diffusion-based prediction
|
| 1071 |
+
use_film: Whether to use FiLM conditioning
|
| 1072 |
+
**kwargs: Additional arguments including pixel_values and attention_mask
|
| 1073 |
+
|
| 1074 |
+
Returns:
|
| 1075 |
+
Tuple of (unnormalized_actions, action_hidden_states)
|
| 1076 |
+
"""
|
| 1077 |
+
# If the special empty token ('') does not already appear after the colon (':') token in the prompt
|
| 1078 |
+
# (after "OUT:" or "ASSISTANT:"), insert it to match the inputs seen at training time
|
| 1079 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1080 |
+
input_ids = torch.cat(
|
| 1081 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1082 |
+
)
|
| 1083 |
+
|
| 1084 |
+
pixel_values = kwargs["pixel_values"]
|
| 1085 |
+
attention_mask = kwargs["attention_mask"]
|
| 1086 |
+
|
| 1087 |
+
# Create fake labels tensor (needed for action mask)
|
| 1088 |
+
labels = input_ids.clone()
|
| 1089 |
+
labels[:] = IGNORE_INDEX # 输入都ignore IGNORE_INDEX = -100
|
| 1090 |
+
|
| 1091 |
+
# Get number of tokens in prompt (excluding the start token)
|
| 1092 |
+
NUM_PROMPT_TOKENS = input_ids.shape[-1] - 1 # Subtract action tokens and stop token
|
| 1093 |
+
|
| 1094 |
+
# Prepare inputs by adding necessary tokens
|
| 1095 |
+
input_ids, attention_mask = self._prepare_input_for_action_prediction(input_ids, attention_mask)
|
| 1096 |
+
|
| 1097 |
+
# Update labels tensor for action mask computation later
|
| 1098 |
+
labels = self._prepare_labels_for_action_prediction(labels, input_ids)
|
| 1099 |
+
|
| 1100 |
+
# Get input embeddings and action masks
|
| 1101 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1102 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 1103 |
+
|
| 1104 |
+
# Extract language embeddings
|
| 1105 |
+
language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 1106 |
+
input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 1107 |
+
)
|
| 1108 |
+
|
| 1109 |
+
# Process vision features
|
| 1110 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values, language_embeddings, use_film)
|
| 1111 |
+
|
| 1112 |
+
# Add proprioceptive features if provided
|
| 1113 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1114 |
+
if use_proprio:
|
| 1115 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1116 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1117 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1118 |
+
)
|
| 1119 |
+
|
| 1120 |
+
# Use diffusion if provided, otherwise use regression or discrete prediction
|
| 1121 |
+
use_diffusion = noisy_action_projector is not None and hasattr(action_head, "noise_scheduler")
|
| 1122 |
+
|
| 1123 |
+
# Calculate number of patches (including proprio token and/or diffusion timestep embedding if present)
|
| 1124 |
+
NUM_PATCHES = self.vision_backbone.get_num_patches() * self.vision_backbone.get_num_images_in_input()
|
| 1125 |
+
if use_proprio:
|
| 1126 |
+
NUM_PATCHES += 1
|
| 1127 |
+
|
| 1128 |
+
normalized_actions, actions_hidden_states = self._regression_or_discrete_prediction(
|
| 1129 |
+
input_embeddings,
|
| 1130 |
+
all_actions_mask,
|
| 1131 |
+
projected_patch_embeddings,
|
| 1132 |
+
attention_mask,
|
| 1133 |
+
labels,
|
| 1134 |
+
NUM_PATCHES,
|
| 1135 |
+
NUM_PROMPT_TOKENS,
|
| 1136 |
+
action_head,
|
| 1137 |
+
)
|
| 1138 |
+
|
| 1139 |
+
# Unnormalize predicted actions
|
| 1140 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1141 |
+
|
| 1142 |
+
return actions, actions_hidden_states
|
| 1143 |
+
|
| 1144 |
+
@staticmethod
|
| 1145 |
+
def _check_unnorm_key(norm_stats: Dict[str, Dict[str, Any]], unnorm_key: Optional[str]) -> str:
|
| 1146 |
+
"""Validate and resolve the unnormalization key for action statistics"""
|
| 1147 |
+
if unnorm_key is None:
|
| 1148 |
+
assert len(norm_stats) == 1, (
|
| 1149 |
+
f"Your model was trained on more than one dataset, "
|
| 1150 |
+
f"please pass a `unnorm_key` from the following options to choose the statistics "
|
| 1151 |
+
f"used for un-normalizing actions: {norm_stats.keys()}"
|
| 1152 |
+
)
|
| 1153 |
+
unnorm_key = next(iter(norm_stats.keys()))
|
| 1154 |
+
# norm states没有加载libero, 为什么?
|
| 1155 |
+
assert unnorm_key in norm_stats, (
|
| 1156 |
+
f"The `unnorm_key` you chose is not in the set of available dataset statistics, "
|
| 1157 |
+
f"please choose from: {norm_stats.keys()}"
|
| 1158 |
+
)
|
| 1159 |
+
return unnorm_key
|
| 1160 |
+
|
| 1161 |
+
def get_action_dim(self, unnorm_key: Optional[str] = None) -> int:
|
| 1162 |
+
"""Get the dimensionality of the policy's action space."""
|
| 1163 |
+
unnorm_key = self._check_unnorm_key(self.norm_stats, unnorm_key)
|
| 1164 |
+
return len(self.norm_stats[unnorm_key]["action"]["min"])
|
| 1165 |
+
|
| 1166 |
+
def get_action_stats(self, unnorm_key: Optional[str] = None) -> Dict[str, Any]:
|
| 1167 |
+
"""Get all the logged statistics for the given dataset."""
|
| 1168 |
+
unnorm_key = self._check_unnorm_key(self.norm_stats, unnorm_key)
|
| 1169 |
+
return self.norm_stats[unnorm_key]["action"]
|
| 1170 |
+
|
| 1171 |
+
|
| 1172 |
+
def lisa_forward(
|
| 1173 |
+
self,
|
| 1174 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1175 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1176 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 1177 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1178 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1179 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1180 |
+
use_cache: Optional[bool] = None,
|
| 1181 |
+
output_attentions: Optional[bool] = None,
|
| 1182 |
+
output_hidden_states: Optional[bool] = None,
|
| 1183 |
+
output_projector_features: Optional[bool] = None,
|
| 1184 |
+
return_dict: Optional[bool] = None,
|
| 1185 |
+
proprio=None,
|
| 1186 |
+
proprio_projector=None,
|
| 1187 |
+
**kwargs
|
| 1188 |
+
) -> Union[Tuple, PrismaticCausalLMOutputWithPast]:
|
| 1189 |
+
"""Run a forward pass through the VLM, returning a PrismaticCausalLMOutputWithPast instance."""
|
| 1190 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1191 |
+
output_hidden_states = (
|
| 1192 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1193 |
+
)
|
| 1194 |
+
output_projector_features = output_projector_features if output_projector_features is not None else False
|
| 1195 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1196 |
+
|
| 1197 |
+
# Respect `use_cache` only if not training (even if `gradient_checkpointing` is off)
|
| 1198 |
+
use_cache = use_cache and not self.training
|
| 1199 |
+
|
| 1200 |
+
# Instantiate Placeholder for Projector Features
|
| 1201 |
+
projected_patch_embeddings = None
|
| 1202 |
+
|
| 1203 |
+
# === Handle Generation with Cache (`input_ids.shape[1] == 1`) =>> requires `past_keys_values` ===
|
| 1204 |
+
if input_ids.shape[1] == 1:
|
| 1205 |
+
assert input_ids.shape[0] == 1, "Generation is only currently supported for batch size of 1!"
|
| 1206 |
+
assert past_key_values is not None, "You must provide `past_key_values` during cached generation!"
|
| 1207 |
+
assert labels is None, "Unexpected key `labels` provided during cached generation!"
|
| 1208 |
+
|
| 1209 |
+
language_model_output = self.language_model(
|
| 1210 |
+
input_ids=input_ids,
|
| 1211 |
+
attention_mask=None,
|
| 1212 |
+
position_ids=None,
|
| 1213 |
+
past_key_values=past_key_values,
|
| 1214 |
+
inputs_embeds=None,
|
| 1215 |
+
labels=None,
|
| 1216 |
+
use_cache=use_cache,
|
| 1217 |
+
output_attentions=output_attentions,
|
| 1218 |
+
output_hidden_states=output_hidden_states,
|
| 1219 |
+
return_dict=return_dict,
|
| 1220 |
+
)
|
| 1221 |
+
|
| 1222 |
+
# === Handle Unimodal Forward ===
|
| 1223 |
+
elif pixel_values is None:
|
| 1224 |
+
raise NotImplementedError
|
| 1225 |
+
|
| 1226 |
+
# === Handle Multimodal Forward ===
|
| 1227 |
+
elif (input_ids.shape[0] == pixel_values.shape[0]) or (inputs_embeds.shape[0] == pixel_values.shape[0]):
|
| 1228 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during multimodal forward!"
|
| 1229 |
+
|
| 1230 |
+
# Get input embeddings (from language model embeddings)
|
| 1231 |
+
input_embeddings = self.get_input_embeddings()(input_ids) # (B, seq_len, D)
|
| 1232 |
+
# Extract the language portion of the input embeddings (i.e. remove the action tokens portion)
|
| 1233 |
+
# language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 1234 |
+
# input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 1235 |
+
# ) # (B, lang_seq_len, llm_dim) 这里就会把结尾的 stop index和padding 也算进去. 没问题吗? 没问题因为ignore了 我直接删了因为不用film
|
| 1236 |
+
# Get visual features
|
| 1237 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1238 |
+
|
| 1239 |
+
# Add proprioceptive state if provided
|
| 1240 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1241 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1242 |
+
)
|
| 1243 |
+
|
| 1244 |
+
all_actions_mask = (labels == ACTION_TOKEN_IDX) #和run forward pass不一样, run forward pass要手动算token number来找偏移.
|
| 1245 |
+
all_actions_mask = all_actions_mask.unsqueeze(-1) # (B, seq_len, 1)
|
| 1246 |
+
input_embeddings = input_embeddings * ~all_actions_mask
|
| 1247 |
+
|
| 1248 |
+
# Build multimodal embeddings & attention mask
|
| 1249 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1250 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1251 |
+
)
|
| 1252 |
+
|
| 1253 |
+
# Build labels for multimodal sequence if needed
|
| 1254 |
+
multimodal_labels = self._build_multimodal_labels(labels, projected_patch_embeddings)
|
| 1255 |
+
|
| 1256 |
+
# Dispatch to language model
|
| 1257 |
+
language_model_output = self.language_model(
|
| 1258 |
+
input_ids=None,
|
| 1259 |
+
attention_mask=multimodal_attention_mask,
|
| 1260 |
+
position_ids=None,
|
| 1261 |
+
past_key_values=None,
|
| 1262 |
+
inputs_embeds=multimodal_embeddings,
|
| 1263 |
+
labels=multimodal_labels,
|
| 1264 |
+
use_cache=use_cache,
|
| 1265 |
+
output_attentions=output_attentions,
|
| 1266 |
+
output_hidden_states=output_hidden_states,
|
| 1267 |
+
return_dict=return_dict,
|
| 1268 |
+
)
|
| 1269 |
+
|
| 1270 |
+
|
| 1271 |
+
# === Otherwise =>> Assume Invalid! ===
|
| 1272 |
+
elif (input_ids.shape[0] != pixel_values.shape[0]) or (inputs_embeds.shape[0] != pixel_values.shape[0]):
|
| 1273 |
+
raise ValueError("Non-homogenous batch of (text, image) input -- forward() does not support mixed batches!")
|
| 1274 |
+
|
| 1275 |
+
else:
|
| 1276 |
+
raise ValueError(
|
| 1277 |
+
"Invalid PrismaticForConditionalGeneration `forward()` call with provided arguments:\n"
|
| 1278 |
+
f"=> `input_ids` = {input_ids is not None}\n"
|
| 1279 |
+
f"=> `attention_mask` = {attention_mask is not None}\n"
|
| 1280 |
+
f"=> `pixel_values` = {pixel_values is not None}\n"
|
| 1281 |
+
f"=> `labels` = {labels is not None}\n"
|
| 1282 |
+
f"=> `input_embeds` = {inputs_embeds is not None}\n"
|
| 1283 |
+
f"=> `past_key_values` = {past_key_values is not None}\n"
|
| 1284 |
+
f"=> `use_cache` = {use_cache}"
|
| 1285 |
+
)
|
| 1286 |
+
|
| 1287 |
+
# Unpack `language_model_output` and return PrismaticCausalLMOutputWithPast (or tuple if not `return_dict`)
|
| 1288 |
+
if not return_dict:
|
| 1289 |
+
if output_projector_features and (projected_patch_embeddings is not None):
|
| 1290 |
+
return *language_model_output, projected_patch_embeddings
|
| 1291 |
+
|
| 1292 |
+
return language_model_output
|
| 1293 |
+
|
| 1294 |
+
return PrismaticCausalLMOutputWithPast(
|
| 1295 |
+
loss=language_model_output.loss,
|
| 1296 |
+
logits=language_model_output.logits,
|
| 1297 |
+
past_key_values=language_model_output.past_key_values,
|
| 1298 |
+
hidden_states=language_model_output.hidden_states,
|
| 1299 |
+
attentions=language_model_output.attentions,
|
| 1300 |
+
projector_features=projected_patch_embeddings,
|
| 1301 |
+
)
|
| 1302 |
+
|
| 1303 |
+
|
| 1304 |
+
|
| 1305 |
+
def mul_predict_action(
|
| 1306 |
+
self,
|
| 1307 |
+
input_ids: Optional[torch.LongTensor] = None, #就是 language instruction.
|
| 1308 |
+
unnorm_key: Optional[str] = None,
|
| 1309 |
+
proprio=None,
|
| 1310 |
+
proprio_projector=None,
|
| 1311 |
+
action_head:L1RegressionActionHead=None,
|
| 1312 |
+
noisy_action_projector=None,
|
| 1313 |
+
use_film: bool = False,
|
| 1314 |
+
**kwargs: str,
|
| 1315 |
+
) -> np.ndarray:
|
| 1316 |
+
# only use in evaluation.
|
| 1317 |
+
cfg = kwargs.get("cfg", None) # Extract cfg from kwargs
|
| 1318 |
+
action_history = kwargs.get("action_history", None)
|
| 1319 |
+
|
| 1320 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1321 |
+
input_ids = torch.cat(
|
| 1322 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1323 |
+
)
|
| 1324 |
+
|
| 1325 |
+
|
| 1326 |
+
pixel_values = kwargs["pixel_values"]
|
| 1327 |
+
attention_mask = kwargs["attention_mask"]
|
| 1328 |
+
|
| 1329 |
+
# input id '<s> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1330 |
+
|
| 1331 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1332 |
+
|
| 1333 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1334 |
+
|
| 1335 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1336 |
+
if use_proprio:
|
| 1337 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1338 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1339 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1340 |
+
)
|
| 1341 |
+
if cfg.action_head_name == "hist":
|
| 1342 |
+
normalized_actions, actions_hidden_states = self.hist_predict_action(
|
| 1343 |
+
input_embeddings,
|
| 1344 |
+
None,
|
| 1345 |
+
projected_patch_embeddings,
|
| 1346 |
+
attention_mask,
|
| 1347 |
+
action_head,
|
| 1348 |
+
cfg=cfg,
|
| 1349 |
+
action_history=action_history,
|
| 1350 |
+
)
|
| 1351 |
+
else:
|
| 1352 |
+
normalized_actions, actions_hidden_states = self.mul_regression_or_discrete_prediction(
|
| 1353 |
+
input_embeddings,
|
| 1354 |
+
None,
|
| 1355 |
+
projected_patch_embeddings,
|
| 1356 |
+
attention_mask,
|
| 1357 |
+
None, #推理不需要labels
|
| 1358 |
+
None, #推理不需要NUM_PATCHES
|
| 1359 |
+
None, #推理不需要NUM_PROMPT_TOKENS
|
| 1360 |
+
action_head,
|
| 1361 |
+
cfg=cfg,
|
| 1362 |
+
)
|
| 1363 |
+
|
| 1364 |
+
|
| 1365 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key) #在这里 unorm, 所以出来的已经是unorm的了. 所以我 history 也要记录 norm 的.
|
| 1366 |
+
|
| 1367 |
+
return actions, normalized_actions
|
| 1368 |
+
|
| 1369 |
+
|
| 1370 |
+
def flow_matching_predict_action(
|
| 1371 |
+
self,
|
| 1372 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1373 |
+
unnorm_key: Optional[str] = None,
|
| 1374 |
+
proprio=None,
|
| 1375 |
+
proprio_projector=None,
|
| 1376 |
+
action_head: FlowMatchingActionHead = None,
|
| 1377 |
+
noisy_action_projector=None,
|
| 1378 |
+
use_film: bool = False,
|
| 1379 |
+
**kwargs: str,
|
| 1380 |
+
) -> np.ndarray:
|
| 1381 |
+
"""Predict actions using Flow Matching"""
|
| 1382 |
+
cfg = kwargs.get("cfg", None)
|
| 1383 |
+
|
| 1384 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1385 |
+
input_ids = torch.cat(
|
| 1386 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1387 |
+
)
|
| 1388 |
+
|
| 1389 |
+
pixel_values = kwargs["pixel_values"]
|
| 1390 |
+
attention_mask = kwargs["attention_mask"]
|
| 1391 |
+
|
| 1392 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1393 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1394 |
+
|
| 1395 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1396 |
+
if use_proprio:
|
| 1397 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1398 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1399 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1400 |
+
)
|
| 1401 |
+
|
| 1402 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1403 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1404 |
+
)
|
| 1405 |
+
|
| 1406 |
+
if cfg.mode == "flow_matching":
|
| 1407 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1408 |
+
language_model_output = self.language_model.generate(
|
| 1409 |
+
inputs_embeds=multimodal_embeddings,
|
| 1410 |
+
max_new_tokens=1,
|
| 1411 |
+
output_hidden_states=True,
|
| 1412 |
+
return_dict_in_generate=True
|
| 1413 |
+
)
|
| 1414 |
+
|
| 1415 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1416 |
+
cognition_features = actions_hidden_states[:, -1]
|
| 1417 |
+
assert (cognition_features.shape[0], cognition_features.shape[1]) == (1, 4096), "Batch size must be 1 for action prediction"
|
| 1418 |
+
|
| 1419 |
+
model_dtype = next(action_head.net.parameters()).dtype
|
| 1420 |
+
cognition_features = cognition_features.unsqueeze(1).to(model_dtype)
|
| 1421 |
+
|
| 1422 |
+
# Sample actions using flow matching
|
| 1423 |
+
normalized_actions = action_head.sample_actions(
|
| 1424 |
+
cognition_features,
|
| 1425 |
+
num_steps=getattr(cfg, 'num_flow_steps', 20)
|
| 1426 |
+
)
|
| 1427 |
+
normalized_actions = normalized_actions[0].cpu().numpy()
|
| 1428 |
+
else:
|
| 1429 |
+
raise NotImplementedError("Multi-token flow matching not yet implemented")
|
| 1430 |
+
else:
|
| 1431 |
+
raise NotImplementedError
|
| 1432 |
+
|
| 1433 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1434 |
+
return actions, actions_hidden_states
|
| 1435 |
+
|
| 1436 |
+
def diffusion_predict_action(
|
| 1437 |
+
self,
|
| 1438 |
+
input_ids: Optional[torch.LongTensor] = None, #就是 language instruction.
|
| 1439 |
+
unnorm_key: Optional[str] = None,
|
| 1440 |
+
proprio=None,
|
| 1441 |
+
proprio_projector=None,
|
| 1442 |
+
action_head:DiTActionHead=None,
|
| 1443 |
+
noisy_action_projector=None,
|
| 1444 |
+
use_film: bool = False,
|
| 1445 |
+
**kwargs: str,
|
| 1446 |
+
) -> np.ndarray:
|
| 1447 |
+
cfg = kwargs.get("cfg", None) # Extract cfg from kwargs
|
| 1448 |
+
|
| 1449 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1450 |
+
input_ids = torch.cat(
|
| 1451 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1452 |
+
)
|
| 1453 |
+
|
| 1454 |
+
|
| 1455 |
+
pixel_values = kwargs["pixel_values"]
|
| 1456 |
+
attention_mask = kwargs["attention_mask"]
|
| 1457 |
+
|
| 1458 |
+
# input id '<s> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1459 |
+
|
| 1460 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1461 |
+
|
| 1462 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1463 |
+
|
| 1464 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1465 |
+
if use_proprio:
|
| 1466 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1467 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1468 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1469 |
+
)
|
| 1470 |
+
|
| 1471 |
+
# normalized_actions, actions_hidden_states = self.mul_regression_or_discrete_prediction(
|
| 1472 |
+
# input_embeddings,
|
| 1473 |
+
# None,
|
| 1474 |
+
# projected_patch_embeddings,
|
| 1475 |
+
# attention_mask,
|
| 1476 |
+
# None, #推理不需要labels
|
| 1477 |
+
# None, #推理不需要NUM_PATCHES
|
| 1478 |
+
# None, #推理不需要NUM_PROMPT_TOKENS
|
| 1479 |
+
# action_head,
|
| 1480 |
+
# cfg=cfg,
|
| 1481 |
+
# )
|
| 1482 |
+
|
| 1483 |
+
# cfg = kwargs.get("cfg", None)
|
| 1484 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1485 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1486 |
+
)
|
| 1487 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1488 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 1489 |
+
# the following is (num of tokens,)
|
| 1490 |
+
|
| 1491 |
+
if cfg.mode == "dit":
|
| 1492 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 1493 |
+
# token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 1494 |
+
# language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 1495 |
+
# actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 1496 |
+
|
| 1497 |
+
# actions_hidden_states_list = [actions_hidden_states0]
|
| 1498 |
+
# for i in range(1, token_num):
|
| 1499 |
+
# token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 1500 |
+
# actions_hidden_states_list.append(token_hidden_state)
|
| 1501 |
+
# combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 1502 |
+
# actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 1503 |
+
raise NotImplementedError
|
| 1504 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1505 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 1506 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 1507 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1508 |
+
cognition_features = actions_hidden_states[:, -1]
|
| 1509 |
+
assert (cognition_features.shape[0], cognition_features.shape[1]) == (1,4096), "Batch size must be 1 for action prediction"
|
| 1510 |
+
using_cfg = cfg.cfg_scale > 1.0
|
| 1511 |
+
|
| 1512 |
+
model_dtype = next(action_head.net.parameters()).dtype
|
| 1513 |
+
B = cognition_features.shape[0]
|
| 1514 |
+
|
| 1515 |
+
cognition_features = cognition_features.unsqueeze(1).to(model_dtype)
|
| 1516 |
+
|
| 1517 |
+
noise = torch.randn(B, cfg.num_actions_chunk, action_head.net.in_channels, device=cognition_features.device).to(model_dtype)
|
| 1518 |
+
|
| 1519 |
+
# TODO: Setup classifier-free guidance: now use cfg
|
| 1520 |
+
noise = torch.cat([noise, noise], 0) # noise.shape torch.Size([2, 16, 7])
|
| 1521 |
+
uncondition = action_head.net.z_embedder.uncondition # torch.Size([1, 4096])
|
| 1522 |
+
uncondition = uncondition.unsqueeze(0) #[1, D] # torch.Size([1, 1, 4096])
|
| 1523 |
+
uncondition = uncondition.expand(B, 1, -1) #[B, 1, D]
|
| 1524 |
+
z = torch.cat([cognition_features, uncondition], 0) # z shape torch.Size([2, 1, 4096])
|
| 1525 |
+
model_kwargs = dict(z=z, cfg_scale=cfg.cfg_scale)
|
| 1526 |
+
sample_fn = action_head.net.forward_with_cfg
|
| 1527 |
+
# default use ddim
|
| 1528 |
+
if action_head.ddim_diffusion is None:
|
| 1529 |
+
action_head.create_ddim(ddim_step=cfg.num_ddim_steps)
|
| 1530 |
+
samples = action_head.ddim_diffusion.ddim_sample_loop(sample_fn,
|
| 1531 |
+
noise.shape,
|
| 1532 |
+
noise,
|
| 1533 |
+
clip_denoised=False,
|
| 1534 |
+
model_kwargs=model_kwargs,
|
| 1535 |
+
progress=False,
|
| 1536 |
+
device=cognition_features.device,
|
| 1537 |
+
eta=0.0
|
| 1538 |
+
)
|
| 1539 |
+
if using_cfg:
|
| 1540 |
+
samples, _ = samples.chunk(2, dim=0) # Remove null class samples
|
| 1541 |
+
normalized_actions = samples[0].cpu().numpy()
|
| 1542 |
+
else:
|
| 1543 |
+
raise NotImplementedError
|
| 1544 |
+
else:
|
| 1545 |
+
raise NotImplementedError
|
| 1546 |
+
|
| 1547 |
+
|
| 1548 |
+
|
| 1549 |
+
# normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 1550 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1551 |
+
|
| 1552 |
+
return actions, actions_hidden_states
|
modeling_prismatic.py.back.20250921_183706
ADDED
|
@@ -0,0 +1,1553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
modeling_prismatic.py
|
| 3 |
+
|
| 4 |
+
Core HuggingFace-style PrismaticPreTrainedModel and PrismaticForConditionalGeneration class definitions.
|
| 5 |
+
Inherits from the default `transformers.PretrainedModel`. Meant to be standalone and self-contained,
|
| 6 |
+
but exactly replicate the logic in `prismatic.models.vlms.prismatic.py`.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import logging
|
| 10 |
+
from dataclasses import dataclass
|
| 11 |
+
from functools import partial
|
| 12 |
+
from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple, Union
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
import timm
|
| 16 |
+
import tokenizers
|
| 17 |
+
import torch
|
| 18 |
+
import torch.nn as nn
|
| 19 |
+
import transformers
|
| 20 |
+
from timm.models.vision_transformer import LayerScale
|
| 21 |
+
from transformers import AutoModelForCausalLM, PretrainedConfig, PreTrainedModel
|
| 22 |
+
from transformers.modeling_outputs import ModelOutput
|
| 23 |
+
from prismatic.models.action_heads import L1RegressionActionHead, DiTActionHead, FlowMatchingActionHead
|
| 24 |
+
from prismatic.training.train_utils import (
|
| 25 |
+
get_current_action_mask,
|
| 26 |
+
get_next_actions_mask,
|
| 27 |
+
)
|
| 28 |
+
from prismatic.vla.constants import (
|
| 29 |
+
ACTION_DIM,
|
| 30 |
+
ACTION_PROPRIO_NORMALIZATION_TYPE,
|
| 31 |
+
IGNORE_INDEX,
|
| 32 |
+
NUM_ACTIONS_CHUNK,
|
| 33 |
+
ACTION_TOKEN_IDX,
|
| 34 |
+
NormalizationType,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
from .configuration_prismatic import OpenVLAConfig, PrismaticConfig
|
| 38 |
+
|
| 39 |
+
# Set up logger
|
| 40 |
+
logger = logging.getLogger(__name__)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# === Utility Functions for Monkey-Patching ===
|
| 44 |
+
def unpack_tuple(fn: Callable[[Any], Tuple[Any]]) -> Callable[[Any], Any]:
|
| 45 |
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
| 46 |
+
result = fn(*args, **kwargs)
|
| 47 |
+
return result[0] if isinstance(result, tuple) else result
|
| 48 |
+
|
| 49 |
+
return wrapper
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
# HF Transformers overwrites parameters with names containing `gamma`; we're going to patch VisionBackbone.LayerScale.
|
| 53 |
+
# =>> TIMM :: https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/vision_transformer.py#L109
|
| 54 |
+
# =>> Transformers :: https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3960
|
| 55 |
+
def _ls_new_forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 56 |
+
return x.mul_(self.scale_factor) if self.inplace else x * self.scale_factor
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def ls_apply_patch(ls_module: LayerScale):
|
| 60 |
+
ls_module.scale_factor = nn.Parameter(ls_module.gamma.clone())
|
| 61 |
+
ls_module.forward = _ls_new_forward.__get__(ls_module, LayerScale)
|
| 62 |
+
del ls_module.gamma
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# === Prismatic Vision Backbone (nn.Module) Definitions (w/ Fused Backbone Support) ===
|
| 66 |
+
class PrismaticVisionBackbone(nn.Module):
|
| 67 |
+
"""
|
| 68 |
+
Vision backbone for Prismatic models that handles image feature extraction.
|
| 69 |
+
|
| 70 |
+
Supports both single backbone (e.g., SigLIP) and fused backbone (e.g., SigLIP + DINOv2) configurations.
|
| 71 |
+
For fused backbones, features from both models are concatenated along the feature dimension.
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
def __init__(
|
| 75 |
+
self,
|
| 76 |
+
use_fused_vision_backbone: bool,
|
| 77 |
+
image_sizes: List[int],
|
| 78 |
+
timm_model_ids: List[str],
|
| 79 |
+
timm_override_act_layers: List[Optional[str]],
|
| 80 |
+
) -> None:
|
| 81 |
+
"""
|
| 82 |
+
Initialize the vision backbone.
|
| 83 |
+
|
| 84 |
+
Args:
|
| 85 |
+
use_fused_vision_backbone: Whether to use two backbones and fuse their features
|
| 86 |
+
image_sizes: List of image sizes for each backbone
|
| 87 |
+
timm_model_ids: List of TIMM model IDs to use for each backbone
|
| 88 |
+
timm_override_act_layers: List of activation layer overrides for each backbone
|
| 89 |
+
"""
|
| 90 |
+
super().__init__()
|
| 91 |
+
self.use_fused_vision_backbone = use_fused_vision_backbone
|
| 92 |
+
self.num_images_in_input = 1 # Default value, can be overridden later
|
| 93 |
+
|
| 94 |
+
# Validate number of (fused) vision backbones
|
| 95 |
+
if len(timm_model_ids) > 2:
|
| 96 |
+
raise ValueError("Prismatic models only support up to 2 (fused) vision backbones!")
|
| 97 |
+
|
| 98 |
+
# Create primary featurizer
|
| 99 |
+
self.featurizer = self._create_featurizer(
|
| 100 |
+
model_id=timm_model_ids[0], img_size=image_sizes[0], act_layer=timm_override_act_layers[0]
|
| 101 |
+
)
|
| 102 |
+
self.embed_dim = self.featurizer.embed_dim
|
| 103 |
+
|
| 104 |
+
# Create secondary featurizer if using fused backbone
|
| 105 |
+
if self.use_fused_vision_backbone:
|
| 106 |
+
self.fused_featurizer = self._create_featurizer(
|
| 107 |
+
model_id=timm_model_ids[1], img_size=image_sizes[1], act_layer=timm_override_act_layers[1]
|
| 108 |
+
)
|
| 109 |
+
self.embed_dim += self.fused_featurizer.embed_dim
|
| 110 |
+
|
| 111 |
+
# Patch LayerScale modules for HF compatibility
|
| 112 |
+
self._patch_layer_scales()
|
| 113 |
+
|
| 114 |
+
def _create_featurizer(self, model_id: str, img_size: int, act_layer: Optional[str]) -> nn.Module:
|
| 115 |
+
"""
|
| 116 |
+
Create a TIMM-based featurizer model with appropriate configurations.
|
| 117 |
+
|
| 118 |
+
Args:
|
| 119 |
+
model_id: The TIMM model ID to load
|
| 120 |
+
img_size: Input image size for the model
|
| 121 |
+
act_layer: Override for the activation layer type
|
| 122 |
+
|
| 123 |
+
Returns:
|
| 124 |
+
A configured featurizer model
|
| 125 |
+
"""
|
| 126 |
+
featurizer = timm.create_model(
|
| 127 |
+
model_id,
|
| 128 |
+
pretrained=False,
|
| 129 |
+
num_classes=0,
|
| 130 |
+
img_size=img_size,
|
| 131 |
+
act_layer=act_layer,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# Monkey-patch the forward function to extract the second-to-last layer features
|
| 135 |
+
num_blocks = len(featurizer.blocks)
|
| 136 |
+
featurizer.forward = unpack_tuple(partial(featurizer.get_intermediate_layers, n={num_blocks - 2}))
|
| 137 |
+
|
| 138 |
+
return featurizer
|
| 139 |
+
|
| 140 |
+
def _patch_layer_scales(self) -> None:
|
| 141 |
+
"""
|
| 142 |
+
Patch all LayerScale modules to be compatible with HF's parameter naming.
|
| 143 |
+
|
| 144 |
+
HF Transformers overwrites parameters with names containing 'gamma',
|
| 145 |
+
so we need to rename and modify the forward method.
|
| 146 |
+
"""
|
| 147 |
+
# Patch primary featurizer
|
| 148 |
+
for module in self.featurizer.modules():
|
| 149 |
+
if isinstance(module, LayerScale):
|
| 150 |
+
ls_apply_patch(module)
|
| 151 |
+
|
| 152 |
+
# Patch secondary featurizer if it exists
|
| 153 |
+
if self.use_fused_vision_backbone:
|
| 154 |
+
for module in self.fused_featurizer.modules():
|
| 155 |
+
if isinstance(module, LayerScale):
|
| 156 |
+
ls_apply_patch(module)
|
| 157 |
+
|
| 158 |
+
def get_num_patches(self) -> int:
|
| 159 |
+
"""
|
| 160 |
+
Returns the number of vision patches output by the vision backbone.
|
| 161 |
+
|
| 162 |
+
Returns:
|
| 163 |
+
Number of patches per image
|
| 164 |
+
"""
|
| 165 |
+
return self.featurizer.patch_embed.num_patches
|
| 166 |
+
|
| 167 |
+
def get_num_images_in_input(self) -> int:
|
| 168 |
+
"""
|
| 169 |
+
Returns the number of input images for the vision backbone.
|
| 170 |
+
|
| 171 |
+
Returns:
|
| 172 |
+
Number of images expected in the input
|
| 173 |
+
"""
|
| 174 |
+
return self.num_images_in_input
|
| 175 |
+
|
| 176 |
+
def set_num_images_in_input(self, num_images_in_input: int) -> None:
|
| 177 |
+
"""
|
| 178 |
+
Sets the number of input images for the vision backbone.
|
| 179 |
+
|
| 180 |
+
Args:
|
| 181 |
+
num_images_in_input: Number of images to expect in the input
|
| 182 |
+
"""
|
| 183 |
+
self.num_images_in_input = num_images_in_input
|
| 184 |
+
|
| 185 |
+
def forward(self, pixel_values: torch.Tensor) -> torch.Tensor:
|
| 186 |
+
"""
|
| 187 |
+
Implements the forward pass for the vision backbone.
|
| 188 |
+
|
| 189 |
+
If `self.use_fused_vision_backbone == True`, uses both SigLIP and DINOv2 transformers to extract visual features
|
| 190 |
+
(otherwise uses SigLIP only). Allows multi-image inputs (but only for fused vision backbone).
|
| 191 |
+
|
| 192 |
+
Args:
|
| 193 |
+
pixel_values (torch.Tensor): Pixels for input image(s), (B, C, H, W).
|
| 194 |
+
"""
|
| 195 |
+
if self.num_images_in_input == 1:
|
| 196 |
+
if not self.use_fused_vision_backbone:
|
| 197 |
+
return self.featurizer(pixel_values)
|
| 198 |
+
|
| 199 |
+
# Split `pixel_values :: [bsz, 2 * 3, resolution, resolution]` =>> featurize =>> channel stack
|
| 200 |
+
img, img_fused = torch.split(pixel_values, [3, 3], dim=1)
|
| 201 |
+
patches, patches_fused = self.featurizer(img), self.fused_featurizer(img_fused)
|
| 202 |
+
|
| 203 |
+
return torch.cat([patches, patches_fused], dim=2)
|
| 204 |
+
|
| 205 |
+
else:
|
| 206 |
+
assert self.use_fused_vision_backbone, "Multi-image inputs require using fused backbone!"
|
| 207 |
+
|
| 208 |
+
# Split `pixel_values` into individual images (each with 6 channels: 3 for SigLIP + 3 for DINOv2)
|
| 209 |
+
images = torch.split(pixel_values, [6] * self.num_images_in_input, dim=1)
|
| 210 |
+
|
| 211 |
+
# Process each image and collect patches
|
| 212 |
+
all_patches = []
|
| 213 |
+
for img in images:
|
| 214 |
+
# Split each image further into two stacks of channels (each with 3 channels)
|
| 215 |
+
img_regular, img_fused = torch.split(img, [3, 3], dim=1)
|
| 216 |
+
|
| 217 |
+
# Get patches from both SigLIP and DINOv2 vision transformers
|
| 218 |
+
patches = self.featurizer(img_regular)
|
| 219 |
+
patches_fused = self.fused_featurizer(img_fused)
|
| 220 |
+
|
| 221 |
+
# Concatenate SigLIP and DINOv2 patches along the hidden dimension
|
| 222 |
+
combined_patches = torch.cat([patches, patches_fused], dim=2)
|
| 223 |
+
all_patches.append(combined_patches)
|
| 224 |
+
|
| 225 |
+
# Concatenate all patches along the patch dimension
|
| 226 |
+
return torch.cat(all_patches, dim=1)
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
# === Prismatic Projector (nn.Module) Definitions ===
|
| 230 |
+
class PrismaticProjector(nn.Module):
|
| 231 |
+
def __init__(self, use_fused_vision_backbone: bool, vision_dim: int, llm_dim: int) -> None:
|
| 232 |
+
super().__init__()
|
| 233 |
+
self.use_fused_vision_backbone = use_fused_vision_backbone
|
| 234 |
+
self.vision_dim, self.llm_dim = vision_dim, llm_dim
|
| 235 |
+
|
| 236 |
+
# Switch on `use_fused_vision_backbone` =>> use slightly different MLPs and projection factors!
|
| 237 |
+
if not self.use_fused_vision_backbone:
|
| 238 |
+
self.fc1 = nn.Linear(self.vision_dim, self.llm_dim, bias=True)
|
| 239 |
+
self.fc2 = nn.Linear(self.llm_dim, self.llm_dim, bias=True)
|
| 240 |
+
self.act_fn1 = nn.GELU()
|
| 241 |
+
else:
|
| 242 |
+
initial_projection_dim = 4 * vision_dim
|
| 243 |
+
self.fc1 = nn.Linear(self.vision_dim, initial_projection_dim, bias=True)
|
| 244 |
+
self.fc2 = nn.Linear(initial_projection_dim, self.llm_dim, bias=True)
|
| 245 |
+
self.fc3 = nn.Linear(self.llm_dim, self.llm_dim, bias=True)
|
| 246 |
+
self.act_fn1 = nn.GELU()
|
| 247 |
+
self.act_fn2 = nn.GELU()
|
| 248 |
+
|
| 249 |
+
def forward(self, img_patches: torch.Tensor) -> torch.Tensor:
|
| 250 |
+
if not self.use_fused_vision_backbone:
|
| 251 |
+
projected_features = self.fc1(img_patches)
|
| 252 |
+
projected_features = self.act_fn1(projected_features)
|
| 253 |
+
projected_features = self.fc2(projected_features)
|
| 254 |
+
else:
|
| 255 |
+
projected_features = self.fc1(img_patches)
|
| 256 |
+
projected_features = self.act_fn1(projected_features)
|
| 257 |
+
projected_features = self.fc2(projected_features)
|
| 258 |
+
projected_features = self.act_fn2(projected_features)
|
| 259 |
+
projected_features = self.fc3(projected_features)
|
| 260 |
+
|
| 261 |
+
return projected_features
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
# === Main HF Class Definitions ===
|
| 265 |
+
@dataclass
|
| 266 |
+
class PrismaticCausalLMOutputWithPast(ModelOutput):
|
| 267 |
+
"""Base class for Prismatic casual (visually-conditioned) language model outputs; also exposes visual features."""
|
| 268 |
+
|
| 269 |
+
loss: Optional[torch.FloatTensor] = None
|
| 270 |
+
logits: torch.FloatTensor = None
|
| 271 |
+
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None
|
| 272 |
+
hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
| 273 |
+
attentions: Optional[Tuple[torch.FloatTensor]] = None
|
| 274 |
+
|
| 275 |
+
# Additions for VLMs
|
| 276 |
+
projector_features: Optional[torch.FloatTensor] = None
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
class PrismaticPreTrainedModel(PreTrainedModel):
|
| 280 |
+
config_class: PretrainedConfig = PrismaticConfig
|
| 281 |
+
base_model_prefix: str = "model"
|
| 282 |
+
supports_gradient_checkpointing: bool = True
|
| 283 |
+
|
| 284 |
+
_no_split_modules: ClassVar[List[str]] = ["PrismaticProjector"]
|
| 285 |
+
_skip_keys_device_placement: str = "past_key_values"
|
| 286 |
+
_supports_flash_attn_2: bool = True
|
| 287 |
+
|
| 288 |
+
def _init_weights(self, module: nn.Module) -> None:
|
| 289 |
+
# Important :: this HF ported version is *not* meant for training from scratch; only inference and fine-tuning!
|
| 290 |
+
# => As such, this init_weights code is not correct; if training VLMs from scratch, use the main codebase at
|
| 291 |
+
# https://github.com/TRI-ML/prismatic-vlms
|
| 292 |
+
std = (
|
| 293 |
+
self.config.initializer_range
|
| 294 |
+
if hasattr(self.config, "initializer_range")
|
| 295 |
+
else self.config.text_config.initializer_range
|
| 296 |
+
)
|
| 297 |
+
|
| 298 |
+
if hasattr(module, "class_embedding"):
|
| 299 |
+
module.class_embedding.data.normal_(mean=0.0, std=std)
|
| 300 |
+
|
| 301 |
+
if isinstance(module, (nn.Linear, nn.Conv2d)):
|
| 302 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 303 |
+
if module.bias is not None:
|
| 304 |
+
module.bias.data.zero_()
|
| 305 |
+
elif isinstance(module, nn.Embedding):
|
| 306 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 307 |
+
if module.padding_idx is not None:
|
| 308 |
+
module.weight.data[module.padding_idx].zero_()
|
| 309 |
+
|
| 310 |
+
@property
|
| 311 |
+
def _supports_sdpa(self) -> bool:
|
| 312 |
+
"""Check LLM supports SDPA Attention"""
|
| 313 |
+
return self.language_model._supports_sdpa
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
class PrismaticForConditionalGeneration(PrismaticPreTrainedModel):
|
| 317 |
+
def __init__(self, config: PrismaticConfig) -> None:
|
| 318 |
+
super().__init__(config)
|
| 319 |
+
|
| 320 |
+
# [Validation] Lightweight Validate on `config` Fields + Dependency Versions
|
| 321 |
+
if config.use_fused_vision_backbone is None:
|
| 322 |
+
raise ValueError("Missing config field `use_fused_vision_backbone`")
|
| 323 |
+
|
| 324 |
+
if timm.__version__ not in {"0.9.10", "0.9.11", "0.9.12", "0.9.16"}:
|
| 325 |
+
raise NotImplementedError(
|
| 326 |
+
"TIMM Version must be >= 0.9.10 and < 1.0.0 (breaking); please raise a GitHub Issue "
|
| 327 |
+
"if you urgently need support for latest TIMM versions."
|
| 328 |
+
)
|
| 329 |
+
|
| 330 |
+
if (transformers.__version__ != "4.40.1") or (tokenizers.__version__ != "0.19.1"):
|
| 331 |
+
logger.warning(
|
| 332 |
+
f"Expected `transformers==4.40.1` and `tokenizers==0.19.1` but got "
|
| 333 |
+
f"`transformers=={transformers.__version__}` and `tokenizers=={tokenizers.__version__}`; "
|
| 334 |
+
f"there might be inference-time regressions due to dependency changes. If in doubt, please"
|
| 335 |
+
f"use the above versions."
|
| 336 |
+
)
|
| 337 |
+
|
| 338 |
+
# Instantiate PrismaticVisionBackbone (w/ Potential Fused Backbone)
|
| 339 |
+
self.vision_backbone = PrismaticVisionBackbone(
|
| 340 |
+
config.use_fused_vision_backbone, config.image_sizes, config.timm_model_ids, config.timm_override_act_layers
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
# Create Multimodal Projector
|
| 344 |
+
self.projector = PrismaticProjector(
|
| 345 |
+
config.use_fused_vision_backbone,
|
| 346 |
+
vision_dim=self.vision_backbone.embed_dim,
|
| 347 |
+
llm_dim=config.text_config.hidden_size,
|
| 348 |
+
)
|
| 349 |
+
|
| 350 |
+
# Instantiate LLM Backbone
|
| 351 |
+
self.language_model = AutoModelForCausalLM.from_config(
|
| 352 |
+
config.text_config, attn_implementation=config._attn_implementation
|
| 353 |
+
)
|
| 354 |
+
self.vocab_size = config.text_config.vocab_size
|
| 355 |
+
self.pad_token_id = config.pad_token_id
|
| 356 |
+
self.llm_dim = config.text_config.hidden_size
|
| 357 |
+
|
| 358 |
+
# HF Boilerplate =>> initializes weights via `_init_weights()` and sets gradient checkpointing
|
| 359 |
+
self.post_init()
|
| 360 |
+
|
| 361 |
+
# === `PreTrainedModel` Boilerplate ===
|
| 362 |
+
def get_input_embeddings(self) -> nn.Module:
|
| 363 |
+
return self.language_model.get_input_embeddings()
|
| 364 |
+
|
| 365 |
+
def set_input_embeddings(self, value: nn.Module) -> None:
|
| 366 |
+
self.language_model.set_input_embeddings(value)
|
| 367 |
+
|
| 368 |
+
def get_output_embeddings(self) -> nn.Module:
|
| 369 |
+
return self.language_model.get_output_embeddings()
|
| 370 |
+
|
| 371 |
+
def set_output_embeddings(self, new_embeddings: nn.Module) -> None:
|
| 372 |
+
self.language_model.set_output_embeddings(new_embeddings)
|
| 373 |
+
|
| 374 |
+
def get_decoder(self) -> nn.Module:
|
| 375 |
+
return self.language_model.get_decoder()
|
| 376 |
+
|
| 377 |
+
def set_decoder(self, decoder: nn.Module) -> None:
|
| 378 |
+
self.language_model.set_decoder(decoder)
|
| 379 |
+
|
| 380 |
+
def tie_weights(self) -> None:
|
| 381 |
+
self.language_model.tie_weights() # Note: `Llama-2` and `Mistral` don't tie weights (no-op)
|
| 382 |
+
|
| 383 |
+
def resize_token_embeddings(
|
| 384 |
+
self, new_num_tokens: Optional[int] = None, pad_to_multiple_of: Optional[int] = None
|
| 385 |
+
) -> nn.Embedding:
|
| 386 |
+
updated_embeddings = self.language_model.resize_token_embeddings(new_num_tokens, pad_to_multiple_of)
|
| 387 |
+
|
| 388 |
+
# Update config/instance variables
|
| 389 |
+
self.config.text_config.vocab_size = updated_embeddings.num_embeddings
|
| 390 |
+
self.vocab_size = updated_embeddings.num_embeddings
|
| 391 |
+
|
| 392 |
+
return updated_embeddings
|
| 393 |
+
|
| 394 |
+
def _replace_input_embeddings(self, input_embeddings, all_actions_mask, noisy_action_features):
|
| 395 |
+
"""
|
| 396 |
+
Replace embeddings in input_embeddings at positions where all_actions_mask is True
|
| 397 |
+
with embeddings from noisy_action_features, using vectorized operations.
|
| 398 |
+
|
| 399 |
+
Args:
|
| 400 |
+
input_embeddings: Tensor of shape (B, S, D)
|
| 401 |
+
all_actions_mask: Boolean tensor of shape (B, S)
|
| 402 |
+
noisy_action_features: Tensor of shape (B, K, D) where K is the number of True values in mask per sample
|
| 403 |
+
|
| 404 |
+
Returns:
|
| 405 |
+
Modified input_embeddings tensor
|
| 406 |
+
"""
|
| 407 |
+
# Clone input to avoid modifying the original tensor
|
| 408 |
+
new_input_embeddings = input_embeddings.clone()
|
| 409 |
+
|
| 410 |
+
# Create a tensor with the same shape of input_embeddings to hold the noisy action features
|
| 411 |
+
repositioned_noisy_action_features = torch.zeros_like(input_embeddings)
|
| 412 |
+
|
| 413 |
+
# Create batch indices for splicing
|
| 414 |
+
batch_indices = torch.arange(input_embeddings.shape[0], device=input_embeddings.device)
|
| 415 |
+
batch_indices = batch_indices.unsqueeze(1).expand(-1, noisy_action_features.shape[1])
|
| 416 |
+
|
| 417 |
+
# Get indices where mask is True for each sample
|
| 418 |
+
masked_indices = torch.stack([torch.where(mask)[0] for mask in all_actions_mask])
|
| 419 |
+
|
| 420 |
+
# Move the noisy action features into their correct positions
|
| 421 |
+
repositioned_noisy_action_features[batch_indices, masked_indices] = noisy_action_features
|
| 422 |
+
|
| 423 |
+
# Combine original input embeddings and noisy action embeddings using the mask
|
| 424 |
+
new_input_embeddings = torch.where(
|
| 425 |
+
all_actions_mask.unsqueeze(-1), repositioned_noisy_action_features, new_input_embeddings
|
| 426 |
+
)
|
| 427 |
+
|
| 428 |
+
return new_input_embeddings
|
| 429 |
+
|
| 430 |
+
def _process_action_masks(self, labels):
|
| 431 |
+
"""Helper to get action masks from labels"""
|
| 432 |
+
current_action_mask = get_current_action_mask(labels) # (B, seq_len)
|
| 433 |
+
next_actions_mask = get_next_actions_mask(labels) # (B, seq_len)
|
| 434 |
+
all_actions_mask = current_action_mask | next_actions_mask # (B, seq_len)
|
| 435 |
+
return all_actions_mask
|
| 436 |
+
|
| 437 |
+
def _process_vision_features(self, pixel_values):
|
| 438 |
+
"""Process vision features with optional FiLM conditioning"""
|
| 439 |
+
patch_features = self.vision_backbone(pixel_values) # (bsz, 256 * num_images, D)
|
| 440 |
+
|
| 441 |
+
# Project patch embeddings into language embedding space
|
| 442 |
+
return self.projector(patch_features)
|
| 443 |
+
|
| 444 |
+
def _process_proprio_features(self, projected_patch_embeddings, proprio, proprio_projector):
|
| 445 |
+
"""Process proprioceptive features and append to vision features"""
|
| 446 |
+
if proprio_projector is not None and proprio is not None:
|
| 447 |
+
# projected_patch_embeddings: (bsz, num_patches * num_images, llm_dim)
|
| 448 |
+
# proprio: (bsz, proprio_dim) or (propro_dim,)
|
| 449 |
+
proprio = proprio.reshape(projected_patch_embeddings.shape[0], -1) # (bsz, proprio_dim)
|
| 450 |
+
proprio_features = proprio_projector(proprio) # (bsz, llm_dim)
|
| 451 |
+
proprio_features = proprio_features.unsqueeze(dim=1) # (bsz, 1, llm_dim)
|
| 452 |
+
# For simplicity, just append proprio token to the end of projected vision patch tokens
|
| 453 |
+
return torch.cat((projected_patch_embeddings, proprio_features), dim=1)
|
| 454 |
+
return projected_patch_embeddings
|
| 455 |
+
|
| 456 |
+
def _build_multimodal_attention(self, input_embeddings, projected_patch_embeddings, attention_mask):
|
| 457 |
+
"""Build multimodal embeddings and attention mask"""
|
| 458 |
+
# juyi: Update attention mask 是不是要改成下三角? 不用, 因为generate会自动屏蔽
|
| 459 |
+
projected_patch_attention_mask = None
|
| 460 |
+
if attention_mask is not None:
|
| 461 |
+
projected_patch_attention_mask = torch.full(
|
| 462 |
+
(projected_patch_embeddings.shape[0], projected_patch_embeddings.shape[1]),
|
| 463 |
+
fill_value=True,
|
| 464 |
+
dtype=attention_mask.dtype,
|
| 465 |
+
device=attention_mask.device,
|
| 466 |
+
)
|
| 467 |
+
|
| 468 |
+
# Build multimodal embeddings & attention mask; insert embeddings after <BOS> token (1:)
|
| 469 |
+
multimodal_embeddings = torch.cat(
|
| 470 |
+
[input_embeddings[:, :1, :], projected_patch_embeddings, input_embeddings[:, 1:, :]], dim=1
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
multimodal_attention_mask = None
|
| 474 |
+
if attention_mask is not None:
|
| 475 |
+
multimodal_attention_mask = torch.cat(
|
| 476 |
+
[attention_mask[:, :1], projected_patch_attention_mask, attention_mask[:, 1:]], dim=1
|
| 477 |
+
)
|
| 478 |
+
|
| 479 |
+
return multimodal_embeddings, multimodal_attention_mask
|
| 480 |
+
|
| 481 |
+
def _build_multimodal_labels(self, labels, projected_patch_embeddings):
|
| 482 |
+
"""Build multimodal labels with IGNORE_INDEX for patch embeddings"""
|
| 483 |
+
if labels is not None:
|
| 484 |
+
projected_patch_labels = torch.full(
|
| 485 |
+
(projected_patch_embeddings.shape[0], projected_patch_embeddings.shape[1]),
|
| 486 |
+
fill_value=IGNORE_INDEX, # 这些位置不需要计算损失。
|
| 487 |
+
dtype=labels.dtype,
|
| 488 |
+
device=labels.device,
|
| 489 |
+
)
|
| 490 |
+
return torch.cat([labels[:, :1], projected_patch_labels, labels[:, 1:]], dim=1) # 第一个token是<BOS>
|
| 491 |
+
return None
|
| 492 |
+
|
| 493 |
+
# === Core Prismatic VLM `forward()` Logic ===
|
| 494 |
+
def forward(
|
| 495 |
+
self,
|
| 496 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 497 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 498 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 499 |
+
labels: Optional[torch.LongTensor] = None,
|
| 500 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 501 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 502 |
+
use_cache: Optional[bool] = None,
|
| 503 |
+
output_attentions: Optional[bool] = None,
|
| 504 |
+
output_hidden_states: Optional[bool] = None,
|
| 505 |
+
output_projector_features: Optional[bool] = None,
|
| 506 |
+
return_dict: Optional[bool] = None,
|
| 507 |
+
proprio=None,
|
| 508 |
+
proprio_projector=None,
|
| 509 |
+
noisy_actions=None,
|
| 510 |
+
noisy_action_projector=None,
|
| 511 |
+
diffusion_timestep_embeddings=None,
|
| 512 |
+
use_film: bool = False,
|
| 513 |
+
) -> Union[Tuple, PrismaticCausalLMOutputWithPast]:
|
| 514 |
+
"""Run a forward pass through the VLM, returning a PrismaticCausalLMOutputWithPast instance."""
|
| 515 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 516 |
+
output_hidden_states = (
|
| 517 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 518 |
+
)
|
| 519 |
+
output_projector_features = output_projector_features if output_projector_features is not None else False
|
| 520 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 521 |
+
|
| 522 |
+
# Respect `use_cache` only if not training (even if `gradient_checkpointing` is off)
|
| 523 |
+
use_cache = use_cache and not self.training
|
| 524 |
+
|
| 525 |
+
# Instantiate Placeholder for Projector Features
|
| 526 |
+
projected_patch_embeddings = None
|
| 527 |
+
|
| 528 |
+
# === Handle Generation with Cache (`input_ids.shape[1] == 1`) =>> requires `past_keys_values` ===
|
| 529 |
+
if input_ids.shape[1] == 1:
|
| 530 |
+
assert input_ids.shape[0] == 1, "Generation is only currently supported for batch size of 1!"
|
| 531 |
+
assert past_key_values is not None, "You must provide `past_key_values` during cached generation!"
|
| 532 |
+
assert labels is None, "Unexpected key `labels` provided during cached generation!"
|
| 533 |
+
|
| 534 |
+
language_model_output = self.language_model(
|
| 535 |
+
input_ids=input_ids,
|
| 536 |
+
attention_mask=None,
|
| 537 |
+
position_ids=None,
|
| 538 |
+
past_key_values=past_key_values,
|
| 539 |
+
inputs_embeds=None,
|
| 540 |
+
labels=None,
|
| 541 |
+
use_cache=use_cache,
|
| 542 |
+
output_attentions=output_attentions,
|
| 543 |
+
output_hidden_states=output_hidden_states,
|
| 544 |
+
return_dict=return_dict,
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
# === Handle Unimodal Forward ===
|
| 548 |
+
elif pixel_values is None:
|
| 549 |
+
assert (input_ids is not None) and (inputs_embeds is None), "Missing `input_ids` in language-only forward!"
|
| 550 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during language-only forward!"
|
| 551 |
+
|
| 552 |
+
language_model_output = self.language_model(
|
| 553 |
+
input_ids=input_ids,
|
| 554 |
+
attention_mask=attention_mask,
|
| 555 |
+
position_ids=None,
|
| 556 |
+
past_key_values=None,
|
| 557 |
+
inputs_embeds=None,
|
| 558 |
+
labels=labels,
|
| 559 |
+
use_cache=use_cache,
|
| 560 |
+
output_attentions=output_attentions,
|
| 561 |
+
output_hidden_states=output_hidden_states,
|
| 562 |
+
return_dict=return_dict,
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
# === Handle Multimodal Forward ===
|
| 566 |
+
elif (input_ids.shape[0] == pixel_values.shape[0]) or (inputs_embeds.shape[0] == pixel_values.shape[0]):
|
| 567 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during multimodal forward!"
|
| 568 |
+
|
| 569 |
+
# Get input embeddings (from language model embeddings)
|
| 570 |
+
input_embeddings = self.get_input_embeddings()(input_ids) # (B, seq_len, D)
|
| 571 |
+
|
| 572 |
+
# Extract action masks
|
| 573 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 574 |
+
|
| 575 |
+
# Extract the language portion of the input embeddings (i.e. remove the action tokens portion)
|
| 576 |
+
language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 577 |
+
input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 578 |
+
) # (B, lang_seq_len, llm_dim)
|
| 579 |
+
|
| 580 |
+
# Get visual features
|
| 581 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values, language_embeddings, use_film)
|
| 582 |
+
# bug: TypeError: PrismaticForConditionalGeneration._process_vision_features() takes 2 positional arguments but 4 were given
|
| 583 |
+
|
| 584 |
+
# Add proprioceptive state if provided
|
| 585 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 586 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 587 |
+
)
|
| 588 |
+
|
| 589 |
+
# [Diffusion] Add diffusion timestep embedding if provided
|
| 590 |
+
if diffusion_timestep_embeddings is not None:
|
| 591 |
+
# For simplicity, just append diffusion timestep embedding to the end of projected vision patch tokens
|
| 592 |
+
projected_patch_embeddings = torch.cat(
|
| 593 |
+
(projected_patch_embeddings, diffusion_timestep_embeddings), dim=1
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
# Process action embeddings
|
| 597 |
+
if noisy_actions is not None:
|
| 598 |
+
# Get mask corresponding to all action tokens
|
| 599 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 600 |
+
|
| 601 |
+
# Reshape noisy actions into individual action tokens
|
| 602 |
+
# noisy_actions: (B, chunk_len, action_dim) -> (B, chunk_len * action_dim, 1)
|
| 603 |
+
B = noisy_actions.shape[0]
|
| 604 |
+
noisy_actions = noisy_actions.reshape(B, -1).unsqueeze(-1)
|
| 605 |
+
|
| 606 |
+
# Project noisy action tokens into language model embedding space
|
| 607 |
+
noisy_action_features = noisy_action_projector(noisy_actions) # (B, chunk_len * action_dim, llm_dim)
|
| 608 |
+
|
| 609 |
+
# Replace embeddings of the action tokens with noisy action embeddings
|
| 610 |
+
input_embeddings = self._replace_input_embeddings(
|
| 611 |
+
input_embeddings, all_actions_mask, noisy_action_features
|
| 612 |
+
)
|
| 613 |
+
else:
|
| 614 |
+
# Replace the embeddings of the action tokens with zeros
|
| 615 |
+
# (Later on, the positional embeddings will be added to them)
|
| 616 |
+
all_actions_mask = all_actions_mask.unsqueeze(-1) # (B, seq_len, 1)
|
| 617 |
+
input_embeddings = input_embeddings * ~all_actions_mask
|
| 618 |
+
|
| 619 |
+
# Build multimodal embeddings & attention mask
|
| 620 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 621 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 622 |
+
)
|
| 623 |
+
|
| 624 |
+
# Build labels for multimodal sequence if needed
|
| 625 |
+
multimodal_labels = self._build_multimodal_labels(labels, projected_patch_embeddings)
|
| 626 |
+
|
| 627 |
+
# Dispatch to language model
|
| 628 |
+
language_model_output = self.language_model(
|
| 629 |
+
input_ids=None,
|
| 630 |
+
attention_mask=multimodal_attention_mask,
|
| 631 |
+
position_ids=None,
|
| 632 |
+
past_key_values=None,
|
| 633 |
+
inputs_embeds=multimodal_embeddings,
|
| 634 |
+
labels=multimodal_labels,
|
| 635 |
+
use_cache=use_cache,
|
| 636 |
+
output_attentions=output_attentions,
|
| 637 |
+
output_hidden_states=output_hidden_states,
|
| 638 |
+
return_dict=return_dict,
|
| 639 |
+
)
|
| 640 |
+
|
| 641 |
+
# === Otherwise =>> Assume Invalid! ===
|
| 642 |
+
elif (input_ids.shape[0] != pixel_values.shape[0]) or (inputs_embeds.shape[0] != pixel_values.shape[0]):
|
| 643 |
+
raise ValueError("Non-homogenous batch of (text, image) input -- forward() does not support mixed batches!")
|
| 644 |
+
|
| 645 |
+
else:
|
| 646 |
+
raise ValueError(
|
| 647 |
+
"Invalid PrismaticForConditionalGeneration `forward()` call with provided arguments:\n"
|
| 648 |
+
f"=> `input_ids` = {input_ids is not None}\n"
|
| 649 |
+
f"=> `attention_mask` = {attention_mask is not None}\n"
|
| 650 |
+
f"=> `pixel_values` = {pixel_values is not None}\n"
|
| 651 |
+
f"=> `labels` = {labels is not None}\n"
|
| 652 |
+
f"=> `input_embeds` = {inputs_embeds is not None}\n"
|
| 653 |
+
f"=> `past_key_values` = {past_key_values is not None}\n"
|
| 654 |
+
f"=> `use_cache` = {use_cache}"
|
| 655 |
+
)
|
| 656 |
+
|
| 657 |
+
# Unpack `language_model_output` and return PrismaticCausalLMOutputWithPast (or tuple if not `return_dict`)
|
| 658 |
+
if not return_dict:
|
| 659 |
+
if output_projector_features and (projected_patch_embeddings is not None):
|
| 660 |
+
return *language_model_output, projected_patch_embeddings
|
| 661 |
+
|
| 662 |
+
return language_model_output
|
| 663 |
+
|
| 664 |
+
return PrismaticCausalLMOutputWithPast(
|
| 665 |
+
loss=language_model_output.loss,
|
| 666 |
+
logits=language_model_output.logits,
|
| 667 |
+
past_key_values=language_model_output.past_key_values,
|
| 668 |
+
hidden_states=language_model_output.hidden_states,
|
| 669 |
+
attentions=language_model_output.attentions,
|
| 670 |
+
projector_features=projected_patch_embeddings,
|
| 671 |
+
)
|
| 672 |
+
|
| 673 |
+
# === GenerationMixin Methods ===
|
| 674 |
+
def prepare_inputs_for_generation(
|
| 675 |
+
self,
|
| 676 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 677 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 678 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 679 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 680 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 681 |
+
**kwargs: str,
|
| 682 |
+
) -> Dict[str, torch.Tensor]:
|
| 683 |
+
"""Borrowed from `LlamaForCausalLM` and simplified for batch size = 1; mirrors original PrismaticVLM logic."""
|
| 684 |
+
if ((input_ids is not None) and (input_ids.shape[0] > 1)) or (
|
| 685 |
+
(inputs_embeds is not None) and (inputs_embeds.shape[0] > 1)
|
| 686 |
+
):
|
| 687 |
+
raise ValueError("Generation with batch size > 1 is not currently supported!")
|
| 688 |
+
|
| 689 |
+
# Handle `past_key_values` (cache) =>> assume `input_ids` just has unprocessed tokens
|
| 690 |
+
if past_key_values is not None:
|
| 691 |
+
input_ids = input_ids[:, -1:]
|
| 692 |
+
|
| 693 |
+
# If `input_embeds` are passed, we only want to use them in the 1st generation step
|
| 694 |
+
if inputs_embeds is not None and past_key_values is None:
|
| 695 |
+
model_inputs = {"input_embeds": inputs_embeds}
|
| 696 |
+
else:
|
| 697 |
+
model_inputs = {"input_ids": input_ids}
|
| 698 |
+
|
| 699 |
+
# Make sure `pixel_values` are preserved in `model_inputs`
|
| 700 |
+
model_inputs.update(
|
| 701 |
+
{
|
| 702 |
+
"attention_mask": attention_mask,
|
| 703 |
+
"pixel_values": pixel_values,
|
| 704 |
+
"past_key_values": past_key_values,
|
| 705 |
+
"use_cache": kwargs.get("use_cache"),
|
| 706 |
+
}
|
| 707 |
+
)
|
| 708 |
+
|
| 709 |
+
return model_inputs
|
| 710 |
+
|
| 711 |
+
# Defer to Language Model (all handle this differently, with different return types)
|
| 712 |
+
def _reorder_cache(self, *args, **kwargs) -> Any:
|
| 713 |
+
return self.language_model._reorder_cache(*args, **kwargs)
|
| 714 |
+
|
| 715 |
+
|
| 716 |
+
class OpenVLAForActionPrediction(PrismaticForConditionalGeneration):
|
| 717 |
+
config_class: PretrainedConfig = OpenVLAConfig
|
| 718 |
+
|
| 719 |
+
def __init__(self, config: OpenVLAConfig) -> None:
|
| 720 |
+
super().__init__(config)
|
| 721 |
+
self.norm_stats = config.norm_stats
|
| 722 |
+
|
| 723 |
+
# Compute action bins
|
| 724 |
+
self.bins = np.linspace(-1, 1, config.n_action_bins)
|
| 725 |
+
self.bin_centers = (self.bins[:-1] + self.bins[1:]) / 2.0
|
| 726 |
+
|
| 727 |
+
# Compute vocab size for de-tokenization -- revert added "multiple of"
|
| 728 |
+
self.vocab_size = self.config.text_config.vocab_size - self.config.pad_to_multiple_of
|
| 729 |
+
|
| 730 |
+
def _prepare_input_for_action_prediction(self, input_ids, attention_mask):
|
| 731 |
+
# eval 会用到这里
|
| 732 |
+
"""Prepares input for action prediction by adding necessary tokens"""
|
| 733 |
+
# Add (ACTION_DIM * NUM_ACTIONS_CHUNK) placeholder tokens to input_ids to simulate action tokens
|
| 734 |
+
placeholder_action_token_ids = (
|
| 735 |
+
torch.ones((input_ids.shape[0], ACTION_DIM * NUM_ACTIONS_CHUNK)).to(input_ids.device).to(input_ids.dtype)
|
| 736 |
+
)
|
| 737 |
+
input_ids = torch.cat([input_ids, placeholder_action_token_ids], dim=-1) # torch.Size([1, 35 + 56= 91])
|
| 738 |
+
|
| 739 |
+
# Extend the attention mask to fit the new shape of input
|
| 740 |
+
# Note: Only batch size == 1 supported right now
|
| 741 |
+
mask_extension = (
|
| 742 |
+
torch.ones((attention_mask.shape[0], input_ids.shape[-1] - attention_mask.shape[-1]))
|
| 743 |
+
.to(attention_mask.device)
|
| 744 |
+
.to(attention_mask.dtype)
|
| 745 |
+
)
|
| 746 |
+
attention_mask = torch.cat([attention_mask, mask_extension], dim=-1)
|
| 747 |
+
|
| 748 |
+
return input_ids, attention_mask
|
| 749 |
+
|
| 750 |
+
def _prepare_labels_for_action_prediction(self, labels, input_ids):
|
| 751 |
+
"""Creates labels tensor for action prediction if not provided"""
|
| 752 |
+
# eval 会用到这里 ,
|
| 753 |
+
# Extends label tensors with fake action labels
|
| 754 |
+
# Adds stop tokens at the end of sequences
|
| 755 |
+
# Handles label preparation for action prediction tasks
|
| 756 |
+
# 他为啥可以随便一个? xuan说 你自定义一个值 ,然后一直指定这个 , PAD token可以吗?
|
| 757 |
+
#TODO: 这里是否要改? 感觉不需要改. 随便写就行了因为labels不重要只是要一个mask. 为什么需要这个函数? 确保 action 预测任务的标签(labels)符合模型的输入长度,并正确地处理序列终止
|
| 758 |
+
# Extend labels tensor with fake action labels
|
| 759 |
+
ARBITRARY_ACTION_TOKEN_IDX = ACTION_TOKEN_IDX # = 为了mask正确生成, action_tokens_only_mask = (labels == ACTION_TOKEN_IDX ), 所以这里也填上ACTION_TOKEN_IDX
|
| 760 |
+
labels_extension = (
|
| 761 |
+
torch.ones((labels.shape[0], input_ids.shape[-1] - labels.shape[-1])).to(labels.device).to(labels.dtype)
|
| 762 |
+
* ARBITRARY_ACTION_TOKEN_IDX
|
| 763 |
+
) #torch.Size([1, 57]),全是 ARBITRARY_ACTION_TOKEN_IDX
|
| 764 |
+
labels = torch.cat([labels, labels_extension], dim=-1)
|
| 765 |
+
|
| 766 |
+
return labels
|
| 767 |
+
|
| 768 |
+
def _unnormalize_actions(self, normalized_actions, unnorm_key=None):
|
| 769 |
+
"""Unnormalize actions using dataset statistics"""
|
| 770 |
+
action_norm_stats = self.get_action_stats(unnorm_key)
|
| 771 |
+
|
| 772 |
+
if ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS:
|
| 773 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["min"], dtype=bool))
|
| 774 |
+
action_high, action_low = np.array(action_norm_stats["max"]), np.array(action_norm_stats["min"])
|
| 775 |
+
elif ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS_Q99:
|
| 776 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["q01"], dtype=bool))
|
| 777 |
+
action_high, action_low = np.array(action_norm_stats["q99"]), np.array(action_norm_stats["q01"])
|
| 778 |
+
else:
|
| 779 |
+
raise ValueError("Unsupported action/proprio normalization type detected!")
|
| 780 |
+
|
| 781 |
+
actions = np.where(
|
| 782 |
+
mask,
|
| 783 |
+
0.5 * (normalized_actions + 1) * (action_high - action_low + 1e-8) + action_low,
|
| 784 |
+
normalized_actions,
|
| 785 |
+
)
|
| 786 |
+
|
| 787 |
+
return actions
|
| 788 |
+
|
| 789 |
+
|
| 790 |
+
def _normalize_actions(self, actions, norm_key=None):
|
| 791 |
+
"""Normalize actions to [-1, 1] using dataset statistics"""
|
| 792 |
+
action_norm_stats = self.get_action_stats(norm_key)
|
| 793 |
+
|
| 794 |
+
if ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS:
|
| 795 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["min"], dtype=bool))
|
| 796 |
+
action_high, action_low = np.array(action_norm_stats["max"]), np.array(action_norm_stats["min"])
|
| 797 |
+
elif ACTION_PROPRIO_NORMALIZATION_TYPE == NormalizationType.BOUNDS_Q99:
|
| 798 |
+
mask = action_norm_stats.get("mask", np.ones_like(action_norm_stats["q01"], dtype=bool))
|
| 799 |
+
action_high, action_low = np.array(action_norm_stats["q99"]), np.array(action_norm_stats["q01"])
|
| 800 |
+
else:
|
| 801 |
+
raise ValueError("Unsupported action/proprio normalization type detected!")
|
| 802 |
+
|
| 803 |
+
normalized = np.where(
|
| 804 |
+
mask,
|
| 805 |
+
2 * (actions - action_low) / (action_high - action_low + 1e-8) - 1,
|
| 806 |
+
actions,
|
| 807 |
+
)
|
| 808 |
+
|
| 809 |
+
return normalized
|
| 810 |
+
|
| 811 |
+
def _run_diffusion_prediction(
|
| 812 |
+
self,
|
| 813 |
+
input_embeddings,
|
| 814 |
+
all_actions_mask,
|
| 815 |
+
noise,
|
| 816 |
+
action_head,
|
| 817 |
+
projected_patch_embeddings,
|
| 818 |
+
labels,
|
| 819 |
+
attention_mask,
|
| 820 |
+
NUM_PATCHES,
|
| 821 |
+
NUM_PROMPT_TOKENS,
|
| 822 |
+
noisy_action_projector,
|
| 823 |
+
):
|
| 824 |
+
"""Run diffusion-based action prediction"""
|
| 825 |
+
# Set diffusion timestep values
|
| 826 |
+
action_head.noise_scheduler.set_timesteps(action_head.num_diffusion_steps)
|
| 827 |
+
# Clone embedding for reuse in each timestep
|
| 828 |
+
orig_projected_patch_embeddings = projected_patch_embeddings.clone()
|
| 829 |
+
curr_noisy_actions = noise
|
| 830 |
+
|
| 831 |
+
# Reverse diffusion: Iteratively denoise to generate action prediction
|
| 832 |
+
for t in action_head.noise_scheduler.timesteps:
|
| 833 |
+
# Get diffusion model's noise prediction (conditioned on VLA latent embedding, current noisy action
|
| 834 |
+
# embedding, and diffusion timestep embedding)
|
| 835 |
+
timesteps = torch.Tensor([t]).to(labels.device)
|
| 836 |
+
diffusion_timestep_embeddings = (
|
| 837 |
+
action_head.time_encoder(timesteps).to(curr_noisy_actions.dtype).to(curr_noisy_actions.device)
|
| 838 |
+
) # (B, llm_dim)
|
| 839 |
+
diffusion_timestep_embeddings = diffusion_timestep_embeddings.unsqueeze(1) # (B, 1, llm_dim)
|
| 840 |
+
|
| 841 |
+
# [Diffusion] Replace the embeddings of the action tokens with noisy actions
|
| 842 |
+
# (Later on, the positional embeddings will be added to them)
|
| 843 |
+
|
| 844 |
+
# For simplicity, append diffusion timestep embedding to the end of projected vision tokens
|
| 845 |
+
projected_patch_embeddings = torch.cat(
|
| 846 |
+
(orig_projected_patch_embeddings, diffusion_timestep_embeddings), dim=1
|
| 847 |
+
)
|
| 848 |
+
|
| 849 |
+
# Reshape and project noisy actions into language embedding space
|
| 850 |
+
B = curr_noisy_actions.shape[0]
|
| 851 |
+
orig_curr_noisy_actions_shape = curr_noisy_actions.shape
|
| 852 |
+
curr_noisy_actions = curr_noisy_actions.reshape(B, -1).unsqueeze(-1)
|
| 853 |
+
noisy_action_features = noisy_action_projector(curr_noisy_actions)
|
| 854 |
+
curr_noisy_actions = curr_noisy_actions.reshape(orig_curr_noisy_actions_shape)
|
| 855 |
+
|
| 856 |
+
# Replace action token embeddings with noisy action embeddings
|
| 857 |
+
input_embeddings = self._replace_input_embeddings(
|
| 858 |
+
input_embeddings.clone(), all_actions_mask, noisy_action_features
|
| 859 |
+
)
|
| 860 |
+
|
| 861 |
+
# Build multimodal embeddings and attention mask
|
| 862 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 863 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 864 |
+
)
|
| 865 |
+
|
| 866 |
+
# Forward pass through language model
|
| 867 |
+
language_model_output = self.language_model(
|
| 868 |
+
input_ids=None,
|
| 869 |
+
attention_mask=multimodal_attention_mask,
|
| 870 |
+
position_ids=None,
|
| 871 |
+
past_key_values=None,
|
| 872 |
+
inputs_embeds=multimodal_embeddings,
|
| 873 |
+
labels=None,
|
| 874 |
+
use_cache=None,
|
| 875 |
+
output_attentions=False,
|
| 876 |
+
output_hidden_states=True,
|
| 877 |
+
return_dict=True,
|
| 878 |
+
)
|
| 879 |
+
|
| 880 |
+
# Extract hidden states for action portion of response
|
| 881 |
+
last_hidden_states = language_model_output.hidden_states[-1] # (B, seq_len, D)
|
| 882 |
+
actions_hidden_states = last_hidden_states[
|
| 883 |
+
:,
|
| 884 |
+
NUM_PATCHES + NUM_PROMPT_TOKENS : NUM_PATCHES + NUM_PROMPT_TOKENS + ACTION_DIM * NUM_ACTIONS_CHUNK,
|
| 885 |
+
:,
|
| 886 |
+
] # (B, act_chunk_len, D)
|
| 887 |
+
|
| 888 |
+
# Predict noise and update noisy actions: x_t -> x_{t-1}
|
| 889 |
+
noise_pred = action_head.predict_noise(actions_hidden_states)
|
| 890 |
+
curr_noisy_actions = action_head.noise_scheduler.step(noise_pred, t, curr_noisy_actions).prev_sample
|
| 891 |
+
|
| 892 |
+
curr_noisy_actions = curr_noisy_actions.reshape(NUM_ACTIONS_CHUNK, ACTION_DIM)
|
| 893 |
+
|
| 894 |
+
# Return final actions
|
| 895 |
+
return curr_noisy_actions.float().cpu().detach().numpy(), actions_hidden_states
|
| 896 |
+
|
| 897 |
+
def _regression_or_discrete_prediction(
|
| 898 |
+
self,
|
| 899 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 900 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 901 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 902 |
+
attention_mask: torch.BoolTensor,
|
| 903 |
+
labels: torch.LongTensor,
|
| 904 |
+
NUM_PATCHES: int,
|
| 905 |
+
NUM_PROMPT_TOKENS: int,
|
| 906 |
+
action_head: L1RegressionActionHead,
|
| 907 |
+
**kwargs,
|
| 908 |
+
):
|
| 909 |
+
"""Run L1 regression-based continuous action prediction or discrete action tokens prediction."""
|
| 910 |
+
# Extract hidden states for action tokens
|
| 911 |
+
# last_hidden_states = language_model_output.hidden_states[-1] # (B, seq_len, D)
|
| 912 |
+
|
| 913 |
+
# actions_hidden_states = last_hidden_states[:, NUM_PATCHES + NUM_PROMPT_TOKENS : NUM_PATCHES + NUM_PROMPT_TOKENS + NUM_ACTIONS_CHUNK * tokennum, :]# (B, act_chunk_len, D)
|
| 914 |
+
# 都不需要取了, 直接就给 token对应的hidden state了 ,太方便了.
|
| 915 |
+
# 为什么第一个是torch.Size([1, 535, 4096])? 我应该选哪个? https://discuss.huggingface.co/t/get-each-generated-token-last-layer-hidden-state/145921
|
| 916 |
+
# language_model_output.sequences tensor([[29871, 32001, 32001, 32001, 32001, 32001, 32001, 32001, 32001, 2]], device='cuda:0')
|
| 917 |
+
cfg = kwargs.pop("cfg", None)
|
| 918 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 919 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 920 |
+
)
|
| 921 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 922 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 923 |
+
# is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 924 |
+
hidden_states = language_model_output.hidden_states[0][-1]
|
| 925 |
+
actions_hidden_states = hidden_states[:, -NUM_ACTIONS_CHUNK:]
|
| 926 |
+
|
| 927 |
+
normalized_actions = action_head.predict_action(actions_hidden_states)
|
| 928 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 929 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 930 |
+
if cfg.mode == "mul":
|
| 931 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 932 |
+
token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 933 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 934 |
+
actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 935 |
+
|
| 936 |
+
actions_hidden_states_list = [actions_hidden_states0]
|
| 937 |
+
for i in range(1, token_num):
|
| 938 |
+
token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 939 |
+
actions_hidden_states_list.append(token_hidden_state)
|
| 940 |
+
# 将所有hidden states拼接起来
|
| 941 |
+
combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 942 |
+
actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 943 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 944 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 945 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 946 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 947 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 948 |
+
else:
|
| 949 |
+
raise NotImplementedError
|
| 950 |
+
else:
|
| 951 |
+
raise NotImplementedError
|
| 952 |
+
return normalized_actions, actions_hidden_states
|
| 953 |
+
|
| 954 |
+
def hist_predict_action(
|
| 955 |
+
self,
|
| 956 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 957 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 958 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 959 |
+
attention_mask: torch.BoolTensor,
|
| 960 |
+
action_head: L1RegressionActionHead,
|
| 961 |
+
**kwargs,
|
| 962 |
+
):
|
| 963 |
+
cfg = kwargs.get("cfg", None)
|
| 964 |
+
action_history = kwargs.get("action_history", None)
|
| 965 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 966 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 967 |
+
)
|
| 968 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 969 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 970 |
+
# the following is (num of tokens,)
|
| 971 |
+
if cfg.mode == "mul":
|
| 972 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 973 |
+
raise NotImplementedError
|
| 974 |
+
# token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 975 |
+
# language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 976 |
+
# actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 977 |
+
# actions_hidden_states_list = [actions_hidden_states0]
|
| 978 |
+
# for i in range(1, token_num):
|
| 979 |
+
# token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 980 |
+
# actions_hidden_states_list.append(token_hidden_state)
|
| 981 |
+
# combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 982 |
+
# actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 983 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 984 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 985 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 986 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 987 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 988 |
+
# 在中间加一个 1 维度
|
| 989 |
+
actions_hidden_states = actions_hidden_states.unsqueeze(1) # for match 3 dim
|
| 990 |
+
else:
|
| 991 |
+
raise NotImplementedError
|
| 992 |
+
else:
|
| 993 |
+
raise NotImplementedError
|
| 994 |
+
|
| 995 |
+
normalized_actions = action_head.predict_action(actions_hidden_states, action_history)
|
| 996 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 997 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 998 |
+
|
| 999 |
+
return normalized_actions, actions_hidden_states
|
| 1000 |
+
|
| 1001 |
+
def mul_regression_or_discrete_prediction(
|
| 1002 |
+
self,
|
| 1003 |
+
input_embeddings: torch.FloatTensor, #lanage instruction 的embedding.
|
| 1004 |
+
all_actions_mask : Optional[torch.BoolTensor], #有啥用? 就是为了提取前面的embedding用. 去掉action .
|
| 1005 |
+
projected_patch_embeddings: torch.FloatTensor,
|
| 1006 |
+
attention_mask: torch.BoolTensor,
|
| 1007 |
+
labels: torch.LongTensor,
|
| 1008 |
+
NUM_PATCHES: int,
|
| 1009 |
+
NUM_PROMPT_TOKENS: int,
|
| 1010 |
+
action_head: L1RegressionActionHead,
|
| 1011 |
+
**kwargs,
|
| 1012 |
+
):
|
| 1013 |
+
cfg = kwargs.get("cfg", None)
|
| 1014 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1015 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1016 |
+
)
|
| 1017 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1018 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 1019 |
+
# the following is (num of tokens,)
|
| 1020 |
+
if cfg.mode == "mul":
|
| 1021 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 1022 |
+
token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 1023 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 1024 |
+
actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 1025 |
+
|
| 1026 |
+
actions_hidden_states_list = [actions_hidden_states0]
|
| 1027 |
+
for i in range(1, token_num):
|
| 1028 |
+
token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 1029 |
+
actions_hidden_states_list.append(token_hidden_state)
|
| 1030 |
+
combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 1031 |
+
actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 1032 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1033 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 1034 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1035 |
+
actions_hidden_states = actions_hidden_states[:, -1]
|
| 1036 |
+
else:
|
| 1037 |
+
raise NotImplementedError
|
| 1038 |
+
else:
|
| 1039 |
+
raise NotImplementedError
|
| 1040 |
+
|
| 1041 |
+
normalized_actions = action_head.predict_action(actions_hidden_states)
|
| 1042 |
+
normalized_actions = normalized_actions.reshape(cfg.num_actions_chunk, ACTION_DIM)
|
| 1043 |
+
# print(f"*** normalized_actions[]: {normalized_actions} ***")
|
| 1044 |
+
if cfg.action_head_name == "medusa":
|
| 1045 |
+
normalized_actions[:, 6] = torch.sigmoid(normalized_actions[:, 6]) # without bs dim.
|
| 1046 |
+
# print(f"*** normalized_actions[]: {normalized_actions} ***")
|
| 1047 |
+
normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 1048 |
+
|
| 1049 |
+
return normalized_actions, actions_hidden_states
|
| 1050 |
+
|
| 1051 |
+
def predict_action(
|
| 1052 |
+
self,
|
| 1053 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1054 |
+
unnorm_key: Optional[str] = None,
|
| 1055 |
+
proprio=None,
|
| 1056 |
+
proprio_projector=None,
|
| 1057 |
+
action_head=None,
|
| 1058 |
+
noisy_action_projector=None,
|
| 1059 |
+
use_film: bool = False,
|
| 1060 |
+
**kwargs: str,
|
| 1061 |
+
) -> np.ndarray:
|
| 1062 |
+
"""Predict actions from input sequence, with options for different prediction methods.
|
| 1063 |
+
|
| 1064 |
+
Args:
|
| 1065 |
+
input_ids: Input token ids
|
| 1066 |
+
unnorm_key: Key for unnormalization statistics
|
| 1067 |
+
proprio: Proprioceptive features
|
| 1068 |
+
proprio_projector: Projector for proprioceptive features
|
| 1069 |
+
action_head: Optional head for L1 regression or diffusion-based prediction
|
| 1070 |
+
noisy_action_projector: Projector for noisy actions in diffusion-based prediction
|
| 1071 |
+
use_film: Whether to use FiLM conditioning
|
| 1072 |
+
**kwargs: Additional arguments including pixel_values and attention_mask
|
| 1073 |
+
|
| 1074 |
+
Returns:
|
| 1075 |
+
Tuple of (unnormalized_actions, action_hidden_states)
|
| 1076 |
+
"""
|
| 1077 |
+
# If the special empty token ('') does not already appear after the colon (':') token in the prompt
|
| 1078 |
+
# (after "OUT:" or "ASSISTANT:"), insert it to match the inputs seen at training time
|
| 1079 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1080 |
+
input_ids = torch.cat(
|
| 1081 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1082 |
+
)
|
| 1083 |
+
|
| 1084 |
+
pixel_values = kwargs["pixel_values"]
|
| 1085 |
+
attention_mask = kwargs["attention_mask"]
|
| 1086 |
+
|
| 1087 |
+
# Create fake labels tensor (needed for action mask)
|
| 1088 |
+
labels = input_ids.clone()
|
| 1089 |
+
labels[:] = IGNORE_INDEX # 输入都ignore IGNORE_INDEX = -100
|
| 1090 |
+
|
| 1091 |
+
# Get number of tokens in prompt (excluding the start token)
|
| 1092 |
+
NUM_PROMPT_TOKENS = input_ids.shape[-1] - 1 # Subtract action tokens and stop token
|
| 1093 |
+
|
| 1094 |
+
# Prepare inputs by adding necessary tokens
|
| 1095 |
+
input_ids, attention_mask = self._prepare_input_for_action_prediction(input_ids, attention_mask)
|
| 1096 |
+
|
| 1097 |
+
# Update labels tensor for action mask computation later
|
| 1098 |
+
labels = self._prepare_labels_for_action_prediction(labels, input_ids)
|
| 1099 |
+
|
| 1100 |
+
# Get input embeddings and action masks
|
| 1101 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1102 |
+
all_actions_mask = self._process_action_masks(labels)
|
| 1103 |
+
|
| 1104 |
+
# Extract language embeddings
|
| 1105 |
+
language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 1106 |
+
input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 1107 |
+
)
|
| 1108 |
+
|
| 1109 |
+
# Process vision features
|
| 1110 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values, language_embeddings, use_film)
|
| 1111 |
+
|
| 1112 |
+
# Add proprioceptive features if provided
|
| 1113 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1114 |
+
if use_proprio:
|
| 1115 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1116 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1117 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1118 |
+
)
|
| 1119 |
+
|
| 1120 |
+
# Use diffusion if provided, otherwise use regression or discrete prediction
|
| 1121 |
+
use_diffusion = noisy_action_projector is not None and hasattr(action_head, "noise_scheduler")
|
| 1122 |
+
|
| 1123 |
+
# Calculate number of patches (including proprio token and/or diffusion timestep embedding if present)
|
| 1124 |
+
NUM_PATCHES = self.vision_backbone.get_num_patches() * self.vision_backbone.get_num_images_in_input()
|
| 1125 |
+
if use_proprio:
|
| 1126 |
+
NUM_PATCHES += 1
|
| 1127 |
+
|
| 1128 |
+
normalized_actions, actions_hidden_states = self._regression_or_discrete_prediction(
|
| 1129 |
+
input_embeddings,
|
| 1130 |
+
all_actions_mask,
|
| 1131 |
+
projected_patch_embeddings,
|
| 1132 |
+
attention_mask,
|
| 1133 |
+
labels,
|
| 1134 |
+
NUM_PATCHES,
|
| 1135 |
+
NUM_PROMPT_TOKENS,
|
| 1136 |
+
action_head,
|
| 1137 |
+
)
|
| 1138 |
+
|
| 1139 |
+
# Unnormalize predicted actions
|
| 1140 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1141 |
+
|
| 1142 |
+
return actions, actions_hidden_states
|
| 1143 |
+
|
| 1144 |
+
@staticmethod
|
| 1145 |
+
def _check_unnorm_key(norm_stats: Dict[str, Dict[str, Any]], unnorm_key: Optional[str]) -> str:
|
| 1146 |
+
"""Validate and resolve the unnormalization key for action statistics"""
|
| 1147 |
+
if unnorm_key is None:
|
| 1148 |
+
assert len(norm_stats) == 1, (
|
| 1149 |
+
f"Your model was trained on more than one dataset, "
|
| 1150 |
+
f"please pass a `unnorm_key` from the following options to choose the statistics "
|
| 1151 |
+
f"used for un-normalizing actions: {norm_stats.keys()}"
|
| 1152 |
+
)
|
| 1153 |
+
unnorm_key = next(iter(norm_stats.keys()))
|
| 1154 |
+
# norm states没有加载libero, 为什么?
|
| 1155 |
+
assert unnorm_key in norm_stats, (
|
| 1156 |
+
f"The `unnorm_key` you chose is not in the set of available dataset statistics, "
|
| 1157 |
+
f"please choose from: {norm_stats.keys()}"
|
| 1158 |
+
)
|
| 1159 |
+
return unnorm_key
|
| 1160 |
+
|
| 1161 |
+
def get_action_dim(self, unnorm_key: Optional[str] = None) -> int:
|
| 1162 |
+
"""Get the dimensionality of the policy's action space."""
|
| 1163 |
+
unnorm_key = self._check_unnorm_key(self.norm_stats, unnorm_key)
|
| 1164 |
+
return len(self.norm_stats[unnorm_key]["action"]["min"])
|
| 1165 |
+
|
| 1166 |
+
def get_action_stats(self, unnorm_key: Optional[str] = None) -> Dict[str, Any]:
|
| 1167 |
+
"""Get all the logged statistics for the given dataset."""
|
| 1168 |
+
unnorm_key = self._check_unnorm_key(self.norm_stats, unnorm_key)
|
| 1169 |
+
return self.norm_stats[unnorm_key]["action"]
|
| 1170 |
+
|
| 1171 |
+
|
| 1172 |
+
def lisa_forward(
|
| 1173 |
+
self,
|
| 1174 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1175 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1176 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 1177 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1178 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1179 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1180 |
+
use_cache: Optional[bool] = None,
|
| 1181 |
+
output_attentions: Optional[bool] = None,
|
| 1182 |
+
output_hidden_states: Optional[bool] = None,
|
| 1183 |
+
output_projector_features: Optional[bool] = None,
|
| 1184 |
+
return_dict: Optional[bool] = None,
|
| 1185 |
+
proprio=None,
|
| 1186 |
+
proprio_projector=None,
|
| 1187 |
+
**kwargs
|
| 1188 |
+
) -> Union[Tuple, PrismaticCausalLMOutputWithPast]:
|
| 1189 |
+
"""Run a forward pass through the VLM, returning a PrismaticCausalLMOutputWithPast instance."""
|
| 1190 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1191 |
+
output_hidden_states = (
|
| 1192 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1193 |
+
)
|
| 1194 |
+
output_projector_features = output_projector_features if output_projector_features is not None else False
|
| 1195 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1196 |
+
|
| 1197 |
+
# Respect `use_cache` only if not training (even if `gradient_checkpointing` is off)
|
| 1198 |
+
use_cache = use_cache and not self.training
|
| 1199 |
+
|
| 1200 |
+
# Instantiate Placeholder for Projector Features
|
| 1201 |
+
projected_patch_embeddings = None
|
| 1202 |
+
|
| 1203 |
+
# === Handle Generation with Cache (`input_ids.shape[1] == 1`) =>> requires `past_keys_values` ===
|
| 1204 |
+
if input_ids.shape[1] == 1:
|
| 1205 |
+
assert input_ids.shape[0] == 1, "Generation is only currently supported for batch size of 1!"
|
| 1206 |
+
assert past_key_values is not None, "You must provide `past_key_values` during cached generation!"
|
| 1207 |
+
assert labels is None, "Unexpected key `labels` provided during cached generation!"
|
| 1208 |
+
|
| 1209 |
+
language_model_output = self.language_model(
|
| 1210 |
+
input_ids=input_ids,
|
| 1211 |
+
attention_mask=None,
|
| 1212 |
+
position_ids=None,
|
| 1213 |
+
past_key_values=past_key_values,
|
| 1214 |
+
inputs_embeds=None,
|
| 1215 |
+
labels=None,
|
| 1216 |
+
use_cache=use_cache,
|
| 1217 |
+
output_attentions=output_attentions,
|
| 1218 |
+
output_hidden_states=output_hidden_states,
|
| 1219 |
+
return_dict=return_dict,
|
| 1220 |
+
)
|
| 1221 |
+
|
| 1222 |
+
# === Handle Unimodal Forward ===
|
| 1223 |
+
elif pixel_values is None:
|
| 1224 |
+
raise NotImplementedError
|
| 1225 |
+
|
| 1226 |
+
# === Handle Multimodal Forward ===
|
| 1227 |
+
elif (input_ids.shape[0] == pixel_values.shape[0]) or (inputs_embeds.shape[0] == pixel_values.shape[0]):
|
| 1228 |
+
assert past_key_values is None, "Unexpected key `past_key_values` provided during multimodal forward!"
|
| 1229 |
+
|
| 1230 |
+
# Get input embeddings (from language model embeddings)
|
| 1231 |
+
input_embeddings = self.get_input_embeddings()(input_ids) # (B, seq_len, D)
|
| 1232 |
+
# Extract the language portion of the input embeddings (i.e. remove the action tokens portion)
|
| 1233 |
+
# language_embeddings = input_embeddings[~all_actions_mask].reshape(
|
| 1234 |
+
# input_embeddings.shape[0], -1, input_embeddings.shape[2]
|
| 1235 |
+
# ) # (B, lang_seq_len, llm_dim) 这里就会把结尾的 stop index和padding 也算进去. 没问题吗? 没问题因为ignore了 我直接删了因为不用film
|
| 1236 |
+
# Get visual features
|
| 1237 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1238 |
+
|
| 1239 |
+
# Add proprioceptive state if provided
|
| 1240 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1241 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1242 |
+
)
|
| 1243 |
+
|
| 1244 |
+
all_actions_mask = (labels == ACTION_TOKEN_IDX) #和run forward pass不一样, run forward pass要手动算token number来找偏移.
|
| 1245 |
+
all_actions_mask = all_actions_mask.unsqueeze(-1) # (B, seq_len, 1)
|
| 1246 |
+
input_embeddings = input_embeddings * ~all_actions_mask
|
| 1247 |
+
|
| 1248 |
+
# Build multimodal embeddings & attention mask
|
| 1249 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1250 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1251 |
+
)
|
| 1252 |
+
|
| 1253 |
+
# Build labels for multimodal sequence if needed
|
| 1254 |
+
multimodal_labels = self._build_multimodal_labels(labels, projected_patch_embeddings)
|
| 1255 |
+
|
| 1256 |
+
# Dispatch to language model
|
| 1257 |
+
language_model_output = self.language_model(
|
| 1258 |
+
input_ids=None,
|
| 1259 |
+
attention_mask=multimodal_attention_mask,
|
| 1260 |
+
position_ids=None,
|
| 1261 |
+
past_key_values=None,
|
| 1262 |
+
inputs_embeds=multimodal_embeddings,
|
| 1263 |
+
labels=multimodal_labels,
|
| 1264 |
+
use_cache=use_cache,
|
| 1265 |
+
output_attentions=output_attentions,
|
| 1266 |
+
output_hidden_states=output_hidden_states,
|
| 1267 |
+
return_dict=return_dict,
|
| 1268 |
+
)
|
| 1269 |
+
|
| 1270 |
+
|
| 1271 |
+
# === Otherwise =>> Assume Invalid! ===
|
| 1272 |
+
elif (input_ids.shape[0] != pixel_values.shape[0]) or (inputs_embeds.shape[0] != pixel_values.shape[0]):
|
| 1273 |
+
raise ValueError("Non-homogenous batch of (text, image) input -- forward() does not support mixed batches!")
|
| 1274 |
+
|
| 1275 |
+
else:
|
| 1276 |
+
raise ValueError(
|
| 1277 |
+
"Invalid PrismaticForConditionalGeneration `forward()` call with provided arguments:\n"
|
| 1278 |
+
f"=> `input_ids` = {input_ids is not None}\n"
|
| 1279 |
+
f"=> `attention_mask` = {attention_mask is not None}\n"
|
| 1280 |
+
f"=> `pixel_values` = {pixel_values is not None}\n"
|
| 1281 |
+
f"=> `labels` = {labels is not None}\n"
|
| 1282 |
+
f"=> `input_embeds` = {inputs_embeds is not None}\n"
|
| 1283 |
+
f"=> `past_key_values` = {past_key_values is not None}\n"
|
| 1284 |
+
f"=> `use_cache` = {use_cache}"
|
| 1285 |
+
)
|
| 1286 |
+
|
| 1287 |
+
# Unpack `language_model_output` and return PrismaticCausalLMOutputWithPast (or tuple if not `return_dict`)
|
| 1288 |
+
if not return_dict:
|
| 1289 |
+
if output_projector_features and (projected_patch_embeddings is not None):
|
| 1290 |
+
return *language_model_output, projected_patch_embeddings
|
| 1291 |
+
|
| 1292 |
+
return language_model_output
|
| 1293 |
+
|
| 1294 |
+
return PrismaticCausalLMOutputWithPast(
|
| 1295 |
+
loss=language_model_output.loss,
|
| 1296 |
+
logits=language_model_output.logits,
|
| 1297 |
+
past_key_values=language_model_output.past_key_values,
|
| 1298 |
+
hidden_states=language_model_output.hidden_states,
|
| 1299 |
+
attentions=language_model_output.attentions,
|
| 1300 |
+
projector_features=projected_patch_embeddings,
|
| 1301 |
+
)
|
| 1302 |
+
|
| 1303 |
+
|
| 1304 |
+
|
| 1305 |
+
def mul_predict_action(
|
| 1306 |
+
self,
|
| 1307 |
+
input_ids: Optional[torch.LongTensor] = None, #就是 language instruction.
|
| 1308 |
+
unnorm_key: Optional[str] = None,
|
| 1309 |
+
proprio=None,
|
| 1310 |
+
proprio_projector=None,
|
| 1311 |
+
action_head:L1RegressionActionHead=None,
|
| 1312 |
+
noisy_action_projector=None,
|
| 1313 |
+
use_film: bool = False,
|
| 1314 |
+
**kwargs: str,
|
| 1315 |
+
) -> np.ndarray:
|
| 1316 |
+
# only use in evaluation.
|
| 1317 |
+
cfg = kwargs.get("cfg", None) # Extract cfg from kwargs
|
| 1318 |
+
action_history = kwargs.get("action_history", None)
|
| 1319 |
+
|
| 1320 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1321 |
+
input_ids = torch.cat(
|
| 1322 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1323 |
+
)
|
| 1324 |
+
|
| 1325 |
+
|
| 1326 |
+
pixel_values = kwargs["pixel_values"]
|
| 1327 |
+
attention_mask = kwargs["attention_mask"]
|
| 1328 |
+
|
| 1329 |
+
# input id '<s> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1330 |
+
import ipdb; ipdb.set_trace()
|
| 1331 |
+
|
| 1332 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1333 |
+
|
| 1334 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1335 |
+
|
| 1336 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1337 |
+
if use_proprio:
|
| 1338 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1339 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1340 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1341 |
+
)
|
| 1342 |
+
if cfg.action_head_name == "hist":
|
| 1343 |
+
normalized_actions, actions_hidden_states = self.hist_predict_action(
|
| 1344 |
+
input_embeddings,
|
| 1345 |
+
None,
|
| 1346 |
+
projected_patch_embeddings,
|
| 1347 |
+
attention_mask,
|
| 1348 |
+
action_head,
|
| 1349 |
+
cfg=cfg,
|
| 1350 |
+
action_history=action_history,
|
| 1351 |
+
)
|
| 1352 |
+
else:
|
| 1353 |
+
normalized_actions, actions_hidden_states = self.mul_regression_or_discrete_prediction(
|
| 1354 |
+
input_embeddings,
|
| 1355 |
+
None,
|
| 1356 |
+
projected_patch_embeddings,
|
| 1357 |
+
attention_mask,
|
| 1358 |
+
None, #推理不需要labels
|
| 1359 |
+
None, #推理不需要NUM_PATCHES
|
| 1360 |
+
None, #推理不需要NUM_PROMPT_TOKENS
|
| 1361 |
+
action_head,
|
| 1362 |
+
cfg=cfg,
|
| 1363 |
+
)
|
| 1364 |
+
|
| 1365 |
+
|
| 1366 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key) #在这里 unorm, 所以出来的已经是unorm的了. 所以我 history 也要记录 norm 的.
|
| 1367 |
+
|
| 1368 |
+
return actions, normalized_actions
|
| 1369 |
+
|
| 1370 |
+
|
| 1371 |
+
def flow_matching_predict_action(
|
| 1372 |
+
self,
|
| 1373 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1374 |
+
unnorm_key: Optional[str] = None,
|
| 1375 |
+
proprio=None,
|
| 1376 |
+
proprio_projector=None,
|
| 1377 |
+
action_head: FlowMatchingActionHead = None,
|
| 1378 |
+
noisy_action_projector=None,
|
| 1379 |
+
use_film: bool = False,
|
| 1380 |
+
**kwargs: str,
|
| 1381 |
+
) -> np.ndarray:
|
| 1382 |
+
"""Predict actions using Flow Matching"""
|
| 1383 |
+
cfg = kwargs.get("cfg", None)
|
| 1384 |
+
|
| 1385 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1386 |
+
input_ids = torch.cat(
|
| 1387 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1388 |
+
)
|
| 1389 |
+
|
| 1390 |
+
pixel_values = kwargs["pixel_values"]
|
| 1391 |
+
attention_mask = kwargs["attention_mask"]
|
| 1392 |
+
|
| 1393 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1394 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1395 |
+
|
| 1396 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1397 |
+
if use_proprio:
|
| 1398 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1399 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1400 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1401 |
+
)
|
| 1402 |
+
|
| 1403 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1404 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1405 |
+
)
|
| 1406 |
+
|
| 1407 |
+
if cfg.mode == "flow_matching":
|
| 1408 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1409 |
+
language_model_output = self.language_model.generate(
|
| 1410 |
+
inputs_embeds=multimodal_embeddings,
|
| 1411 |
+
max_new_tokens=1,
|
| 1412 |
+
output_hidden_states=True,
|
| 1413 |
+
return_dict_in_generate=True
|
| 1414 |
+
)
|
| 1415 |
+
|
| 1416 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1417 |
+
cognition_features = actions_hidden_states[:, -1]
|
| 1418 |
+
assert (cognition_features.shape[0], cognition_features.shape[1]) == (1, 4096), "Batch size must be 1 for action prediction"
|
| 1419 |
+
|
| 1420 |
+
model_dtype = next(action_head.net.parameters()).dtype
|
| 1421 |
+
cognition_features = cognition_features.unsqueeze(1).to(model_dtype)
|
| 1422 |
+
|
| 1423 |
+
# Sample actions using flow matching
|
| 1424 |
+
normalized_actions = action_head.sample_actions(
|
| 1425 |
+
cognition_features,
|
| 1426 |
+
num_steps=getattr(cfg, 'num_flow_steps', 20)
|
| 1427 |
+
)
|
| 1428 |
+
normalized_actions = normalized_actions[0].cpu().numpy()
|
| 1429 |
+
else:
|
| 1430 |
+
raise NotImplementedError("Multi-token flow matching not yet implemented")
|
| 1431 |
+
else:
|
| 1432 |
+
raise NotImplementedError
|
| 1433 |
+
|
| 1434 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1435 |
+
return actions, actions_hidden_states
|
| 1436 |
+
|
| 1437 |
+
def diffusion_predict_action(
|
| 1438 |
+
self,
|
| 1439 |
+
input_ids: Optional[torch.LongTensor] = None, #就是 language instruction.
|
| 1440 |
+
unnorm_key: Optional[str] = None,
|
| 1441 |
+
proprio=None,
|
| 1442 |
+
proprio_projector=None,
|
| 1443 |
+
action_head:DiTActionHead=None,
|
| 1444 |
+
noisy_action_projector=None,
|
| 1445 |
+
use_film: bool = False,
|
| 1446 |
+
**kwargs: str,
|
| 1447 |
+
) -> np.ndarray:
|
| 1448 |
+
cfg = kwargs.get("cfg", None) # Extract cfg from kwargs
|
| 1449 |
+
|
| 1450 |
+
if not torch.all(input_ids[:, -1] == 29871):
|
| 1451 |
+
input_ids = torch.cat(
|
| 1452 |
+
(input_ids, torch.unsqueeze(torch.Tensor([29871]).long(), dim=0).to(input_ids.device)), dim=1
|
| 1453 |
+
)
|
| 1454 |
+
|
| 1455 |
+
|
| 1456 |
+
pixel_values = kwargs["pixel_values"]
|
| 1457 |
+
attention_mask = kwargs["attention_mask"]
|
| 1458 |
+
|
| 1459 |
+
# input id '<s> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1460 |
+
|
| 1461 |
+
input_embeddings = self.get_input_embeddings()(input_ids)
|
| 1462 |
+
|
| 1463 |
+
projected_patch_embeddings = self._process_vision_features(pixel_values)
|
| 1464 |
+
|
| 1465 |
+
use_proprio = proprio_projector is not None and proprio is not None
|
| 1466 |
+
if use_proprio:
|
| 1467 |
+
proprio = torch.Tensor(proprio).to(projected_patch_embeddings.device, dtype=projected_patch_embeddings.dtype)
|
| 1468 |
+
projected_patch_embeddings = self._process_proprio_features(
|
| 1469 |
+
projected_patch_embeddings, proprio, proprio_projector
|
| 1470 |
+
)
|
| 1471 |
+
|
| 1472 |
+
# normalized_actions, actions_hidden_states = self.mul_regression_or_discrete_prediction(
|
| 1473 |
+
# input_embeddings,
|
| 1474 |
+
# None,
|
| 1475 |
+
# projected_patch_embeddings,
|
| 1476 |
+
# attention_mask,
|
| 1477 |
+
# None, #推理不需要labels
|
| 1478 |
+
# None, #推理不需要NUM_PATCHES
|
| 1479 |
+
# None, #推理不需要NUM_PROMPT_TOKENS
|
| 1480 |
+
# action_head,
|
| 1481 |
+
# cfg=cfg,
|
| 1482 |
+
# )
|
| 1483 |
+
|
| 1484 |
+
# cfg = kwargs.get("cfg", None)
|
| 1485 |
+
multimodal_embeddings, multimodal_attention_mask = self._build_multimodal_attention(
|
| 1486 |
+
input_embeddings, projected_patch_embeddings, attention_mask
|
| 1487 |
+
)
|
| 1488 |
+
# multimodal_embeddings 例子'<s> <512 image token> <pripor token> In: What action should the robot take to open the middle drawer of the cabinet?\nOut:'
|
| 1489 |
+
# first language_model_output.hidden_states , is tuple (1 token, 33 layers, torch.Size([1, 314, 4096]))
|
| 1490 |
+
# the following is (num of tokens,)
|
| 1491 |
+
|
| 1492 |
+
if cfg.mode == "dit":
|
| 1493 |
+
if cfg.num_actions_chunk//cfg.num_actions_per_token > 1:
|
| 1494 |
+
# token_num = cfg.num_actions_chunk//cfg.num_actions_per_token
|
| 1495 |
+
# language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,min_new_tokens=token_num, max_new_tokens=token_num,output_hidden_states=True,return_dict_in_generate=True)
|
| 1496 |
+
# actions_hidden_states0 = language_model_output.hidden_states[0][-1][:, -1] # 第一个token的hidden state的last layer
|
| 1497 |
+
|
| 1498 |
+
# actions_hidden_states_list = [actions_hidden_states0]
|
| 1499 |
+
# for i in range(1, token_num):
|
| 1500 |
+
# token_hidden_state = language_model_output.hidden_states[i][-1][0] # i+1个token的hidden state的last layer
|
| 1501 |
+
# actions_hidden_states_list.append(token_hidden_state)
|
| 1502 |
+
# combined_hidden_states = torch.stack(actions_hidden_states_list, dim=0) # (16, 4096)
|
| 1503 |
+
# actions_hidden_states = combined_hidden_states.reshape(multimodal_embeddings.shape[0], token_num, multimodal_embeddings.shape[-1])
|
| 1504 |
+
raise NotImplementedError
|
| 1505 |
+
elif cfg.num_actions_chunk//cfg.num_actions_per_token == 1:
|
| 1506 |
+
language_model_output = self.language_model.generate(inputs_embeds=multimodal_embeddings,max_new_tokens=1,output_hidden_states=True,return_dict_in_generate=True)
|
| 1507 |
+
# assert language_model_output.sequences == torch.tensor([[32001]], device=multimodal_embeddings.device)
|
| 1508 |
+
actions_hidden_states = language_model_output.hidden_states[0][-1]
|
| 1509 |
+
cognition_features = actions_hidden_states[:, -1]
|
| 1510 |
+
assert (cognition_features.shape[0], cognition_features.shape[1]) == (1,4096), "Batch size must be 1 for action prediction"
|
| 1511 |
+
using_cfg = cfg.cfg_scale > 1.0
|
| 1512 |
+
|
| 1513 |
+
model_dtype = next(action_head.net.parameters()).dtype
|
| 1514 |
+
B = cognition_features.shape[0]
|
| 1515 |
+
|
| 1516 |
+
cognition_features = cognition_features.unsqueeze(1).to(model_dtype)
|
| 1517 |
+
|
| 1518 |
+
noise = torch.randn(B, cfg.num_actions_chunk, action_head.net.in_channels, device=cognition_features.device).to(model_dtype)
|
| 1519 |
+
|
| 1520 |
+
# TODO: Setup classifier-free guidance: now use cfg
|
| 1521 |
+
noise = torch.cat([noise, noise], 0) # noise.shape torch.Size([2, 16, 7])
|
| 1522 |
+
uncondition = action_head.net.z_embedder.uncondition # torch.Size([1, 4096])
|
| 1523 |
+
uncondition = uncondition.unsqueeze(0) #[1, D] # torch.Size([1, 1, 4096])
|
| 1524 |
+
uncondition = uncondition.expand(B, 1, -1) #[B, 1, D]
|
| 1525 |
+
z = torch.cat([cognition_features, uncondition], 0) # z shape torch.Size([2, 1, 4096])
|
| 1526 |
+
model_kwargs = dict(z=z, cfg_scale=cfg.cfg_scale)
|
| 1527 |
+
sample_fn = action_head.net.forward_with_cfg
|
| 1528 |
+
# default use ddim
|
| 1529 |
+
if action_head.ddim_diffusion is None:
|
| 1530 |
+
action_head.create_ddim(ddim_step=cfg.num_ddim_steps)
|
| 1531 |
+
samples = action_head.ddim_diffusion.ddim_sample_loop(sample_fn,
|
| 1532 |
+
noise.shape,
|
| 1533 |
+
noise,
|
| 1534 |
+
clip_denoised=False,
|
| 1535 |
+
model_kwargs=model_kwargs,
|
| 1536 |
+
progress=False,
|
| 1537 |
+
device=cognition_features.device,
|
| 1538 |
+
eta=0.0
|
| 1539 |
+
)
|
| 1540 |
+
if using_cfg:
|
| 1541 |
+
samples, _ = samples.chunk(2, dim=0) # Remove null class samples
|
| 1542 |
+
normalized_actions = samples[0].cpu().numpy()
|
| 1543 |
+
else:
|
| 1544 |
+
raise NotImplementedError
|
| 1545 |
+
else:
|
| 1546 |
+
raise NotImplementedError
|
| 1547 |
+
|
| 1548 |
+
|
| 1549 |
+
|
| 1550 |
+
# normalized_actions = normalized_actions.float().cpu().detach().numpy()
|
| 1551 |
+
actions = self._unnormalize_actions(normalized_actions, unnorm_key)
|
| 1552 |
+
|
| 1553 |
+
return actions, actions_hidden_states
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_processor_type": "PrismaticImageProcessor",
|
| 3 |
+
"image_resize_strategy": "resize-naive",
|
| 4 |
+
"input_sizes": [
|
| 5 |
+
[
|
| 6 |
+
3,
|
| 7 |
+
224,
|
| 8 |
+
224
|
| 9 |
+
],
|
| 10 |
+
[
|
| 11 |
+
3,
|
| 12 |
+
224,
|
| 13 |
+
224
|
| 14 |
+
]
|
| 15 |
+
],
|
| 16 |
+
"interpolations": [
|
| 17 |
+
"bicubic",
|
| 18 |
+
"bicubic"
|
| 19 |
+
],
|
| 20 |
+
"means": [
|
| 21 |
+
[
|
| 22 |
+
0.485,
|
| 23 |
+
0.456,
|
| 24 |
+
0.406
|
| 25 |
+
],
|
| 26 |
+
[
|
| 27 |
+
0.5,
|
| 28 |
+
0.5,
|
| 29 |
+
0.5
|
| 30 |
+
]
|
| 31 |
+
],
|
| 32 |
+
"processor_class": "PrismaticProcessor",
|
| 33 |
+
"stds": [
|
| 34 |
+
[
|
| 35 |
+
0.229,
|
| 36 |
+
0.224,
|
| 37 |
+
0.225
|
| 38 |
+
],
|
| 39 |
+
[
|
| 40 |
+
0.5,
|
| 41 |
+
0.5,
|
| 42 |
+
0.5
|
| 43 |
+
]
|
| 44 |
+
],
|
| 45 |
+
"tvf_crop_params": [
|
| 46 |
+
{
|
| 47 |
+
"output_size": [
|
| 48 |
+
224,
|
| 49 |
+
224
|
| 50 |
+
]
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"output_size": [
|
| 54 |
+
224,
|
| 55 |
+
224
|
| 56 |
+
]
|
| 57 |
+
}
|
| 58 |
+
],
|
| 59 |
+
"tvf_do_letterbox": false,
|
| 60 |
+
"tvf_letterbox_fill": null,
|
| 61 |
+
"tvf_normalize_params": [
|
| 62 |
+
{
|
| 63 |
+
"inplace": false,
|
| 64 |
+
"mean": [
|
| 65 |
+
0.484375,
|
| 66 |
+
0.455078125,
|
| 67 |
+
0.40625
|
| 68 |
+
],
|
| 69 |
+
"std": [
|
| 70 |
+
0.228515625,
|
| 71 |
+
0.2236328125,
|
| 72 |
+
0.224609375
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"inplace": false,
|
| 77 |
+
"mean": [
|
| 78 |
+
0.5,
|
| 79 |
+
0.5,
|
| 80 |
+
0.5
|
| 81 |
+
],
|
| 82 |
+
"std": [
|
| 83 |
+
0.5,
|
| 84 |
+
0.5,
|
| 85 |
+
0.5
|
| 86 |
+
]
|
| 87 |
+
}
|
| 88 |
+
],
|
| 89 |
+
"tvf_resize_params": [
|
| 90 |
+
{
|
| 91 |
+
"antialias": true,
|
| 92 |
+
"interpolation": 3,
|
| 93 |
+
"max_size": null,
|
| 94 |
+
"size": [
|
| 95 |
+
224,
|
| 96 |
+
224
|
| 97 |
+
]
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"antialias": true,
|
| 101 |
+
"interpolation": 3,
|
| 102 |
+
"max_size": null,
|
| 103 |
+
"size": [
|
| 104 |
+
224,
|
| 105 |
+
224
|
| 106 |
+
]
|
| 107 |
+
}
|
| 108 |
+
],
|
| 109 |
+
"use_fused_vision_backbone": true
|
| 110 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
{
|
| 4 |
+
"content": "<ACT>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false
|
| 9 |
+
}
|
| 10 |
+
],
|
| 11 |
+
"bos_token": {
|
| 12 |
+
"content": "<|begin_of_text|>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false
|
| 17 |
+
},
|
| 18 |
+
"eos_token": {
|
| 19 |
+
"content": "<|end_of_text|>",
|
| 20 |
+
"lstrip": false,
|
| 21 |
+
"normalized": false,
|
| 22 |
+
"rstrip": false,
|
| 23 |
+
"single_word": false
|
| 24 |
+
},
|
| 25 |
+
"pad_token": {
|
| 26 |
+
"content": "<PAD>",
|
| 27 |
+
"lstrip": false,
|
| 28 |
+
"normalized": false,
|
| 29 |
+
"rstrip": false,
|
| 30 |
+
"single_word": false
|
| 31 |
+
}
|
| 32 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:181432f1f6f7a4a71b3b17f3da5d631873d77f153394c8807bfff2a7473ab217
|
| 3 |
+
size 17210284
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"128000": {
|
| 4 |
+
"content": "<|begin_of_text|>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"128001": {
|
| 12 |
+
"content": "<|end_of_text|>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"128002": {
|
| 20 |
+
"content": "<|reserved_special_token_0|>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"128003": {
|
| 28 |
+
"content": "<|reserved_special_token_1|>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"128004": {
|
| 36 |
+
"content": "<|finetune_right_pad_id|>",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
},
|
| 43 |
+
"128005": {
|
| 44 |
+
"content": "<|reserved_special_token_2|>",
|
| 45 |
+
"lstrip": false,
|
| 46 |
+
"normalized": false,
|
| 47 |
+
"rstrip": false,
|
| 48 |
+
"single_word": false,
|
| 49 |
+
"special": true
|
| 50 |
+
},
|
| 51 |
+
"128006": {
|
| 52 |
+
"content": "<|start_header_id|>",
|
| 53 |
+
"lstrip": false,
|
| 54 |
+
"normalized": false,
|
| 55 |
+
"rstrip": false,
|
| 56 |
+
"single_word": false,
|
| 57 |
+
"special": true
|
| 58 |
+
},
|
| 59 |
+
"128007": {
|
| 60 |
+
"content": "<|end_header_id|>",
|
| 61 |
+
"lstrip": false,
|
| 62 |
+
"normalized": false,
|
| 63 |
+
"rstrip": false,
|
| 64 |
+
"single_word": false,
|
| 65 |
+
"special": true
|
| 66 |
+
},
|
| 67 |
+
"128008": {
|
| 68 |
+
"content": "<|eom_id|>",
|
| 69 |
+
"lstrip": false,
|
| 70 |
+
"normalized": false,
|
| 71 |
+
"rstrip": false,
|
| 72 |
+
"single_word": false,
|
| 73 |
+
"special": true
|
| 74 |
+
},
|
| 75 |
+
"128009": {
|
| 76 |
+
"content": "<|eot_id|>",
|
| 77 |
+
"lstrip": false,
|
| 78 |
+
"normalized": false,
|
| 79 |
+
"rstrip": false,
|
| 80 |
+
"single_word": false,
|
| 81 |
+
"special": true
|
| 82 |
+
},
|
| 83 |
+
"128010": {
|
| 84 |
+
"content": "<|python_tag|>",
|
| 85 |
+
"lstrip": false,
|
| 86 |
+
"normalized": false,
|
| 87 |
+
"rstrip": false,
|
| 88 |
+
"single_word": false,
|
| 89 |
+
"special": true
|
| 90 |
+
},
|
| 91 |
+
"128011": {
|
| 92 |
+
"content": "<|reserved_special_token_3|>",
|
| 93 |
+
"lstrip": false,
|
| 94 |
+
"normalized": false,
|
| 95 |
+
"rstrip": false,
|
| 96 |
+
"single_word": false,
|
| 97 |
+
"special": true
|
| 98 |
+
},
|
| 99 |
+
"128012": {
|
| 100 |
+
"content": "<|reserved_special_token_4|>",
|
| 101 |
+
"lstrip": false,
|
| 102 |
+
"normalized": false,
|
| 103 |
+
"rstrip": false,
|
| 104 |
+
"single_word": false,
|
| 105 |
+
"special": true
|
| 106 |
+
},
|
| 107 |
+
"128013": {
|
| 108 |
+
"content": "<|reserved_special_token_5|>",
|
| 109 |
+
"lstrip": false,
|
| 110 |
+
"normalized": false,
|
| 111 |
+
"rstrip": false,
|
| 112 |
+
"single_word": false,
|
| 113 |
+
"special": true
|
| 114 |
+
},
|
| 115 |
+
"128014": {
|
| 116 |
+
"content": "<|reserved_special_token_6|>",
|
| 117 |
+
"lstrip": false,
|
| 118 |
+
"normalized": false,
|
| 119 |
+
"rstrip": false,
|
| 120 |
+
"single_word": false,
|
| 121 |
+
"special": true
|
| 122 |
+
},
|
| 123 |
+
"128015": {
|
| 124 |
+
"content": "<|reserved_special_token_7|>",
|
| 125 |
+
"lstrip": false,
|
| 126 |
+
"normalized": false,
|
| 127 |
+
"rstrip": false,
|
| 128 |
+
"single_word": false,
|
| 129 |
+
"special": true
|
| 130 |
+
},
|
| 131 |
+
"128016": {
|
| 132 |
+
"content": "<|reserved_special_token_8|>",
|
| 133 |
+
"lstrip": false,
|
| 134 |
+
"normalized": false,
|
| 135 |
+
"rstrip": false,
|
| 136 |
+
"single_word": false,
|
| 137 |
+
"special": true
|
| 138 |
+
},
|
| 139 |
+
"128017": {
|
| 140 |
+
"content": "<|reserved_special_token_9|>",
|
| 141 |
+
"lstrip": false,
|
| 142 |
+
"normalized": false,
|
| 143 |
+
"rstrip": false,
|
| 144 |
+
"single_word": false,
|
| 145 |
+
"special": true
|
| 146 |
+
},
|
| 147 |
+
"128018": {
|
| 148 |
+
"content": "<|reserved_special_token_10|>",
|
| 149 |
+
"lstrip": false,
|
| 150 |
+
"normalized": false,
|
| 151 |
+
"rstrip": false,
|
| 152 |
+
"single_word": false,
|
| 153 |
+
"special": true
|
| 154 |
+
},
|
| 155 |
+
"128019": {
|
| 156 |
+
"content": "<|reserved_special_token_11|>",
|
| 157 |
+
"lstrip": false,
|
| 158 |
+
"normalized": false,
|
| 159 |
+
"rstrip": false,
|
| 160 |
+
"single_word": false,
|
| 161 |
+
"special": true
|
| 162 |
+
},
|
| 163 |
+
"128020": {
|
| 164 |
+
"content": "<|reserved_special_token_12|>",
|
| 165 |
+
"lstrip": false,
|
| 166 |
+
"normalized": false,
|
| 167 |
+
"rstrip": false,
|
| 168 |
+
"single_word": false,
|
| 169 |
+
"special": true
|
| 170 |
+
},
|
| 171 |
+
"128021": {
|
| 172 |
+
"content": "<|reserved_special_token_13|>",
|
| 173 |
+
"lstrip": false,
|
| 174 |
+
"normalized": false,
|
| 175 |
+
"rstrip": false,
|
| 176 |
+
"single_word": false,
|
| 177 |
+
"special": true
|
| 178 |
+
},
|
| 179 |
+
"128022": {
|
| 180 |
+
"content": "<|reserved_special_token_14|>",
|
| 181 |
+
"lstrip": false,
|
| 182 |
+
"normalized": false,
|
| 183 |
+
"rstrip": false,
|
| 184 |
+
"single_word": false,
|
| 185 |
+
"special": true
|
| 186 |
+
},
|
| 187 |
+
"128023": {
|
| 188 |
+
"content": "<|reserved_special_token_15|>",
|
| 189 |
+
"lstrip": false,
|
| 190 |
+
"normalized": false,
|
| 191 |
+
"rstrip": false,
|
| 192 |
+
"single_word": false,
|
| 193 |
+
"special": true
|
| 194 |
+
},
|
| 195 |
+
"128024": {
|
| 196 |
+
"content": "<|reserved_special_token_16|>",
|
| 197 |
+
"lstrip": false,
|
| 198 |
+
"normalized": false,
|
| 199 |
+
"rstrip": false,
|
| 200 |
+
"single_word": false,
|
| 201 |
+
"special": true
|
| 202 |
+
},
|
| 203 |
+
"128025": {
|
| 204 |
+
"content": "<|reserved_special_token_17|>",
|
| 205 |
+
"lstrip": false,
|
| 206 |
+
"normalized": false,
|
| 207 |
+
"rstrip": false,
|
| 208 |
+
"single_word": false,
|
| 209 |
+
"special": true
|
| 210 |
+
},
|
| 211 |
+
"128026": {
|
| 212 |
+
"content": "<|reserved_special_token_18|>",
|
| 213 |
+
"lstrip": false,
|
| 214 |
+
"normalized": false,
|
| 215 |
+
"rstrip": false,
|
| 216 |
+
"single_word": false,
|
| 217 |
+
"special": true
|
| 218 |
+
},
|
| 219 |
+
"128027": {
|
| 220 |
+
"content": "<|reserved_special_token_19|>",
|
| 221 |
+
"lstrip": false,
|
| 222 |
+
"normalized": false,
|
| 223 |
+
"rstrip": false,
|
| 224 |
+
"single_word": false,
|
| 225 |
+
"special": true
|
| 226 |
+
},
|
| 227 |
+
"128028": {
|
| 228 |
+
"content": "<|reserved_special_token_20|>",
|
| 229 |
+
"lstrip": false,
|
| 230 |
+
"normalized": false,
|
| 231 |
+
"rstrip": false,
|
| 232 |
+
"single_word": false,
|
| 233 |
+
"special": true
|
| 234 |
+
},
|
| 235 |
+
"128029": {
|
| 236 |
+
"content": "<|reserved_special_token_21|>",
|
| 237 |
+
"lstrip": false,
|
| 238 |
+
"normalized": false,
|
| 239 |
+
"rstrip": false,
|
| 240 |
+
"single_word": false,
|
| 241 |
+
"special": true
|
| 242 |
+
},
|
| 243 |
+
"128030": {
|
| 244 |
+
"content": "<|reserved_special_token_22|>",
|
| 245 |
+
"lstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"rstrip": false,
|
| 248 |
+
"single_word": false,
|
| 249 |
+
"special": true
|
| 250 |
+
},
|
| 251 |
+
"128031": {
|
| 252 |
+
"content": "<|reserved_special_token_23|>",
|
| 253 |
+
"lstrip": false,
|
| 254 |
+
"normalized": false,
|
| 255 |
+
"rstrip": false,
|
| 256 |
+
"single_word": false,
|
| 257 |
+
"special": true
|
| 258 |
+
},
|
| 259 |
+
"128032": {
|
| 260 |
+
"content": "<|reserved_special_token_24|>",
|
| 261 |
+
"lstrip": false,
|
| 262 |
+
"normalized": false,
|
| 263 |
+
"rstrip": false,
|
| 264 |
+
"single_word": false,
|
| 265 |
+
"special": true
|
| 266 |
+
},
|
| 267 |
+
"128033": {
|
| 268 |
+
"content": "<|reserved_special_token_25|>",
|
| 269 |
+
"lstrip": false,
|
| 270 |
+
"normalized": false,
|
| 271 |
+
"rstrip": false,
|
| 272 |
+
"single_word": false,
|
| 273 |
+
"special": true
|
| 274 |
+
},
|
| 275 |
+
"128034": {
|
| 276 |
+
"content": "<|reserved_special_token_26|>",
|
| 277 |
+
"lstrip": false,
|
| 278 |
+
"normalized": false,
|
| 279 |
+
"rstrip": false,
|
| 280 |
+
"single_word": false,
|
| 281 |
+
"special": true
|
| 282 |
+
},
|
| 283 |
+
"128035": {
|
| 284 |
+
"content": "<|reserved_special_token_27|>",
|
| 285 |
+
"lstrip": false,
|
| 286 |
+
"normalized": false,
|
| 287 |
+
"rstrip": false,
|
| 288 |
+
"single_word": false,
|
| 289 |
+
"special": true
|
| 290 |
+
},
|
| 291 |
+
"128036": {
|
| 292 |
+
"content": "<|reserved_special_token_28|>",
|
| 293 |
+
"lstrip": false,
|
| 294 |
+
"normalized": false,
|
| 295 |
+
"rstrip": false,
|
| 296 |
+
"single_word": false,
|
| 297 |
+
"special": true
|
| 298 |
+
},
|
| 299 |
+
"128037": {
|
| 300 |
+
"content": "<|reserved_special_token_29|>",
|
| 301 |
+
"lstrip": false,
|
| 302 |
+
"normalized": false,
|
| 303 |
+
"rstrip": false,
|
| 304 |
+
"single_word": false,
|
| 305 |
+
"special": true
|
| 306 |
+
},
|
| 307 |
+
"128038": {
|
| 308 |
+
"content": "<|reserved_special_token_30|>",
|
| 309 |
+
"lstrip": false,
|
| 310 |
+
"normalized": false,
|
| 311 |
+
"rstrip": false,
|
| 312 |
+
"single_word": false,
|
| 313 |
+
"special": true
|
| 314 |
+
},
|
| 315 |
+
"128039": {
|
| 316 |
+
"content": "<|reserved_special_token_31|>",
|
| 317 |
+
"lstrip": false,
|
| 318 |
+
"normalized": false,
|
| 319 |
+
"rstrip": false,
|
| 320 |
+
"single_word": false,
|
| 321 |
+
"special": true
|
| 322 |
+
},
|
| 323 |
+
"128040": {
|
| 324 |
+
"content": "<|reserved_special_token_32|>",
|
| 325 |
+
"lstrip": false,
|
| 326 |
+
"normalized": false,
|
| 327 |
+
"rstrip": false,
|
| 328 |
+
"single_word": false,
|
| 329 |
+
"special": true
|
| 330 |
+
},
|
| 331 |
+
"128041": {
|
| 332 |
+
"content": "<|reserved_special_token_33|>",
|
| 333 |
+
"lstrip": false,
|
| 334 |
+
"normalized": false,
|
| 335 |
+
"rstrip": false,
|
| 336 |
+
"single_word": false,
|
| 337 |
+
"special": true
|
| 338 |
+
},
|
| 339 |
+
"128042": {
|
| 340 |
+
"content": "<|reserved_special_token_34|>",
|
| 341 |
+
"lstrip": false,
|
| 342 |
+
"normalized": false,
|
| 343 |
+
"rstrip": false,
|
| 344 |
+
"single_word": false,
|
| 345 |
+
"special": true
|
| 346 |
+
},
|
| 347 |
+
"128043": {
|
| 348 |
+
"content": "<|reserved_special_token_35|>",
|
| 349 |
+
"lstrip": false,
|
| 350 |
+
"normalized": false,
|
| 351 |
+
"rstrip": false,
|
| 352 |
+
"single_word": false,
|
| 353 |
+
"special": true
|
| 354 |
+
},
|
| 355 |
+
"128044": {
|
| 356 |
+
"content": "<|reserved_special_token_36|>",
|
| 357 |
+
"lstrip": false,
|
| 358 |
+
"normalized": false,
|
| 359 |
+
"rstrip": false,
|
| 360 |
+
"single_word": false,
|
| 361 |
+
"special": true
|
| 362 |
+
},
|
| 363 |
+
"128045": {
|
| 364 |
+
"content": "<|reserved_special_token_37|>",
|
| 365 |
+
"lstrip": false,
|
| 366 |
+
"normalized": false,
|
| 367 |
+
"rstrip": false,
|
| 368 |
+
"single_word": false,
|
| 369 |
+
"special": true
|
| 370 |
+
},
|
| 371 |
+
"128046": {
|
| 372 |
+
"content": "<|reserved_special_token_38|>",
|
| 373 |
+
"lstrip": false,
|
| 374 |
+
"normalized": false,
|
| 375 |
+
"rstrip": false,
|
| 376 |
+
"single_word": false,
|
| 377 |
+
"special": true
|
| 378 |
+
},
|
| 379 |
+
"128047": {
|
| 380 |
+
"content": "<|reserved_special_token_39|>",
|
| 381 |
+
"lstrip": false,
|
| 382 |
+
"normalized": false,
|
| 383 |
+
"rstrip": false,
|
| 384 |
+
"single_word": false,
|
| 385 |
+
"special": true
|
| 386 |
+
},
|
| 387 |
+
"128048": {
|
| 388 |
+
"content": "<|reserved_special_token_40|>",
|
| 389 |
+
"lstrip": false,
|
| 390 |
+
"normalized": false,
|
| 391 |
+
"rstrip": false,
|
| 392 |
+
"single_word": false,
|
| 393 |
+
"special": true
|
| 394 |
+
},
|
| 395 |
+
"128049": {
|
| 396 |
+
"content": "<|reserved_special_token_41|>",
|
| 397 |
+
"lstrip": false,
|
| 398 |
+
"normalized": false,
|
| 399 |
+
"rstrip": false,
|
| 400 |
+
"single_word": false,
|
| 401 |
+
"special": true
|
| 402 |
+
},
|
| 403 |
+
"128050": {
|
| 404 |
+
"content": "<|reserved_special_token_42|>",
|
| 405 |
+
"lstrip": false,
|
| 406 |
+
"normalized": false,
|
| 407 |
+
"rstrip": false,
|
| 408 |
+
"single_word": false,
|
| 409 |
+
"special": true
|
| 410 |
+
},
|
| 411 |
+
"128051": {
|
| 412 |
+
"content": "<|reserved_special_token_43|>",
|
| 413 |
+
"lstrip": false,
|
| 414 |
+
"normalized": false,
|
| 415 |
+
"rstrip": false,
|
| 416 |
+
"single_word": false,
|
| 417 |
+
"special": true
|
| 418 |
+
},
|
| 419 |
+
"128052": {
|
| 420 |
+
"content": "<|reserved_special_token_44|>",
|
| 421 |
+
"lstrip": false,
|
| 422 |
+
"normalized": false,
|
| 423 |
+
"rstrip": false,
|
| 424 |
+
"single_word": false,
|
| 425 |
+
"special": true
|
| 426 |
+
},
|
| 427 |
+
"128053": {
|
| 428 |
+
"content": "<|reserved_special_token_45|>",
|
| 429 |
+
"lstrip": false,
|
| 430 |
+
"normalized": false,
|
| 431 |
+
"rstrip": false,
|
| 432 |
+
"single_word": false,
|
| 433 |
+
"special": true
|
| 434 |
+
},
|
| 435 |
+
"128054": {
|
| 436 |
+
"content": "<|reserved_special_token_46|>",
|
| 437 |
+
"lstrip": false,
|
| 438 |
+
"normalized": false,
|
| 439 |
+
"rstrip": false,
|
| 440 |
+
"single_word": false,
|
| 441 |
+
"special": true
|
| 442 |
+
},
|
| 443 |
+
"128055": {
|
| 444 |
+
"content": "<|reserved_special_token_47|>",
|
| 445 |
+
"lstrip": false,
|
| 446 |
+
"normalized": false,
|
| 447 |
+
"rstrip": false,
|
| 448 |
+
"single_word": false,
|
| 449 |
+
"special": true
|
| 450 |
+
},
|
| 451 |
+
"128056": {
|
| 452 |
+
"content": "<|reserved_special_token_48|>",
|
| 453 |
+
"lstrip": false,
|
| 454 |
+
"normalized": false,
|
| 455 |
+
"rstrip": false,
|
| 456 |
+
"single_word": false,
|
| 457 |
+
"special": true
|
| 458 |
+
},
|
| 459 |
+
"128057": {
|
| 460 |
+
"content": "<|reserved_special_token_49|>",
|
| 461 |
+
"lstrip": false,
|
| 462 |
+
"normalized": false,
|
| 463 |
+
"rstrip": false,
|
| 464 |
+
"single_word": false,
|
| 465 |
+
"special": true
|
| 466 |
+
},
|
| 467 |
+
"128058": {
|
| 468 |
+
"content": "<|reserved_special_token_50|>",
|
| 469 |
+
"lstrip": false,
|
| 470 |
+
"normalized": false,
|
| 471 |
+
"rstrip": false,
|
| 472 |
+
"single_word": false,
|
| 473 |
+
"special": true
|
| 474 |
+
},
|
| 475 |
+
"128059": {
|
| 476 |
+
"content": "<|reserved_special_token_51|>",
|
| 477 |
+
"lstrip": false,
|
| 478 |
+
"normalized": false,
|
| 479 |
+
"rstrip": false,
|
| 480 |
+
"single_word": false,
|
| 481 |
+
"special": true
|
| 482 |
+
},
|
| 483 |
+
"128060": {
|
| 484 |
+
"content": "<|reserved_special_token_52|>",
|
| 485 |
+
"lstrip": false,
|
| 486 |
+
"normalized": false,
|
| 487 |
+
"rstrip": false,
|
| 488 |
+
"single_word": false,
|
| 489 |
+
"special": true
|
| 490 |
+
},
|
| 491 |
+
"128061": {
|
| 492 |
+
"content": "<|reserved_special_token_53|>",
|
| 493 |
+
"lstrip": false,
|
| 494 |
+
"normalized": false,
|
| 495 |
+
"rstrip": false,
|
| 496 |
+
"single_word": false,
|
| 497 |
+
"special": true
|
| 498 |
+
},
|
| 499 |
+
"128062": {
|
| 500 |
+
"content": "<|reserved_special_token_54|>",
|
| 501 |
+
"lstrip": false,
|
| 502 |
+
"normalized": false,
|
| 503 |
+
"rstrip": false,
|
| 504 |
+
"single_word": false,
|
| 505 |
+
"special": true
|
| 506 |
+
},
|
| 507 |
+
"128063": {
|
| 508 |
+
"content": "<|reserved_special_token_55|>",
|
| 509 |
+
"lstrip": false,
|
| 510 |
+
"normalized": false,
|
| 511 |
+
"rstrip": false,
|
| 512 |
+
"single_word": false,
|
| 513 |
+
"special": true
|
| 514 |
+
},
|
| 515 |
+
"128064": {
|
| 516 |
+
"content": "<|reserved_special_token_56|>",
|
| 517 |
+
"lstrip": false,
|
| 518 |
+
"normalized": false,
|
| 519 |
+
"rstrip": false,
|
| 520 |
+
"single_word": false,
|
| 521 |
+
"special": true
|
| 522 |
+
},
|
| 523 |
+
"128065": {
|
| 524 |
+
"content": "<|reserved_special_token_57|>",
|
| 525 |
+
"lstrip": false,
|
| 526 |
+
"normalized": false,
|
| 527 |
+
"rstrip": false,
|
| 528 |
+
"single_word": false,
|
| 529 |
+
"special": true
|
| 530 |
+
},
|
| 531 |
+
"128066": {
|
| 532 |
+
"content": "<|reserved_special_token_58|>",
|
| 533 |
+
"lstrip": false,
|
| 534 |
+
"normalized": false,
|
| 535 |
+
"rstrip": false,
|
| 536 |
+
"single_word": false,
|
| 537 |
+
"special": true
|
| 538 |
+
},
|
| 539 |
+
"128067": {
|
| 540 |
+
"content": "<|reserved_special_token_59|>",
|
| 541 |
+
"lstrip": false,
|
| 542 |
+
"normalized": false,
|
| 543 |
+
"rstrip": false,
|
| 544 |
+
"single_word": false,
|
| 545 |
+
"special": true
|
| 546 |
+
},
|
| 547 |
+
"128068": {
|
| 548 |
+
"content": "<|reserved_special_token_60|>",
|
| 549 |
+
"lstrip": false,
|
| 550 |
+
"normalized": false,
|
| 551 |
+
"rstrip": false,
|
| 552 |
+
"single_word": false,
|
| 553 |
+
"special": true
|
| 554 |
+
},
|
| 555 |
+
"128069": {
|
| 556 |
+
"content": "<|reserved_special_token_61|>",
|
| 557 |
+
"lstrip": false,
|
| 558 |
+
"normalized": false,
|
| 559 |
+
"rstrip": false,
|
| 560 |
+
"single_word": false,
|
| 561 |
+
"special": true
|
| 562 |
+
},
|
| 563 |
+
"128070": {
|
| 564 |
+
"content": "<|reserved_special_token_62|>",
|
| 565 |
+
"lstrip": false,
|
| 566 |
+
"normalized": false,
|
| 567 |
+
"rstrip": false,
|
| 568 |
+
"single_word": false,
|
| 569 |
+
"special": true
|
| 570 |
+
},
|
| 571 |
+
"128071": {
|
| 572 |
+
"content": "<|reserved_special_token_63|>",
|
| 573 |
+
"lstrip": false,
|
| 574 |
+
"normalized": false,
|
| 575 |
+
"rstrip": false,
|
| 576 |
+
"single_word": false,
|
| 577 |
+
"special": true
|
| 578 |
+
},
|
| 579 |
+
"128072": {
|
| 580 |
+
"content": "<|reserved_special_token_64|>",
|
| 581 |
+
"lstrip": false,
|
| 582 |
+
"normalized": false,
|
| 583 |
+
"rstrip": false,
|
| 584 |
+
"single_word": false,
|
| 585 |
+
"special": true
|
| 586 |
+
},
|
| 587 |
+
"128073": {
|
| 588 |
+
"content": "<|reserved_special_token_65|>",
|
| 589 |
+
"lstrip": false,
|
| 590 |
+
"normalized": false,
|
| 591 |
+
"rstrip": false,
|
| 592 |
+
"single_word": false,
|
| 593 |
+
"special": true
|
| 594 |
+
},
|
| 595 |
+
"128074": {
|
| 596 |
+
"content": "<|reserved_special_token_66|>",
|
| 597 |
+
"lstrip": false,
|
| 598 |
+
"normalized": false,
|
| 599 |
+
"rstrip": false,
|
| 600 |
+
"single_word": false,
|
| 601 |
+
"special": true
|
| 602 |
+
},
|
| 603 |
+
"128075": {
|
| 604 |
+
"content": "<|reserved_special_token_67|>",
|
| 605 |
+
"lstrip": false,
|
| 606 |
+
"normalized": false,
|
| 607 |
+
"rstrip": false,
|
| 608 |
+
"single_word": false,
|
| 609 |
+
"special": true
|
| 610 |
+
},
|
| 611 |
+
"128076": {
|
| 612 |
+
"content": "<|reserved_special_token_68|>",
|
| 613 |
+
"lstrip": false,
|
| 614 |
+
"normalized": false,
|
| 615 |
+
"rstrip": false,
|
| 616 |
+
"single_word": false,
|
| 617 |
+
"special": true
|
| 618 |
+
},
|
| 619 |
+
"128077": {
|
| 620 |
+
"content": "<|reserved_special_token_69|>",
|
| 621 |
+
"lstrip": false,
|
| 622 |
+
"normalized": false,
|
| 623 |
+
"rstrip": false,
|
| 624 |
+
"single_word": false,
|
| 625 |
+
"special": true
|
| 626 |
+
},
|
| 627 |
+
"128078": {
|
| 628 |
+
"content": "<|reserved_special_token_70|>",
|
| 629 |
+
"lstrip": false,
|
| 630 |
+
"normalized": false,
|
| 631 |
+
"rstrip": false,
|
| 632 |
+
"single_word": false,
|
| 633 |
+
"special": true
|
| 634 |
+
},
|
| 635 |
+
"128079": {
|
| 636 |
+
"content": "<|reserved_special_token_71|>",
|
| 637 |
+
"lstrip": false,
|
| 638 |
+
"normalized": false,
|
| 639 |
+
"rstrip": false,
|
| 640 |
+
"single_word": false,
|
| 641 |
+
"special": true
|
| 642 |
+
},
|
| 643 |
+
"128080": {
|
| 644 |
+
"content": "<|reserved_special_token_72|>",
|
| 645 |
+
"lstrip": false,
|
| 646 |
+
"normalized": false,
|
| 647 |
+
"rstrip": false,
|
| 648 |
+
"single_word": false,
|
| 649 |
+
"special": true
|
| 650 |
+
},
|
| 651 |
+
"128081": {
|
| 652 |
+
"content": "<|reserved_special_token_73|>",
|
| 653 |
+
"lstrip": false,
|
| 654 |
+
"normalized": false,
|
| 655 |
+
"rstrip": false,
|
| 656 |
+
"single_word": false,
|
| 657 |
+
"special": true
|
| 658 |
+
},
|
| 659 |
+
"128082": {
|
| 660 |
+
"content": "<|reserved_special_token_74|>",
|
| 661 |
+
"lstrip": false,
|
| 662 |
+
"normalized": false,
|
| 663 |
+
"rstrip": false,
|
| 664 |
+
"single_word": false,
|
| 665 |
+
"special": true
|
| 666 |
+
},
|
| 667 |
+
"128083": {
|
| 668 |
+
"content": "<|reserved_special_token_75|>",
|
| 669 |
+
"lstrip": false,
|
| 670 |
+
"normalized": false,
|
| 671 |
+
"rstrip": false,
|
| 672 |
+
"single_word": false,
|
| 673 |
+
"special": true
|
| 674 |
+
},
|
| 675 |
+
"128084": {
|
| 676 |
+
"content": "<|reserved_special_token_76|>",
|
| 677 |
+
"lstrip": false,
|
| 678 |
+
"normalized": false,
|
| 679 |
+
"rstrip": false,
|
| 680 |
+
"single_word": false,
|
| 681 |
+
"special": true
|
| 682 |
+
},
|
| 683 |
+
"128085": {
|
| 684 |
+
"content": "<|reserved_special_token_77|>",
|
| 685 |
+
"lstrip": false,
|
| 686 |
+
"normalized": false,
|
| 687 |
+
"rstrip": false,
|
| 688 |
+
"single_word": false,
|
| 689 |
+
"special": true
|
| 690 |
+
},
|
| 691 |
+
"128086": {
|
| 692 |
+
"content": "<|reserved_special_token_78|>",
|
| 693 |
+
"lstrip": false,
|
| 694 |
+
"normalized": false,
|
| 695 |
+
"rstrip": false,
|
| 696 |
+
"single_word": false,
|
| 697 |
+
"special": true
|
| 698 |
+
},
|
| 699 |
+
"128087": {
|
| 700 |
+
"content": "<|reserved_special_token_79|>",
|
| 701 |
+
"lstrip": false,
|
| 702 |
+
"normalized": false,
|
| 703 |
+
"rstrip": false,
|
| 704 |
+
"single_word": false,
|
| 705 |
+
"special": true
|
| 706 |
+
},
|
| 707 |
+
"128088": {
|
| 708 |
+
"content": "<|reserved_special_token_80|>",
|
| 709 |
+
"lstrip": false,
|
| 710 |
+
"normalized": false,
|
| 711 |
+
"rstrip": false,
|
| 712 |
+
"single_word": false,
|
| 713 |
+
"special": true
|
| 714 |
+
},
|
| 715 |
+
"128089": {
|
| 716 |
+
"content": "<|reserved_special_token_81|>",
|
| 717 |
+
"lstrip": false,
|
| 718 |
+
"normalized": false,
|
| 719 |
+
"rstrip": false,
|
| 720 |
+
"single_word": false,
|
| 721 |
+
"special": true
|
| 722 |
+
},
|
| 723 |
+
"128090": {
|
| 724 |
+
"content": "<|reserved_special_token_82|>",
|
| 725 |
+
"lstrip": false,
|
| 726 |
+
"normalized": false,
|
| 727 |
+
"rstrip": false,
|
| 728 |
+
"single_word": false,
|
| 729 |
+
"special": true
|
| 730 |
+
},
|
| 731 |
+
"128091": {
|
| 732 |
+
"content": "<|reserved_special_token_83|>",
|
| 733 |
+
"lstrip": false,
|
| 734 |
+
"normalized": false,
|
| 735 |
+
"rstrip": false,
|
| 736 |
+
"single_word": false,
|
| 737 |
+
"special": true
|
| 738 |
+
},
|
| 739 |
+
"128092": {
|
| 740 |
+
"content": "<|reserved_special_token_84|>",
|
| 741 |
+
"lstrip": false,
|
| 742 |
+
"normalized": false,
|
| 743 |
+
"rstrip": false,
|
| 744 |
+
"single_word": false,
|
| 745 |
+
"special": true
|
| 746 |
+
},
|
| 747 |
+
"128093": {
|
| 748 |
+
"content": "<|reserved_special_token_85|>",
|
| 749 |
+
"lstrip": false,
|
| 750 |
+
"normalized": false,
|
| 751 |
+
"rstrip": false,
|
| 752 |
+
"single_word": false,
|
| 753 |
+
"special": true
|
| 754 |
+
},
|
| 755 |
+
"128094": {
|
| 756 |
+
"content": "<|reserved_special_token_86|>",
|
| 757 |
+
"lstrip": false,
|
| 758 |
+
"normalized": false,
|
| 759 |
+
"rstrip": false,
|
| 760 |
+
"single_word": false,
|
| 761 |
+
"special": true
|
| 762 |
+
},
|
| 763 |
+
"128095": {
|
| 764 |
+
"content": "<|reserved_special_token_87|>",
|
| 765 |
+
"lstrip": false,
|
| 766 |
+
"normalized": false,
|
| 767 |
+
"rstrip": false,
|
| 768 |
+
"single_word": false,
|
| 769 |
+
"special": true
|
| 770 |
+
},
|
| 771 |
+
"128096": {
|
| 772 |
+
"content": "<|reserved_special_token_88|>",
|
| 773 |
+
"lstrip": false,
|
| 774 |
+
"normalized": false,
|
| 775 |
+
"rstrip": false,
|
| 776 |
+
"single_word": false,
|
| 777 |
+
"special": true
|
| 778 |
+
},
|
| 779 |
+
"128097": {
|
| 780 |
+
"content": "<|reserved_special_token_89|>",
|
| 781 |
+
"lstrip": false,
|
| 782 |
+
"normalized": false,
|
| 783 |
+
"rstrip": false,
|
| 784 |
+
"single_word": false,
|
| 785 |
+
"special": true
|
| 786 |
+
},
|
| 787 |
+
"128098": {
|
| 788 |
+
"content": "<|reserved_special_token_90|>",
|
| 789 |
+
"lstrip": false,
|
| 790 |
+
"normalized": false,
|
| 791 |
+
"rstrip": false,
|
| 792 |
+
"single_word": false,
|
| 793 |
+
"special": true
|
| 794 |
+
},
|
| 795 |
+
"128099": {
|
| 796 |
+
"content": "<|reserved_special_token_91|>",
|
| 797 |
+
"lstrip": false,
|
| 798 |
+
"normalized": false,
|
| 799 |
+
"rstrip": false,
|
| 800 |
+
"single_word": false,
|
| 801 |
+
"special": true
|
| 802 |
+
},
|
| 803 |
+
"128100": {
|
| 804 |
+
"content": "<|reserved_special_token_92|>",
|
| 805 |
+
"lstrip": false,
|
| 806 |
+
"normalized": false,
|
| 807 |
+
"rstrip": false,
|
| 808 |
+
"single_word": false,
|
| 809 |
+
"special": true
|
| 810 |
+
},
|
| 811 |
+
"128101": {
|
| 812 |
+
"content": "<|reserved_special_token_93|>",
|
| 813 |
+
"lstrip": false,
|
| 814 |
+
"normalized": false,
|
| 815 |
+
"rstrip": false,
|
| 816 |
+
"single_word": false,
|
| 817 |
+
"special": true
|
| 818 |
+
},
|
| 819 |
+
"128102": {
|
| 820 |
+
"content": "<|reserved_special_token_94|>",
|
| 821 |
+
"lstrip": false,
|
| 822 |
+
"normalized": false,
|
| 823 |
+
"rstrip": false,
|
| 824 |
+
"single_word": false,
|
| 825 |
+
"special": true
|
| 826 |
+
},
|
| 827 |
+
"128103": {
|
| 828 |
+
"content": "<|reserved_special_token_95|>",
|
| 829 |
+
"lstrip": false,
|
| 830 |
+
"normalized": false,
|
| 831 |
+
"rstrip": false,
|
| 832 |
+
"single_word": false,
|
| 833 |
+
"special": true
|
| 834 |
+
},
|
| 835 |
+
"128104": {
|
| 836 |
+
"content": "<|reserved_special_token_96|>",
|
| 837 |
+
"lstrip": false,
|
| 838 |
+
"normalized": false,
|
| 839 |
+
"rstrip": false,
|
| 840 |
+
"single_word": false,
|
| 841 |
+
"special": true
|
| 842 |
+
},
|
| 843 |
+
"128105": {
|
| 844 |
+
"content": "<|reserved_special_token_97|>",
|
| 845 |
+
"lstrip": false,
|
| 846 |
+
"normalized": false,
|
| 847 |
+
"rstrip": false,
|
| 848 |
+
"single_word": false,
|
| 849 |
+
"special": true
|
| 850 |
+
},
|
| 851 |
+
"128106": {
|
| 852 |
+
"content": "<|reserved_special_token_98|>",
|
| 853 |
+
"lstrip": false,
|
| 854 |
+
"normalized": false,
|
| 855 |
+
"rstrip": false,
|
| 856 |
+
"single_word": false,
|
| 857 |
+
"special": true
|
| 858 |
+
},
|
| 859 |
+
"128107": {
|
| 860 |
+
"content": "<|reserved_special_token_99|>",
|
| 861 |
+
"lstrip": false,
|
| 862 |
+
"normalized": false,
|
| 863 |
+
"rstrip": false,
|
| 864 |
+
"single_word": false,
|
| 865 |
+
"special": true
|
| 866 |
+
},
|
| 867 |
+
"128108": {
|
| 868 |
+
"content": "<|reserved_special_token_100|>",
|
| 869 |
+
"lstrip": false,
|
| 870 |
+
"normalized": false,
|
| 871 |
+
"rstrip": false,
|
| 872 |
+
"single_word": false,
|
| 873 |
+
"special": true
|
| 874 |
+
},
|
| 875 |
+
"128109": {
|
| 876 |
+
"content": "<|reserved_special_token_101|>",
|
| 877 |
+
"lstrip": false,
|
| 878 |
+
"normalized": false,
|
| 879 |
+
"rstrip": false,
|
| 880 |
+
"single_word": false,
|
| 881 |
+
"special": true
|
| 882 |
+
},
|
| 883 |
+
"128110": {
|
| 884 |
+
"content": "<|reserved_special_token_102|>",
|
| 885 |
+
"lstrip": false,
|
| 886 |
+
"normalized": false,
|
| 887 |
+
"rstrip": false,
|
| 888 |
+
"single_word": false,
|
| 889 |
+
"special": true
|
| 890 |
+
},
|
| 891 |
+
"128111": {
|
| 892 |
+
"content": "<|reserved_special_token_103|>",
|
| 893 |
+
"lstrip": false,
|
| 894 |
+
"normalized": false,
|
| 895 |
+
"rstrip": false,
|
| 896 |
+
"single_word": false,
|
| 897 |
+
"special": true
|
| 898 |
+
},
|
| 899 |
+
"128112": {
|
| 900 |
+
"content": "<|reserved_special_token_104|>",
|
| 901 |
+
"lstrip": false,
|
| 902 |
+
"normalized": false,
|
| 903 |
+
"rstrip": false,
|
| 904 |
+
"single_word": false,
|
| 905 |
+
"special": true
|
| 906 |
+
},
|
| 907 |
+
"128113": {
|
| 908 |
+
"content": "<|reserved_special_token_105|>",
|
| 909 |
+
"lstrip": false,
|
| 910 |
+
"normalized": false,
|
| 911 |
+
"rstrip": false,
|
| 912 |
+
"single_word": false,
|
| 913 |
+
"special": true
|
| 914 |
+
},
|
| 915 |
+
"128114": {
|
| 916 |
+
"content": "<|reserved_special_token_106|>",
|
| 917 |
+
"lstrip": false,
|
| 918 |
+
"normalized": false,
|
| 919 |
+
"rstrip": false,
|
| 920 |
+
"single_word": false,
|
| 921 |
+
"special": true
|
| 922 |
+
},
|
| 923 |
+
"128115": {
|
| 924 |
+
"content": "<|reserved_special_token_107|>",
|
| 925 |
+
"lstrip": false,
|
| 926 |
+
"normalized": false,
|
| 927 |
+
"rstrip": false,
|
| 928 |
+
"single_word": false,
|
| 929 |
+
"special": true
|
| 930 |
+
},
|
| 931 |
+
"128116": {
|
| 932 |
+
"content": "<|reserved_special_token_108|>",
|
| 933 |
+
"lstrip": false,
|
| 934 |
+
"normalized": false,
|
| 935 |
+
"rstrip": false,
|
| 936 |
+
"single_word": false,
|
| 937 |
+
"special": true
|
| 938 |
+
},
|
| 939 |
+
"128117": {
|
| 940 |
+
"content": "<|reserved_special_token_109|>",
|
| 941 |
+
"lstrip": false,
|
| 942 |
+
"normalized": false,
|
| 943 |
+
"rstrip": false,
|
| 944 |
+
"single_word": false,
|
| 945 |
+
"special": true
|
| 946 |
+
},
|
| 947 |
+
"128118": {
|
| 948 |
+
"content": "<|reserved_special_token_110|>",
|
| 949 |
+
"lstrip": false,
|
| 950 |
+
"normalized": false,
|
| 951 |
+
"rstrip": false,
|
| 952 |
+
"single_word": false,
|
| 953 |
+
"special": true
|
| 954 |
+
},
|
| 955 |
+
"128119": {
|
| 956 |
+
"content": "<|reserved_special_token_111|>",
|
| 957 |
+
"lstrip": false,
|
| 958 |
+
"normalized": false,
|
| 959 |
+
"rstrip": false,
|
| 960 |
+
"single_word": false,
|
| 961 |
+
"special": true
|
| 962 |
+
},
|
| 963 |
+
"128120": {
|
| 964 |
+
"content": "<|reserved_special_token_112|>",
|
| 965 |
+
"lstrip": false,
|
| 966 |
+
"normalized": false,
|
| 967 |
+
"rstrip": false,
|
| 968 |
+
"single_word": false,
|
| 969 |
+
"special": true
|
| 970 |
+
},
|
| 971 |
+
"128121": {
|
| 972 |
+
"content": "<|reserved_special_token_113|>",
|
| 973 |
+
"lstrip": false,
|
| 974 |
+
"normalized": false,
|
| 975 |
+
"rstrip": false,
|
| 976 |
+
"single_word": false,
|
| 977 |
+
"special": true
|
| 978 |
+
},
|
| 979 |
+
"128122": {
|
| 980 |
+
"content": "<|reserved_special_token_114|>",
|
| 981 |
+
"lstrip": false,
|
| 982 |
+
"normalized": false,
|
| 983 |
+
"rstrip": false,
|
| 984 |
+
"single_word": false,
|
| 985 |
+
"special": true
|
| 986 |
+
},
|
| 987 |
+
"128123": {
|
| 988 |
+
"content": "<|reserved_special_token_115|>",
|
| 989 |
+
"lstrip": false,
|
| 990 |
+
"normalized": false,
|
| 991 |
+
"rstrip": false,
|
| 992 |
+
"single_word": false,
|
| 993 |
+
"special": true
|
| 994 |
+
},
|
| 995 |
+
"128124": {
|
| 996 |
+
"content": "<|reserved_special_token_116|>",
|
| 997 |
+
"lstrip": false,
|
| 998 |
+
"normalized": false,
|
| 999 |
+
"rstrip": false,
|
| 1000 |
+
"single_word": false,
|
| 1001 |
+
"special": true
|
| 1002 |
+
},
|
| 1003 |
+
"128125": {
|
| 1004 |
+
"content": "<|reserved_special_token_117|>",
|
| 1005 |
+
"lstrip": false,
|
| 1006 |
+
"normalized": false,
|
| 1007 |
+
"rstrip": false,
|
| 1008 |
+
"single_word": false,
|
| 1009 |
+
"special": true
|
| 1010 |
+
},
|
| 1011 |
+
"128126": {
|
| 1012 |
+
"content": "<|reserved_special_token_118|>",
|
| 1013 |
+
"lstrip": false,
|
| 1014 |
+
"normalized": false,
|
| 1015 |
+
"rstrip": false,
|
| 1016 |
+
"single_word": false,
|
| 1017 |
+
"special": true
|
| 1018 |
+
},
|
| 1019 |
+
"128127": {
|
| 1020 |
+
"content": "<|reserved_special_token_119|>",
|
| 1021 |
+
"lstrip": false,
|
| 1022 |
+
"normalized": false,
|
| 1023 |
+
"rstrip": false,
|
| 1024 |
+
"single_word": false,
|
| 1025 |
+
"special": true
|
| 1026 |
+
},
|
| 1027 |
+
"128128": {
|
| 1028 |
+
"content": "<|reserved_special_token_120|>",
|
| 1029 |
+
"lstrip": false,
|
| 1030 |
+
"normalized": false,
|
| 1031 |
+
"rstrip": false,
|
| 1032 |
+
"single_word": false,
|
| 1033 |
+
"special": true
|
| 1034 |
+
},
|
| 1035 |
+
"128129": {
|
| 1036 |
+
"content": "<|reserved_special_token_121|>",
|
| 1037 |
+
"lstrip": false,
|
| 1038 |
+
"normalized": false,
|
| 1039 |
+
"rstrip": false,
|
| 1040 |
+
"single_word": false,
|
| 1041 |
+
"special": true
|
| 1042 |
+
},
|
| 1043 |
+
"128130": {
|
| 1044 |
+
"content": "<|reserved_special_token_122|>",
|
| 1045 |
+
"lstrip": false,
|
| 1046 |
+
"normalized": false,
|
| 1047 |
+
"rstrip": false,
|
| 1048 |
+
"single_word": false,
|
| 1049 |
+
"special": true
|
| 1050 |
+
},
|
| 1051 |
+
"128131": {
|
| 1052 |
+
"content": "<|reserved_special_token_123|>",
|
| 1053 |
+
"lstrip": false,
|
| 1054 |
+
"normalized": false,
|
| 1055 |
+
"rstrip": false,
|
| 1056 |
+
"single_word": false,
|
| 1057 |
+
"special": true
|
| 1058 |
+
},
|
| 1059 |
+
"128132": {
|
| 1060 |
+
"content": "<|reserved_special_token_124|>",
|
| 1061 |
+
"lstrip": false,
|
| 1062 |
+
"normalized": false,
|
| 1063 |
+
"rstrip": false,
|
| 1064 |
+
"single_word": false,
|
| 1065 |
+
"special": true
|
| 1066 |
+
},
|
| 1067 |
+
"128133": {
|
| 1068 |
+
"content": "<|reserved_special_token_125|>",
|
| 1069 |
+
"lstrip": false,
|
| 1070 |
+
"normalized": false,
|
| 1071 |
+
"rstrip": false,
|
| 1072 |
+
"single_word": false,
|
| 1073 |
+
"special": true
|
| 1074 |
+
},
|
| 1075 |
+
"128134": {
|
| 1076 |
+
"content": "<|reserved_special_token_126|>",
|
| 1077 |
+
"lstrip": false,
|
| 1078 |
+
"normalized": false,
|
| 1079 |
+
"rstrip": false,
|
| 1080 |
+
"single_word": false,
|
| 1081 |
+
"special": true
|
| 1082 |
+
},
|
| 1083 |
+
"128135": {
|
| 1084 |
+
"content": "<|reserved_special_token_127|>",
|
| 1085 |
+
"lstrip": false,
|
| 1086 |
+
"normalized": false,
|
| 1087 |
+
"rstrip": false,
|
| 1088 |
+
"single_word": false,
|
| 1089 |
+
"special": true
|
| 1090 |
+
},
|
| 1091 |
+
"128136": {
|
| 1092 |
+
"content": "<|reserved_special_token_128|>",
|
| 1093 |
+
"lstrip": false,
|
| 1094 |
+
"normalized": false,
|
| 1095 |
+
"rstrip": false,
|
| 1096 |
+
"single_word": false,
|
| 1097 |
+
"special": true
|
| 1098 |
+
},
|
| 1099 |
+
"128137": {
|
| 1100 |
+
"content": "<|reserved_special_token_129|>",
|
| 1101 |
+
"lstrip": false,
|
| 1102 |
+
"normalized": false,
|
| 1103 |
+
"rstrip": false,
|
| 1104 |
+
"single_word": false,
|
| 1105 |
+
"special": true
|
| 1106 |
+
},
|
| 1107 |
+
"128138": {
|
| 1108 |
+
"content": "<|reserved_special_token_130|>",
|
| 1109 |
+
"lstrip": false,
|
| 1110 |
+
"normalized": false,
|
| 1111 |
+
"rstrip": false,
|
| 1112 |
+
"single_word": false,
|
| 1113 |
+
"special": true
|
| 1114 |
+
},
|
| 1115 |
+
"128139": {
|
| 1116 |
+
"content": "<|reserved_special_token_131|>",
|
| 1117 |
+
"lstrip": false,
|
| 1118 |
+
"normalized": false,
|
| 1119 |
+
"rstrip": false,
|
| 1120 |
+
"single_word": false,
|
| 1121 |
+
"special": true
|
| 1122 |
+
},
|
| 1123 |
+
"128140": {
|
| 1124 |
+
"content": "<|reserved_special_token_132|>",
|
| 1125 |
+
"lstrip": false,
|
| 1126 |
+
"normalized": false,
|
| 1127 |
+
"rstrip": false,
|
| 1128 |
+
"single_word": false,
|
| 1129 |
+
"special": true
|
| 1130 |
+
},
|
| 1131 |
+
"128141": {
|
| 1132 |
+
"content": "<|reserved_special_token_133|>",
|
| 1133 |
+
"lstrip": false,
|
| 1134 |
+
"normalized": false,
|
| 1135 |
+
"rstrip": false,
|
| 1136 |
+
"single_word": false,
|
| 1137 |
+
"special": true
|
| 1138 |
+
},
|
| 1139 |
+
"128142": {
|
| 1140 |
+
"content": "<|reserved_special_token_134|>",
|
| 1141 |
+
"lstrip": false,
|
| 1142 |
+
"normalized": false,
|
| 1143 |
+
"rstrip": false,
|
| 1144 |
+
"single_word": false,
|
| 1145 |
+
"special": true
|
| 1146 |
+
},
|
| 1147 |
+
"128143": {
|
| 1148 |
+
"content": "<|reserved_special_token_135|>",
|
| 1149 |
+
"lstrip": false,
|
| 1150 |
+
"normalized": false,
|
| 1151 |
+
"rstrip": false,
|
| 1152 |
+
"single_word": false,
|
| 1153 |
+
"special": true
|
| 1154 |
+
},
|
| 1155 |
+
"128144": {
|
| 1156 |
+
"content": "<|reserved_special_token_136|>",
|
| 1157 |
+
"lstrip": false,
|
| 1158 |
+
"normalized": false,
|
| 1159 |
+
"rstrip": false,
|
| 1160 |
+
"single_word": false,
|
| 1161 |
+
"special": true
|
| 1162 |
+
},
|
| 1163 |
+
"128145": {
|
| 1164 |
+
"content": "<|reserved_special_token_137|>",
|
| 1165 |
+
"lstrip": false,
|
| 1166 |
+
"normalized": false,
|
| 1167 |
+
"rstrip": false,
|
| 1168 |
+
"single_word": false,
|
| 1169 |
+
"special": true
|
| 1170 |
+
},
|
| 1171 |
+
"128146": {
|
| 1172 |
+
"content": "<|reserved_special_token_138|>",
|
| 1173 |
+
"lstrip": false,
|
| 1174 |
+
"normalized": false,
|
| 1175 |
+
"rstrip": false,
|
| 1176 |
+
"single_word": false,
|
| 1177 |
+
"special": true
|
| 1178 |
+
},
|
| 1179 |
+
"128147": {
|
| 1180 |
+
"content": "<|reserved_special_token_139|>",
|
| 1181 |
+
"lstrip": false,
|
| 1182 |
+
"normalized": false,
|
| 1183 |
+
"rstrip": false,
|
| 1184 |
+
"single_word": false,
|
| 1185 |
+
"special": true
|
| 1186 |
+
},
|
| 1187 |
+
"128148": {
|
| 1188 |
+
"content": "<|reserved_special_token_140|>",
|
| 1189 |
+
"lstrip": false,
|
| 1190 |
+
"normalized": false,
|
| 1191 |
+
"rstrip": false,
|
| 1192 |
+
"single_word": false,
|
| 1193 |
+
"special": true
|
| 1194 |
+
},
|
| 1195 |
+
"128149": {
|
| 1196 |
+
"content": "<|reserved_special_token_141|>",
|
| 1197 |
+
"lstrip": false,
|
| 1198 |
+
"normalized": false,
|
| 1199 |
+
"rstrip": false,
|
| 1200 |
+
"single_word": false,
|
| 1201 |
+
"special": true
|
| 1202 |
+
},
|
| 1203 |
+
"128150": {
|
| 1204 |
+
"content": "<|reserved_special_token_142|>",
|
| 1205 |
+
"lstrip": false,
|
| 1206 |
+
"normalized": false,
|
| 1207 |
+
"rstrip": false,
|
| 1208 |
+
"single_word": false,
|
| 1209 |
+
"special": true
|
| 1210 |
+
},
|
| 1211 |
+
"128151": {
|
| 1212 |
+
"content": "<|reserved_special_token_143|>",
|
| 1213 |
+
"lstrip": false,
|
| 1214 |
+
"normalized": false,
|
| 1215 |
+
"rstrip": false,
|
| 1216 |
+
"single_word": false,
|
| 1217 |
+
"special": true
|
| 1218 |
+
},
|
| 1219 |
+
"128152": {
|
| 1220 |
+
"content": "<|reserved_special_token_144|>",
|
| 1221 |
+
"lstrip": false,
|
| 1222 |
+
"normalized": false,
|
| 1223 |
+
"rstrip": false,
|
| 1224 |
+
"single_word": false,
|
| 1225 |
+
"special": true
|
| 1226 |
+
},
|
| 1227 |
+
"128153": {
|
| 1228 |
+
"content": "<|reserved_special_token_145|>",
|
| 1229 |
+
"lstrip": false,
|
| 1230 |
+
"normalized": false,
|
| 1231 |
+
"rstrip": false,
|
| 1232 |
+
"single_word": false,
|
| 1233 |
+
"special": true
|
| 1234 |
+
},
|
| 1235 |
+
"128154": {
|
| 1236 |
+
"content": "<|reserved_special_token_146|>",
|
| 1237 |
+
"lstrip": false,
|
| 1238 |
+
"normalized": false,
|
| 1239 |
+
"rstrip": false,
|
| 1240 |
+
"single_word": false,
|
| 1241 |
+
"special": true
|
| 1242 |
+
},
|
| 1243 |
+
"128155": {
|
| 1244 |
+
"content": "<|reserved_special_token_147|>",
|
| 1245 |
+
"lstrip": false,
|
| 1246 |
+
"normalized": false,
|
| 1247 |
+
"rstrip": false,
|
| 1248 |
+
"single_word": false,
|
| 1249 |
+
"special": true
|
| 1250 |
+
},
|
| 1251 |
+
"128156": {
|
| 1252 |
+
"content": "<|reserved_special_token_148|>",
|
| 1253 |
+
"lstrip": false,
|
| 1254 |
+
"normalized": false,
|
| 1255 |
+
"rstrip": false,
|
| 1256 |
+
"single_word": false,
|
| 1257 |
+
"special": true
|
| 1258 |
+
},
|
| 1259 |
+
"128157": {
|
| 1260 |
+
"content": "<|reserved_special_token_149|>",
|
| 1261 |
+
"lstrip": false,
|
| 1262 |
+
"normalized": false,
|
| 1263 |
+
"rstrip": false,
|
| 1264 |
+
"single_word": false,
|
| 1265 |
+
"special": true
|
| 1266 |
+
},
|
| 1267 |
+
"128158": {
|
| 1268 |
+
"content": "<|reserved_special_token_150|>",
|
| 1269 |
+
"lstrip": false,
|
| 1270 |
+
"normalized": false,
|
| 1271 |
+
"rstrip": false,
|
| 1272 |
+
"single_word": false,
|
| 1273 |
+
"special": true
|
| 1274 |
+
},
|
| 1275 |
+
"128159": {
|
| 1276 |
+
"content": "<|reserved_special_token_151|>",
|
| 1277 |
+
"lstrip": false,
|
| 1278 |
+
"normalized": false,
|
| 1279 |
+
"rstrip": false,
|
| 1280 |
+
"single_word": false,
|
| 1281 |
+
"special": true
|
| 1282 |
+
},
|
| 1283 |
+
"128160": {
|
| 1284 |
+
"content": "<|reserved_special_token_152|>",
|
| 1285 |
+
"lstrip": false,
|
| 1286 |
+
"normalized": false,
|
| 1287 |
+
"rstrip": false,
|
| 1288 |
+
"single_word": false,
|
| 1289 |
+
"special": true
|
| 1290 |
+
},
|
| 1291 |
+
"128161": {
|
| 1292 |
+
"content": "<|reserved_special_token_153|>",
|
| 1293 |
+
"lstrip": false,
|
| 1294 |
+
"normalized": false,
|
| 1295 |
+
"rstrip": false,
|
| 1296 |
+
"single_word": false,
|
| 1297 |
+
"special": true
|
| 1298 |
+
},
|
| 1299 |
+
"128162": {
|
| 1300 |
+
"content": "<|reserved_special_token_154|>",
|
| 1301 |
+
"lstrip": false,
|
| 1302 |
+
"normalized": false,
|
| 1303 |
+
"rstrip": false,
|
| 1304 |
+
"single_word": false,
|
| 1305 |
+
"special": true
|
| 1306 |
+
},
|
| 1307 |
+
"128163": {
|
| 1308 |
+
"content": "<|reserved_special_token_155|>",
|
| 1309 |
+
"lstrip": false,
|
| 1310 |
+
"normalized": false,
|
| 1311 |
+
"rstrip": false,
|
| 1312 |
+
"single_word": false,
|
| 1313 |
+
"special": true
|
| 1314 |
+
},
|
| 1315 |
+
"128164": {
|
| 1316 |
+
"content": "<|reserved_special_token_156|>",
|
| 1317 |
+
"lstrip": false,
|
| 1318 |
+
"normalized": false,
|
| 1319 |
+
"rstrip": false,
|
| 1320 |
+
"single_word": false,
|
| 1321 |
+
"special": true
|
| 1322 |
+
},
|
| 1323 |
+
"128165": {
|
| 1324 |
+
"content": "<|reserved_special_token_157|>",
|
| 1325 |
+
"lstrip": false,
|
| 1326 |
+
"normalized": false,
|
| 1327 |
+
"rstrip": false,
|
| 1328 |
+
"single_word": false,
|
| 1329 |
+
"special": true
|
| 1330 |
+
},
|
| 1331 |
+
"128166": {
|
| 1332 |
+
"content": "<|reserved_special_token_158|>",
|
| 1333 |
+
"lstrip": false,
|
| 1334 |
+
"normalized": false,
|
| 1335 |
+
"rstrip": false,
|
| 1336 |
+
"single_word": false,
|
| 1337 |
+
"special": true
|
| 1338 |
+
},
|
| 1339 |
+
"128167": {
|
| 1340 |
+
"content": "<|reserved_special_token_159|>",
|
| 1341 |
+
"lstrip": false,
|
| 1342 |
+
"normalized": false,
|
| 1343 |
+
"rstrip": false,
|
| 1344 |
+
"single_word": false,
|
| 1345 |
+
"special": true
|
| 1346 |
+
},
|
| 1347 |
+
"128168": {
|
| 1348 |
+
"content": "<|reserved_special_token_160|>",
|
| 1349 |
+
"lstrip": false,
|
| 1350 |
+
"normalized": false,
|
| 1351 |
+
"rstrip": false,
|
| 1352 |
+
"single_word": false,
|
| 1353 |
+
"special": true
|
| 1354 |
+
},
|
| 1355 |
+
"128169": {
|
| 1356 |
+
"content": "<|reserved_special_token_161|>",
|
| 1357 |
+
"lstrip": false,
|
| 1358 |
+
"normalized": false,
|
| 1359 |
+
"rstrip": false,
|
| 1360 |
+
"single_word": false,
|
| 1361 |
+
"special": true
|
| 1362 |
+
},
|
| 1363 |
+
"128170": {
|
| 1364 |
+
"content": "<|reserved_special_token_162|>",
|
| 1365 |
+
"lstrip": false,
|
| 1366 |
+
"normalized": false,
|
| 1367 |
+
"rstrip": false,
|
| 1368 |
+
"single_word": false,
|
| 1369 |
+
"special": true
|
| 1370 |
+
},
|
| 1371 |
+
"128171": {
|
| 1372 |
+
"content": "<|reserved_special_token_163|>",
|
| 1373 |
+
"lstrip": false,
|
| 1374 |
+
"normalized": false,
|
| 1375 |
+
"rstrip": false,
|
| 1376 |
+
"single_word": false,
|
| 1377 |
+
"special": true
|
| 1378 |
+
},
|
| 1379 |
+
"128172": {
|
| 1380 |
+
"content": "<|reserved_special_token_164|>",
|
| 1381 |
+
"lstrip": false,
|
| 1382 |
+
"normalized": false,
|
| 1383 |
+
"rstrip": false,
|
| 1384 |
+
"single_word": false,
|
| 1385 |
+
"special": true
|
| 1386 |
+
},
|
| 1387 |
+
"128173": {
|
| 1388 |
+
"content": "<|reserved_special_token_165|>",
|
| 1389 |
+
"lstrip": false,
|
| 1390 |
+
"normalized": false,
|
| 1391 |
+
"rstrip": false,
|
| 1392 |
+
"single_word": false,
|
| 1393 |
+
"special": true
|
| 1394 |
+
},
|
| 1395 |
+
"128174": {
|
| 1396 |
+
"content": "<|reserved_special_token_166|>",
|
| 1397 |
+
"lstrip": false,
|
| 1398 |
+
"normalized": false,
|
| 1399 |
+
"rstrip": false,
|
| 1400 |
+
"single_word": false,
|
| 1401 |
+
"special": true
|
| 1402 |
+
},
|
| 1403 |
+
"128175": {
|
| 1404 |
+
"content": "<|reserved_special_token_167|>",
|
| 1405 |
+
"lstrip": false,
|
| 1406 |
+
"normalized": false,
|
| 1407 |
+
"rstrip": false,
|
| 1408 |
+
"single_word": false,
|
| 1409 |
+
"special": true
|
| 1410 |
+
},
|
| 1411 |
+
"128176": {
|
| 1412 |
+
"content": "<|reserved_special_token_168|>",
|
| 1413 |
+
"lstrip": false,
|
| 1414 |
+
"normalized": false,
|
| 1415 |
+
"rstrip": false,
|
| 1416 |
+
"single_word": false,
|
| 1417 |
+
"special": true
|
| 1418 |
+
},
|
| 1419 |
+
"128177": {
|
| 1420 |
+
"content": "<|reserved_special_token_169|>",
|
| 1421 |
+
"lstrip": false,
|
| 1422 |
+
"normalized": false,
|
| 1423 |
+
"rstrip": false,
|
| 1424 |
+
"single_word": false,
|
| 1425 |
+
"special": true
|
| 1426 |
+
},
|
| 1427 |
+
"128178": {
|
| 1428 |
+
"content": "<|reserved_special_token_170|>",
|
| 1429 |
+
"lstrip": false,
|
| 1430 |
+
"normalized": false,
|
| 1431 |
+
"rstrip": false,
|
| 1432 |
+
"single_word": false,
|
| 1433 |
+
"special": true
|
| 1434 |
+
},
|
| 1435 |
+
"128179": {
|
| 1436 |
+
"content": "<|reserved_special_token_171|>",
|
| 1437 |
+
"lstrip": false,
|
| 1438 |
+
"normalized": false,
|
| 1439 |
+
"rstrip": false,
|
| 1440 |
+
"single_word": false,
|
| 1441 |
+
"special": true
|
| 1442 |
+
},
|
| 1443 |
+
"128180": {
|
| 1444 |
+
"content": "<|reserved_special_token_172|>",
|
| 1445 |
+
"lstrip": false,
|
| 1446 |
+
"normalized": false,
|
| 1447 |
+
"rstrip": false,
|
| 1448 |
+
"single_word": false,
|
| 1449 |
+
"special": true
|
| 1450 |
+
},
|
| 1451 |
+
"128181": {
|
| 1452 |
+
"content": "<|reserved_special_token_173|>",
|
| 1453 |
+
"lstrip": false,
|
| 1454 |
+
"normalized": false,
|
| 1455 |
+
"rstrip": false,
|
| 1456 |
+
"single_word": false,
|
| 1457 |
+
"special": true
|
| 1458 |
+
},
|
| 1459 |
+
"128182": {
|
| 1460 |
+
"content": "<|reserved_special_token_174|>",
|
| 1461 |
+
"lstrip": false,
|
| 1462 |
+
"normalized": false,
|
| 1463 |
+
"rstrip": false,
|
| 1464 |
+
"single_word": false,
|
| 1465 |
+
"special": true
|
| 1466 |
+
},
|
| 1467 |
+
"128183": {
|
| 1468 |
+
"content": "<|reserved_special_token_175|>",
|
| 1469 |
+
"lstrip": false,
|
| 1470 |
+
"normalized": false,
|
| 1471 |
+
"rstrip": false,
|
| 1472 |
+
"single_word": false,
|
| 1473 |
+
"special": true
|
| 1474 |
+
},
|
| 1475 |
+
"128184": {
|
| 1476 |
+
"content": "<|reserved_special_token_176|>",
|
| 1477 |
+
"lstrip": false,
|
| 1478 |
+
"normalized": false,
|
| 1479 |
+
"rstrip": false,
|
| 1480 |
+
"single_word": false,
|
| 1481 |
+
"special": true
|
| 1482 |
+
},
|
| 1483 |
+
"128185": {
|
| 1484 |
+
"content": "<|reserved_special_token_177|>",
|
| 1485 |
+
"lstrip": false,
|
| 1486 |
+
"normalized": false,
|
| 1487 |
+
"rstrip": false,
|
| 1488 |
+
"single_word": false,
|
| 1489 |
+
"special": true
|
| 1490 |
+
},
|
| 1491 |
+
"128186": {
|
| 1492 |
+
"content": "<|reserved_special_token_178|>",
|
| 1493 |
+
"lstrip": false,
|
| 1494 |
+
"normalized": false,
|
| 1495 |
+
"rstrip": false,
|
| 1496 |
+
"single_word": false,
|
| 1497 |
+
"special": true
|
| 1498 |
+
},
|
| 1499 |
+
"128187": {
|
| 1500 |
+
"content": "<|reserved_special_token_179|>",
|
| 1501 |
+
"lstrip": false,
|
| 1502 |
+
"normalized": false,
|
| 1503 |
+
"rstrip": false,
|
| 1504 |
+
"single_word": false,
|
| 1505 |
+
"special": true
|
| 1506 |
+
},
|
| 1507 |
+
"128188": {
|
| 1508 |
+
"content": "<|reserved_special_token_180|>",
|
| 1509 |
+
"lstrip": false,
|
| 1510 |
+
"normalized": false,
|
| 1511 |
+
"rstrip": false,
|
| 1512 |
+
"single_word": false,
|
| 1513 |
+
"special": true
|
| 1514 |
+
},
|
| 1515 |
+
"128189": {
|
| 1516 |
+
"content": "<|reserved_special_token_181|>",
|
| 1517 |
+
"lstrip": false,
|
| 1518 |
+
"normalized": false,
|
| 1519 |
+
"rstrip": false,
|
| 1520 |
+
"single_word": false,
|
| 1521 |
+
"special": true
|
| 1522 |
+
},
|
| 1523 |
+
"128190": {
|
| 1524 |
+
"content": "<|reserved_special_token_182|>",
|
| 1525 |
+
"lstrip": false,
|
| 1526 |
+
"normalized": false,
|
| 1527 |
+
"rstrip": false,
|
| 1528 |
+
"single_word": false,
|
| 1529 |
+
"special": true
|
| 1530 |
+
},
|
| 1531 |
+
"128191": {
|
| 1532 |
+
"content": "<|reserved_special_token_183|>",
|
| 1533 |
+
"lstrip": false,
|
| 1534 |
+
"normalized": false,
|
| 1535 |
+
"rstrip": false,
|
| 1536 |
+
"single_word": false,
|
| 1537 |
+
"special": true
|
| 1538 |
+
},
|
| 1539 |
+
"128192": {
|
| 1540 |
+
"content": "<|reserved_special_token_184|>",
|
| 1541 |
+
"lstrip": false,
|
| 1542 |
+
"normalized": false,
|
| 1543 |
+
"rstrip": false,
|
| 1544 |
+
"single_word": false,
|
| 1545 |
+
"special": true
|
| 1546 |
+
},
|
| 1547 |
+
"128193": {
|
| 1548 |
+
"content": "<|reserved_special_token_185|>",
|
| 1549 |
+
"lstrip": false,
|
| 1550 |
+
"normalized": false,
|
| 1551 |
+
"rstrip": false,
|
| 1552 |
+
"single_word": false,
|
| 1553 |
+
"special": true
|
| 1554 |
+
},
|
| 1555 |
+
"128194": {
|
| 1556 |
+
"content": "<|reserved_special_token_186|>",
|
| 1557 |
+
"lstrip": false,
|
| 1558 |
+
"normalized": false,
|
| 1559 |
+
"rstrip": false,
|
| 1560 |
+
"single_word": false,
|
| 1561 |
+
"special": true
|
| 1562 |
+
},
|
| 1563 |
+
"128195": {
|
| 1564 |
+
"content": "<|reserved_special_token_187|>",
|
| 1565 |
+
"lstrip": false,
|
| 1566 |
+
"normalized": false,
|
| 1567 |
+
"rstrip": false,
|
| 1568 |
+
"single_word": false,
|
| 1569 |
+
"special": true
|
| 1570 |
+
},
|
| 1571 |
+
"128196": {
|
| 1572 |
+
"content": "<|reserved_special_token_188|>",
|
| 1573 |
+
"lstrip": false,
|
| 1574 |
+
"normalized": false,
|
| 1575 |
+
"rstrip": false,
|
| 1576 |
+
"single_word": false,
|
| 1577 |
+
"special": true
|
| 1578 |
+
},
|
| 1579 |
+
"128197": {
|
| 1580 |
+
"content": "<|reserved_special_token_189|>",
|
| 1581 |
+
"lstrip": false,
|
| 1582 |
+
"normalized": false,
|
| 1583 |
+
"rstrip": false,
|
| 1584 |
+
"single_word": false,
|
| 1585 |
+
"special": true
|
| 1586 |
+
},
|
| 1587 |
+
"128198": {
|
| 1588 |
+
"content": "<|reserved_special_token_190|>",
|
| 1589 |
+
"lstrip": false,
|
| 1590 |
+
"normalized": false,
|
| 1591 |
+
"rstrip": false,
|
| 1592 |
+
"single_word": false,
|
| 1593 |
+
"special": true
|
| 1594 |
+
},
|
| 1595 |
+
"128199": {
|
| 1596 |
+
"content": "<|reserved_special_token_191|>",
|
| 1597 |
+
"lstrip": false,
|
| 1598 |
+
"normalized": false,
|
| 1599 |
+
"rstrip": false,
|
| 1600 |
+
"single_word": false,
|
| 1601 |
+
"special": true
|
| 1602 |
+
},
|
| 1603 |
+
"128200": {
|
| 1604 |
+
"content": "<|reserved_special_token_192|>",
|
| 1605 |
+
"lstrip": false,
|
| 1606 |
+
"normalized": false,
|
| 1607 |
+
"rstrip": false,
|
| 1608 |
+
"single_word": false,
|
| 1609 |
+
"special": true
|
| 1610 |
+
},
|
| 1611 |
+
"128201": {
|
| 1612 |
+
"content": "<|reserved_special_token_193|>",
|
| 1613 |
+
"lstrip": false,
|
| 1614 |
+
"normalized": false,
|
| 1615 |
+
"rstrip": false,
|
| 1616 |
+
"single_word": false,
|
| 1617 |
+
"special": true
|
| 1618 |
+
},
|
| 1619 |
+
"128202": {
|
| 1620 |
+
"content": "<|reserved_special_token_194|>",
|
| 1621 |
+
"lstrip": false,
|
| 1622 |
+
"normalized": false,
|
| 1623 |
+
"rstrip": false,
|
| 1624 |
+
"single_word": false,
|
| 1625 |
+
"special": true
|
| 1626 |
+
},
|
| 1627 |
+
"128203": {
|
| 1628 |
+
"content": "<|reserved_special_token_195|>",
|
| 1629 |
+
"lstrip": false,
|
| 1630 |
+
"normalized": false,
|
| 1631 |
+
"rstrip": false,
|
| 1632 |
+
"single_word": false,
|
| 1633 |
+
"special": true
|
| 1634 |
+
},
|
| 1635 |
+
"128204": {
|
| 1636 |
+
"content": "<|reserved_special_token_196|>",
|
| 1637 |
+
"lstrip": false,
|
| 1638 |
+
"normalized": false,
|
| 1639 |
+
"rstrip": false,
|
| 1640 |
+
"single_word": false,
|
| 1641 |
+
"special": true
|
| 1642 |
+
},
|
| 1643 |
+
"128205": {
|
| 1644 |
+
"content": "<|reserved_special_token_197|>",
|
| 1645 |
+
"lstrip": false,
|
| 1646 |
+
"normalized": false,
|
| 1647 |
+
"rstrip": false,
|
| 1648 |
+
"single_word": false,
|
| 1649 |
+
"special": true
|
| 1650 |
+
},
|
| 1651 |
+
"128206": {
|
| 1652 |
+
"content": "<|reserved_special_token_198|>",
|
| 1653 |
+
"lstrip": false,
|
| 1654 |
+
"normalized": false,
|
| 1655 |
+
"rstrip": false,
|
| 1656 |
+
"single_word": false,
|
| 1657 |
+
"special": true
|
| 1658 |
+
},
|
| 1659 |
+
"128207": {
|
| 1660 |
+
"content": "<|reserved_special_token_199|>",
|
| 1661 |
+
"lstrip": false,
|
| 1662 |
+
"normalized": false,
|
| 1663 |
+
"rstrip": false,
|
| 1664 |
+
"single_word": false,
|
| 1665 |
+
"special": true
|
| 1666 |
+
},
|
| 1667 |
+
"128208": {
|
| 1668 |
+
"content": "<|reserved_special_token_200|>",
|
| 1669 |
+
"lstrip": false,
|
| 1670 |
+
"normalized": false,
|
| 1671 |
+
"rstrip": false,
|
| 1672 |
+
"single_word": false,
|
| 1673 |
+
"special": true
|
| 1674 |
+
},
|
| 1675 |
+
"128209": {
|
| 1676 |
+
"content": "<|reserved_special_token_201|>",
|
| 1677 |
+
"lstrip": false,
|
| 1678 |
+
"normalized": false,
|
| 1679 |
+
"rstrip": false,
|
| 1680 |
+
"single_word": false,
|
| 1681 |
+
"special": true
|
| 1682 |
+
},
|
| 1683 |
+
"128210": {
|
| 1684 |
+
"content": "<|reserved_special_token_202|>",
|
| 1685 |
+
"lstrip": false,
|
| 1686 |
+
"normalized": false,
|
| 1687 |
+
"rstrip": false,
|
| 1688 |
+
"single_word": false,
|
| 1689 |
+
"special": true
|
| 1690 |
+
},
|
| 1691 |
+
"128211": {
|
| 1692 |
+
"content": "<|reserved_special_token_203|>",
|
| 1693 |
+
"lstrip": false,
|
| 1694 |
+
"normalized": false,
|
| 1695 |
+
"rstrip": false,
|
| 1696 |
+
"single_word": false,
|
| 1697 |
+
"special": true
|
| 1698 |
+
},
|
| 1699 |
+
"128212": {
|
| 1700 |
+
"content": "<|reserved_special_token_204|>",
|
| 1701 |
+
"lstrip": false,
|
| 1702 |
+
"normalized": false,
|
| 1703 |
+
"rstrip": false,
|
| 1704 |
+
"single_word": false,
|
| 1705 |
+
"special": true
|
| 1706 |
+
},
|
| 1707 |
+
"128213": {
|
| 1708 |
+
"content": "<|reserved_special_token_205|>",
|
| 1709 |
+
"lstrip": false,
|
| 1710 |
+
"normalized": false,
|
| 1711 |
+
"rstrip": false,
|
| 1712 |
+
"single_word": false,
|
| 1713 |
+
"special": true
|
| 1714 |
+
},
|
| 1715 |
+
"128214": {
|
| 1716 |
+
"content": "<|reserved_special_token_206|>",
|
| 1717 |
+
"lstrip": false,
|
| 1718 |
+
"normalized": false,
|
| 1719 |
+
"rstrip": false,
|
| 1720 |
+
"single_word": false,
|
| 1721 |
+
"special": true
|
| 1722 |
+
},
|
| 1723 |
+
"128215": {
|
| 1724 |
+
"content": "<|reserved_special_token_207|>",
|
| 1725 |
+
"lstrip": false,
|
| 1726 |
+
"normalized": false,
|
| 1727 |
+
"rstrip": false,
|
| 1728 |
+
"single_word": false,
|
| 1729 |
+
"special": true
|
| 1730 |
+
},
|
| 1731 |
+
"128216": {
|
| 1732 |
+
"content": "<|reserved_special_token_208|>",
|
| 1733 |
+
"lstrip": false,
|
| 1734 |
+
"normalized": false,
|
| 1735 |
+
"rstrip": false,
|
| 1736 |
+
"single_word": false,
|
| 1737 |
+
"special": true
|
| 1738 |
+
},
|
| 1739 |
+
"128217": {
|
| 1740 |
+
"content": "<|reserved_special_token_209|>",
|
| 1741 |
+
"lstrip": false,
|
| 1742 |
+
"normalized": false,
|
| 1743 |
+
"rstrip": false,
|
| 1744 |
+
"single_word": false,
|
| 1745 |
+
"special": true
|
| 1746 |
+
},
|
| 1747 |
+
"128218": {
|
| 1748 |
+
"content": "<|reserved_special_token_210|>",
|
| 1749 |
+
"lstrip": false,
|
| 1750 |
+
"normalized": false,
|
| 1751 |
+
"rstrip": false,
|
| 1752 |
+
"single_word": false,
|
| 1753 |
+
"special": true
|
| 1754 |
+
},
|
| 1755 |
+
"128219": {
|
| 1756 |
+
"content": "<|reserved_special_token_211|>",
|
| 1757 |
+
"lstrip": false,
|
| 1758 |
+
"normalized": false,
|
| 1759 |
+
"rstrip": false,
|
| 1760 |
+
"single_word": false,
|
| 1761 |
+
"special": true
|
| 1762 |
+
},
|
| 1763 |
+
"128220": {
|
| 1764 |
+
"content": "<|reserved_special_token_212|>",
|
| 1765 |
+
"lstrip": false,
|
| 1766 |
+
"normalized": false,
|
| 1767 |
+
"rstrip": false,
|
| 1768 |
+
"single_word": false,
|
| 1769 |
+
"special": true
|
| 1770 |
+
},
|
| 1771 |
+
"128221": {
|
| 1772 |
+
"content": "<|reserved_special_token_213|>",
|
| 1773 |
+
"lstrip": false,
|
| 1774 |
+
"normalized": false,
|
| 1775 |
+
"rstrip": false,
|
| 1776 |
+
"single_word": false,
|
| 1777 |
+
"special": true
|
| 1778 |
+
},
|
| 1779 |
+
"128222": {
|
| 1780 |
+
"content": "<|reserved_special_token_214|>",
|
| 1781 |
+
"lstrip": false,
|
| 1782 |
+
"normalized": false,
|
| 1783 |
+
"rstrip": false,
|
| 1784 |
+
"single_word": false,
|
| 1785 |
+
"special": true
|
| 1786 |
+
},
|
| 1787 |
+
"128223": {
|
| 1788 |
+
"content": "<|reserved_special_token_215|>",
|
| 1789 |
+
"lstrip": false,
|
| 1790 |
+
"normalized": false,
|
| 1791 |
+
"rstrip": false,
|
| 1792 |
+
"single_word": false,
|
| 1793 |
+
"special": true
|
| 1794 |
+
},
|
| 1795 |
+
"128224": {
|
| 1796 |
+
"content": "<|reserved_special_token_216|>",
|
| 1797 |
+
"lstrip": false,
|
| 1798 |
+
"normalized": false,
|
| 1799 |
+
"rstrip": false,
|
| 1800 |
+
"single_word": false,
|
| 1801 |
+
"special": true
|
| 1802 |
+
},
|
| 1803 |
+
"128225": {
|
| 1804 |
+
"content": "<|reserved_special_token_217|>",
|
| 1805 |
+
"lstrip": false,
|
| 1806 |
+
"normalized": false,
|
| 1807 |
+
"rstrip": false,
|
| 1808 |
+
"single_word": false,
|
| 1809 |
+
"special": true
|
| 1810 |
+
},
|
| 1811 |
+
"128226": {
|
| 1812 |
+
"content": "<|reserved_special_token_218|>",
|
| 1813 |
+
"lstrip": false,
|
| 1814 |
+
"normalized": false,
|
| 1815 |
+
"rstrip": false,
|
| 1816 |
+
"single_word": false,
|
| 1817 |
+
"special": true
|
| 1818 |
+
},
|
| 1819 |
+
"128227": {
|
| 1820 |
+
"content": "<|reserved_special_token_219|>",
|
| 1821 |
+
"lstrip": false,
|
| 1822 |
+
"normalized": false,
|
| 1823 |
+
"rstrip": false,
|
| 1824 |
+
"single_word": false,
|
| 1825 |
+
"special": true
|
| 1826 |
+
},
|
| 1827 |
+
"128228": {
|
| 1828 |
+
"content": "<|reserved_special_token_220|>",
|
| 1829 |
+
"lstrip": false,
|
| 1830 |
+
"normalized": false,
|
| 1831 |
+
"rstrip": false,
|
| 1832 |
+
"single_word": false,
|
| 1833 |
+
"special": true
|
| 1834 |
+
},
|
| 1835 |
+
"128229": {
|
| 1836 |
+
"content": "<|reserved_special_token_221|>",
|
| 1837 |
+
"lstrip": false,
|
| 1838 |
+
"normalized": false,
|
| 1839 |
+
"rstrip": false,
|
| 1840 |
+
"single_word": false,
|
| 1841 |
+
"special": true
|
| 1842 |
+
},
|
| 1843 |
+
"128230": {
|
| 1844 |
+
"content": "<|reserved_special_token_222|>",
|
| 1845 |
+
"lstrip": false,
|
| 1846 |
+
"normalized": false,
|
| 1847 |
+
"rstrip": false,
|
| 1848 |
+
"single_word": false,
|
| 1849 |
+
"special": true
|
| 1850 |
+
},
|
| 1851 |
+
"128231": {
|
| 1852 |
+
"content": "<|reserved_special_token_223|>",
|
| 1853 |
+
"lstrip": false,
|
| 1854 |
+
"normalized": false,
|
| 1855 |
+
"rstrip": false,
|
| 1856 |
+
"single_word": false,
|
| 1857 |
+
"special": true
|
| 1858 |
+
},
|
| 1859 |
+
"128232": {
|
| 1860 |
+
"content": "<|reserved_special_token_224|>",
|
| 1861 |
+
"lstrip": false,
|
| 1862 |
+
"normalized": false,
|
| 1863 |
+
"rstrip": false,
|
| 1864 |
+
"single_word": false,
|
| 1865 |
+
"special": true
|
| 1866 |
+
},
|
| 1867 |
+
"128233": {
|
| 1868 |
+
"content": "<|reserved_special_token_225|>",
|
| 1869 |
+
"lstrip": false,
|
| 1870 |
+
"normalized": false,
|
| 1871 |
+
"rstrip": false,
|
| 1872 |
+
"single_word": false,
|
| 1873 |
+
"special": true
|
| 1874 |
+
},
|
| 1875 |
+
"128234": {
|
| 1876 |
+
"content": "<|reserved_special_token_226|>",
|
| 1877 |
+
"lstrip": false,
|
| 1878 |
+
"normalized": false,
|
| 1879 |
+
"rstrip": false,
|
| 1880 |
+
"single_word": false,
|
| 1881 |
+
"special": true
|
| 1882 |
+
},
|
| 1883 |
+
"128235": {
|
| 1884 |
+
"content": "<|reserved_special_token_227|>",
|
| 1885 |
+
"lstrip": false,
|
| 1886 |
+
"normalized": false,
|
| 1887 |
+
"rstrip": false,
|
| 1888 |
+
"single_word": false,
|
| 1889 |
+
"special": true
|
| 1890 |
+
},
|
| 1891 |
+
"128236": {
|
| 1892 |
+
"content": "<|reserved_special_token_228|>",
|
| 1893 |
+
"lstrip": false,
|
| 1894 |
+
"normalized": false,
|
| 1895 |
+
"rstrip": false,
|
| 1896 |
+
"single_word": false,
|
| 1897 |
+
"special": true
|
| 1898 |
+
},
|
| 1899 |
+
"128237": {
|
| 1900 |
+
"content": "<|reserved_special_token_229|>",
|
| 1901 |
+
"lstrip": false,
|
| 1902 |
+
"normalized": false,
|
| 1903 |
+
"rstrip": false,
|
| 1904 |
+
"single_word": false,
|
| 1905 |
+
"special": true
|
| 1906 |
+
},
|
| 1907 |
+
"128238": {
|
| 1908 |
+
"content": "<|reserved_special_token_230|>",
|
| 1909 |
+
"lstrip": false,
|
| 1910 |
+
"normalized": false,
|
| 1911 |
+
"rstrip": false,
|
| 1912 |
+
"single_word": false,
|
| 1913 |
+
"special": true
|
| 1914 |
+
},
|
| 1915 |
+
"128239": {
|
| 1916 |
+
"content": "<|reserved_special_token_231|>",
|
| 1917 |
+
"lstrip": false,
|
| 1918 |
+
"normalized": false,
|
| 1919 |
+
"rstrip": false,
|
| 1920 |
+
"single_word": false,
|
| 1921 |
+
"special": true
|
| 1922 |
+
},
|
| 1923 |
+
"128240": {
|
| 1924 |
+
"content": "<|reserved_special_token_232|>",
|
| 1925 |
+
"lstrip": false,
|
| 1926 |
+
"normalized": false,
|
| 1927 |
+
"rstrip": false,
|
| 1928 |
+
"single_word": false,
|
| 1929 |
+
"special": true
|
| 1930 |
+
},
|
| 1931 |
+
"128241": {
|
| 1932 |
+
"content": "<|reserved_special_token_233|>",
|
| 1933 |
+
"lstrip": false,
|
| 1934 |
+
"normalized": false,
|
| 1935 |
+
"rstrip": false,
|
| 1936 |
+
"single_word": false,
|
| 1937 |
+
"special": true
|
| 1938 |
+
},
|
| 1939 |
+
"128242": {
|
| 1940 |
+
"content": "<|reserved_special_token_234|>",
|
| 1941 |
+
"lstrip": false,
|
| 1942 |
+
"normalized": false,
|
| 1943 |
+
"rstrip": false,
|
| 1944 |
+
"single_word": false,
|
| 1945 |
+
"special": true
|
| 1946 |
+
},
|
| 1947 |
+
"128243": {
|
| 1948 |
+
"content": "<|reserved_special_token_235|>",
|
| 1949 |
+
"lstrip": false,
|
| 1950 |
+
"normalized": false,
|
| 1951 |
+
"rstrip": false,
|
| 1952 |
+
"single_word": false,
|
| 1953 |
+
"special": true
|
| 1954 |
+
},
|
| 1955 |
+
"128244": {
|
| 1956 |
+
"content": "<|reserved_special_token_236|>",
|
| 1957 |
+
"lstrip": false,
|
| 1958 |
+
"normalized": false,
|
| 1959 |
+
"rstrip": false,
|
| 1960 |
+
"single_word": false,
|
| 1961 |
+
"special": true
|
| 1962 |
+
},
|
| 1963 |
+
"128245": {
|
| 1964 |
+
"content": "<|reserved_special_token_237|>",
|
| 1965 |
+
"lstrip": false,
|
| 1966 |
+
"normalized": false,
|
| 1967 |
+
"rstrip": false,
|
| 1968 |
+
"single_word": false,
|
| 1969 |
+
"special": true
|
| 1970 |
+
},
|
| 1971 |
+
"128246": {
|
| 1972 |
+
"content": "<|reserved_special_token_238|>",
|
| 1973 |
+
"lstrip": false,
|
| 1974 |
+
"normalized": false,
|
| 1975 |
+
"rstrip": false,
|
| 1976 |
+
"single_word": false,
|
| 1977 |
+
"special": true
|
| 1978 |
+
},
|
| 1979 |
+
"128247": {
|
| 1980 |
+
"content": "<|reserved_special_token_239|>",
|
| 1981 |
+
"lstrip": false,
|
| 1982 |
+
"normalized": false,
|
| 1983 |
+
"rstrip": false,
|
| 1984 |
+
"single_word": false,
|
| 1985 |
+
"special": true
|
| 1986 |
+
},
|
| 1987 |
+
"128248": {
|
| 1988 |
+
"content": "<|reserved_special_token_240|>",
|
| 1989 |
+
"lstrip": false,
|
| 1990 |
+
"normalized": false,
|
| 1991 |
+
"rstrip": false,
|
| 1992 |
+
"single_word": false,
|
| 1993 |
+
"special": true
|
| 1994 |
+
},
|
| 1995 |
+
"128249": {
|
| 1996 |
+
"content": "<|reserved_special_token_241|>",
|
| 1997 |
+
"lstrip": false,
|
| 1998 |
+
"normalized": false,
|
| 1999 |
+
"rstrip": false,
|
| 2000 |
+
"single_word": false,
|
| 2001 |
+
"special": true
|
| 2002 |
+
},
|
| 2003 |
+
"128250": {
|
| 2004 |
+
"content": "<|reserved_special_token_242|>",
|
| 2005 |
+
"lstrip": false,
|
| 2006 |
+
"normalized": false,
|
| 2007 |
+
"rstrip": false,
|
| 2008 |
+
"single_word": false,
|
| 2009 |
+
"special": true
|
| 2010 |
+
},
|
| 2011 |
+
"128251": {
|
| 2012 |
+
"content": "<|reserved_special_token_243|>",
|
| 2013 |
+
"lstrip": false,
|
| 2014 |
+
"normalized": false,
|
| 2015 |
+
"rstrip": false,
|
| 2016 |
+
"single_word": false,
|
| 2017 |
+
"special": true
|
| 2018 |
+
},
|
| 2019 |
+
"128252": {
|
| 2020 |
+
"content": "<|reserved_special_token_244|>",
|
| 2021 |
+
"lstrip": false,
|
| 2022 |
+
"normalized": false,
|
| 2023 |
+
"rstrip": false,
|
| 2024 |
+
"single_word": false,
|
| 2025 |
+
"special": true
|
| 2026 |
+
},
|
| 2027 |
+
"128253": {
|
| 2028 |
+
"content": "<|reserved_special_token_245|>",
|
| 2029 |
+
"lstrip": false,
|
| 2030 |
+
"normalized": false,
|
| 2031 |
+
"rstrip": false,
|
| 2032 |
+
"single_word": false,
|
| 2033 |
+
"special": true
|
| 2034 |
+
},
|
| 2035 |
+
"128254": {
|
| 2036 |
+
"content": "<|reserved_special_token_246|>",
|
| 2037 |
+
"lstrip": false,
|
| 2038 |
+
"normalized": false,
|
| 2039 |
+
"rstrip": false,
|
| 2040 |
+
"single_word": false,
|
| 2041 |
+
"special": true
|
| 2042 |
+
},
|
| 2043 |
+
"128255": {
|
| 2044 |
+
"content": "<|reserved_special_token_247|>",
|
| 2045 |
+
"lstrip": false,
|
| 2046 |
+
"normalized": false,
|
| 2047 |
+
"rstrip": false,
|
| 2048 |
+
"single_word": false,
|
| 2049 |
+
"special": true
|
| 2050 |
+
},
|
| 2051 |
+
"128256": {
|
| 2052 |
+
"content": "<PAD>",
|
| 2053 |
+
"lstrip": false,
|
| 2054 |
+
"normalized": false,
|
| 2055 |
+
"rstrip": false,
|
| 2056 |
+
"single_word": false,
|
| 2057 |
+
"special": true
|
| 2058 |
+
},
|
| 2059 |
+
"128257": {
|
| 2060 |
+
"content": "<ACT>",
|
| 2061 |
+
"lstrip": false,
|
| 2062 |
+
"normalized": false,
|
| 2063 |
+
"rstrip": false,
|
| 2064 |
+
"single_word": false,
|
| 2065 |
+
"special": true
|
| 2066 |
+
}
|
| 2067 |
+
},
|
| 2068 |
+
"additional_special_tokens": [
|
| 2069 |
+
"<ACT>"
|
| 2070 |
+
],
|
| 2071 |
+
"bos_token": "<|begin_of_text|>",
|
| 2072 |
+
"clean_up_tokenization_spaces": true,
|
| 2073 |
+
"eos_token": "<|end_of_text|>",
|
| 2074 |
+
"extra_special_tokens": {},
|
| 2075 |
+
"model_input_names": [
|
| 2076 |
+
"input_ids",
|
| 2077 |
+
"attention_mask"
|
| 2078 |
+
],
|
| 2079 |
+
"model_max_length": 2048,
|
| 2080 |
+
"pad_token": "<PAD>",
|
| 2081 |
+
"padding_side": "right",
|
| 2082 |
+
"processor_class": "PrismaticProcessor",
|
| 2083 |
+
"tokenizer_class": "PreTrainedTokenizer"
|
| 2084 |
+
}
|