Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- chat_template.jinja +3 -0
- config.json +242 -0
- configuration_gar.py +63 -0
- image_processing_perception_lm_fast.py +378 -0
- model.safetensors +3 -0
- modeling_gar.py +352 -0
- modeling_perception_lm.py +865 -0
- preprocessor_config.json +40 -0
- processing_gar.py +316 -0
- processor_config.json +9 -0
- special_tokens_map.json +19 -0
- tokenizer.json +3 -0
- tokenizer_config.json +2118 -0
- video_preprocessor_config.json +37 -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
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{- bos_token }}{%- if messages[0]['role'] == 'system' -%} {%- set system_message = messages[0]['content']|trim %}
|
| 2 |
+
{%- set messages = messages[1:] %}
|
| 3 |
+
{%- else %} {%- set system_message = 'You are a helpful language and vision assistant. You are able to understand the visual content that the user provides, and assist the user with a variety of tasks using natural language.' %}{%- endif %}{{- '<|start_header_id|>system<|end_header_id|>\n\n' }}{{- system_message }}{{- '<|eot_id|>' }}{%- for message in messages %}{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' }}{%- for content in message['content'] | selectattr('type', 'equalto', 'image') %}{{ '<|image|>' }}{%- endfor %}{%- for content in message['content'] | selectattr('type', 'equalto', 'video') %}{{ '<|video|>' }}{%- endfor %}{%- for content in message['content'] | selectattr('type', 'equalto', 'text') %}{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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"GARModel"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_gar.GARConfig",
|
| 7 |
+
"AutoModel": "modeling_gar.GARModel",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_gar.GARModel"
|
| 9 |
+
},
|
| 10 |
+
"crop_tokens_ids": [
|
| 11 |
+
128004,
|
| 12 |
+
128005,
|
| 13 |
+
128008,
|
| 14 |
+
128010,
|
| 15 |
+
128011
|
| 16 |
+
],
|
| 17 |
+
"kernel_size": [
|
| 18 |
+
14,
|
| 19 |
+
14
|
| 20 |
+
],
|
| 21 |
+
"mask_path_embedding_out_channels": 1024,
|
| 22 |
+
"mllm_config": {
|
| 23 |
+
"_name_or_path": "/mnt/bn/zilongdata-us/wangyuhao/model/Perception-LM-1B",
|
| 24 |
+
"architectures": [
|
| 25 |
+
"PerceptionLMForConditionalGeneration"
|
| 26 |
+
],
|
| 27 |
+
"image_token_id": 128002,
|
| 28 |
+
"model_type": "perception_lm",
|
| 29 |
+
"projector_pooling_ratio": 2,
|
| 30 |
+
"text_config": {
|
| 31 |
+
"_name_or_path": "",
|
| 32 |
+
"add_cross_attention": false,
|
| 33 |
+
"architectures": null,
|
| 34 |
+
"attention_bias": false,
|
| 35 |
+
"attention_dropout": 0.0,
|
| 36 |
+
"bad_words_ids": null,
|
| 37 |
+
"begin_suppress_tokens": null,
|
| 38 |
+
"bos_token_id": 128000,
|
| 39 |
+
"chunk_size_feed_forward": 0,
|
| 40 |
+
"cross_attention_hidden_size": null,
|
| 41 |
+
"decoder_start_token_id": null,
|
| 42 |
+
"diversity_penalty": 0.0,
|
| 43 |
+
"do_sample": false,
|
| 44 |
+
"early_stopping": false,
|
| 45 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 46 |
+
"eos_token_id": [
|
| 47 |
+
128001,
|
| 48 |
+
128009
|
| 49 |
+
],
|
| 50 |
+
"exponential_decay_length_penalty": null,
|
| 51 |
+
"finetuning_task": null,
|
| 52 |
+
"forced_bos_token_id": null,
|
| 53 |
+
"forced_eos_token_id": null,
|
| 54 |
+
"head_dim": 64,
|
| 55 |
+
"hidden_act": "silu",
|
| 56 |
+
"hidden_size": 2048,
|
| 57 |
+
"id2label": {
|
| 58 |
+
"0": "LABEL_0",
|
| 59 |
+
"1": "LABEL_1"
|
| 60 |
+
},
|
| 61 |
+
"initializer_range": 0.02,
|
| 62 |
+
"intermediate_size": 8192,
|
| 63 |
+
"is_decoder": false,
|
| 64 |
+
"is_encoder_decoder": false,
|
| 65 |
+
"label2id": {
|
| 66 |
+
"LABEL_0": 0,
|
| 67 |
+
"LABEL_1": 1
|
| 68 |
+
},
|
| 69 |
+
"length_penalty": 1.0,
|
| 70 |
+
"max_length": 20,
|
| 71 |
+
"max_position_embeddings": 11520,
|
| 72 |
+
"min_length": 0,
|
| 73 |
+
"mlp_bias": false,
|
| 74 |
+
"model_type": "llama",
|
| 75 |
+
"no_repeat_ngram_size": 0,
|
| 76 |
+
"num_attention_heads": 32,
|
| 77 |
+
"num_beam_groups": 1,
|
| 78 |
+
"num_beams": 1,
|
| 79 |
+
"num_hidden_layers": 16,
|
| 80 |
+
"num_key_value_heads": 8,
|
| 81 |
+
"num_return_sequences": 1,
|
| 82 |
+
"output_attentions": false,
|
| 83 |
+
"output_hidden_states": false,
|
| 84 |
+
"output_scores": false,
|
| 85 |
+
"pad_token_id": null,
|
| 86 |
+
"prefix": null,
|
| 87 |
+
"pretraining_tp": 1,
|
| 88 |
+
"problem_type": null,
|
| 89 |
+
"pruned_heads": {},
|
| 90 |
+
"remove_invalid_values": false,
|
| 91 |
+
"repetition_penalty": 1.0,
|
| 92 |
+
"return_dict": true,
|
| 93 |
+
"return_dict_in_generate": false,
|
| 94 |
+
"rms_norm_eps": 1e-05,
|
| 95 |
+
"rope_scaling": {
|
| 96 |
+
"factor": 32.0,
|
| 97 |
+
"high_freq_factor": 4.0,
|
| 98 |
+
"low_freq_factor": 1.0,
|
| 99 |
+
"original_max_position_embeddings": 8192,
|
| 100 |
+
"rope_type": "llama3"
|
| 101 |
+
},
|
| 102 |
+
"rope_theta": 500000.0,
|
| 103 |
+
"sep_token_id": null,
|
| 104 |
+
"suppress_tokens": null,
|
| 105 |
+
"task_specific_params": null,
|
| 106 |
+
"temperature": 1.0,
|
| 107 |
+
"tf_legacy_loss": false,
|
| 108 |
+
"tie_encoder_decoder": false,
|
| 109 |
+
"tie_word_embeddings": true,
|
| 110 |
+
"tokenizer_class": null,
|
| 111 |
+
"top_k": 50,
|
| 112 |
+
"top_p": 1.0,
|
| 113 |
+
"torch_dtype": "bfloat16",
|
| 114 |
+
"torchscript": false,
|
| 115 |
+
"typical_p": 1.0,
|
| 116 |
+
"use_bfloat16": false,
|
| 117 |
+
"use_cache": true,
|
| 118 |
+
"use_flash_attn": true,
|
| 119 |
+
"vocab_size": 128262
|
| 120 |
+
},
|
| 121 |
+
"torch_dtype": "bfloat16",
|
| 122 |
+
"use_flash_attn": true,
|
| 123 |
+
"video_token_id": 128003,
|
| 124 |
+
"vision_config": {
|
| 125 |
+
"_name_or_path": "",
|
| 126 |
+
"add_cross_attention": false,
|
| 127 |
+
"architecture": "vit_pe_core_large_patch14_336",
|
| 128 |
+
"architectures": null,
|
| 129 |
+
"bad_words_ids": null,
|
| 130 |
+
"begin_suppress_tokens": null,
|
| 131 |
+
"bos_token_id": null,
|
| 132 |
+
"chunk_size_feed_forward": 0,
|
| 133 |
+
"cross_attention_hidden_size": null,
|
| 134 |
+
"decoder_start_token_id": null,
|
| 135 |
+
"diversity_penalty": 0.0,
|
| 136 |
+
"do_pooling": true,
|
| 137 |
+
"do_sample": false,
|
| 138 |
+
"early_stopping": false,
|
| 139 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 140 |
+
"eos_token_id": null,
|
| 141 |
+
"exponential_decay_length_penalty": null,
|
| 142 |
+
"finetuning_task": null,
|
| 143 |
+
"forced_bos_token_id": null,
|
| 144 |
+
"forced_eos_token_id": null,
|
| 145 |
+
"global_pool": "map",
|
| 146 |
+
"initializer_range": 0.02,
|
| 147 |
+
"is_decoder": false,
|
| 148 |
+
"is_encoder_decoder": false,
|
| 149 |
+
"label_names": [
|
| 150 |
+
"LABEL_0",
|
| 151 |
+
"LABEL_1"
|
| 152 |
+
],
|
| 153 |
+
"length_penalty": 1.0,
|
| 154 |
+
"max_length": 20,
|
| 155 |
+
"min_length": 0,
|
| 156 |
+
"model_args": {
|
| 157 |
+
"depth": 23,
|
| 158 |
+
"embed_dim": 1024,
|
| 159 |
+
"global_pool": "",
|
| 160 |
+
"img_size": [
|
| 161 |
+
448,
|
| 162 |
+
448
|
| 163 |
+
],
|
| 164 |
+
"init_values": 0.1,
|
| 165 |
+
"ref_feat_shape": [
|
| 166 |
+
32,
|
| 167 |
+
32
|
| 168 |
+
],
|
| 169 |
+
"use_post_transformer_norm": false
|
| 170 |
+
},
|
| 171 |
+
"model_type": "timm_wrapper",
|
| 172 |
+
"no_repeat_ngram_size": 0,
|
| 173 |
+
"num_beam_groups": 1,
|
| 174 |
+
"num_beams": 1,
|
| 175 |
+
"num_classes": 2,
|
| 176 |
+
"num_features": 1024,
|
| 177 |
+
"num_return_sequences": 1,
|
| 178 |
+
"output_attentions": false,
|
| 179 |
+
"output_hidden_states": false,
|
| 180 |
+
"output_scores": false,
|
| 181 |
+
"pad_token_id": null,
|
| 182 |
+
"prefix": null,
|
| 183 |
+
"pretrained_cfg": {
|
| 184 |
+
"classifier": "head",
|
| 185 |
+
"crop_mode": "center",
|
| 186 |
+
"crop_pct": 1.0,
|
| 187 |
+
"custom_load": false,
|
| 188 |
+
"first_conv": "patch_embed.proj",
|
| 189 |
+
"fixed_input_size": true,
|
| 190 |
+
"input_size": [
|
| 191 |
+
3,
|
| 192 |
+
336,
|
| 193 |
+
336
|
| 194 |
+
],
|
| 195 |
+
"interpolation": "bicubic",
|
| 196 |
+
"license": "custom",
|
| 197 |
+
"mean": [
|
| 198 |
+
0.5,
|
| 199 |
+
0.5,
|
| 200 |
+
0.5
|
| 201 |
+
],
|
| 202 |
+
"pool_size": null,
|
| 203 |
+
"std": [
|
| 204 |
+
0.5,
|
| 205 |
+
0.5,
|
| 206 |
+
0.5
|
| 207 |
+
],
|
| 208 |
+
"tag": "fb"
|
| 209 |
+
},
|
| 210 |
+
"problem_type": null,
|
| 211 |
+
"pruned_heads": {},
|
| 212 |
+
"remove_invalid_values": false,
|
| 213 |
+
"repetition_penalty": 1.0,
|
| 214 |
+
"return_dict": true,
|
| 215 |
+
"return_dict_in_generate": false,
|
| 216 |
+
"sep_token_id": null,
|
| 217 |
+
"suppress_tokens": null,
|
| 218 |
+
"task_specific_params": null,
|
| 219 |
+
"temperature": 1.0,
|
| 220 |
+
"tf_legacy_loss": false,
|
| 221 |
+
"tie_encoder_decoder": false,
|
| 222 |
+
"tie_word_embeddings": true,
|
| 223 |
+
"tokenizer_class": null,
|
| 224 |
+
"top_k": 50,
|
| 225 |
+
"top_p": 1.0,
|
| 226 |
+
"torch_dtype": "bfloat16",
|
| 227 |
+
"torchscript": false,
|
| 228 |
+
"typical_p": 1.0,
|
| 229 |
+
"use_bfloat16": false,
|
| 230 |
+
"use_flash_attn": false
|
| 231 |
+
},
|
| 232 |
+
"vision_use_cls_token": true
|
| 233 |
+
},
|
| 234 |
+
"model_type": "GAR",
|
| 235 |
+
"output_attentions": false,
|
| 236 |
+
"patch_size_h": 14,
|
| 237 |
+
"patch_size_w": 14,
|
| 238 |
+
"prompt_numbers": 5,
|
| 239 |
+
"max_num_tiles": 16,
|
| 240 |
+
"torch_dtype": "bfloat16",
|
| 241 |
+
"transformers_version": null
|
| 242 |
+
}
|
configuration_gar.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
from transformers.utils import logging
|
| 3 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
+
from transformers import AutoConfig, PerceptionLMConfig
|
| 5 |
+
|
| 6 |
+
logger = logging.get_logger(__name__)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class GARConfig(PretrainedConfig):
|
| 10 |
+
model_type = 'GAR'
|
| 11 |
+
is_composition = True
|
| 12 |
+
|
| 13 |
+
def __init__(
|
| 14 |
+
self,
|
| 15 |
+
mllm_config=None,
|
| 16 |
+
prompt_numbers=5,
|
| 17 |
+
crop_tokens_ids=[128004, 128005, 128008, 128010, 128011],
|
| 18 |
+
use_flash_attn=True,
|
| 19 |
+
**kwargs,
|
| 20 |
+
):
|
| 21 |
+
super().__init__(**kwargs)
|
| 22 |
+
if mllm_config is None:
|
| 23 |
+
mllm_config = {}
|
| 24 |
+
logger.info('mllm_config is None. Initializing the PerceptionLM with default values.')
|
| 25 |
+
|
| 26 |
+
if mllm_config is None:
|
| 27 |
+
self.mllm_config = AutoConfig.from_pretrained("facebook/Perception-LM-1B")
|
| 28 |
+
else:
|
| 29 |
+
self.mllm_config = PerceptionLMConfig(**mllm_config)
|
| 30 |
+
self.prompt_numbers = prompt_numbers
|
| 31 |
+
|
| 32 |
+
self.crop_tokens_ids = crop_tokens_ids
|
| 33 |
+
assert len(self.crop_tokens_ids) == self.prompt_numbers, f'{self.crop_tokens_ids} crop_tokens_ids length should be {self.prompt_numbers}'
|
| 34 |
+
|
| 35 |
+
try:
|
| 36 |
+
self.patch_size_h = self.mllm_config.vision_config.model_args["img_size"][0] // self.mllm_config.vision_config.model_args["ref_feat_shape"][0]
|
| 37 |
+
self.patch_size_w = self.mllm_config.vision_config.model_args["img_size"][1] // self.mllm_config.vision_config.model_args["ref_feat_shape"][1]
|
| 38 |
+
self.kernel_size = [self.patch_size_h, self.patch_size_w]
|
| 39 |
+
except:
|
| 40 |
+
self.patch_size_h = 16
|
| 41 |
+
self.patch_size_w = 16
|
| 42 |
+
self.kernel_size = [self.patch_size_h, self.patch_size_w]
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
self.mask_path_embedding_out_channels = self.mllm_config.vision_config.num_features
|
| 46 |
+
except:
|
| 47 |
+
self.mask_path_embedding_out_channels = 1280
|
| 48 |
+
|
| 49 |
+
self.mllm_config.use_flash_attn = True if use_flash_attn else False
|
| 50 |
+
self.mllm_config.text_config.use_flash_attn = True if use_flash_attn else False
|
| 51 |
+
self.mllm_config.vision_config.use_flash_attn = False
|
| 52 |
+
|
| 53 |
+
def to_dict(self):
|
| 54 |
+
"""
|
| 55 |
+
Serializes this instance to a Python dictionary. Override the default [`~PretrainedConfig.to_dict`].
|
| 56 |
+
|
| 57 |
+
Returns:
|
| 58 |
+
`Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance,
|
| 59 |
+
"""
|
| 60 |
+
output = copy.deepcopy(self.__dict__)
|
| 61 |
+
output['mllm_config'] = self.mllm_config.to_dict()
|
| 62 |
+
output['model_type'] = self.__class__.model_type
|
| 63 |
+
return output
|
image_processing_perception_lm_fast.py
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# *************************************************************************
|
| 2 |
+
# This file may have been modified by Bytedance Inc. (“Bytedance Inc.'s Mo-
|
| 3 |
+
# difications”). All Bytedance Inc.'s Modifications are Copyright (2025) B-
|
| 4 |
+
# ytedance Inc..
|
| 5 |
+
# *************************************************************************
|
| 6 |
+
|
| 7 |
+
# Adapted from https://github.com/huggingface/transformers/blob/v4.55.4/src/transformers/models/perception_lm/image_processing_perception_lm_fast.py
|
| 8 |
+
|
| 9 |
+
# Copyright 2025 Meta Platforms, Inc. and the HuggingFace Inc. team. All rights reserved.
|
| 10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 11 |
+
# you may not use this file except in compliance with the License.
|
| 12 |
+
# You may obtain a copy of the License at
|
| 13 |
+
#
|
| 14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 15 |
+
#
|
| 16 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 19 |
+
# See the License for the specific language governing permissions and
|
| 20 |
+
# limitations under the License.
|
| 21 |
+
"""Fast Image processor class for PerceptionLM."""
|
| 22 |
+
|
| 23 |
+
import math
|
| 24 |
+
from functools import reduce
|
| 25 |
+
from typing import Optional, Union
|
| 26 |
+
|
| 27 |
+
import numpy as np
|
| 28 |
+
from transformers.image_processing_utils import BatchFeature
|
| 29 |
+
from transformers.image_processing_utils_fast import (
|
| 30 |
+
BaseImageProcessorFast,
|
| 31 |
+
DefaultFastImageProcessorKwargs,
|
| 32 |
+
get_image_size,
|
| 33 |
+
group_images_by_shape,
|
| 34 |
+
reorder_images,
|
| 35 |
+
)
|
| 36 |
+
from transformers.image_utils import (
|
| 37 |
+
IMAGENET_STANDARD_MEAN,
|
| 38 |
+
IMAGENET_STANDARD_STD,
|
| 39 |
+
ChannelDimension,
|
| 40 |
+
PILImageResampling,
|
| 41 |
+
)
|
| 42 |
+
from transformers.processing_utils import Unpack
|
| 43 |
+
from transformers.utils import (
|
| 44 |
+
TensorType,
|
| 45 |
+
auto_docstring,
|
| 46 |
+
is_torch_available,
|
| 47 |
+
is_torchvision_available,
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
if is_torch_available():
|
| 51 |
+
import torch
|
| 52 |
+
|
| 53 |
+
if is_torchvision_available():
|
| 54 |
+
from torchvision.transforms import functional as F
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class PerceptionLMFastImageProcessorKwargs(DefaultFastImageProcessorKwargs):
|
| 58 |
+
r"""
|
| 59 |
+
vision_input_type (`str`, *optional*, defaults to `"thumb+tile"`):
|
| 60 |
+
Vision processing strategy. `"thumb+tile"` uses both thumbnails and multiple tiles for
|
| 61 |
+
multi-scale processing, otherwise uses single tile for lower memory usage.
|
| 62 |
+
tile_size (`int`, *optional*, defaults to `448`):
|
| 63 |
+
Height and width dimension (in pixels) of each tile used for image processing.
|
| 64 |
+
max_num_tiles (`int`, *optional*, defaults to `36`):
|
| 65 |
+
Maximum number of tiles an image can be split into based on its aspect ratio.
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
vision_input_type: str = "thumb+tile"
|
| 69 |
+
tile_size: int = 448
|
| 70 |
+
max_num_tiles: int = 36
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
@auto_docstring
|
| 74 |
+
class PerceptionLMImageProcessorFast(BaseImageProcessorFast):
|
| 75 |
+
resample = PILImageResampling.BICUBIC
|
| 76 |
+
image_mean = IMAGENET_STANDARD_MEAN
|
| 77 |
+
image_std = IMAGENET_STANDARD_STD
|
| 78 |
+
do_resize = True
|
| 79 |
+
do_center_crop = False
|
| 80 |
+
do_rescale = True
|
| 81 |
+
do_normalize = True
|
| 82 |
+
do_convert_rgb = True
|
| 83 |
+
size = {"width": 448, "height": 448} # for backward compatibility in tests
|
| 84 |
+
valid_kwargs = PerceptionLMFastImageProcessorKwargs
|
| 85 |
+
|
| 86 |
+
def __init__(self, **kwargs: Unpack[PerceptionLMFastImageProcessorKwargs]) -> None:
|
| 87 |
+
super().__init__(**kwargs)
|
| 88 |
+
|
| 89 |
+
@auto_docstring
|
| 90 |
+
def preprocess(
|
| 91 |
+
self, images, **kwargs: Unpack[PerceptionLMFastImageProcessorKwargs]
|
| 92 |
+
) -> BatchFeature:
|
| 93 |
+
return super().preprocess(images, **kwargs)
|
| 94 |
+
|
| 95 |
+
@staticmethod
|
| 96 |
+
def _factors(n: int):
|
| 97 |
+
"""Return all factors of a number."""
|
| 98 |
+
return set(
|
| 99 |
+
reduce(
|
| 100 |
+
list.__add__,
|
| 101 |
+
([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0),
|
| 102 |
+
)
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
def _find_supported_aspect_ratios(self):
|
| 106 |
+
"""
|
| 107 |
+
This function computes all the allowed aspect ratios for a fixed
|
| 108 |
+
number of input chunks. The order of returned items matters for the result of `_fit_image_to_canvas` function.
|
| 109 |
+
If tie exists in `_fit_image_to_canvas`, the latter in `_find_supported_aspect_ratios` wins.
|
| 110 |
+
|
| 111 |
+
For example, with `num_tiles=5`, it will return:
|
| 112 |
+
{
|
| 113 |
+
0.2: [(1, 5)],
|
| 114 |
+
5.0: [(5, 1)],
|
| 115 |
+
0.25: [(1, 4)],
|
| 116 |
+
1.0: [(2, 2), (1, 1)],
|
| 117 |
+
4.0: [(4, 1)],
|
| 118 |
+
0.3333333333333333: [(1, 3)],
|
| 119 |
+
3.0: [(3, 1)],
|
| 120 |
+
0.5: [(1, 2)],
|
| 121 |
+
2.0: [(2, 1)]
|
| 122 |
+
}
|
| 123 |
+
"""
|
| 124 |
+
asp_dict = {}
|
| 125 |
+
for chunk_size in range(self.max_num_tiles, 0, -1):
|
| 126 |
+
_factors = sorted(self._factors(chunk_size))
|
| 127 |
+
_asp_ratios = [(x, chunk_size // x) for x in _factors]
|
| 128 |
+
for ratio in _asp_ratios:
|
| 129 |
+
k = ratio[0] / ratio[1]
|
| 130 |
+
if k not in asp_dict:
|
| 131 |
+
asp_dict[k] = [ratio]
|
| 132 |
+
else:
|
| 133 |
+
asp_dict[k].append(ratio)
|
| 134 |
+
return asp_dict
|
| 135 |
+
|
| 136 |
+
def _get_image_height_width(
|
| 137 |
+
self, image_width: int, image_height: int, target_width: int, target_height: int
|
| 138 |
+
) -> tuple[int, int]:
|
| 139 |
+
"""
|
| 140 |
+
Given image width, height and target width, height for the canvas, return the dimensions of how the image would be resized
|
| 141 |
+
with aspect ratio preservation.
|
| 142 |
+
"""
|
| 143 |
+
scale = image_width / image_height
|
| 144 |
+
|
| 145 |
+
if scale > 1.0:
|
| 146 |
+
# Width is larger than height
|
| 147 |
+
|
| 148 |
+
# Rescaling factor is the minimum of the two scaling factors. Else one side would be outside of the canvas.
|
| 149 |
+
rescaling_factor = min(
|
| 150 |
+
target_width / image_width, target_height / image_height
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
# Set new width to target width and height to the rescaled height.
|
| 154 |
+
new_w = rescaling_factor * image_width
|
| 155 |
+
new_h = math.floor(new_w / scale)
|
| 156 |
+
|
| 157 |
+
else:
|
| 158 |
+
# Height is larger than width
|
| 159 |
+
|
| 160 |
+
# Rescaling factor is the minimum of the two scaling factors. Else one side would be outside of the canvas.
|
| 161 |
+
rescaling_factor = min(
|
| 162 |
+
target_width / image_width, target_height / image_height
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
# Set new height to target height and width to the rescaled width.
|
| 166 |
+
new_h = rescaling_factor * image_height
|
| 167 |
+
new_w = math.floor(new_h * scale)
|
| 168 |
+
|
| 169 |
+
return new_w, new_h
|
| 170 |
+
|
| 171 |
+
def _fit_image_to_canvas(self, img_width: int, img_height: int, tile_size: int):
|
| 172 |
+
"""
|
| 173 |
+
Given an image width, height and target number of chunks this function will see if the image
|
| 174 |
+
can be fit into any of the canvases that can be build from arranging the tiles in a grid.
|
| 175 |
+
If the image can be fit onto several canvases, it will return the canvas where the shorter edge
|
| 176 |
+
of the image will be largest.
|
| 177 |
+
"""
|
| 178 |
+
# Initialize the optimal canvas to None. If no canvas is found where image fits, function returns None.
|
| 179 |
+
optimal_canvas = None
|
| 180 |
+
optimal_image_width_height = None
|
| 181 |
+
|
| 182 |
+
scale = img_width / img_height
|
| 183 |
+
|
| 184 |
+
# Gather all potential supported image resolutions and iterate through them to find best match
|
| 185 |
+
potential_arrangements = [
|
| 186 |
+
item
|
| 187 |
+
for sublist in self._find_supported_aspect_ratios().values()
|
| 188 |
+
for item in sublist
|
| 189 |
+
]
|
| 190 |
+
for n_w, n_h in potential_arrangements:
|
| 191 |
+
# Compute the canvas size
|
| 192 |
+
canvas_width, canvas_height = n_w * tile_size, n_h * tile_size
|
| 193 |
+
|
| 194 |
+
# Check if image can fit into the canvas without downsampling
|
| 195 |
+
if canvas_width >= img_width and canvas_height >= img_height:
|
| 196 |
+
# If we did not find a good canvas yet, we will use the current one
|
| 197 |
+
if optimal_canvas is None:
|
| 198 |
+
# Set optimal canvas and determine the actual image height and width in the canvas with aspect ratio preserving resampling
|
| 199 |
+
optimal_canvas = (n_w, n_h)
|
| 200 |
+
optimal_image_width_height = self._get_image_height_width(
|
| 201 |
+
image_width=img_width,
|
| 202 |
+
image_height=img_height,
|
| 203 |
+
target_width=n_w * tile_size,
|
| 204 |
+
target_height=n_h * tile_size,
|
| 205 |
+
)
|
| 206 |
+
else:
|
| 207 |
+
# If we already found an optimal canvas before, we will check if the shorter edge of the image will be larger than the current optimal canvas.
|
| 208 |
+
# This means we can potentially upsample the image resolution which is beneficial to performance.
|
| 209 |
+
image_width_height = self._get_image_height_width(
|
| 210 |
+
image_width=img_width,
|
| 211 |
+
image_height=img_height,
|
| 212 |
+
target_width=n_w * tile_size,
|
| 213 |
+
target_height=n_h * tile_size,
|
| 214 |
+
)
|
| 215 |
+
# Llama3V dynamic tiling. Priortize biggest canvas.
|
| 216 |
+
if (
|
| 217 |
+
scale < 1.0
|
| 218 |
+
and (image_width_height[0] >= optimal_image_width_height[0])
|
| 219 |
+
) or (
|
| 220 |
+
scale >= 1.0
|
| 221 |
+
and (image_width_height[1] >= optimal_image_width_height[1])
|
| 222 |
+
):
|
| 223 |
+
optimal_canvas = (n_w, n_h)
|
| 224 |
+
optimal_image_width_height = image_width_height
|
| 225 |
+
return optimal_canvas
|
| 226 |
+
|
| 227 |
+
def _find_closest_aspect_ratio(
|
| 228 |
+
self, img_width: int, img_height: int, tile_size: int
|
| 229 |
+
) -> tuple:
|
| 230 |
+
"""
|
| 231 |
+
Given an image width, height and target number of chunks
|
| 232 |
+
this function will find the closest supported aspect ratio.
|
| 233 |
+
"""
|
| 234 |
+
target_aspect_ratio = img_width / img_height
|
| 235 |
+
asp_dict = self._find_supported_aspect_ratios()
|
| 236 |
+
closest_aspect_ratio = None
|
| 237 |
+
if target_aspect_ratio >= 1:
|
| 238 |
+
closest_aspect_ratio = min(
|
| 239 |
+
[k for k in asp_dict if k <= target_aspect_ratio],
|
| 240 |
+
key=lambda x: abs(x - target_aspect_ratio),
|
| 241 |
+
)
|
| 242 |
+
tiles_given_aspect_ratio = asp_dict[closest_aspect_ratio]
|
| 243 |
+
# select largest width
|
| 244 |
+
return max(tiles_given_aspect_ratio, key=lambda x: x[0])
|
| 245 |
+
else:
|
| 246 |
+
closest_aspect_ratio = min(
|
| 247 |
+
[k for k in asp_dict if k > target_aspect_ratio],
|
| 248 |
+
key=lambda x: abs(1 / x - 1 / target_aspect_ratio),
|
| 249 |
+
)
|
| 250 |
+
tiles_given_aspect_ratio = asp_dict[closest_aspect_ratio]
|
| 251 |
+
# select largest height
|
| 252 |
+
return max(tiles_given_aspect_ratio, key=lambda x: x[1])
|
| 253 |
+
|
| 254 |
+
def _split(self, image: torch.Tensor, ncw: int, nch: int) -> torch.Tensor:
|
| 255 |
+
# Split image into number of required tiles (width x height)
|
| 256 |
+
batch_size, num_channels, height, width = image.size()
|
| 257 |
+
image = image.view(
|
| 258 |
+
batch_size, num_channels, nch, height // nch, ncw, width // ncw
|
| 259 |
+
)
|
| 260 |
+
# Permute dimensions to reorder the axes
|
| 261 |
+
image = image.permute(0, 2, 4, 1, 3, 5).contiguous()
|
| 262 |
+
# Reshape into the desired output shape (batch_size * 4, num_channels, width/2, height/2)
|
| 263 |
+
image = image.view(
|
| 264 |
+
batch_size, ncw * nch, num_channels, height // nch, width // ncw
|
| 265 |
+
)
|
| 266 |
+
return image
|
| 267 |
+
|
| 268 |
+
def resize(
|
| 269 |
+
self,
|
| 270 |
+
image: np.ndarray,
|
| 271 |
+
tile_size: int,
|
| 272 |
+
max_num_tiles: int,
|
| 273 |
+
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
| 274 |
+
input_data_format: Optional[Union[str, ChannelDimension]] = None,
|
| 275 |
+
):
|
| 276 |
+
height, width = get_image_size(image, channel_dim=input_data_format)
|
| 277 |
+
if max_num_tiles > 1:
|
| 278 |
+
aspect_ratio = self._fit_image_to_canvas(
|
| 279 |
+
img_width=width, img_height=height, tile_size=tile_size
|
| 280 |
+
)
|
| 281 |
+
if aspect_ratio is None:
|
| 282 |
+
# If we did not find a canvas, we have to find the closest aspect ratio and downsample the image
|
| 283 |
+
aspect_ratio = self._find_closest_aspect_ratio(
|
| 284 |
+
img_width=width, img_height=height, tile_size=tile_size
|
| 285 |
+
)
|
| 286 |
+
else:
|
| 287 |
+
aspect_ratio = (1, 1)
|
| 288 |
+
new_width, new_height = aspect_ratio[0] * tile_size, aspect_ratio[1] * tile_size
|
| 289 |
+
image = F.resize(image, (new_height, new_width), interpolation=resample)
|
| 290 |
+
return image, aspect_ratio
|
| 291 |
+
|
| 292 |
+
def _preprocess(
|
| 293 |
+
self,
|
| 294 |
+
images: list["torch.Tensor"],
|
| 295 |
+
do_resize: bool,
|
| 296 |
+
do_rescale: Optional[bool],
|
| 297 |
+
rescale_factor: Optional[Union[int, float]],
|
| 298 |
+
do_normalize: Optional[bool],
|
| 299 |
+
image_mean: Optional[Union[float, list[float]]],
|
| 300 |
+
image_std: Optional[Union[float, list[float]]],
|
| 301 |
+
vision_input_type: str,
|
| 302 |
+
tile_size: int,
|
| 303 |
+
max_num_tiles: int,
|
| 304 |
+
return_tensors: Optional[Union[str, TensorType]],
|
| 305 |
+
disable_grouping: bool,
|
| 306 |
+
**kwargs: Unpack[PerceptionLMFastImageProcessorKwargs],
|
| 307 |
+
) -> BatchFeature:
|
| 308 |
+
# Group images by size for batched transformation
|
| 309 |
+
|
| 310 |
+
resample = kwargs.pop("resample", self.resample)
|
| 311 |
+
|
| 312 |
+
grouped_images, grouped_images_index = group_images_by_shape(
|
| 313 |
+
images, disable_grouping=disable_grouping
|
| 314 |
+
)
|
| 315 |
+
resized_images_grouped = {}
|
| 316 |
+
aspect_ratio = [1, 1]
|
| 317 |
+
for shape, stacked_images in grouped_images.items():
|
| 318 |
+
if do_resize:
|
| 319 |
+
if vision_input_type == "thumb+tile":
|
| 320 |
+
thumbnails, _ = self.resize(
|
| 321 |
+
stacked_images,
|
| 322 |
+
tile_size,
|
| 323 |
+
max_num_tiles=1,
|
| 324 |
+
resample=resample,
|
| 325 |
+
)
|
| 326 |
+
images_for_tiling, (tiles_w, tiles_h) = self.resize(
|
| 327 |
+
stacked_images,
|
| 328 |
+
tile_size,
|
| 329 |
+
max_num_tiles=max_num_tiles,
|
| 330 |
+
resample=resample,
|
| 331 |
+
)
|
| 332 |
+
image_tiles = self._split(images_for_tiling, tiles_w, tiles_h)
|
| 333 |
+
stacked_images = torch.cat(
|
| 334 |
+
[thumbnails.unsqueeze(1), image_tiles], dim=1
|
| 335 |
+
)
|
| 336 |
+
aspect_ratio = [tiles_w, tiles_h]
|
| 337 |
+
else: # vanilla single tile for low memory devices
|
| 338 |
+
stacked_images, _ = self.resize(
|
| 339 |
+
stacked_images,
|
| 340 |
+
tile_size,
|
| 341 |
+
max_num_tiles=1,
|
| 342 |
+
resample=resample,
|
| 343 |
+
)
|
| 344 |
+
|
| 345 |
+
resized_images_grouped[shape] = stacked_images
|
| 346 |
+
resized_images = reorder_images(resized_images_grouped, grouped_images_index)
|
| 347 |
+
|
| 348 |
+
grouped_images, grouped_images_index = group_images_by_shape(
|
| 349 |
+
resized_images, disable_grouping=disable_grouping
|
| 350 |
+
)
|
| 351 |
+
processed_images_grouped = {}
|
| 352 |
+
for shape, stacked_images in grouped_images.items():
|
| 353 |
+
# Fused rescale and normalize
|
| 354 |
+
stacked_images = self.rescale_and_normalize(
|
| 355 |
+
stacked_images,
|
| 356 |
+
do_rescale,
|
| 357 |
+
rescale_factor,
|
| 358 |
+
do_normalize,
|
| 359 |
+
image_mean,
|
| 360 |
+
image_std,
|
| 361 |
+
)
|
| 362 |
+
processed_images_grouped[shape] = stacked_images
|
| 363 |
+
processed_images = reorder_images(
|
| 364 |
+
processed_images_grouped, grouped_images_index
|
| 365 |
+
)
|
| 366 |
+
processed_images = [
|
| 367 |
+
p[None] if p.ndim == 3 else p for p in processed_images
|
| 368 |
+
] # add tiles dimension if needed
|
| 369 |
+
processed_images = (
|
| 370 |
+
torch.stack(processed_images, dim=0) if return_tensors else processed_images
|
| 371 |
+
)
|
| 372 |
+
return BatchFeature(
|
| 373 |
+
data={"pixel_values": processed_images, "aspect_ratio": aspect_ratio},
|
| 374 |
+
tensor_type=return_tensors,
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
__all__ = ["PerceptionLMImageProcessorFast"]
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9314ba927fcef833a56fd3e3d664ff4093e27af6c8415ce808951a34061f393b
|
| 3 |
+
size 3068342248
|
modeling_gar.py
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, Optional, Tuple, Union
|
| 2 |
+
from torch import nn
|
| 3 |
+
from transformers.modeling_outputs import CausalLMOutputWithPast
|
| 4 |
+
from transformers.utils import logging
|
| 5 |
+
from typing import Optional, Union
|
| 6 |
+
import torch
|
| 7 |
+
import torchvision
|
| 8 |
+
from torch import nn
|
| 9 |
+
from einops import rearrange
|
| 10 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 11 |
+
from transformers import GenerationConfig
|
| 12 |
+
|
| 13 |
+
from .configuration_gar import GARConfig
|
| 14 |
+
from .modeling_perception_lm import PerceptionLMForConditionalGeneration
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
logger = logging.get_logger(__name__)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class GARModel(PreTrainedModel):
|
| 21 |
+
config_class = GARConfig
|
| 22 |
+
main_input_name = 'pixel_values'
|
| 23 |
+
base_model_prefix = 'language_model'
|
| 24 |
+
_no_split_modules = ['LlamaDecoderLayer']
|
| 25 |
+
_supports_flash_attn_2 = True
|
| 26 |
+
supports_gradient_checkpointing = True
|
| 27 |
+
|
| 28 |
+
def __init__(
|
| 29 |
+
self,
|
| 30 |
+
config: GARConfig,
|
| 31 |
+
mllm=None,
|
| 32 |
+
mask_patch_embedding=None,
|
| 33 |
+
use_flash_attn=True,
|
| 34 |
+
):
|
| 35 |
+
super().__init__(config)
|
| 36 |
+
use_flash_attn = use_flash_attn
|
| 37 |
+
config.mllm_config.use_flash_attn = True if use_flash_attn else False
|
| 38 |
+
config.mllm_config.text_config.use_flash_attn = True if use_flash_attn else False
|
| 39 |
+
config.mllm_config.vision_config.use_flash_attn = False
|
| 40 |
+
|
| 41 |
+
config.mllm_config._attn_implementation = 'flash_attention_2' if use_flash_attn else 'eager'
|
| 42 |
+
config.mllm_config.vision_config._attn_implementation = 'eager'
|
| 43 |
+
|
| 44 |
+
self.prompt_numbers = config.prompt_numbers
|
| 45 |
+
|
| 46 |
+
if mllm is not None:
|
| 47 |
+
self.mllm = mllm
|
| 48 |
+
else:
|
| 49 |
+
self.mllm = PerceptionLMForConditionalGeneration(config.mllm_config)
|
| 50 |
+
if mask_patch_embedding is not None:
|
| 51 |
+
self.mask_patch_embedding = mask_patch_embedding
|
| 52 |
+
else:
|
| 53 |
+
self.mask_patch_embedding = nn.Conv2d(
|
| 54 |
+
in_channels=3,
|
| 55 |
+
out_channels=config.mask_path_embedding_out_channels,
|
| 56 |
+
kernel_size=config.kernel_size,
|
| 57 |
+
stride=config.kernel_size,
|
| 58 |
+
bias=False,
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
self.crop_tokens_ids = config.crop_tokens_ids
|
| 62 |
+
|
| 63 |
+
@property
|
| 64 |
+
def lm_head(self):
|
| 65 |
+
return self.mllm.model.language_model.get_output_embeddings()
|
| 66 |
+
|
| 67 |
+
def get_input_embeddings(self):
|
| 68 |
+
return self.mllm.model.language_model.get_input_embeddings()
|
| 69 |
+
|
| 70 |
+
def get_output_embeddings(self):
|
| 71 |
+
return self.mllm.model.language_model.get_output_embeddings()
|
| 72 |
+
|
| 73 |
+
def forward(self, data, data_samples=None, mode='loss'):
|
| 74 |
+
crop_tokens = self.crop_tokens_ids
|
| 75 |
+
# (batch_size, num_tiles, channels, height, width)
|
| 76 |
+
pixel_values = data['pixel_values'].to(self.mllm.device).to(self.mllm.dtype)
|
| 77 |
+
mask_values = torch.round((data['global_mask_values'] + 1.) / 2. * 255.).long().to(self.mllm.device)
|
| 78 |
+
mask_values = torch.clamp(mask_values, min=0, max=self.prompt_numbers)
|
| 79 |
+
assert mask_values.max() < self.prompt_numbers + 1 and mask_values.min() >= 0
|
| 80 |
+
|
| 81 |
+
mask_embeds = self.mask_patch_embedding((mask_values != self.prompt_numbers).to(self.mllm.dtype)) # binary mask
|
| 82 |
+
input_ids = data['input_ids']
|
| 83 |
+
aspect_ratios = data['aspect_ratios']
|
| 84 |
+
bboxes = data['bboxes']
|
| 85 |
+
assert input_ids.shape[0] == 1, "Currently only support batch_size=1"
|
| 86 |
+
|
| 87 |
+
inputs_embeds = self.mllm.get_input_embeddings()(input_ids)
|
| 88 |
+
labels = data['labels']
|
| 89 |
+
|
| 90 |
+
image_features = None
|
| 91 |
+
if pixel_values is not None:
|
| 92 |
+
image_features = self.mllm.get_image_features(
|
| 93 |
+
pixel_values=pixel_values.unsqueeze(0),
|
| 94 |
+
mask_embeds=mask_embeds,
|
| 95 |
+
)
|
| 96 |
+
image_features = image_features.to(inputs_embeds.device, dtype=inputs_embeds.dtype)
|
| 97 |
+
special_image_mask, _ = self.mllm.get_placeholder_mask(
|
| 98 |
+
input_ids, inputs_embeds=inputs_embeds, image_features=image_features
|
| 99 |
+
)
|
| 100 |
+
inputs_embeds = inputs_embeds.masked_scatter(special_image_mask, image_features)
|
| 101 |
+
|
| 102 |
+
# feature replay
|
| 103 |
+
new_inputs_embeds = []
|
| 104 |
+
new_labels = []
|
| 105 |
+
image_features_tiles = rearrange(image_features[1:].unsqueeze(0), 'b n (h w) c -> b n c h w', h=16, w=16)
|
| 106 |
+
for batch_idx in range(inputs_embeds.shape[0]):
|
| 107 |
+
curr_inputs_embeds = inputs_embeds[batch_idx]
|
| 108 |
+
curr_labels = labels[batch_idx]
|
| 109 |
+
for crop_token in crop_tokens:
|
| 110 |
+
if crop_token in input_ids[batch_idx]:
|
| 111 |
+
target_mask = input_ids[batch_idx].eq(crop_token)
|
| 112 |
+
target_indices = target_mask.nonzero().squeeze()
|
| 113 |
+
head_idx = target_indices.min().item()
|
| 114 |
+
tail_idx = target_indices.max().item()
|
| 115 |
+
image_features_recover = self._merge(image_features_tiles, aspect_ratios[batch_idx][0], aspect_ratios[batch_idx][1])
|
| 116 |
+
feat_h, feat_w = image_features_recover.shape[2:]
|
| 117 |
+
|
| 118 |
+
x1, y1, x2, y2 = bboxes[batch_idx][str(crop_token)]
|
| 119 |
+
orig_h, orig_w = feat_h * 28, feat_w * 28
|
| 120 |
+
|
| 121 |
+
# origin box
|
| 122 |
+
roi_orig_x1 = x1 * orig_w
|
| 123 |
+
roi_orig_y1 = y1 * orig_h
|
| 124 |
+
roi_orig_x2 = x2 * orig_w
|
| 125 |
+
roi_orig_y2 = y2 * orig_h
|
| 126 |
+
|
| 127 |
+
# feat box
|
| 128 |
+
spatial_scale = feat_w / orig_w
|
| 129 |
+
roi_feat_x1 = roi_orig_x1 * spatial_scale
|
| 130 |
+
roi_feat_y1 = roi_orig_y1 * spatial_scale
|
| 131 |
+
roi_feat_x2 = roi_orig_x2 * spatial_scale
|
| 132 |
+
roi_feat_y2 = roi_orig_y2 * spatial_scale
|
| 133 |
+
|
| 134 |
+
roi = torch.tensor(
|
| 135 |
+
[0, roi_feat_x1, roi_feat_y1, roi_feat_x2, roi_feat_y2],
|
| 136 |
+
dtype=torch.float32, device=image_features_recover.device,
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
roi_features = torchvision.ops.roi_align(
|
| 140 |
+
input=image_features_recover.float(),
|
| 141 |
+
boxes=roi.unsqueeze(0),
|
| 142 |
+
output_size=(16, 16),
|
| 143 |
+
spatial_scale=spatial_scale,
|
| 144 |
+
sampling_ratio=2,
|
| 145 |
+
aligned=True,
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
image_features_replay = roi_features.permute(0, 2, 3, 1).flatten(1, 2).to(image_features_recover.dtype).squeeze()
|
| 149 |
+
|
| 150 |
+
curr_inputs_embeds = torch.cat([
|
| 151 |
+
curr_inputs_embeds[:head_idx],
|
| 152 |
+
image_features_replay,
|
| 153 |
+
curr_inputs_embeds[tail_idx+1:],
|
| 154 |
+
])
|
| 155 |
+
curr_labels = torch.cat([
|
| 156 |
+
curr_labels[:head_idx],
|
| 157 |
+
-100 * torch.ones(image_features_replay.shape[0], dtype=torch.long, device=labels.device),
|
| 158 |
+
curr_labels[tail_idx+1:],
|
| 159 |
+
])
|
| 160 |
+
|
| 161 |
+
assert curr_inputs_embeds.shape[0] == curr_labels.shape[0], f"shape mismatch, got {curr_inputs_embeds.shape[0]} != {curr_labels.shape[0]}"
|
| 162 |
+
|
| 163 |
+
new_inputs_embeds.append(curr_inputs_embeds.unsqueeze(0))
|
| 164 |
+
new_labels.append(curr_labels)
|
| 165 |
+
|
| 166 |
+
inputs_embeds = torch.cat(new_inputs_embeds, dim=0)
|
| 167 |
+
labels = torch.cat(new_labels, dim=0)
|
| 168 |
+
|
| 169 |
+
skip_this_batch = False
|
| 170 |
+
|
| 171 |
+
if mode == "loss":
|
| 172 |
+
position_ids = torch.arange(0, inputs_embeds.shape[1], dtype=torch.long, device=inputs_embeds.device).unsqueeze(0).repeat(inputs_embeds.shape[0], 1)
|
| 173 |
+
attention_mask = torch.ones(inputs_embeds.shape[0], inputs_embeds.shape[1], dtype=torch.long, device=inputs_embeds.device)
|
| 174 |
+
use_cache = False
|
| 175 |
+
|
| 176 |
+
outputs, _skip_this_case = self._llm_forward(
|
| 177 |
+
inputs_embeds=inputs_embeds,
|
| 178 |
+
position_ids=position_ids,
|
| 179 |
+
attention_mask=attention_mask,
|
| 180 |
+
labels=labels,
|
| 181 |
+
use_cache=use_cache
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
if skip_this_batch or _skip_this_case:
|
| 185 |
+
print("skip this batch!")
|
| 186 |
+
loss_dict = {'loss': outputs.loss * 0.0}
|
| 187 |
+
else:
|
| 188 |
+
loss_dict = {'loss': outputs.loss}
|
| 189 |
+
return loss_dict
|
| 190 |
+
|
| 191 |
+
elif mode == "predict":
|
| 192 |
+
pass
|
| 193 |
+
elif mode == "tensor":
|
| 194 |
+
pass
|
| 195 |
+
else:
|
| 196 |
+
raise NotImplementedError
|
| 197 |
+
|
| 198 |
+
return outputs
|
| 199 |
+
|
| 200 |
+
def _merge(self, tiles: torch.Tensor, ncw: int, nch: int) -> torch.Tensor:
|
| 201 |
+
batch_size, num_tiles, num_channels, tile_height, tile_width = tiles.size()
|
| 202 |
+
assert num_tiles == ncw * nch, f"{ncw * nch} != {num_tiles}"
|
| 203 |
+
|
| 204 |
+
tiles = tiles.view(batch_size, nch, ncw, num_channels, tile_height, tile_width)
|
| 205 |
+
tiles = tiles.permute(0, 3, 1, 4, 2, 5).contiguous()
|
| 206 |
+
|
| 207 |
+
original_height = nch * tile_height
|
| 208 |
+
original_width = ncw * tile_width
|
| 209 |
+
|
| 210 |
+
image = tiles.view(batch_size, num_channels, original_height, original_width)
|
| 211 |
+
|
| 212 |
+
return image
|
| 213 |
+
|
| 214 |
+
def _llm_forward(
|
| 215 |
+
self,
|
| 216 |
+
inputs_embeds: torch.FloatTensor,
|
| 217 |
+
input_ids: torch.LongTensor = None,
|
| 218 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 219 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 220 |
+
image_flags: Optional[torch.LongTensor] = None,
|
| 221 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 222 |
+
labels: Optional[torch.LongTensor] = None,
|
| 223 |
+
use_cache: Optional[bool] = None,
|
| 224 |
+
output_attentions: Optional[bool] = None,
|
| 225 |
+
output_hidden_states: Optional[bool] = None,
|
| 226 |
+
return_dict: Optional[bool] = None,
|
| 227 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
| 228 |
+
return_dict = return_dict if return_dict is not None \
|
| 229 |
+
else self.mllm.config.use_return_dict
|
| 230 |
+
skip_this_case = False
|
| 231 |
+
|
| 232 |
+
outputs = self.mllm(
|
| 233 |
+
inputs_embeds=inputs_embeds,
|
| 234 |
+
attention_mask=attention_mask,
|
| 235 |
+
position_ids=position_ids,
|
| 236 |
+
labels=labels,
|
| 237 |
+
past_key_values=past_key_values,
|
| 238 |
+
use_cache=use_cache,
|
| 239 |
+
output_attentions=output_attentions,
|
| 240 |
+
output_hidden_states=output_hidden_states,
|
| 241 |
+
return_dict=return_dict,
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
return outputs, skip_this_case
|
| 245 |
+
|
| 246 |
+
@torch.no_grad()
|
| 247 |
+
def generate(
|
| 248 |
+
self,
|
| 249 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 250 |
+
global_mask_values: Optional[torch.LongTensor] = None,
|
| 251 |
+
aspect_ratios: Optional[torch.FloatTensor] = None,
|
| 252 |
+
bboxes: Optional[torch.FloatTensor] = None,
|
| 253 |
+
input_ids: Optional[torch.FloatTensor] = None,
|
| 254 |
+
attention_mask: Optional[torch.LongTensor] = None,
|
| 255 |
+
generation_config: Optional[GenerationConfig] = None,
|
| 256 |
+
output_hidden_states: Optional[bool] = None,
|
| 257 |
+
return_dict: Optional[bool] = None,
|
| 258 |
+
**generate_kwargs,
|
| 259 |
+
) -> torch.LongTensor:
|
| 260 |
+
device = self.device
|
| 261 |
+
|
| 262 |
+
if pixel_values is not None:
|
| 263 |
+
pixel_values = pixel_values.to(device).to(self.mllm.dtype)
|
| 264 |
+
if global_mask_values is not None:
|
| 265 |
+
|
| 266 |
+
mask_values = torch.round((global_mask_values + 1.) / 2. * 255.).long().to(device)
|
| 267 |
+
mask_values = torch.clamp(mask_values, min=0, max=self.prompt_numbers)
|
| 268 |
+
|
| 269 |
+
assert mask_values.max() < self.prompt_numbers + 1 and mask_values.min() >= 0, f"max: {mask_values.max()}, min: {mask_values.min()}"
|
| 270 |
+
mask_embeds = self.mask_patch_embedding((mask_values != self.prompt_numbers).to(self.mllm.dtype))
|
| 271 |
+
else:
|
| 272 |
+
mask_embeds = None
|
| 273 |
+
|
| 274 |
+
inputs_embeds = self.mllm.get_input_embeddings()(input_ids)
|
| 275 |
+
|
| 276 |
+
image_features = self.mllm.get_image_features(
|
| 277 |
+
pixel_values=pixel_values.unsqueeze(0),
|
| 278 |
+
mask_embeds=mask_embeds,
|
| 279 |
+
)
|
| 280 |
+
image_features = image_features.to(inputs_embeds.device, dtype=inputs_embeds.dtype)
|
| 281 |
+
special_image_mask, _ = self.mllm.get_placeholder_mask(
|
| 282 |
+
input_ids, inputs_embeds=inputs_embeds, image_features=image_features
|
| 283 |
+
)
|
| 284 |
+
inputs_embeds = inputs_embeds.masked_scatter(special_image_mask, image_features)
|
| 285 |
+
|
| 286 |
+
# feature replay
|
| 287 |
+
new_inputs_embeds = []
|
| 288 |
+
image_features_tiles = rearrange(image_features[1:].unsqueeze(0), 'b n (h w) c -> b n c h w', h=16, w=16)
|
| 289 |
+
for batch_idx in range(inputs_embeds.shape[0]):
|
| 290 |
+
curr_inputs_embeds = inputs_embeds[batch_idx]
|
| 291 |
+
for crop_token in self.crop_tokens_ids:
|
| 292 |
+
if crop_token in input_ids[batch_idx]:
|
| 293 |
+
target_mask = input_ids[batch_idx].eq(crop_token)
|
| 294 |
+
target_indices = target_mask.nonzero().squeeze()
|
| 295 |
+
head_idx = target_indices.min().item()
|
| 296 |
+
tail_idx = target_indices.max().item()
|
| 297 |
+
image_features_recover = self._merge(image_features_tiles, aspect_ratios[batch_idx][0], aspect_ratios[batch_idx][1])
|
| 298 |
+
feat_h, feat_w = image_features_recover.shape[2:]
|
| 299 |
+
x1, y1, x2, y2 = bboxes[batch_idx][str(crop_token)]
|
| 300 |
+
orig_h, orig_w = feat_h * 28, feat_w * 28
|
| 301 |
+
|
| 302 |
+
# origin box
|
| 303 |
+
roi_orig_x1 = x1 * orig_w
|
| 304 |
+
roi_orig_y1 = y1 * orig_h
|
| 305 |
+
roi_orig_x2 = x2 * orig_w
|
| 306 |
+
roi_orig_y2 = y2 * orig_h
|
| 307 |
+
|
| 308 |
+
# feat box
|
| 309 |
+
spatial_scale = feat_w / orig_w
|
| 310 |
+
roi_feat_x1 = roi_orig_x1 * spatial_scale
|
| 311 |
+
roi_feat_y1 = roi_orig_y1 * spatial_scale
|
| 312 |
+
roi_feat_x2 = roi_orig_x2 * spatial_scale
|
| 313 |
+
roi_feat_y2 = roi_orig_y2 * spatial_scale
|
| 314 |
+
|
| 315 |
+
roi = torch.tensor(
|
| 316 |
+
[0, roi_feat_x1, roi_feat_y1, roi_feat_x2, roi_feat_y2],
|
| 317 |
+
dtype=torch.float32, device=image_features_recover.device,
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
roi_features = torchvision.ops.roi_align(
|
| 321 |
+
input=image_features_recover.float(),
|
| 322 |
+
boxes=roi.unsqueeze(0),
|
| 323 |
+
output_size=(16, 16),
|
| 324 |
+
spatial_scale=spatial_scale,
|
| 325 |
+
sampling_ratio=2,
|
| 326 |
+
aligned=True,
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
image_features_replay = roi_features.permute(0, 2, 3, 1).flatten(1, 2).to(image_features_recover.dtype).squeeze()
|
| 330 |
+
|
| 331 |
+
curr_inputs_embeds = torch.cat([
|
| 332 |
+
curr_inputs_embeds[:head_idx],
|
| 333 |
+
image_features_replay,
|
| 334 |
+
curr_inputs_embeds[tail_idx+1:],
|
| 335 |
+
])
|
| 336 |
+
|
| 337 |
+
new_inputs_embeds.append(curr_inputs_embeds.unsqueeze(0))
|
| 338 |
+
inputs_embeds = torch.cat(new_inputs_embeds, dim=0)
|
| 339 |
+
else:
|
| 340 |
+
inputs_embeds = self.mllm.get_input_embeddings()(input_ids)
|
| 341 |
+
|
| 342 |
+
outputs = self.mllm.generate(
|
| 343 |
+
inputs_embeds=inputs_embeds,
|
| 344 |
+
attention_mask=attention_mask,
|
| 345 |
+
generation_config=generation_config,
|
| 346 |
+
output_hidden_states=output_hidden_states,
|
| 347 |
+
# return_dict=return_dict,
|
| 348 |
+
use_cache=True,
|
| 349 |
+
return_dict_in_generate=True,
|
| 350 |
+
)
|
| 351 |
+
|
| 352 |
+
return outputs
|
modeling_perception_lm.py
ADDED
|
@@ -0,0 +1,865 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# *************************************************************************
|
| 2 |
+
# This file may have been modified by Bytedance Inc. (“Bytedance Inc.'s Mo-
|
| 3 |
+
# difications”). All Bytedance Inc.'s Modifications are Copyright (2025) B-
|
| 4 |
+
# ytedance Inc..
|
| 5 |
+
# *************************************************************************
|
| 6 |
+
|
| 7 |
+
# Adapted from https://github.com/huggingface/transformers/blob/v4.55.4/src/transformers/models/perception_lm/modeling_perception_lm.py
|
| 8 |
+
|
| 9 |
+
# coding=utf-8
|
| 10 |
+
# Copyright 2025 Meta Platforms, Inc. and the HuggingFace Inc. team. All rights reserved.
|
| 11 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 12 |
+
# you may not use this file except in compliance with the License.
|
| 13 |
+
# You may obtain a copy of the License at
|
| 14 |
+
#
|
| 15 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 16 |
+
#
|
| 17 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 18 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 19 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 20 |
+
# See the License for the specific language governing permissions and
|
| 21 |
+
# limitations under the License.
|
| 22 |
+
|
| 23 |
+
import math
|
| 24 |
+
from dataclasses import dataclass
|
| 25 |
+
from typing import Optional, Union
|
| 26 |
+
|
| 27 |
+
import torch
|
| 28 |
+
import torch.nn.functional as F
|
| 29 |
+
import torchvision
|
| 30 |
+
from einops import rearrange
|
| 31 |
+
from timm.models._manipulate import checkpoint
|
| 32 |
+
from torch import nn
|
| 33 |
+
from transformers import AutoModel, PerceptionLMConfig
|
| 34 |
+
from transformers.generation import GenerationMixin
|
| 35 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, ModelOutput
|
| 36 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 37 |
+
from transformers.utils import auto_docstring, can_return_tuple
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class PerceptionLMAdaptiveAvgPooling(nn.Module):
|
| 41 |
+
def __init__(self, pooling_ratio=2):
|
| 42 |
+
super().__init__()
|
| 43 |
+
self.pooling_ratio = pooling_ratio
|
| 44 |
+
|
| 45 |
+
def forward(self, hidden_states):
|
| 46 |
+
b, num_tokens, c = hidden_states.shape
|
| 47 |
+
h = int(math.sqrt(num_tokens))
|
| 48 |
+
if h * h != num_tokens:
|
| 49 |
+
raise ValueError(
|
| 50 |
+
f"num_tokens {num_tokens} is expected to be a square number"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
shape = (h // self.pooling_ratio, h // self.pooling_ratio)
|
| 54 |
+
hidden_states = hidden_states.permute(0, 2, 1).reshape(b, -1, h, h)
|
| 55 |
+
hidden_states = F.adaptive_avg_pool2d(hidden_states, shape)
|
| 56 |
+
hidden_states = hidden_states.flatten(2).transpose(1, 2)
|
| 57 |
+
|
| 58 |
+
return hidden_states
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class PerceptionLMMultiModalProjector(nn.Module):
|
| 62 |
+
def __init__(self, config: PerceptionLMConfig):
|
| 63 |
+
super().__init__()
|
| 64 |
+
input_size = config.vision_config.model_args["embed_dim"]
|
| 65 |
+
output_size = config.text_config.hidden_size
|
| 66 |
+
self.linear_1 = nn.Linear(
|
| 67 |
+
in_features=input_size,
|
| 68 |
+
out_features=output_size,
|
| 69 |
+
bias=True,
|
| 70 |
+
)
|
| 71 |
+
self.gelu = nn.GELU()
|
| 72 |
+
self.linear_2 = nn.Linear(
|
| 73 |
+
in_features=output_size,
|
| 74 |
+
out_features=output_size,
|
| 75 |
+
bias=True,
|
| 76 |
+
)
|
| 77 |
+
self.pooling = (
|
| 78 |
+
PerceptionLMAdaptiveAvgPooling(config.projector_pooling_ratio)
|
| 79 |
+
if config.projector_pooling_ratio > 1
|
| 80 |
+
else nn.Identity()
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
def forward(self, features):
|
| 84 |
+
features = features.permute(1, 0, 2) # NLD -> LND
|
| 85 |
+
features = self.linear_1(features)
|
| 86 |
+
features = self.gelu(features)
|
| 87 |
+
features = self.linear_2(features)
|
| 88 |
+
features = features.permute(1, 0, 2) # LND -> NLD
|
| 89 |
+
features = self.pooling(features)
|
| 90 |
+
return features
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
@auto_docstring
|
| 94 |
+
class PerceptionLMPreTrainedModel(PreTrainedModel):
|
| 95 |
+
config: PerceptionLMConfig
|
| 96 |
+
base_model_prefix = "model"
|
| 97 |
+
supports_gradient_checkpointing = True
|
| 98 |
+
_skip_keys_device_placement = "past_key_values"
|
| 99 |
+
|
| 100 |
+
_supports_flash_attn = True
|
| 101 |
+
_supports_sdpa = True
|
| 102 |
+
|
| 103 |
+
_can_compile_fullgraph = True
|
| 104 |
+
_supports_flex_attn = True
|
| 105 |
+
_supports_attention_backend = True
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
@dataclass
|
| 109 |
+
@auto_docstring(
|
| 110 |
+
custom_intro="""
|
| 111 |
+
Base class for PerceptionLM outputs, with hidden states and attentions.
|
| 112 |
+
"""
|
| 113 |
+
)
|
| 114 |
+
class PerceptionLMModelOutputWithPast(BaseModelOutputWithPast):
|
| 115 |
+
r"""
|
| 116 |
+
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 117 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
| 118 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`)
|
| 119 |
+
|
| 120 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 121 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 122 |
+
image_hidden_states (`torch.FloatTensor`, *optional*):
|
| 123 |
+
A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
|
| 124 |
+
Image hidden_states of the model produced by the vision encoder and after projecting the last hidden state.
|
| 125 |
+
video_hidden_states (`torch.FloatTensor`, *optional*):
|
| 126 |
+
A `torch.FloatTensor` of size `(batch_size, num_videos, sequence_length, hidden_size)`.
|
| 127 |
+
Video hidden_states of the model produced by the vision encoder and after projecting the last hidden state.
|
| 128 |
+
"""
|
| 129 |
+
|
| 130 |
+
image_hidden_states: Optional[torch.FloatTensor] = None
|
| 131 |
+
|
| 132 |
+
video_hidden_states: Optional[torch.FloatTensor] = None
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
@dataclass
|
| 136 |
+
@auto_docstring(
|
| 137 |
+
custom_intro="""
|
| 138 |
+
Base class for PerceptionLM causal language model (or autoregressive) outputs.
|
| 139 |
+
"""
|
| 140 |
+
)
|
| 141 |
+
class PerceptionLMCausalLMOutputWithPast(ModelOutput):
|
| 142 |
+
r"""
|
| 143 |
+
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
|
| 144 |
+
Language modeling loss (for next-token prediction).
|
| 145 |
+
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
|
| 146 |
+
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
|
| 147 |
+
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 148 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
| 149 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`)
|
| 150 |
+
|
| 151 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 152 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 153 |
+
image_hidden_states (`torch.FloatTensor`, *optional*):
|
| 154 |
+
A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
|
| 155 |
+
Image hidden_states of the model produced by the vision encoder and after projecting the last hidden state.
|
| 156 |
+
video_hidden_states (`torch.FloatTensor`, *optional*):
|
| 157 |
+
A `torch.FloatTensor` of size `(batch_size, num_videos, sequence_length, hidden_size)`.
|
| 158 |
+
Video hidden_states of the model produced by the vision encoder and after projecting the last hidden state.
|
| 159 |
+
"""
|
| 160 |
+
|
| 161 |
+
loss: Optional[torch.FloatTensor] = None
|
| 162 |
+
logits: Optional[torch.FloatTensor] = None
|
| 163 |
+
past_key_values: Optional[list[torch.FloatTensor]] = None
|
| 164 |
+
hidden_states: Optional[tuple[torch.FloatTensor]] = None
|
| 165 |
+
attentions: Optional[tuple[torch.FloatTensor]] = None
|
| 166 |
+
image_hidden_states: Optional[torch.FloatTensor] = None
|
| 167 |
+
|
| 168 |
+
video_hidden_states: Optional[torch.FloatTensor] = None
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
@auto_docstring
|
| 172 |
+
class PerceptionLMModel(PerceptionLMPreTrainedModel):
|
| 173 |
+
_checkpoint_conversion_mapping = {}
|
| 174 |
+
|
| 175 |
+
def __init__(self, config: PerceptionLMConfig):
|
| 176 |
+
super().__init__(config)
|
| 177 |
+
self.vision_tower = AutoModel.from_config(config.vision_config)
|
| 178 |
+
|
| 179 |
+
def custom_forward_features(
|
| 180 |
+
self,
|
| 181 |
+
x: torch.Tensor,
|
| 182 |
+
mask_embeds: Optional[torch.Tensor] = None,
|
| 183 |
+
) -> torch.Tensor:
|
| 184 |
+
"""Forward pass through feature extraction layers.
|
| 185 |
+
|
| 186 |
+
Args:
|
| 187 |
+
x: Input tensor.
|
| 188 |
+
|
| 189 |
+
Returns:
|
| 190 |
+
Feature tensor.
|
| 191 |
+
"""
|
| 192 |
+
x = self.patch_embed(x)
|
| 193 |
+
if mask_embeds is not None:
|
| 194 |
+
x = x + mask_embeds.flatten(2).transpose(1, 2)
|
| 195 |
+
x, rot_pos_embed = self._pos_embed(x)
|
| 196 |
+
x = self.norm_pre(x)
|
| 197 |
+
|
| 198 |
+
if getattr(self, "rope_mixed", False) and rot_pos_embed is not None:
|
| 199 |
+
# Handle depth-dependent embeddings for mixed mode
|
| 200 |
+
# pos embed has shape (depth, num_heads, H*W, dim) or (depth, batch_size, num_heads, H*W, dim)
|
| 201 |
+
for i, blk in enumerate(self.blocks):
|
| 202 |
+
if self.grad_checkpointing and not torch.jit.is_scripting():
|
| 203 |
+
x = checkpoint(blk, x, rope=rot_pos_embed[i])
|
| 204 |
+
else:
|
| 205 |
+
x = blk(x, rope=rot_pos_embed[i])
|
| 206 |
+
else:
|
| 207 |
+
# Standard path for non-mixed mode
|
| 208 |
+
for blk in self.blocks:
|
| 209 |
+
if self.grad_checkpointing and not torch.jit.is_scripting():
|
| 210 |
+
x = checkpoint(blk, x, rope=rot_pos_embed)
|
| 211 |
+
else:
|
| 212 |
+
x = blk(x, rope=rot_pos_embed)
|
| 213 |
+
|
| 214 |
+
x = self.norm(x)
|
| 215 |
+
return x
|
| 216 |
+
|
| 217 |
+
self.vision_tower.timm_model.forward_features = custom_forward_features.__get__(
|
| 218 |
+
self.vision_tower.timm_model
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
self.multi_modal_projector = PerceptionLMMultiModalProjector(config)
|
| 222 |
+
self.language_model = AutoModel.from_config(config.text_config)
|
| 223 |
+
self.post_init()
|
| 224 |
+
|
| 225 |
+
def get_input_embeddings(self):
|
| 226 |
+
return self.language_model.get_input_embeddings()
|
| 227 |
+
|
| 228 |
+
def set_input_embeddings(self, value):
|
| 229 |
+
self.language_model.set_input_embeddings(value)
|
| 230 |
+
|
| 231 |
+
def set_decoder(self, decoder):
|
| 232 |
+
self.language_model = decoder
|
| 233 |
+
|
| 234 |
+
def get_decoder(self):
|
| 235 |
+
return self.language_model
|
| 236 |
+
|
| 237 |
+
def get_image_features(
|
| 238 |
+
self,
|
| 239 |
+
pixel_values: torch.FloatTensor,
|
| 240 |
+
mask_embeds: Optional[torch.FloatTensor] = None,
|
| 241 |
+
**kwargs,
|
| 242 |
+
):
|
| 243 |
+
"""
|
| 244 |
+
Obtains image last hidden states from the vision tower and apply multimodal projection.
|
| 245 |
+
|
| 246 |
+
Args:
|
| 247 |
+
pixel_values (`torch.FloatTensor]` of shape `(batch_size, num_tiles, channels, height, width)`)
|
| 248 |
+
The tensors corresponding to the input images.
|
| 249 |
+
Returns:
|
| 250 |
+
image_features (`torch.Tensor`): Image feature tensor of shape `(num_tiles, num_patches, embed_dim)`).
|
| 251 |
+
"""
|
| 252 |
+
if len(pixel_values.shape) == 5:
|
| 253 |
+
pixel_values = pixel_values.flatten(0, 1)
|
| 254 |
+
assert (
|
| 255 |
+
len(pixel_values.shape) == 4
|
| 256 |
+
), f"pixel_values should be of shape (batch_size * num_tiles, channels, height, width). But got {pixel_values.shape}."
|
| 257 |
+
# pre-mask
|
| 258 |
+
image_outputs = self.vision_tower(pixel_values, mask_embeds=mask_embeds)
|
| 259 |
+
# image_outputs = self.vision_tower(pixel_values)
|
| 260 |
+
image_outputs = image_outputs.last_hidden_state
|
| 261 |
+
if self.config.vision_use_cls_token:
|
| 262 |
+
image_outputs = image_outputs[:, 1:, :]
|
| 263 |
+
# post-mask
|
| 264 |
+
# if mask_embeds is not None:
|
| 265 |
+
# image_outputs = image_outputs + mask_embeds.flatten(2).transpose(1, 2)
|
| 266 |
+
image_features = self.multi_modal_projector(image_outputs)
|
| 267 |
+
return image_features
|
| 268 |
+
|
| 269 |
+
def get_placeholder_mask(
|
| 270 |
+
self,
|
| 271 |
+
input_ids: torch.LongTensor,
|
| 272 |
+
inputs_embeds: torch.FloatTensor,
|
| 273 |
+
image_features: torch.FloatTensor = None,
|
| 274 |
+
video_features: torch.FloatTensor = None,
|
| 275 |
+
):
|
| 276 |
+
"""
|
| 277 |
+
Obtains multimodal placeholdr mask from `input_ids` or `inputs_embeds`, and checks that the placeholder token count is
|
| 278 |
+
equal to the length of multimodal features. If the lengths are different, an error is raised.
|
| 279 |
+
"""
|
| 280 |
+
if input_ids is None:
|
| 281 |
+
special_image_mask = inputs_embeds == self.get_input_embeddings()(
|
| 282 |
+
torch.tensor(
|
| 283 |
+
self.config.image_token_id,
|
| 284 |
+
dtype=torch.long,
|
| 285 |
+
device=inputs_embeds.device,
|
| 286 |
+
)
|
| 287 |
+
)
|
| 288 |
+
special_image_mask = special_image_mask.all(-1)
|
| 289 |
+
special_video_mask = inputs_embeds == self.get_input_embeddings()(
|
| 290 |
+
torch.tensor(
|
| 291 |
+
self.config.video_token_id,
|
| 292 |
+
dtype=torch.long,
|
| 293 |
+
device=inputs_embeds.device,
|
| 294 |
+
)
|
| 295 |
+
)
|
| 296 |
+
special_video_mask = special_video_mask.all(-1)
|
| 297 |
+
else:
|
| 298 |
+
special_image_mask = input_ids == self.config.image_token_id
|
| 299 |
+
special_video_mask = input_ids == self.config.video_token_id
|
| 300 |
+
|
| 301 |
+
n_image_tokens = special_image_mask.sum()
|
| 302 |
+
special_image_mask = (
|
| 303 |
+
special_image_mask.unsqueeze(-1)
|
| 304 |
+
.expand_as(inputs_embeds)
|
| 305 |
+
.to(inputs_embeds.device)
|
| 306 |
+
)
|
| 307 |
+
if (
|
| 308 |
+
image_features is not None
|
| 309 |
+
and inputs_embeds[special_image_mask].numel() != image_features.numel()
|
| 310 |
+
):
|
| 311 |
+
raise ValueError(
|
| 312 |
+
f"Image features and image tokens do not match: tokens: {n_image_tokens}, features {image_features.size()[:-1].numel()}"
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
+
n_video_tokens = special_video_mask.sum()
|
| 316 |
+
special_video_mask = (
|
| 317 |
+
special_video_mask.unsqueeze(-1)
|
| 318 |
+
.expand_as(inputs_embeds)
|
| 319 |
+
.to(inputs_embeds.device)
|
| 320 |
+
)
|
| 321 |
+
if (
|
| 322 |
+
video_features is not None
|
| 323 |
+
and inputs_embeds[special_video_mask].numel() != video_features.numel()
|
| 324 |
+
):
|
| 325 |
+
raise ValueError(
|
| 326 |
+
f"Videos features and image tokens do not match: tokens: {n_video_tokens}, features {video_features.size()[:-1].numel()}"
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
return special_image_mask, special_video_mask
|
| 330 |
+
|
| 331 |
+
@can_return_tuple
|
| 332 |
+
@auto_docstring
|
| 333 |
+
def forward(
|
| 334 |
+
self,
|
| 335 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 336 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
| 337 |
+
mask_embeds: Optional[torch.FloatTensor] = None,
|
| 338 |
+
pixel_values_videos: Optional[torch.FloatTensor] = None,
|
| 339 |
+
attention_mask: Optional[torch.Tensor] = None, # need
|
| 340 |
+
position_ids: Optional[torch.LongTensor] = None, # need
|
| 341 |
+
past_key_values: Optional[list[torch.FloatTensor]] = None,
|
| 342 |
+
inputs_embeds: Optional[torch.FloatTensor] = None, # need
|
| 343 |
+
use_cache: Optional[bool] = None, # need
|
| 344 |
+
output_attentions: Optional[bool] = None,
|
| 345 |
+
output_hidden_states: Optional[bool] = None,
|
| 346 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 347 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 348 |
+
**lm_kwargs,
|
| 349 |
+
) -> Union[tuple, PerceptionLMModelOutputWithPast]:
|
| 350 |
+
output_attentions = (
|
| 351 |
+
output_attentions
|
| 352 |
+
if output_attentions is not None
|
| 353 |
+
else self.config.output_attentions
|
| 354 |
+
)
|
| 355 |
+
output_hidden_states = (
|
| 356 |
+
output_hidden_states
|
| 357 |
+
if output_hidden_states is not None
|
| 358 |
+
else self.config.output_hidden_states
|
| 359 |
+
)
|
| 360 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 361 |
+
raise ValueError(
|
| 362 |
+
"You must specify exactly one of input_ids or inputs_embeds"
|
| 363 |
+
)
|
| 364 |
+
if (
|
| 365 |
+
pixel_values is not None or pixel_values_videos is not None
|
| 366 |
+
) and inputs_embeds is not None:
|
| 367 |
+
raise ValueError(
|
| 368 |
+
"You cannot specify both (pixel_values or pixel_values_videos) and inputs_embeds at the same time, and must specify either one"
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
if inputs_embeds is None:
|
| 372 |
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
| 373 |
+
|
| 374 |
+
image_features = None
|
| 375 |
+
if pixel_values is not None:
|
| 376 |
+
image_features = self.get_image_features(
|
| 377 |
+
pixel_values=pixel_values, mask_embeds=mask_embeds
|
| 378 |
+
)
|
| 379 |
+
image_features = image_features.to(
|
| 380 |
+
inputs_embeds.device, dtype=inputs_embeds.dtype
|
| 381 |
+
)
|
| 382 |
+
special_image_mask, _ = self.get_placeholder_mask(
|
| 383 |
+
input_ids, inputs_embeds=inputs_embeds, image_features=image_features
|
| 384 |
+
)
|
| 385 |
+
inputs_embeds = inputs_embeds.masked_scatter(
|
| 386 |
+
special_image_mask, image_features
|
| 387 |
+
)
|
| 388 |
+
|
| 389 |
+
video_features = None
|
| 390 |
+
if pixel_values_videos is not None:
|
| 391 |
+
video_features = self.get_image_features(pixel_values=pixel_values_videos)
|
| 392 |
+
video_features = video_features.to(
|
| 393 |
+
inputs_embeds.device, dtype=inputs_embeds.dtype
|
| 394 |
+
)
|
| 395 |
+
_, special_video_mask = self.get_placeholder_mask(
|
| 396 |
+
input_ids, inputs_embeds=inputs_embeds, video_features=video_features
|
| 397 |
+
)
|
| 398 |
+
inputs_embeds = inputs_embeds.masked_scatter(
|
| 399 |
+
special_video_mask, video_features
|
| 400 |
+
)
|
| 401 |
+
|
| 402 |
+
outputs = self.language_model(
|
| 403 |
+
attention_mask=attention_mask,
|
| 404 |
+
position_ids=position_ids,
|
| 405 |
+
past_key_values=past_key_values,
|
| 406 |
+
inputs_embeds=inputs_embeds,
|
| 407 |
+
use_cache=use_cache,
|
| 408 |
+
output_attentions=output_attentions,
|
| 409 |
+
output_hidden_states=output_hidden_states,
|
| 410 |
+
return_dict=True,
|
| 411 |
+
cache_position=cache_position,
|
| 412 |
+
logits_to_keep=logits_to_keep,
|
| 413 |
+
**lm_kwargs,
|
| 414 |
+
)
|
| 415 |
+
return PerceptionLMModelOutputWithPast(
|
| 416 |
+
last_hidden_state=outputs.last_hidden_state,
|
| 417 |
+
hidden_states=outputs.hidden_states,
|
| 418 |
+
past_key_values=outputs.past_key_values,
|
| 419 |
+
attentions=outputs.attentions,
|
| 420 |
+
image_hidden_states=image_features if pixel_values is not None else None,
|
| 421 |
+
video_hidden_states=(
|
| 422 |
+
video_features if pixel_values_videos is not None else None
|
| 423 |
+
),
|
| 424 |
+
)
|
| 425 |
+
|
| 426 |
+
|
| 427 |
+
@auto_docstring
|
| 428 |
+
class PerceptionLMForConditionalGeneration(
|
| 429 |
+
PerceptionLMPreTrainedModel, GenerationMixin
|
| 430 |
+
):
|
| 431 |
+
_checkpoint_conversion_mapping = {}
|
| 432 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 433 |
+
|
| 434 |
+
def __init__(self, config: PerceptionLMConfig):
|
| 435 |
+
super().__init__(config)
|
| 436 |
+
self.model = PerceptionLMModel(config)
|
| 437 |
+
self.lm_head = nn.Linear(
|
| 438 |
+
config.text_config.hidden_size, config.text_config.vocab_size, bias=False
|
| 439 |
+
)
|
| 440 |
+
self.post_init()
|
| 441 |
+
|
| 442 |
+
def get_input_embeddings(self):
|
| 443 |
+
return self.model.get_input_embeddings()
|
| 444 |
+
|
| 445 |
+
def set_input_embeddings(self, value):
|
| 446 |
+
self.model.set_input_embeddings(value)
|
| 447 |
+
|
| 448 |
+
def get_output_embeddings(self) -> nn.Module:
|
| 449 |
+
return self.lm_head
|
| 450 |
+
|
| 451 |
+
def set_decoder(self, decoder):
|
| 452 |
+
self.model.set_decoder(decoder)
|
| 453 |
+
|
| 454 |
+
def get_decoder(self):
|
| 455 |
+
return self.model.get_decoder()
|
| 456 |
+
|
| 457 |
+
def get_image_features(
|
| 458 |
+
self,
|
| 459 |
+
pixel_values: torch.FloatTensor,
|
| 460 |
+
mask_embeds: Optional[torch.FloatTensor] = None,
|
| 461 |
+
**kwargs,
|
| 462 |
+
):
|
| 463 |
+
return self.model.get_image_features(
|
| 464 |
+
pixel_values=pixel_values, mask_embeds=mask_embeds, **kwargs
|
| 465 |
+
)
|
| 466 |
+
|
| 467 |
+
def get_placeholder_mask(
|
| 468 |
+
self,
|
| 469 |
+
input_ids: torch.LongTensor,
|
| 470 |
+
inputs_embeds: torch.FloatTensor,
|
| 471 |
+
image_features: torch.FloatTensor = None,
|
| 472 |
+
video_features: torch.FloatTensor = None,
|
| 473 |
+
):
|
| 474 |
+
return self.model.get_placeholder_mask(
|
| 475 |
+
input_ids=input_ids,
|
| 476 |
+
inputs_embeds=inputs_embeds,
|
| 477 |
+
image_features=image_features,
|
| 478 |
+
video_features=video_features,
|
| 479 |
+
)
|
| 480 |
+
|
| 481 |
+
@can_return_tuple
|
| 482 |
+
@auto_docstring
|
| 483 |
+
def forward(
|
| 484 |
+
self,
|
| 485 |
+
input_ids: Optional[torch.LongTensor] = None, # no need
|
| 486 |
+
pixel_values: Optional[torch.FloatTensor] = None, # no need
|
| 487 |
+
pixel_values_videos: Optional[torch.FloatTensor] = None, # no need
|
| 488 |
+
attention_mask: Optional[torch.Tensor] = None, # need
|
| 489 |
+
position_ids: Optional[torch.LongTensor] = None, # need
|
| 490 |
+
past_key_values: Optional[list[torch.FloatTensor]] = None,
|
| 491 |
+
inputs_embeds: Optional[torch.FloatTensor] = None, # need
|
| 492 |
+
labels: Optional[torch.LongTensor] = None, # need
|
| 493 |
+
use_cache: Optional[bool] = None, # need
|
| 494 |
+
output_attentions: Optional[bool] = None,
|
| 495 |
+
output_hidden_states: Optional[bool] = None,
|
| 496 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 497 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 498 |
+
**lm_kwargs,
|
| 499 |
+
) -> Union[tuple, PerceptionLMCausalLMOutputWithPast]:
|
| 500 |
+
r"""
|
| 501 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 502 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
| 503 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
| 504 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
| 505 |
+
|
| 506 |
+
Example:
|
| 507 |
+
|
| 508 |
+
```python
|
| 509 |
+
>>> from PIL import Image
|
| 510 |
+
>>> import requests
|
| 511 |
+
>>> from transformers import AutoProcessor, PerceptionLMForConditionalGeneration
|
| 512 |
+
|
| 513 |
+
>>> model = PerceptionLMForConditionalGeneration.from_pretrained("perception_lm-hf/perception_lm-1.5-7b-hf")
|
| 514 |
+
>>> processor = AutoProcessor.from_pretrained("perception_lm-hf/perception_lm-1.5-7b-hf")
|
| 515 |
+
|
| 516 |
+
>>> prompt = "USER: <image>\nWhat's the content of the image? ASSISTANT:"
|
| 517 |
+
>>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
|
| 518 |
+
>>> image = Image.open(requests.get(url, stream=True).raw)
|
| 519 |
+
|
| 520 |
+
>>> inputs = processor(images=image, text=prompt, return_tensors="pt")
|
| 521 |
+
|
| 522 |
+
>>> # Generate
|
| 523 |
+
>>> generate_ids = model.generate(**inputs, max_new_tokens=15)
|
| 524 |
+
>>> processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 525 |
+
"USER: \nWhat's the content of the image? ASSISTANT: The image features a busy city street with a stop sign prominently displayed"
|
| 526 |
+
```"""
|
| 527 |
+
outputs = self.model(
|
| 528 |
+
input_ids=input_ids,
|
| 529 |
+
pixel_values=pixel_values,
|
| 530 |
+
pixel_values_videos=pixel_values_videos,
|
| 531 |
+
attention_mask=attention_mask,
|
| 532 |
+
position_ids=position_ids,
|
| 533 |
+
past_key_values=past_key_values,
|
| 534 |
+
inputs_embeds=inputs_embeds,
|
| 535 |
+
use_cache=use_cache,
|
| 536 |
+
output_attentions=output_attentions,
|
| 537 |
+
output_hidden_states=output_hidden_states,
|
| 538 |
+
cache_position=cache_position,
|
| 539 |
+
logits_to_keep=logits_to_keep,
|
| 540 |
+
**lm_kwargs,
|
| 541 |
+
)
|
| 542 |
+
|
| 543 |
+
hidden_states = outputs[0]
|
| 544 |
+
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 545 |
+
slice_indices = (
|
| 546 |
+
slice(-logits_to_keep, None)
|
| 547 |
+
if isinstance(logits_to_keep, int)
|
| 548 |
+
else logits_to_keep
|
| 549 |
+
)
|
| 550 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :])
|
| 551 |
+
|
| 552 |
+
loss = None
|
| 553 |
+
|
| 554 |
+
if labels is not None:
|
| 555 |
+
loss = self.loss_function(
|
| 556 |
+
logits=logits,
|
| 557 |
+
labels=labels,
|
| 558 |
+
vocab_size=self.config.text_config.vocab_size,
|
| 559 |
+
**lm_kwargs,
|
| 560 |
+
)
|
| 561 |
+
|
| 562 |
+
return PerceptionLMCausalLMOutputWithPast(
|
| 563 |
+
loss=loss,
|
| 564 |
+
logits=logits,
|
| 565 |
+
past_key_values=outputs.past_key_values,
|
| 566 |
+
hidden_states=outputs.hidden_states,
|
| 567 |
+
attentions=outputs.attentions,
|
| 568 |
+
image_hidden_states=outputs.image_hidden_states,
|
| 569 |
+
video_hidden_states=outputs.video_hidden_states,
|
| 570 |
+
)
|
| 571 |
+
|
| 572 |
+
def prepare_inputs_for_generation(
|
| 573 |
+
self,
|
| 574 |
+
input_ids,
|
| 575 |
+
past_key_values=None,
|
| 576 |
+
inputs_embeds=None,
|
| 577 |
+
pixel_values=None,
|
| 578 |
+
mask_embeds=None,
|
| 579 |
+
pixel_values_videos=None,
|
| 580 |
+
attention_mask=None,
|
| 581 |
+
cache_position=None,
|
| 582 |
+
logits_to_keep=None,
|
| 583 |
+
feature_replay=None,
|
| 584 |
+
feature_replay_video=None,
|
| 585 |
+
crop_tokens=[128004],
|
| 586 |
+
roi_align=None,
|
| 587 |
+
bboxes=None,
|
| 588 |
+
aspect_ratios=True,
|
| 589 |
+
processor=None,
|
| 590 |
+
**kwargs,
|
| 591 |
+
):
|
| 592 |
+
# Overwritten -- in specific circumstances we don't want to forward image inputs to the model
|
| 593 |
+
|
| 594 |
+
model_inputs = super().prepare_inputs_for_generation(
|
| 595 |
+
input_ids,
|
| 596 |
+
past_key_values=past_key_values,
|
| 597 |
+
inputs_embeds=inputs_embeds,
|
| 598 |
+
attention_mask=attention_mask,
|
| 599 |
+
cache_position=cache_position,
|
| 600 |
+
logits_to_keep=logits_to_keep,
|
| 601 |
+
**kwargs,
|
| 602 |
+
)
|
| 603 |
+
|
| 604 |
+
assert not (feature_replay and feature_replay_video)
|
| 605 |
+
|
| 606 |
+
if cache_position[0] == 0:
|
| 607 |
+
inputs_embeds = model_inputs["inputs_embeds"]
|
| 608 |
+
|
| 609 |
+
if inputs_embeds is None:
|
| 610 |
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
| 611 |
+
|
| 612 |
+
image_features = None
|
| 613 |
+
if pixel_values is not None:
|
| 614 |
+
image_features = self.get_image_features(
|
| 615 |
+
pixel_values=pixel_values, mask_embeds=mask_embeds
|
| 616 |
+
)
|
| 617 |
+
image_features = image_features.to(
|
| 618 |
+
inputs_embeds.device, dtype=inputs_embeds.dtype
|
| 619 |
+
)
|
| 620 |
+
special_image_mask, _ = self.get_placeholder_mask(
|
| 621 |
+
input_ids,
|
| 622 |
+
inputs_embeds=inputs_embeds,
|
| 623 |
+
image_features=image_features,
|
| 624 |
+
)
|
| 625 |
+
inputs_embeds = inputs_embeds.masked_scatter(
|
| 626 |
+
special_image_mask, image_features
|
| 627 |
+
)
|
| 628 |
+
|
| 629 |
+
video_features = None
|
| 630 |
+
if pixel_values_videos is not None:
|
| 631 |
+
video_features = self.get_image_features(
|
| 632 |
+
pixel_values=pixel_values_videos
|
| 633 |
+
)
|
| 634 |
+
video_features = video_features.to(
|
| 635 |
+
inputs_embeds.device, dtype=inputs_embeds.dtype
|
| 636 |
+
)
|
| 637 |
+
_, special_video_mask = self.get_placeholder_mask(
|
| 638 |
+
input_ids,
|
| 639 |
+
inputs_embeds=inputs_embeds,
|
| 640 |
+
video_features=video_features,
|
| 641 |
+
)
|
| 642 |
+
inputs_embeds = inputs_embeds.masked_scatter(
|
| 643 |
+
special_video_mask, video_features
|
| 644 |
+
)
|
| 645 |
+
|
| 646 |
+
if feature_replay:
|
| 647 |
+
assert (
|
| 648 |
+
inputs_embeds.shape[0] == 1
|
| 649 |
+
), "Currently only support batch_size=1 for feature replay"
|
| 650 |
+
|
| 651 |
+
def _merge(tiles: torch.Tensor, ncw: int, nch: int) -> torch.Tensor:
|
| 652 |
+
# merge image tiles to the original image
|
| 653 |
+
# input: (batch_size, ncw * nch, num_channels, height//nch, width//ncw)
|
| 654 |
+
# output: (batch_size, num_channels, height, width)
|
| 655 |
+
|
| 656 |
+
batch_size, num_tiles, num_channels, tile_height, tile_width = (
|
| 657 |
+
tiles.size()
|
| 658 |
+
)
|
| 659 |
+
assert num_tiles == ncw * nch, f"{ncw * nch} != {num_tiles}"
|
| 660 |
+
|
| 661 |
+
tiles = tiles.view(
|
| 662 |
+
batch_size, nch, ncw, num_channels, tile_height, tile_width
|
| 663 |
+
)
|
| 664 |
+
tiles = tiles.permute(0, 3, 1, 4, 2, 5).contiguous()
|
| 665 |
+
|
| 666 |
+
original_height = nch * tile_height
|
| 667 |
+
original_width = ncw * tile_width
|
| 668 |
+
|
| 669 |
+
image = tiles.view(
|
| 670 |
+
batch_size, num_channels, original_height, original_width
|
| 671 |
+
)
|
| 672 |
+
|
| 673 |
+
return image
|
| 674 |
+
|
| 675 |
+
new_inputs_embeds = []
|
| 676 |
+
image_features_tiles = rearrange(
|
| 677 |
+
image_features[1:].unsqueeze(0),
|
| 678 |
+
"b n (h w) c -> b n c h w",
|
| 679 |
+
h=16,
|
| 680 |
+
w=16,
|
| 681 |
+
)
|
| 682 |
+
for batch_idx in range(inputs_embeds.shape[0]):
|
| 683 |
+
curr_inputs_emebds = inputs_embeds[batch_idx]
|
| 684 |
+
for crop_token in crop_tokens:
|
| 685 |
+
if crop_token in input_ids[batch_idx]:
|
| 686 |
+
target_mask = input_ids[batch_idx].eq(crop_token)
|
| 687 |
+
target_indices = target_mask.nonzero().squeeze()
|
| 688 |
+
head_idx = target_indices.min().item()
|
| 689 |
+
tail_idx = target_indices.max().item()
|
| 690 |
+
image_features_recover = _merge(
|
| 691 |
+
image_features_tiles,
|
| 692 |
+
aspect_ratios[batch_idx][0],
|
| 693 |
+
aspect_ratios[batch_idx][1],
|
| 694 |
+
)
|
| 695 |
+
x1, y1, x2, y2 = bboxes[batch_idx][str(crop_token)]
|
| 696 |
+
feat_h, feat_w = image_features_recover.shape[2:]
|
| 697 |
+
orig_h, orig_w = feat_h * 28, feat_w * 28 # 原图尺寸
|
| 698 |
+
|
| 699 |
+
# origin box
|
| 700 |
+
roi_orig_x1 = x1 * orig_w
|
| 701 |
+
roi_orig_y1 = y1 * orig_h
|
| 702 |
+
roi_orig_x2 = x2 * orig_w
|
| 703 |
+
roi_orig_y2 = y2 * orig_h
|
| 704 |
+
|
| 705 |
+
# feat box
|
| 706 |
+
spatial_scale = feat_w / orig_w
|
| 707 |
+
roi_feat_x1 = roi_orig_x1 * spatial_scale
|
| 708 |
+
roi_feat_y1 = roi_orig_y1 * spatial_scale
|
| 709 |
+
roi_feat_x2 = roi_orig_x2 * spatial_scale
|
| 710 |
+
roi_feat_y2 = roi_orig_y2 * spatial_scale
|
| 711 |
+
|
| 712 |
+
roi = torch.tensor(
|
| 713 |
+
[0, roi_feat_x1, roi_feat_y1, roi_feat_x2, roi_feat_y2],
|
| 714 |
+
dtype=torch.float32,
|
| 715 |
+
device=image_features_recover.device,
|
| 716 |
+
)
|
| 717 |
+
|
| 718 |
+
roi_features = torchvision.ops.roi_align(
|
| 719 |
+
input=image_features_recover.float(),
|
| 720 |
+
boxes=roi.unsqueeze(0),
|
| 721 |
+
output_size=(16, 16),
|
| 722 |
+
spatial_scale=spatial_scale,
|
| 723 |
+
sampling_ratio=2,
|
| 724 |
+
aligned=True,
|
| 725 |
+
)
|
| 726 |
+
|
| 727 |
+
image_features_replay = (
|
| 728 |
+
roi_features.permute(0, 2, 3, 1)
|
| 729 |
+
.flatten(1, 2)
|
| 730 |
+
.to(image_features_recover.dtype)
|
| 731 |
+
.squeeze()
|
| 732 |
+
)
|
| 733 |
+
|
| 734 |
+
curr_inputs_emebds = torch.cat(
|
| 735 |
+
[
|
| 736 |
+
inputs_embeds[batch_idx][:head_idx],
|
| 737 |
+
image_features_replay,
|
| 738 |
+
inputs_embeds[batch_idx][tail_idx + 1 :],
|
| 739 |
+
]
|
| 740 |
+
)
|
| 741 |
+
|
| 742 |
+
new_inputs_embeds.append(curr_inputs_emebds.unsqueeze(0))
|
| 743 |
+
|
| 744 |
+
inputs_embeds = torch.cat(new_inputs_embeds, dim=0)
|
| 745 |
+
model_inputs["position_ids"] = (
|
| 746 |
+
torch.arange(
|
| 747 |
+
0,
|
| 748 |
+
inputs_embeds.shape[1],
|
| 749 |
+
dtype=torch.long,
|
| 750 |
+
device=inputs_embeds.device,
|
| 751 |
+
)
|
| 752 |
+
.unsqueeze(0)
|
| 753 |
+
.repeat(inputs_embeds.shape[0], 1)
|
| 754 |
+
)
|
| 755 |
+
model_inputs["attention_mask"] = torch.ones(
|
| 756 |
+
inputs_embeds.shape[0],
|
| 757 |
+
inputs_embeds.shape[1],
|
| 758 |
+
dtype=torch.long,
|
| 759 |
+
device=inputs_embeds.device,
|
| 760 |
+
)
|
| 761 |
+
model_inputs["cache_position"] = model_inputs["position_ids"].clone()
|
| 762 |
+
|
| 763 |
+
elif feature_replay_video:
|
| 764 |
+
assert (
|
| 765 |
+
inputs_embeds.shape[0] == 1
|
| 766 |
+
), "Currently only support batch_size=1 for feature replay"
|
| 767 |
+
assert processor is not None, "Need processor"
|
| 768 |
+
|
| 769 |
+
new_inputs_embeds = []
|
| 770 |
+
image_features_tiles = rearrange(
|
| 771 |
+
image_features.unsqueeze(0), "b n (h w) c -> b n c h w", h=16, w=16
|
| 772 |
+
)
|
| 773 |
+
for batch_idx in range(inputs_embeds.shape[0]):
|
| 774 |
+
curr_inputs_emebds = inputs_embeds[batch_idx]
|
| 775 |
+
for frame_idx in range(image_features.shape[0]):
|
| 776 |
+
crop_token = processor.tokenizer.convert_tokens_to_ids(
|
| 777 |
+
f"<|reserved_special_token_{2 + frame_idx}|>"
|
| 778 |
+
)
|
| 779 |
+
if crop_token in input_ids[batch_idx]:
|
| 780 |
+
target_mask = input_ids[batch_idx].eq(crop_token)
|
| 781 |
+
target_indices = target_mask.nonzero().squeeze()
|
| 782 |
+
head_idx = target_indices.min().item()
|
| 783 |
+
tail_idx = target_indices.max().item()
|
| 784 |
+
x1, y1, x2, y2 = bboxes[batch_idx][str(crop_token)]
|
| 785 |
+
feat_h, feat_w = 16, 16
|
| 786 |
+
orig_h, orig_w = feat_h * 28, feat_w * 28
|
| 787 |
+
|
| 788 |
+
# origin box
|
| 789 |
+
roi_orig_x1 = x1 * orig_w
|
| 790 |
+
roi_orig_y1 = y1 * orig_h
|
| 791 |
+
roi_orig_x2 = x2 * orig_w
|
| 792 |
+
roi_orig_y2 = y2 * orig_h
|
| 793 |
+
|
| 794 |
+
# feat box
|
| 795 |
+
spatial_scale = feat_w / orig_w
|
| 796 |
+
roi_feat_x1 = roi_orig_x1 * spatial_scale
|
| 797 |
+
roi_feat_y1 = roi_orig_y1 * spatial_scale
|
| 798 |
+
roi_feat_x2 = roi_orig_x2 * spatial_scale
|
| 799 |
+
roi_feat_y2 = roi_orig_y2 * spatial_scale
|
| 800 |
+
|
| 801 |
+
roi = torch.tensor(
|
| 802 |
+
[0, roi_feat_x1, roi_feat_y1, roi_feat_x2, roi_feat_y2],
|
| 803 |
+
dtype=torch.float32,
|
| 804 |
+
device=image_features_tiles.device,
|
| 805 |
+
)
|
| 806 |
+
|
| 807 |
+
roi_features = torchvision.ops.roi_align(
|
| 808 |
+
input=image_features_tiles[:, frame_idx].float(),
|
| 809 |
+
boxes=roi.unsqueeze(0),
|
| 810 |
+
output_size=(16, 16),
|
| 811 |
+
spatial_scale=spatial_scale,
|
| 812 |
+
sampling_ratio=2,
|
| 813 |
+
aligned=True,
|
| 814 |
+
)
|
| 815 |
+
|
| 816 |
+
image_features_replay = (
|
| 817 |
+
roi_features.permute(0, 2, 3, 1)
|
| 818 |
+
.flatten(1, 2)
|
| 819 |
+
.to(image_features_tiles.dtype)
|
| 820 |
+
.squeeze()
|
| 821 |
+
)
|
| 822 |
+
|
| 823 |
+
curr_inputs_emebds = torch.cat(
|
| 824 |
+
[
|
| 825 |
+
curr_inputs_emebds[:head_idx],
|
| 826 |
+
image_features_replay,
|
| 827 |
+
curr_inputs_emebds[tail_idx + 1 :],
|
| 828 |
+
]
|
| 829 |
+
)
|
| 830 |
+
|
| 831 |
+
new_inputs_embeds.append(curr_inputs_emebds.unsqueeze(0))
|
| 832 |
+
|
| 833 |
+
inputs_embeds = torch.cat(new_inputs_embeds, dim=0)
|
| 834 |
+
model_inputs["position_ids"] = (
|
| 835 |
+
torch.arange(
|
| 836 |
+
0,
|
| 837 |
+
inputs_embeds.shape[1],
|
| 838 |
+
dtype=torch.long,
|
| 839 |
+
device=inputs_embeds.device,
|
| 840 |
+
)
|
| 841 |
+
.unsqueeze(0)
|
| 842 |
+
.repeat(inputs_embeds.shape[0], 1)
|
| 843 |
+
)
|
| 844 |
+
model_inputs["attention_mask"] = torch.ones(
|
| 845 |
+
inputs_embeds.shape[0],
|
| 846 |
+
inputs_embeds.shape[1],
|
| 847 |
+
dtype=torch.long,
|
| 848 |
+
device=inputs_embeds.device,
|
| 849 |
+
)
|
| 850 |
+
model_inputs["cache_position"] = model_inputs["position_ids"].clone()
|
| 851 |
+
|
| 852 |
+
model_inputs["inputs_embeds"] = inputs_embeds
|
| 853 |
+
model_inputs["input_ids"] = None
|
| 854 |
+
model_inputs["pixel_values"] = None
|
| 855 |
+
model_inputs["pixel_values_videos"] = None
|
| 856 |
+
model_inputs["mask_embeds"] = None
|
| 857 |
+
|
| 858 |
+
return model_inputs
|
| 859 |
+
|
| 860 |
+
|
| 861 |
+
__all__ = [
|
| 862 |
+
"PerceptionLMForConditionalGeneration",
|
| 863 |
+
"PerceptionLMPreTrainedModel",
|
| 864 |
+
"PerceptionLMModel",
|
| 865 |
+
]
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoImageProcessor": "image_processing_perception_lm_fast.PerceptionLMImageProcessorFast",
|
| 4 |
+
"AutoProcessor": "processing_gar.GARPerceptionLMProcessor"
|
| 5 |
+
},
|
| 6 |
+
"crop_size": null,
|
| 7 |
+
"data_format": "channels_first",
|
| 8 |
+
"default_to_square": true,
|
| 9 |
+
"device": null,
|
| 10 |
+
"disable_grouping": null,
|
| 11 |
+
"do_center_crop": false,
|
| 12 |
+
"do_convert_rgb": true,
|
| 13 |
+
"do_normalize": true,
|
| 14 |
+
"do_rescale": true,
|
| 15 |
+
"do_resize": true,
|
| 16 |
+
"image_mean": [
|
| 17 |
+
0.5,
|
| 18 |
+
0.5,
|
| 19 |
+
0.5
|
| 20 |
+
],
|
| 21 |
+
"image_processor_type": "PerceptionLMImageProcessorFast",
|
| 22 |
+
"image_std": [
|
| 23 |
+
0.5,
|
| 24 |
+
0.5,
|
| 25 |
+
0.5
|
| 26 |
+
],
|
| 27 |
+
"input_data_format": null,
|
| 28 |
+
"max_frame_tiles": 1,
|
| 29 |
+
"max_num_tiles": 16,
|
| 30 |
+
"processor_class": "GARPerceptionLMProcessor",
|
| 31 |
+
"resample": 3,
|
| 32 |
+
"rescale_factor": 0.00392156862745098,
|
| 33 |
+
"return_tensors": null,
|
| 34 |
+
"size": {
|
| 35 |
+
"height": 448,
|
| 36 |
+
"width": 448
|
| 37 |
+
},
|
| 38 |
+
"tile_size": 448,
|
| 39 |
+
"vision_input_type": "thumb+tile"
|
| 40 |
+
}
|
processing_gar.py
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2025 Meta Platforms, Inc. and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""
|
| 15 |
+
Processor class for PerceptionLM.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
from typing import Iterable, Union
|
| 19 |
+
|
| 20 |
+
import numpy as np
|
| 21 |
+
from transformers.feature_extraction_utils import BatchFeature
|
| 22 |
+
from transformers.image_utils import ImageInput, get_image_size, to_numpy_array
|
| 23 |
+
from transformers.processing_utils import (
|
| 24 |
+
MultiModalData,
|
| 25 |
+
ProcessingKwargs,
|
| 26 |
+
ProcessorMixin,
|
| 27 |
+
Unpack,
|
| 28 |
+
)
|
| 29 |
+
from transformers.tokenization_utils_base import PreTokenizedInput, TextInput
|
| 30 |
+
from transformers.utils import logging
|
| 31 |
+
from transformers.video_utils import VideoInput
|
| 32 |
+
from transformers.image_utils import PILImageResampling
|
| 33 |
+
from .image_processing_perception_lm_fast import PerceptionLMImageProcessorFast
|
| 34 |
+
from transformers import AutoTokenizer, AutoProcessor, AutoImageProcessor
|
| 35 |
+
|
| 36 |
+
logger = logging.get_logger(__name__)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class PerceptionLMProcessorKwargs(ProcessingKwargs, total=False):
|
| 40 |
+
_defaults = {
|
| 41 |
+
"text_kwargs": {
|
| 42 |
+
"padding": False,
|
| 43 |
+
"return_mm_token_type_ids": False,
|
| 44 |
+
},
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class GARPerceptionLMProcessor(ProcessorMixin):
|
| 49 |
+
r"""
|
| 50 |
+
Constructs a PerceptionLM processor which wraps a PerceptionLM image processor, a PerceptionLM video processor, and a tokenizer into a single processor.
|
| 51 |
+
|
| 52 |
+
[`PerceptionLMProcessor`] offers all the functionalities of [`PerceptionLMImageProcessorFast`], [`PerceptionLMVideoProcessor`], and the tokenizer (e.g. [`LlamaTokenizerFast`]). See the
|
| 53 |
+
[`~PerceptionLMProcessor.__call__`] and [`~PerceptionLMProcessor.decode`] for more information.
|
| 54 |
+
|
| 55 |
+
Args:
|
| 56 |
+
video_processor ([`PerceptionLMVideoProcessor`], *optional*):
|
| 57 |
+
The video processor to process video inputs.
|
| 58 |
+
image_processor ([`PerceptionLMImageProcessorFast`], *optional*):
|
| 59 |
+
The image processor to process image inputs.
|
| 60 |
+
tokenizer ([`LlamaTokenizerFast`] or similar, *optional*):
|
| 61 |
+
The tokenizer to process text inputs.
|
| 62 |
+
patch_size (`int`, *optional*):
|
| 63 |
+
Patch size from the vision tower.
|
| 64 |
+
chat_template (`str`, *optional*):
|
| 65 |
+
A Jinja template which will be used to convert lists of messages in a chat into a tokenizable string.
|
| 66 |
+
pooling_ratio (`int`, *optional*, defaults to 2):
|
| 67 |
+
Pooling ratio for vision tokens. If not 1, 2D adaptive pooling is applied over projected vision tokens.
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
attributes = ["video_processor", "image_processor", "tokenizer"]
|
| 71 |
+
image_processor_class = "AutoImageProcessor"
|
| 72 |
+
video_processor_class = "AutoVideoProcessor"
|
| 73 |
+
tokenizer_class = "AutoTokenizer"
|
| 74 |
+
|
| 75 |
+
def __init__(
|
| 76 |
+
self,
|
| 77 |
+
video_processor=None,
|
| 78 |
+
image_processor=None,
|
| 79 |
+
tokenizer=None,
|
| 80 |
+
patch_size=None,
|
| 81 |
+
chat_template=None,
|
| 82 |
+
pooling_ratio=2,
|
| 83 |
+
**kwargs,
|
| 84 |
+
):
|
| 85 |
+
self.patch_size = patch_size
|
| 86 |
+
self.pooling_ratio = pooling_ratio
|
| 87 |
+
self.image_token = tokenizer.image_token
|
| 88 |
+
self.video_token = tokenizer.video_token
|
| 89 |
+
self.image_token_id = tokenizer.image_token_id
|
| 90 |
+
self.video_token_id = tokenizer.video_token_id
|
| 91 |
+
super().__init__(
|
| 92 |
+
video_processor, image_processor, tokenizer, chat_template=chat_template,
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
def __call__(
|
| 96 |
+
self,
|
| 97 |
+
images: ImageInput = None,
|
| 98 |
+
visual_prompts: ImageInput = None,
|
| 99 |
+
text: Union[
|
| 100 |
+
TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]
|
| 101 |
+
] = None,
|
| 102 |
+
audio=None,
|
| 103 |
+
videos: VideoInput = None,
|
| 104 |
+
**kwargs: Unpack[PerceptionLMProcessorKwargs],
|
| 105 |
+
) -> BatchFeature:
|
| 106 |
+
"""
|
| 107 |
+
Prepares a batch containing one or more sequences of text and/or images and/or videos.
|
| 108 |
+
|
| 109 |
+
If `text` is provided, it is tokenized using the tokenizer.
|
| 110 |
+
If `images` is provided, they are processed using the image processor.
|
| 111 |
+
If `videos` is provided, they are processed using the video processor.
|
| 112 |
+
|
| 113 |
+
Args:
|
| 114 |
+
images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`, *optional*):
|
| 115 |
+
The image or batch of images to be processed. Each image can be a PIL image, NumPy array, or PyTorch tensor.
|
| 116 |
+
Both channels-first and channels-last formats are supported.
|
| 117 |
+
text (`str`, `List[str]`, *optional*):
|
| 118 |
+
The sequence or batch of sequences to be tokenized. Each sequence can be a string.
|
| 119 |
+
videos (`Any`, *optional*):
|
| 120 |
+
The video or batch of videos to be processed.
|
| 121 |
+
return_tensors (`str` or [`~utils.TensorType`], *optional*):
|
| 122 |
+
If set, will return tensors of a particular framework. Acceptable values are:
|
| 123 |
+
- `'tf'`: Return TensorFlow `tf.constant` objects.
|
| 124 |
+
- `'pt'`: Return PyTorch `torch.Tensor` objects.
|
| 125 |
+
- `'np'`: Return NumPy `np.ndarray` objects.
|
| 126 |
+
- `'jax'`: Return JAX `jnp.ndarray` objects.
|
| 127 |
+
|
| 128 |
+
Returns:
|
| 129 |
+
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
|
| 130 |
+
|
| 131 |
+
- **input_ids** -- List of token ids to be fed to a model. Returned when `text` is provided.
|
| 132 |
+
- **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
|
| 133 |
+
`return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is provided).
|
| 134 |
+
- **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is provided.
|
| 135 |
+
- **pixel_values_videos** -- Video pixel values to be fed to a model. Returned when `videos` is provided.
|
| 136 |
+
"""
|
| 137 |
+
if text is None:
|
| 138 |
+
raise ValueError(
|
| 139 |
+
"You have to specify at least `text` input. Optionally, you can also specify `images` or `videos`."
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
output_kwargs = self._merge_kwargs(
|
| 143 |
+
PerceptionLMProcessorKwargs,
|
| 144 |
+
tokenizer_init_kwargs=self.tokenizer.init_kwargs,
|
| 145 |
+
**kwargs,
|
| 146 |
+
)
|
| 147 |
+
if images is not None:
|
| 148 |
+
image_inputs = self.image_processor(
|
| 149 |
+
images=images, **output_kwargs["images_kwargs"]
|
| 150 |
+
)
|
| 151 |
+
else:
|
| 152 |
+
image_inputs = {}
|
| 153 |
+
|
| 154 |
+
if visual_prompts is not None:
|
| 155 |
+
visual_prompts_inputs = self.image_processor(
|
| 156 |
+
images=visual_prompts, **output_kwargs["images_kwargs"], resample=PILImageResampling.NEAREST
|
| 157 |
+
)
|
| 158 |
+
image_inputs["mask_values"] = visual_prompts_inputs["pixel_values"]
|
| 159 |
+
else:
|
| 160 |
+
image_inputs["mask_values"] = None
|
| 161 |
+
|
| 162 |
+
if videos is not None:
|
| 163 |
+
videos_inputs = self.video_processor(
|
| 164 |
+
videos, **output_kwargs["videos_kwargs"]
|
| 165 |
+
)
|
| 166 |
+
else:
|
| 167 |
+
videos_inputs = {}
|
| 168 |
+
|
| 169 |
+
if isinstance(text, str):
|
| 170 |
+
text = [text]
|
| 171 |
+
elif not isinstance(text, list) and not isinstance(text[0], str):
|
| 172 |
+
raise ValueError(
|
| 173 |
+
"Invalid input text. Please provide a string, or a list of strings"
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
# try to expand inputs in processing if we have the necessary parts
|
| 177 |
+
prompt_strings = []
|
| 178 |
+
pixel_values = iter(image_inputs.get("pixel_values", []))
|
| 179 |
+
pixel_values_videos = iter(videos_inputs.get("pixel_values_videos", []))
|
| 180 |
+
for sample in text:
|
| 181 |
+
# Replace the media token with the expanded media token sequence
|
| 182 |
+
sample = self._expand_media_tokens(
|
| 183 |
+
sample, self.tokenizer.image_token, pixel_values
|
| 184 |
+
)
|
| 185 |
+
sample = self._expand_media_tokens(
|
| 186 |
+
sample, self.tokenizer.video_token, pixel_values_videos
|
| 187 |
+
)
|
| 188 |
+
prompt_strings.append(sample)
|
| 189 |
+
|
| 190 |
+
return_tensors = output_kwargs["text_kwargs"].pop("return_tensors", None)
|
| 191 |
+
return_mm_token_type_ids = output_kwargs["text_kwargs"].pop(
|
| 192 |
+
"return_mm_token_type_ids", False
|
| 193 |
+
)
|
| 194 |
+
text_inputs = self.tokenizer(
|
| 195 |
+
prompt_strings, **output_kwargs["text_kwargs"], return_tensors=None
|
| 196 |
+
)
|
| 197 |
+
self._check_special_mm_tokens(
|
| 198 |
+
prompt_strings, text_inputs, modalities=["image", "video"]
|
| 199 |
+
)
|
| 200 |
+
|
| 201 |
+
if return_mm_token_type_ids:
|
| 202 |
+
array_ids = np.array(text_inputs["input_ids"])
|
| 203 |
+
mm_token_type_ids = np.zeros_like(text_inputs["input_ids"])
|
| 204 |
+
mm_token_type_ids[array_ids == self.image_token_id] = 1
|
| 205 |
+
text_inputs["mm_token_type_ids"] = mm_token_type_ids.tolist()
|
| 206 |
+
|
| 207 |
+
return BatchFeature(
|
| 208 |
+
data={**text_inputs, **image_inputs, **videos_inputs},
|
| 209 |
+
tensor_type=return_tensors,
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
def _expand_media_tokens(self, sample, media_token: str, media_iter: Iterable):
|
| 213 |
+
media_count = sample.count(media_token)
|
| 214 |
+
if media_count > 0:
|
| 215 |
+
media_list = [next(media_iter) for _ in range(media_count)]
|
| 216 |
+
sample_splits = sample.split(media_token)
|
| 217 |
+
media_token_list = []
|
| 218 |
+
for media in media_list:
|
| 219 |
+
height, width = get_image_size(to_numpy_array(media))
|
| 220 |
+
num_tiles = media.shape[0]
|
| 221 |
+
num_media_tokens = (
|
| 222 |
+
(height // self.patch_size // self.pooling_ratio)
|
| 223 |
+
* (width // self.patch_size // self.pooling_ratio)
|
| 224 |
+
* num_tiles
|
| 225 |
+
)
|
| 226 |
+
media_token_list.append(num_media_tokens)
|
| 227 |
+
sample = ""
|
| 228 |
+
for i, num_media_tokens in enumerate(media_token_list):
|
| 229 |
+
sample += sample_splits[i]
|
| 230 |
+
sample += media_token * num_media_tokens
|
| 231 |
+
sample += sample_splits[-1]
|
| 232 |
+
return sample
|
| 233 |
+
|
| 234 |
+
def _get_num_multimodal_tokens(self, image_sizes=None, **kwargs):
|
| 235 |
+
"""
|
| 236 |
+
Computes the number of placeholder tokens needed for multimodal inputs with the given sizes.
|
| 237 |
+
|
| 238 |
+
Args:
|
| 239 |
+
image_sizes (`list[list[int]]`, *optional*):
|
| 240 |
+
The input sizes formatted as (height, width) per each image.
|
| 241 |
+
|
| 242 |
+
Returns:
|
| 243 |
+
`MultiModalData`: A `MultiModalData` object holding number of tokens per each of the provided
|
| 244 |
+
input modalities, along with other useful data.
|
| 245 |
+
"""
|
| 246 |
+
|
| 247 |
+
vision_data = {}
|
| 248 |
+
if image_sizes is not None:
|
| 249 |
+
images_kwargs = PerceptionLMProcessorKwargs._defaults.get(
|
| 250 |
+
"images_kwargs", {}
|
| 251 |
+
)
|
| 252 |
+
images_kwargs.update(kwargs)
|
| 253 |
+
tile_size = (
|
| 254 |
+
images_kwargs.get("tile_size", None) or self.image_processor.tile_size
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
num_image_tokens = []
|
| 258 |
+
num_image_patches = []
|
| 259 |
+
for height, width in image_sizes:
|
| 260 |
+
if self.image_processor.vision_input_type == "thumb+tile":
|
| 261 |
+
aspect_ratio = self.image_processor._fit_image_to_canvas(
|
| 262 |
+
img_width=width, img_height=height, tile_size=tile_size
|
| 263 |
+
)
|
| 264 |
+
if aspect_ratio is None:
|
| 265 |
+
aspect_ratio = self.image_processor._find_closest_aspect_ratio(
|
| 266 |
+
img_width=width, img_height=height, tile_size=tile_size
|
| 267 |
+
)
|
| 268 |
+
num_tiles = (
|
| 269 |
+
aspect_ratio[0] * aspect_ratio[1] + 1
|
| 270 |
+
) # base image and tiles
|
| 271 |
+
else:
|
| 272 |
+
num_tiles = 1
|
| 273 |
+
|
| 274 |
+
num_image_tokens.append(
|
| 275 |
+
(tile_size // self.patch_size // self.pooling_ratio)
|
| 276 |
+
* (tile_size // self.patch_size // self.pooling_ratio)
|
| 277 |
+
* num_tiles
|
| 278 |
+
)
|
| 279 |
+
num_image_patches.append(num_tiles)
|
| 280 |
+
|
| 281 |
+
vision_data.update(
|
| 282 |
+
{
|
| 283 |
+
"num_image_tokens": num_image_tokens,
|
| 284 |
+
"num_image_patches": num_image_patches,
|
| 285 |
+
}
|
| 286 |
+
)
|
| 287 |
+
return MultiModalData(**vision_data)
|
| 288 |
+
|
| 289 |
+
def batch_decode(self, *args, **kwargs):
|
| 290 |
+
"""
|
| 291 |
+
This method forwards all its arguments to PerceptionLMTokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please
|
| 292 |
+
refer to the docstring of this method for more information.
|
| 293 |
+
"""
|
| 294 |
+
return self.tokenizer.batch_decode(*args, **kwargs)
|
| 295 |
+
|
| 296 |
+
def decode(self, *args, **kwargs):
|
| 297 |
+
"""
|
| 298 |
+
This method forwards all its arguments to PerceptionLMTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to
|
| 299 |
+
the docstring of this method for more information.
|
| 300 |
+
"""
|
| 301 |
+
return self.tokenizer.decode(*args, **kwargs)
|
| 302 |
+
|
| 303 |
+
@property
|
| 304 |
+
def model_input_names(self):
|
| 305 |
+
tokenizer_input_names = self.tokenizer.model_input_names
|
| 306 |
+
image_processor_input_names = self.image_processor.model_input_names
|
| 307 |
+
return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))
|
| 308 |
+
|
| 309 |
+
AutoProcessor.register("GARPerceptionLMProcessor", GARPerceptionLMProcessor)
|
| 310 |
+
AutoImageProcessor.register(
|
| 311 |
+
"GARPerceptionLMImageProcessorFast",
|
| 312 |
+
slow_image_processor_class=None,
|
| 313 |
+
fast_image_processor_class=PerceptionLMImageProcessorFast
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
__all__ = ["GARPerceptionLMProcessor"]
|
processor_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"patch_size": 14,
|
| 3 |
+
"pooling_ratio": 2,
|
| 4 |
+
"processor_class": "GARPerceptionLMProcessor",
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoImageProcessor": "image_processing_perception_lm_fast.PerceptionLMImageProcessorFast",
|
| 7 |
+
"AutoProcessor": "processing_gar.GARPerceptionLMProcessor"
|
| 8 |
+
}
|
| 9 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<|begin_of_text|>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<|eot_id|>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"image_token": "<|image|>",
|
| 17 |
+
"pad_token": "<|end_of_text|>",
|
| 18 |
+
"video_token": "<|video|>"
|
| 19 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5531cfd169b9f439ecb1339ada499771bf9a7391217dfbb51fd3a03a9fa0ce0
|
| 3 |
+
size 17211041
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,2118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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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": "<|image|>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"128003": {
|
| 28 |
+
"content": "<|video|>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"128004": {
|
| 36 |
+
"content": "<|reserved_special_token_2|>",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
},
|
| 43 |
+
"128005": {
|
| 44 |
+
"content": "<|reserved_special_token_3|>",
|
| 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": "<|reserved_special_token_4|>",
|
| 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": "<|reserved_special_token_5|>",
|
| 85 |
+
"lstrip": false,
|
| 86 |
+
"normalized": false,
|
| 87 |
+
"rstrip": false,
|
| 88 |
+
"single_word": false,
|
| 89 |
+
"special": true
|
| 90 |
+
},
|
| 91 |
+
"128011": {
|
| 92 |
+
"content": "<|reserved_special_token_6|>",
|
| 93 |
+
"lstrip": false,
|
| 94 |
+
"normalized": false,
|
| 95 |
+
"rstrip": false,
|
| 96 |
+
"single_word": false,
|
| 97 |
+
"special": true
|
| 98 |
+
},
|
| 99 |
+
"128012": {
|
| 100 |
+
"content": "<|reserved_special_token_7|>",
|
| 101 |
+
"lstrip": false,
|
| 102 |
+
"normalized": false,
|
| 103 |
+
"rstrip": false,
|
| 104 |
+
"single_word": false,
|
| 105 |
+
"special": true
|
| 106 |
+
},
|
| 107 |
+
"128013": {
|
| 108 |
+
"content": "<|reserved_special_token_8|>",
|
| 109 |
+
"lstrip": false,
|
| 110 |
+
"normalized": false,
|
| 111 |
+
"rstrip": false,
|
| 112 |
+
"single_word": false,
|
| 113 |
+
"special": true
|
| 114 |
+
},
|
| 115 |
+
"128014": {
|
| 116 |
+
"content": "<|reserved_special_token_9|>",
|
| 117 |
+
"lstrip": false,
|
| 118 |
+
"normalized": false,
|
| 119 |
+
"rstrip": false,
|
| 120 |
+
"single_word": false,
|
| 121 |
+
"special": true
|
| 122 |
+
},
|
| 123 |
+
"128015": {
|
| 124 |
+
"content": "<|reserved_special_token_10|>",
|
| 125 |
+
"lstrip": false,
|
| 126 |
+
"normalized": false,
|
| 127 |
+
"rstrip": false,
|
| 128 |
+
"single_word": false,
|
| 129 |
+
"special": true
|
| 130 |
+
},
|
| 131 |
+
"128016": {
|
| 132 |
+
"content": "<|reserved_special_token_11|>",
|
| 133 |
+
"lstrip": false,
|
| 134 |
+
"normalized": false,
|
| 135 |
+
"rstrip": false,
|
| 136 |
+
"single_word": false,
|
| 137 |
+
"special": true
|
| 138 |
+
},
|
| 139 |
+
"128017": {
|
| 140 |
+
"content": "<|reserved_special_token_12|>",
|
| 141 |
+
"lstrip": false,
|
| 142 |
+
"normalized": false,
|
| 143 |
+
"rstrip": false,
|
| 144 |
+
"single_word": false,
|
| 145 |
+
"special": true
|
| 146 |
+
},
|
| 147 |
+
"128018": {
|
| 148 |
+
"content": "<|reserved_special_token_13|>",
|
| 149 |
+
"lstrip": false,
|
| 150 |
+
"normalized": false,
|
| 151 |
+
"rstrip": false,
|
| 152 |
+
"single_word": false,
|
| 153 |
+
"special": true
|
| 154 |
+
},
|
| 155 |
+
"128019": {
|
| 156 |
+
"content": "<|reserved_special_token_14|>",
|
| 157 |
+
"lstrip": false,
|
| 158 |
+
"normalized": false,
|
| 159 |
+
"rstrip": false,
|
| 160 |
+
"single_word": false,
|
| 161 |
+
"special": true
|
| 162 |
+
},
|
| 163 |
+
"128020": {
|
| 164 |
+
"content": "<|reserved_special_token_15|>",
|
| 165 |
+
"lstrip": false,
|
| 166 |
+
"normalized": false,
|
| 167 |
+
"rstrip": false,
|
| 168 |
+
"single_word": false,
|
| 169 |
+
"special": true
|
| 170 |
+
},
|
| 171 |
+
"128021": {
|
| 172 |
+
"content": "<|reserved_special_token_16|>",
|
| 173 |
+
"lstrip": false,
|
| 174 |
+
"normalized": false,
|
| 175 |
+
"rstrip": false,
|
| 176 |
+
"single_word": false,
|
| 177 |
+
"special": true
|
| 178 |
+
},
|
| 179 |
+
"128022": {
|
| 180 |
+
"content": "<|reserved_special_token_17|>",
|
| 181 |
+
"lstrip": false,
|
| 182 |
+
"normalized": false,
|
| 183 |
+
"rstrip": false,
|
| 184 |
+
"single_word": false,
|
| 185 |
+
"special": true
|
| 186 |
+
},
|
| 187 |
+
"128023": {
|
| 188 |
+
"content": "<|reserved_special_token_18|>",
|
| 189 |
+
"lstrip": false,
|
| 190 |
+
"normalized": false,
|
| 191 |
+
"rstrip": false,
|
| 192 |
+
"single_word": false,
|
| 193 |
+
"special": true
|
| 194 |
+
},
|
| 195 |
+
"128024": {
|
| 196 |
+
"content": "<|reserved_special_token_19|>",
|
| 197 |
+
"lstrip": false,
|
| 198 |
+
"normalized": false,
|
| 199 |
+
"rstrip": false,
|
| 200 |
+
"single_word": false,
|
| 201 |
+
"special": true
|
| 202 |
+
},
|
| 203 |
+
"128025": {
|
| 204 |
+
"content": "<|reserved_special_token_20|>",
|
| 205 |
+
"lstrip": false,
|
| 206 |
+
"normalized": false,
|
| 207 |
+
"rstrip": false,
|
| 208 |
+
"single_word": false,
|
| 209 |
+
"special": true
|
| 210 |
+
},
|
| 211 |
+
"128026": {
|
| 212 |
+
"content": "<|reserved_special_token_21|>",
|
| 213 |
+
"lstrip": false,
|
| 214 |
+
"normalized": false,
|
| 215 |
+
"rstrip": false,
|
| 216 |
+
"single_word": false,
|
| 217 |
+
"special": true
|
| 218 |
+
},
|
| 219 |
+
"128027": {
|
| 220 |
+
"content": "<|reserved_special_token_22|>",
|
| 221 |
+
"lstrip": false,
|
| 222 |
+
"normalized": false,
|
| 223 |
+
"rstrip": false,
|
| 224 |
+
"single_word": false,
|
| 225 |
+
"special": true
|
| 226 |
+
},
|
| 227 |
+
"128028": {
|
| 228 |
+
"content": "<|reserved_special_token_23|>",
|
| 229 |
+
"lstrip": false,
|
| 230 |
+
"normalized": false,
|
| 231 |
+
"rstrip": false,
|
| 232 |
+
"single_word": false,
|
| 233 |
+
"special": true
|
| 234 |
+
},
|
| 235 |
+
"128029": {
|
| 236 |
+
"content": "<|reserved_special_token_24|>",
|
| 237 |
+
"lstrip": false,
|
| 238 |
+
"normalized": false,
|
| 239 |
+
"rstrip": false,
|
| 240 |
+
"single_word": false,
|
| 241 |
+
"special": true
|
| 242 |
+
},
|
| 243 |
+
"128030": {
|
| 244 |
+
"content": "<|reserved_special_token_25|>",
|
| 245 |
+
"lstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"rstrip": false,
|
| 248 |
+
"single_word": false,
|
| 249 |
+
"special": true
|
| 250 |
+
},
|
| 251 |
+
"128031": {
|
| 252 |
+
"content": "<|reserved_special_token_26|>",
|
| 253 |
+
"lstrip": false,
|
| 254 |
+
"normalized": false,
|
| 255 |
+
"rstrip": false,
|
| 256 |
+
"single_word": false,
|
| 257 |
+
"special": true
|
| 258 |
+
},
|
| 259 |
+
"128032": {
|
| 260 |
+
"content": "<|reserved_special_token_27|>",
|
| 261 |
+
"lstrip": false,
|
| 262 |
+
"normalized": false,
|
| 263 |
+
"rstrip": false,
|
| 264 |
+
"single_word": false,
|
| 265 |
+
"special": true
|
| 266 |
+
},
|
| 267 |
+
"128033": {
|
| 268 |
+
"content": "<|reserved_special_token_28|>",
|
| 269 |
+
"lstrip": false,
|
| 270 |
+
"normalized": false,
|
| 271 |
+
"rstrip": false,
|
| 272 |
+
"single_word": false,
|
| 273 |
+
"special": true
|
| 274 |
+
},
|
| 275 |
+
"128034": {
|
| 276 |
+
"content": "<|reserved_special_token_29|>",
|
| 277 |
+
"lstrip": false,
|
| 278 |
+
"normalized": false,
|
| 279 |
+
"rstrip": false,
|
| 280 |
+
"single_word": false,
|
| 281 |
+
"special": true
|
| 282 |
+
},
|
| 283 |
+
"128035": {
|
| 284 |
+
"content": "<|reserved_special_token_30|>",
|
| 285 |
+
"lstrip": false,
|
| 286 |
+
"normalized": false,
|
| 287 |
+
"rstrip": false,
|
| 288 |
+
"single_word": false,
|
| 289 |
+
"special": true
|
| 290 |
+
},
|
| 291 |
+
"128036": {
|
| 292 |
+
"content": "<|reserved_special_token_31|>",
|
| 293 |
+
"lstrip": false,
|
| 294 |
+
"normalized": false,
|
| 295 |
+
"rstrip": false,
|
| 296 |
+
"single_word": false,
|
| 297 |
+
"special": true
|
| 298 |
+
},
|
| 299 |
+
"128037": {
|
| 300 |
+
"content": "<|reserved_special_token_32|>",
|
| 301 |
+
"lstrip": false,
|
| 302 |
+
"normalized": false,
|
| 303 |
+
"rstrip": false,
|
| 304 |
+
"single_word": false,
|
| 305 |
+
"special": true
|
| 306 |
+
},
|
| 307 |
+
"128038": {
|
| 308 |
+
"content": "<|reserved_special_token_33|>",
|
| 309 |
+
"lstrip": false,
|
| 310 |
+
"normalized": false,
|
| 311 |
+
"rstrip": false,
|
| 312 |
+
"single_word": false,
|
| 313 |
+
"special": true
|
| 314 |
+
},
|
| 315 |
+
"128039": {
|
| 316 |
+
"content": "<|reserved_special_token_34|>",
|
| 317 |
+
"lstrip": false,
|
| 318 |
+
"normalized": false,
|
| 319 |
+
"rstrip": false,
|
| 320 |
+
"single_word": false,
|
| 321 |
+
"special": true
|
| 322 |
+
},
|
| 323 |
+
"128040": {
|
| 324 |
+
"content": "<|reserved_special_token_35|>",
|
| 325 |
+
"lstrip": false,
|
| 326 |
+
"normalized": false,
|
| 327 |
+
"rstrip": false,
|
| 328 |
+
"single_word": false,
|
| 329 |
+
"special": true
|
| 330 |
+
},
|
| 331 |
+
"128041": {
|
| 332 |
+
"content": "<|reserved_special_token_36|>",
|
| 333 |
+
"lstrip": false,
|
| 334 |
+
"normalized": false,
|
| 335 |
+
"rstrip": false,
|
| 336 |
+
"single_word": false,
|
| 337 |
+
"special": true
|
| 338 |
+
},
|
| 339 |
+
"128042": {
|
| 340 |
+
"content": "<|reserved_special_token_37|>",
|
| 341 |
+
"lstrip": false,
|
| 342 |
+
"normalized": false,
|
| 343 |
+
"rstrip": false,
|
| 344 |
+
"single_word": false,
|
| 345 |
+
"special": true
|
| 346 |
+
},
|
| 347 |
+
"128043": {
|
| 348 |
+
"content": "<|reserved_special_token_38|>",
|
| 349 |
+
"lstrip": false,
|
| 350 |
+
"normalized": false,
|
| 351 |
+
"rstrip": false,
|
| 352 |
+
"single_word": false,
|
| 353 |
+
"special": true
|
| 354 |
+
},
|
| 355 |
+
"128044": {
|
| 356 |
+
"content": "<|reserved_special_token_39|>",
|
| 357 |
+
"lstrip": false,
|
| 358 |
+
"normalized": false,
|
| 359 |
+
"rstrip": false,
|
| 360 |
+
"single_word": false,
|
| 361 |
+
"special": true
|
| 362 |
+
},
|
| 363 |
+
"128045": {
|
| 364 |
+
"content": "<|reserved_special_token_40|>",
|
| 365 |
+
"lstrip": false,
|
| 366 |
+
"normalized": false,
|
| 367 |
+
"rstrip": false,
|
| 368 |
+
"single_word": false,
|
| 369 |
+
"special": true
|
| 370 |
+
},
|
| 371 |
+
"128046": {
|
| 372 |
+
"content": "<|reserved_special_token_41|>",
|
| 373 |
+
"lstrip": false,
|
| 374 |
+
"normalized": false,
|
| 375 |
+
"rstrip": false,
|
| 376 |
+
"single_word": false,
|
| 377 |
+
"special": true
|
| 378 |
+
},
|
| 379 |
+
"128047": {
|
| 380 |
+
"content": "<|reserved_special_token_42|>",
|
| 381 |
+
"lstrip": false,
|
| 382 |
+
"normalized": false,
|
| 383 |
+
"rstrip": false,
|
| 384 |
+
"single_word": false,
|
| 385 |
+
"special": true
|
| 386 |
+
},
|
| 387 |
+
"128048": {
|
| 388 |
+
"content": "<|reserved_special_token_43|>",
|
| 389 |
+
"lstrip": false,
|
| 390 |
+
"normalized": false,
|
| 391 |
+
"rstrip": false,
|
| 392 |
+
"single_word": false,
|
| 393 |
+
"special": true
|
| 394 |
+
},
|
| 395 |
+
"128049": {
|
| 396 |
+
"content": "<|reserved_special_token_44|>",
|
| 397 |
+
"lstrip": false,
|
| 398 |
+
"normalized": false,
|
| 399 |
+
"rstrip": false,
|
| 400 |
+
"single_word": false,
|
| 401 |
+
"special": true
|
| 402 |
+
},
|
| 403 |
+
"128050": {
|
| 404 |
+
"content": "<|reserved_special_token_45|>",
|
| 405 |
+
"lstrip": false,
|
| 406 |
+
"normalized": false,
|
| 407 |
+
"rstrip": false,
|
| 408 |
+
"single_word": false,
|
| 409 |
+
"special": true
|
| 410 |
+
},
|
| 411 |
+
"128051": {
|
| 412 |
+
"content": "<|reserved_special_token_46|>",
|
| 413 |
+
"lstrip": false,
|
| 414 |
+
"normalized": false,
|
| 415 |
+
"rstrip": false,
|
| 416 |
+
"single_word": false,
|
| 417 |
+
"special": true
|
| 418 |
+
},
|
| 419 |
+
"128052": {
|
| 420 |
+
"content": "<|reserved_special_token_47|>",
|
| 421 |
+
"lstrip": false,
|
| 422 |
+
"normalized": false,
|
| 423 |
+
"rstrip": false,
|
| 424 |
+
"single_word": false,
|
| 425 |
+
"special": true
|
| 426 |
+
},
|
| 427 |
+
"128053": {
|
| 428 |
+
"content": "<|reserved_special_token_48|>",
|
| 429 |
+
"lstrip": false,
|
| 430 |
+
"normalized": false,
|
| 431 |
+
"rstrip": false,
|
| 432 |
+
"single_word": false,
|
| 433 |
+
"special": true
|
| 434 |
+
},
|
| 435 |
+
"128054": {
|
| 436 |
+
"content": "<|reserved_special_token_49|>",
|
| 437 |
+
"lstrip": false,
|
| 438 |
+
"normalized": false,
|
| 439 |
+
"rstrip": false,
|
| 440 |
+
"single_word": false,
|
| 441 |
+
"special": true
|
| 442 |
+
},
|
| 443 |
+
"128055": {
|
| 444 |
+
"content": "<|reserved_special_token_50|>",
|
| 445 |
+
"lstrip": false,
|
| 446 |
+
"normalized": false,
|
| 447 |
+
"rstrip": false,
|
| 448 |
+
"single_word": false,
|
| 449 |
+
"special": true
|
| 450 |
+
},
|
| 451 |
+
"128056": {
|
| 452 |
+
"content": "<|reserved_special_token_51|>",
|
| 453 |
+
"lstrip": false,
|
| 454 |
+
"normalized": false,
|
| 455 |
+
"rstrip": false,
|
| 456 |
+
"single_word": false,
|
| 457 |
+
"special": true
|
| 458 |
+
},
|
| 459 |
+
"128057": {
|
| 460 |
+
"content": "<|reserved_special_token_52|>",
|
| 461 |
+
"lstrip": false,
|
| 462 |
+
"normalized": false,
|
| 463 |
+
"rstrip": false,
|
| 464 |
+
"single_word": false,
|
| 465 |
+
"special": true
|
| 466 |
+
},
|
| 467 |
+
"128058": {
|
| 468 |
+
"content": "<|reserved_special_token_53|>",
|
| 469 |
+
"lstrip": false,
|
| 470 |
+
"normalized": false,
|
| 471 |
+
"rstrip": false,
|
| 472 |
+
"single_word": false,
|
| 473 |
+
"special": true
|
| 474 |
+
},
|
| 475 |
+
"128059": {
|
| 476 |
+
"content": "<|reserved_special_token_54|>",
|
| 477 |
+
"lstrip": false,
|
| 478 |
+
"normalized": false,
|
| 479 |
+
"rstrip": false,
|
| 480 |
+
"single_word": false,
|
| 481 |
+
"special": true
|
| 482 |
+
},
|
| 483 |
+
"128060": {
|
| 484 |
+
"content": "<|reserved_special_token_55|>",
|
| 485 |
+
"lstrip": false,
|
| 486 |
+
"normalized": false,
|
| 487 |
+
"rstrip": false,
|
| 488 |
+
"single_word": false,
|
| 489 |
+
"special": true
|
| 490 |
+
},
|
| 491 |
+
"128061": {
|
| 492 |
+
"content": "<|reserved_special_token_56|>",
|
| 493 |
+
"lstrip": false,
|
| 494 |
+
"normalized": false,
|
| 495 |
+
"rstrip": false,
|
| 496 |
+
"single_word": false,
|
| 497 |
+
"special": true
|
| 498 |
+
},
|
| 499 |
+
"128062": {
|
| 500 |
+
"content": "<|reserved_special_token_57|>",
|
| 501 |
+
"lstrip": false,
|
| 502 |
+
"normalized": false,
|
| 503 |
+
"rstrip": false,
|
| 504 |
+
"single_word": false,
|
| 505 |
+
"special": true
|
| 506 |
+
},
|
| 507 |
+
"128063": {
|
| 508 |
+
"content": "<|reserved_special_token_58|>",
|
| 509 |
+
"lstrip": false,
|
| 510 |
+
"normalized": false,
|
| 511 |
+
"rstrip": false,
|
| 512 |
+
"single_word": false,
|
| 513 |
+
"special": true
|
| 514 |
+
},
|
| 515 |
+
"128064": {
|
| 516 |
+
"content": "<|reserved_special_token_59|>",
|
| 517 |
+
"lstrip": false,
|
| 518 |
+
"normalized": false,
|
| 519 |
+
"rstrip": false,
|
| 520 |
+
"single_word": false,
|
| 521 |
+
"special": true
|
| 522 |
+
},
|
| 523 |
+
"128065": {
|
| 524 |
+
"content": "<|reserved_special_token_60|>",
|
| 525 |
+
"lstrip": false,
|
| 526 |
+
"normalized": false,
|
| 527 |
+
"rstrip": false,
|
| 528 |
+
"single_word": false,
|
| 529 |
+
"special": true
|
| 530 |
+
},
|
| 531 |
+
"128066": {
|
| 532 |
+
"content": "<|reserved_special_token_61|>",
|
| 533 |
+
"lstrip": false,
|
| 534 |
+
"normalized": false,
|
| 535 |
+
"rstrip": false,
|
| 536 |
+
"single_word": false,
|
| 537 |
+
"special": true
|
| 538 |
+
},
|
| 539 |
+
"128067": {
|
| 540 |
+
"content": "<|reserved_special_token_62|>",
|
| 541 |
+
"lstrip": false,
|
| 542 |
+
"normalized": false,
|
| 543 |
+
"rstrip": false,
|
| 544 |
+
"single_word": false,
|
| 545 |
+
"special": true
|
| 546 |
+
},
|
| 547 |
+
"128068": {
|
| 548 |
+
"content": "<|reserved_special_token_63|>",
|
| 549 |
+
"lstrip": false,
|
| 550 |
+
"normalized": false,
|
| 551 |
+
"rstrip": false,
|
| 552 |
+
"single_word": false,
|
| 553 |
+
"special": true
|
| 554 |
+
},
|
| 555 |
+
"128069": {
|
| 556 |
+
"content": "<|reserved_special_token_64|>",
|
| 557 |
+
"lstrip": false,
|
| 558 |
+
"normalized": false,
|
| 559 |
+
"rstrip": false,
|
| 560 |
+
"single_word": false,
|
| 561 |
+
"special": true
|
| 562 |
+
},
|
| 563 |
+
"128070": {
|
| 564 |
+
"content": "<|reserved_special_token_65|>",
|
| 565 |
+
"lstrip": false,
|
| 566 |
+
"normalized": false,
|
| 567 |
+
"rstrip": false,
|
| 568 |
+
"single_word": false,
|
| 569 |
+
"special": true
|
| 570 |
+
},
|
| 571 |
+
"128071": {
|
| 572 |
+
"content": "<|reserved_special_token_66|>",
|
| 573 |
+
"lstrip": false,
|
| 574 |
+
"normalized": false,
|
| 575 |
+
"rstrip": false,
|
| 576 |
+
"single_word": false,
|
| 577 |
+
"special": true
|
| 578 |
+
},
|
| 579 |
+
"128072": {
|
| 580 |
+
"content": "<|reserved_special_token_67|>",
|
| 581 |
+
"lstrip": false,
|
| 582 |
+
"normalized": false,
|
| 583 |
+
"rstrip": false,
|
| 584 |
+
"single_word": false,
|
| 585 |
+
"special": true
|
| 586 |
+
},
|
| 587 |
+
"128073": {
|
| 588 |
+
"content": "<|reserved_special_token_68|>",
|
| 589 |
+
"lstrip": false,
|
| 590 |
+
"normalized": false,
|
| 591 |
+
"rstrip": false,
|
| 592 |
+
"single_word": false,
|
| 593 |
+
"special": true
|
| 594 |
+
},
|
| 595 |
+
"128074": {
|
| 596 |
+
"content": "<|reserved_special_token_69|>",
|
| 597 |
+
"lstrip": false,
|
| 598 |
+
"normalized": false,
|
| 599 |
+
"rstrip": false,
|
| 600 |
+
"single_word": false,
|
| 601 |
+
"special": true
|
| 602 |
+
},
|
| 603 |
+
"128075": {
|
| 604 |
+
"content": "<|reserved_special_token_70|>",
|
| 605 |
+
"lstrip": false,
|
| 606 |
+
"normalized": false,
|
| 607 |
+
"rstrip": false,
|
| 608 |
+
"single_word": false,
|
| 609 |
+
"special": true
|
| 610 |
+
},
|
| 611 |
+
"128076": {
|
| 612 |
+
"content": "<|reserved_special_token_71|>",
|
| 613 |
+
"lstrip": false,
|
| 614 |
+
"normalized": false,
|
| 615 |
+
"rstrip": false,
|
| 616 |
+
"single_word": false,
|
| 617 |
+
"special": true
|
| 618 |
+
},
|
| 619 |
+
"128077": {
|
| 620 |
+
"content": "<|reserved_special_token_72|>",
|
| 621 |
+
"lstrip": false,
|
| 622 |
+
"normalized": false,
|
| 623 |
+
"rstrip": false,
|
| 624 |
+
"single_word": false,
|
| 625 |
+
"special": true
|
| 626 |
+
},
|
| 627 |
+
"128078": {
|
| 628 |
+
"content": "<|reserved_special_token_73|>",
|
| 629 |
+
"lstrip": false,
|
| 630 |
+
"normalized": false,
|
| 631 |
+
"rstrip": false,
|
| 632 |
+
"single_word": false,
|
| 633 |
+
"special": true
|
| 634 |
+
},
|
| 635 |
+
"128079": {
|
| 636 |
+
"content": "<|reserved_special_token_74|>",
|
| 637 |
+
"lstrip": false,
|
| 638 |
+
"normalized": false,
|
| 639 |
+
"rstrip": false,
|
| 640 |
+
"single_word": false,
|
| 641 |
+
"special": true
|
| 642 |
+
},
|
| 643 |
+
"128080": {
|
| 644 |
+
"content": "<|reserved_special_token_75|>",
|
| 645 |
+
"lstrip": false,
|
| 646 |
+
"normalized": false,
|
| 647 |
+
"rstrip": false,
|
| 648 |
+
"single_word": false,
|
| 649 |
+
"special": true
|
| 650 |
+
},
|
| 651 |
+
"128081": {
|
| 652 |
+
"content": "<|reserved_special_token_76|>",
|
| 653 |
+
"lstrip": false,
|
| 654 |
+
"normalized": false,
|
| 655 |
+
"rstrip": false,
|
| 656 |
+
"single_word": false,
|
| 657 |
+
"special": true
|
| 658 |
+
},
|
| 659 |
+
"128082": {
|
| 660 |
+
"content": "<|reserved_special_token_77|>",
|
| 661 |
+
"lstrip": false,
|
| 662 |
+
"normalized": false,
|
| 663 |
+
"rstrip": false,
|
| 664 |
+
"single_word": false,
|
| 665 |
+
"special": true
|
| 666 |
+
},
|
| 667 |
+
"128083": {
|
| 668 |
+
"content": "<|reserved_special_token_78|>",
|
| 669 |
+
"lstrip": false,
|
| 670 |
+
"normalized": false,
|
| 671 |
+
"rstrip": false,
|
| 672 |
+
"single_word": false,
|
| 673 |
+
"special": true
|
| 674 |
+
},
|
| 675 |
+
"128084": {
|
| 676 |
+
"content": "<|reserved_special_token_79|>",
|
| 677 |
+
"lstrip": false,
|
| 678 |
+
"normalized": false,
|
| 679 |
+
"rstrip": false,
|
| 680 |
+
"single_word": false,
|
| 681 |
+
"special": true
|
| 682 |
+
},
|
| 683 |
+
"128085": {
|
| 684 |
+
"content": "<|reserved_special_token_80|>",
|
| 685 |
+
"lstrip": false,
|
| 686 |
+
"normalized": false,
|
| 687 |
+
"rstrip": false,
|
| 688 |
+
"single_word": false,
|
| 689 |
+
"special": true
|
| 690 |
+
},
|
| 691 |
+
"128086": {
|
| 692 |
+
"content": "<|reserved_special_token_81|>",
|
| 693 |
+
"lstrip": false,
|
| 694 |
+
"normalized": false,
|
| 695 |
+
"rstrip": false,
|
| 696 |
+
"single_word": false,
|
| 697 |
+
"special": true
|
| 698 |
+
},
|
| 699 |
+
"128087": {
|
| 700 |
+
"content": "<|reserved_special_token_82|>",
|
| 701 |
+
"lstrip": false,
|
| 702 |
+
"normalized": false,
|
| 703 |
+
"rstrip": false,
|
| 704 |
+
"single_word": false,
|
| 705 |
+
"special": true
|
| 706 |
+
},
|
| 707 |
+
"128088": {
|
| 708 |
+
"content": "<|reserved_special_token_83|>",
|
| 709 |
+
"lstrip": false,
|
| 710 |
+
"normalized": false,
|
| 711 |
+
"rstrip": false,
|
| 712 |
+
"single_word": false,
|
| 713 |
+
"special": true
|
| 714 |
+
},
|
| 715 |
+
"128089": {
|
| 716 |
+
"content": "<|reserved_special_token_84|>",
|
| 717 |
+
"lstrip": false,
|
| 718 |
+
"normalized": false,
|
| 719 |
+
"rstrip": false,
|
| 720 |
+
"single_word": false,
|
| 721 |
+
"special": true
|
| 722 |
+
},
|
| 723 |
+
"128090": {
|
| 724 |
+
"content": "<|reserved_special_token_85|>",
|
| 725 |
+
"lstrip": false,
|
| 726 |
+
"normalized": false,
|
| 727 |
+
"rstrip": false,
|
| 728 |
+
"single_word": false,
|
| 729 |
+
"special": true
|
| 730 |
+
},
|
| 731 |
+
"128091": {
|
| 732 |
+
"content": "<|reserved_special_token_86|>",
|
| 733 |
+
"lstrip": false,
|
| 734 |
+
"normalized": false,
|
| 735 |
+
"rstrip": false,
|
| 736 |
+
"single_word": false,
|
| 737 |
+
"special": true
|
| 738 |
+
},
|
| 739 |
+
"128092": {
|
| 740 |
+
"content": "<|reserved_special_token_87|>",
|
| 741 |
+
"lstrip": false,
|
| 742 |
+
"normalized": false,
|
| 743 |
+
"rstrip": false,
|
| 744 |
+
"single_word": false,
|
| 745 |
+
"special": true
|
| 746 |
+
},
|
| 747 |
+
"128093": {
|
| 748 |
+
"content": "<|reserved_special_token_88|>",
|
| 749 |
+
"lstrip": false,
|
| 750 |
+
"normalized": false,
|
| 751 |
+
"rstrip": false,
|
| 752 |
+
"single_word": false,
|
| 753 |
+
"special": true
|
| 754 |
+
},
|
| 755 |
+
"128094": {
|
| 756 |
+
"content": "<|reserved_special_token_89|>",
|
| 757 |
+
"lstrip": false,
|
| 758 |
+
"normalized": false,
|
| 759 |
+
"rstrip": false,
|
| 760 |
+
"single_word": false,
|
| 761 |
+
"special": true
|
| 762 |
+
},
|
| 763 |
+
"128095": {
|
| 764 |
+
"content": "<|reserved_special_token_90|>",
|
| 765 |
+
"lstrip": false,
|
| 766 |
+
"normalized": false,
|
| 767 |
+
"rstrip": false,
|
| 768 |
+
"single_word": false,
|
| 769 |
+
"special": true
|
| 770 |
+
},
|
| 771 |
+
"128096": {
|
| 772 |
+
"content": "<|reserved_special_token_91|>",
|
| 773 |
+
"lstrip": false,
|
| 774 |
+
"normalized": false,
|
| 775 |
+
"rstrip": false,
|
| 776 |
+
"single_word": false,
|
| 777 |
+
"special": true
|
| 778 |
+
},
|
| 779 |
+
"128097": {
|
| 780 |
+
"content": "<|reserved_special_token_92|>",
|
| 781 |
+
"lstrip": false,
|
| 782 |
+
"normalized": false,
|
| 783 |
+
"rstrip": false,
|
| 784 |
+
"single_word": false,
|
| 785 |
+
"special": true
|
| 786 |
+
},
|
| 787 |
+
"128098": {
|
| 788 |
+
"content": "<|reserved_special_token_93|>",
|
| 789 |
+
"lstrip": false,
|
| 790 |
+
"normalized": false,
|
| 791 |
+
"rstrip": false,
|
| 792 |
+
"single_word": false,
|
| 793 |
+
"special": true
|
| 794 |
+
},
|
| 795 |
+
"128099": {
|
| 796 |
+
"content": "<|reserved_special_token_94|>",
|
| 797 |
+
"lstrip": false,
|
| 798 |
+
"normalized": false,
|
| 799 |
+
"rstrip": false,
|
| 800 |
+
"single_word": false,
|
| 801 |
+
"special": true
|
| 802 |
+
},
|
| 803 |
+
"128100": {
|
| 804 |
+
"content": "<|reserved_special_token_95|>",
|
| 805 |
+
"lstrip": false,
|
| 806 |
+
"normalized": false,
|
| 807 |
+
"rstrip": false,
|
| 808 |
+
"single_word": false,
|
| 809 |
+
"special": true
|
| 810 |
+
},
|
| 811 |
+
"128101": {
|
| 812 |
+
"content": "<|reserved_special_token_96|>",
|
| 813 |
+
"lstrip": false,
|
| 814 |
+
"normalized": false,
|
| 815 |
+
"rstrip": false,
|
| 816 |
+
"single_word": false,
|
| 817 |
+
"special": true
|
| 818 |
+
},
|
| 819 |
+
"128102": {
|
| 820 |
+
"content": "<|reserved_special_token_97|>",
|
| 821 |
+
"lstrip": false,
|
| 822 |
+
"normalized": false,
|
| 823 |
+
"rstrip": false,
|
| 824 |
+
"single_word": false,
|
| 825 |
+
"special": true
|
| 826 |
+
},
|
| 827 |
+
"128103": {
|
| 828 |
+
"content": "<|reserved_special_token_98|>",
|
| 829 |
+
"lstrip": false,
|
| 830 |
+
"normalized": false,
|
| 831 |
+
"rstrip": false,
|
| 832 |
+
"single_word": false,
|
| 833 |
+
"special": true
|
| 834 |
+
},
|
| 835 |
+
"128104": {
|
| 836 |
+
"content": "<|reserved_special_token_99|>",
|
| 837 |
+
"lstrip": false,
|
| 838 |
+
"normalized": false,
|
| 839 |
+
"rstrip": false,
|
| 840 |
+
"single_word": false,
|
| 841 |
+
"special": true
|
| 842 |
+
},
|
| 843 |
+
"128105": {
|
| 844 |
+
"content": "<|reserved_special_token_100|>",
|
| 845 |
+
"lstrip": false,
|
| 846 |
+
"normalized": false,
|
| 847 |
+
"rstrip": false,
|
| 848 |
+
"single_word": false,
|
| 849 |
+
"special": true
|
| 850 |
+
},
|
| 851 |
+
"128106": {
|
| 852 |
+
"content": "<|reserved_special_token_101|>",
|
| 853 |
+
"lstrip": false,
|
| 854 |
+
"normalized": false,
|
| 855 |
+
"rstrip": false,
|
| 856 |
+
"single_word": false,
|
| 857 |
+
"special": true
|
| 858 |
+
},
|
| 859 |
+
"128107": {
|
| 860 |
+
"content": "<|reserved_special_token_102|>",
|
| 861 |
+
"lstrip": false,
|
| 862 |
+
"normalized": false,
|
| 863 |
+
"rstrip": false,
|
| 864 |
+
"single_word": false,
|
| 865 |
+
"special": true
|
| 866 |
+
},
|
| 867 |
+
"128108": {
|
| 868 |
+
"content": "<|reserved_special_token_103|>",
|
| 869 |
+
"lstrip": false,
|
| 870 |
+
"normalized": false,
|
| 871 |
+
"rstrip": false,
|
| 872 |
+
"single_word": false,
|
| 873 |
+
"special": true
|
| 874 |
+
},
|
| 875 |
+
"128109": {
|
| 876 |
+
"content": "<|reserved_special_token_104|>",
|
| 877 |
+
"lstrip": false,
|
| 878 |
+
"normalized": false,
|
| 879 |
+
"rstrip": false,
|
| 880 |
+
"single_word": false,
|
| 881 |
+
"special": true
|
| 882 |
+
},
|
| 883 |
+
"128110": {
|
| 884 |
+
"content": "<|reserved_special_token_105|>",
|
| 885 |
+
"lstrip": false,
|
| 886 |
+
"normalized": false,
|
| 887 |
+
"rstrip": false,
|
| 888 |
+
"single_word": false,
|
| 889 |
+
"special": true
|
| 890 |
+
},
|
| 891 |
+
"128111": {
|
| 892 |
+
"content": "<|reserved_special_token_106|>",
|
| 893 |
+
"lstrip": false,
|
| 894 |
+
"normalized": false,
|
| 895 |
+
"rstrip": false,
|
| 896 |
+
"single_word": false,
|
| 897 |
+
"special": true
|
| 898 |
+
},
|
| 899 |
+
"128112": {
|
| 900 |
+
"content": "<|reserved_special_token_107|>",
|
| 901 |
+
"lstrip": false,
|
| 902 |
+
"normalized": false,
|
| 903 |
+
"rstrip": false,
|
| 904 |
+
"single_word": false,
|
| 905 |
+
"special": true
|
| 906 |
+
},
|
| 907 |
+
"128113": {
|
| 908 |
+
"content": "<|reserved_special_token_108|>",
|
| 909 |
+
"lstrip": false,
|
| 910 |
+
"normalized": false,
|
| 911 |
+
"rstrip": false,
|
| 912 |
+
"single_word": false,
|
| 913 |
+
"special": true
|
| 914 |
+
},
|
| 915 |
+
"128114": {
|
| 916 |
+
"content": "<|reserved_special_token_109|>",
|
| 917 |
+
"lstrip": false,
|
| 918 |
+
"normalized": false,
|
| 919 |
+
"rstrip": false,
|
| 920 |
+
"single_word": false,
|
| 921 |
+
"special": true
|
| 922 |
+
},
|
| 923 |
+
"128115": {
|
| 924 |
+
"content": "<|reserved_special_token_110|>",
|
| 925 |
+
"lstrip": false,
|
| 926 |
+
"normalized": false,
|
| 927 |
+
"rstrip": false,
|
| 928 |
+
"single_word": false,
|
| 929 |
+
"special": true
|
| 930 |
+
},
|
| 931 |
+
"128116": {
|
| 932 |
+
"content": "<|reserved_special_token_111|>",
|
| 933 |
+
"lstrip": false,
|
| 934 |
+
"normalized": false,
|
| 935 |
+
"rstrip": false,
|
| 936 |
+
"single_word": false,
|
| 937 |
+
"special": true
|
| 938 |
+
},
|
| 939 |
+
"128117": {
|
| 940 |
+
"content": "<|reserved_special_token_112|>",
|
| 941 |
+
"lstrip": false,
|
| 942 |
+
"normalized": false,
|
| 943 |
+
"rstrip": false,
|
| 944 |
+
"single_word": false,
|
| 945 |
+
"special": true
|
| 946 |
+
},
|
| 947 |
+
"128118": {
|
| 948 |
+
"content": "<|reserved_special_token_113|>",
|
| 949 |
+
"lstrip": false,
|
| 950 |
+
"normalized": false,
|
| 951 |
+
"rstrip": false,
|
| 952 |
+
"single_word": false,
|
| 953 |
+
"special": true
|
| 954 |
+
},
|
| 955 |
+
"128119": {
|
| 956 |
+
"content": "<|reserved_special_token_114|>",
|
| 957 |
+
"lstrip": false,
|
| 958 |
+
"normalized": false,
|
| 959 |
+
"rstrip": false,
|
| 960 |
+
"single_word": false,
|
| 961 |
+
"special": true
|
| 962 |
+
},
|
| 963 |
+
"128120": {
|
| 964 |
+
"content": "<|reserved_special_token_115|>",
|
| 965 |
+
"lstrip": false,
|
| 966 |
+
"normalized": false,
|
| 967 |
+
"rstrip": false,
|
| 968 |
+
"single_word": false,
|
| 969 |
+
"special": true
|
| 970 |
+
},
|
| 971 |
+
"128121": {
|
| 972 |
+
"content": "<|reserved_special_token_116|>",
|
| 973 |
+
"lstrip": false,
|
| 974 |
+
"normalized": false,
|
| 975 |
+
"rstrip": false,
|
| 976 |
+
"single_word": false,
|
| 977 |
+
"special": true
|
| 978 |
+
},
|
| 979 |
+
"128122": {
|
| 980 |
+
"content": "<|reserved_special_token_117|>",
|
| 981 |
+
"lstrip": false,
|
| 982 |
+
"normalized": false,
|
| 983 |
+
"rstrip": false,
|
| 984 |
+
"single_word": false,
|
| 985 |
+
"special": true
|
| 986 |
+
},
|
| 987 |
+
"128123": {
|
| 988 |
+
"content": "<|reserved_special_token_118|>",
|
| 989 |
+
"lstrip": false,
|
| 990 |
+
"normalized": false,
|
| 991 |
+
"rstrip": false,
|
| 992 |
+
"single_word": false,
|
| 993 |
+
"special": true
|
| 994 |
+
},
|
| 995 |
+
"128124": {
|
| 996 |
+
"content": "<|reserved_special_token_119|>",
|
| 997 |
+
"lstrip": false,
|
| 998 |
+
"normalized": false,
|
| 999 |
+
"rstrip": false,
|
| 1000 |
+
"single_word": false,
|
| 1001 |
+
"special": true
|
| 1002 |
+
},
|
| 1003 |
+
"128125": {
|
| 1004 |
+
"content": "<|reserved_special_token_120|>",
|
| 1005 |
+
"lstrip": false,
|
| 1006 |
+
"normalized": false,
|
| 1007 |
+
"rstrip": false,
|
| 1008 |
+
"single_word": false,
|
| 1009 |
+
"special": true
|
| 1010 |
+
},
|
| 1011 |
+
"128126": {
|
| 1012 |
+
"content": "<|reserved_special_token_121|>",
|
| 1013 |
+
"lstrip": false,
|
| 1014 |
+
"normalized": false,
|
| 1015 |
+
"rstrip": false,
|
| 1016 |
+
"single_word": false,
|
| 1017 |
+
"special": true
|
| 1018 |
+
},
|
| 1019 |
+
"128127": {
|
| 1020 |
+
"content": "<|reserved_special_token_122|>",
|
| 1021 |
+
"lstrip": false,
|
| 1022 |
+
"normalized": false,
|
| 1023 |
+
"rstrip": false,
|
| 1024 |
+
"single_word": false,
|
| 1025 |
+
"special": true
|
| 1026 |
+
},
|
| 1027 |
+
"128128": {
|
| 1028 |
+
"content": "<|reserved_special_token_123|>",
|
| 1029 |
+
"lstrip": false,
|
| 1030 |
+
"normalized": false,
|
| 1031 |
+
"rstrip": false,
|
| 1032 |
+
"single_word": false,
|
| 1033 |
+
"special": true
|
| 1034 |
+
},
|
| 1035 |
+
"128129": {
|
| 1036 |
+
"content": "<|reserved_special_token_124|>",
|
| 1037 |
+
"lstrip": false,
|
| 1038 |
+
"normalized": false,
|
| 1039 |
+
"rstrip": false,
|
| 1040 |
+
"single_word": false,
|
| 1041 |
+
"special": true
|
| 1042 |
+
},
|
| 1043 |
+
"128130": {
|
| 1044 |
+
"content": "<|reserved_special_token_125|>",
|
| 1045 |
+
"lstrip": false,
|
| 1046 |
+
"normalized": false,
|
| 1047 |
+
"rstrip": false,
|
| 1048 |
+
"single_word": false,
|
| 1049 |
+
"special": true
|
| 1050 |
+
},
|
| 1051 |
+
"128131": {
|
| 1052 |
+
"content": "<|reserved_special_token_126|>",
|
| 1053 |
+
"lstrip": false,
|
| 1054 |
+
"normalized": false,
|
| 1055 |
+
"rstrip": false,
|
| 1056 |
+
"single_word": false,
|
| 1057 |
+
"special": true
|
| 1058 |
+
},
|
| 1059 |
+
"128132": {
|
| 1060 |
+
"content": "<|reserved_special_token_127|>",
|
| 1061 |
+
"lstrip": false,
|
| 1062 |
+
"normalized": false,
|
| 1063 |
+
"rstrip": false,
|
| 1064 |
+
"single_word": false,
|
| 1065 |
+
"special": true
|
| 1066 |
+
},
|
| 1067 |
+
"128133": {
|
| 1068 |
+
"content": "<|reserved_special_token_128|>",
|
| 1069 |
+
"lstrip": false,
|
| 1070 |
+
"normalized": false,
|
| 1071 |
+
"rstrip": false,
|
| 1072 |
+
"single_word": false,
|
| 1073 |
+
"special": true
|
| 1074 |
+
},
|
| 1075 |
+
"128134": {
|
| 1076 |
+
"content": "<|reserved_special_token_129|>",
|
| 1077 |
+
"lstrip": false,
|
| 1078 |
+
"normalized": false,
|
| 1079 |
+
"rstrip": false,
|
| 1080 |
+
"single_word": false,
|
| 1081 |
+
"special": true
|
| 1082 |
+
},
|
| 1083 |
+
"128135": {
|
| 1084 |
+
"content": "<|reserved_special_token_130|>",
|
| 1085 |
+
"lstrip": false,
|
| 1086 |
+
"normalized": false,
|
| 1087 |
+
"rstrip": false,
|
| 1088 |
+
"single_word": false,
|
| 1089 |
+
"special": true
|
| 1090 |
+
},
|
| 1091 |
+
"128136": {
|
| 1092 |
+
"content": "<|reserved_special_token_131|>",
|
| 1093 |
+
"lstrip": false,
|
| 1094 |
+
"normalized": false,
|
| 1095 |
+
"rstrip": false,
|
| 1096 |
+
"single_word": false,
|
| 1097 |
+
"special": true
|
| 1098 |
+
},
|
| 1099 |
+
"128137": {
|
| 1100 |
+
"content": "<|reserved_special_token_132|>",
|
| 1101 |
+
"lstrip": false,
|
| 1102 |
+
"normalized": false,
|
| 1103 |
+
"rstrip": false,
|
| 1104 |
+
"single_word": false,
|
| 1105 |
+
"special": true
|
| 1106 |
+
},
|
| 1107 |
+
"128138": {
|
| 1108 |
+
"content": "<|reserved_special_token_133|>",
|
| 1109 |
+
"lstrip": false,
|
| 1110 |
+
"normalized": false,
|
| 1111 |
+
"rstrip": false,
|
| 1112 |
+
"single_word": false,
|
| 1113 |
+
"special": true
|
| 1114 |
+
},
|
| 1115 |
+
"128139": {
|
| 1116 |
+
"content": "<|reserved_special_token_134|>",
|
| 1117 |
+
"lstrip": false,
|
| 1118 |
+
"normalized": false,
|
| 1119 |
+
"rstrip": false,
|
| 1120 |
+
"single_word": false,
|
| 1121 |
+
"special": true
|
| 1122 |
+
},
|
| 1123 |
+
"128140": {
|
| 1124 |
+
"content": "<|reserved_special_token_135|>",
|
| 1125 |
+
"lstrip": false,
|
| 1126 |
+
"normalized": false,
|
| 1127 |
+
"rstrip": false,
|
| 1128 |
+
"single_word": false,
|
| 1129 |
+
"special": true
|
| 1130 |
+
},
|
| 1131 |
+
"128141": {
|
| 1132 |
+
"content": "<|reserved_special_token_136|>",
|
| 1133 |
+
"lstrip": false,
|
| 1134 |
+
"normalized": false,
|
| 1135 |
+
"rstrip": false,
|
| 1136 |
+
"single_word": false,
|
| 1137 |
+
"special": true
|
| 1138 |
+
},
|
| 1139 |
+
"128142": {
|
| 1140 |
+
"content": "<|reserved_special_token_137|>",
|
| 1141 |
+
"lstrip": false,
|
| 1142 |
+
"normalized": false,
|
| 1143 |
+
"rstrip": false,
|
| 1144 |
+
"single_word": false,
|
| 1145 |
+
"special": true
|
| 1146 |
+
},
|
| 1147 |
+
"128143": {
|
| 1148 |
+
"content": "<|reserved_special_token_138|>",
|
| 1149 |
+
"lstrip": false,
|
| 1150 |
+
"normalized": false,
|
| 1151 |
+
"rstrip": false,
|
| 1152 |
+
"single_word": false,
|
| 1153 |
+
"special": true
|
| 1154 |
+
},
|
| 1155 |
+
"128144": {
|
| 1156 |
+
"content": "<|reserved_special_token_139|>",
|
| 1157 |
+
"lstrip": false,
|
| 1158 |
+
"normalized": false,
|
| 1159 |
+
"rstrip": false,
|
| 1160 |
+
"single_word": false,
|
| 1161 |
+
"special": true
|
| 1162 |
+
},
|
| 1163 |
+
"128145": {
|
| 1164 |
+
"content": "<|reserved_special_token_140|>",
|
| 1165 |
+
"lstrip": false,
|
| 1166 |
+
"normalized": false,
|
| 1167 |
+
"rstrip": false,
|
| 1168 |
+
"single_word": false,
|
| 1169 |
+
"special": true
|
| 1170 |
+
},
|
| 1171 |
+
"128146": {
|
| 1172 |
+
"content": "<|reserved_special_token_141|>",
|
| 1173 |
+
"lstrip": false,
|
| 1174 |
+
"normalized": false,
|
| 1175 |
+
"rstrip": false,
|
| 1176 |
+
"single_word": false,
|
| 1177 |
+
"special": true
|
| 1178 |
+
},
|
| 1179 |
+
"128147": {
|
| 1180 |
+
"content": "<|reserved_special_token_142|>",
|
| 1181 |
+
"lstrip": false,
|
| 1182 |
+
"normalized": false,
|
| 1183 |
+
"rstrip": false,
|
| 1184 |
+
"single_word": false,
|
| 1185 |
+
"special": true
|
| 1186 |
+
},
|
| 1187 |
+
"128148": {
|
| 1188 |
+
"content": "<|reserved_special_token_143|>",
|
| 1189 |
+
"lstrip": false,
|
| 1190 |
+
"normalized": false,
|
| 1191 |
+
"rstrip": false,
|
| 1192 |
+
"single_word": false,
|
| 1193 |
+
"special": true
|
| 1194 |
+
},
|
| 1195 |
+
"128149": {
|
| 1196 |
+
"content": "<|reserved_special_token_144|>",
|
| 1197 |
+
"lstrip": false,
|
| 1198 |
+
"normalized": false,
|
| 1199 |
+
"rstrip": false,
|
| 1200 |
+
"single_word": false,
|
| 1201 |
+
"special": true
|
| 1202 |
+
},
|
| 1203 |
+
"128150": {
|
| 1204 |
+
"content": "<|reserved_special_token_145|>",
|
| 1205 |
+
"lstrip": false,
|
| 1206 |
+
"normalized": false,
|
| 1207 |
+
"rstrip": false,
|
| 1208 |
+
"single_word": false,
|
| 1209 |
+
"special": true
|
| 1210 |
+
},
|
| 1211 |
+
"128151": {
|
| 1212 |
+
"content": "<|reserved_special_token_146|>",
|
| 1213 |
+
"lstrip": false,
|
| 1214 |
+
"normalized": false,
|
| 1215 |
+
"rstrip": false,
|
| 1216 |
+
"single_word": false,
|
| 1217 |
+
"special": true
|
| 1218 |
+
},
|
| 1219 |
+
"128152": {
|
| 1220 |
+
"content": "<|reserved_special_token_147|>",
|
| 1221 |
+
"lstrip": false,
|
| 1222 |
+
"normalized": false,
|
| 1223 |
+
"rstrip": false,
|
| 1224 |
+
"single_word": false,
|
| 1225 |
+
"special": true
|
| 1226 |
+
},
|
| 1227 |
+
"128153": {
|
| 1228 |
+
"content": "<|reserved_special_token_148|>",
|
| 1229 |
+
"lstrip": false,
|
| 1230 |
+
"normalized": false,
|
| 1231 |
+
"rstrip": false,
|
| 1232 |
+
"single_word": false,
|
| 1233 |
+
"special": true
|
| 1234 |
+
},
|
| 1235 |
+
"128154": {
|
| 1236 |
+
"content": "<|reserved_special_token_149|>",
|
| 1237 |
+
"lstrip": false,
|
| 1238 |
+
"normalized": false,
|
| 1239 |
+
"rstrip": false,
|
| 1240 |
+
"single_word": false,
|
| 1241 |
+
"special": true
|
| 1242 |
+
},
|
| 1243 |
+
"128155": {
|
| 1244 |
+
"content": "<|reserved_special_token_150|>",
|
| 1245 |
+
"lstrip": false,
|
| 1246 |
+
"normalized": false,
|
| 1247 |
+
"rstrip": false,
|
| 1248 |
+
"single_word": false,
|
| 1249 |
+
"special": true
|
| 1250 |
+
},
|
| 1251 |
+
"128156": {
|
| 1252 |
+
"content": "<|reserved_special_token_151|>",
|
| 1253 |
+
"lstrip": false,
|
| 1254 |
+
"normalized": false,
|
| 1255 |
+
"rstrip": false,
|
| 1256 |
+
"single_word": false,
|
| 1257 |
+
"special": true
|
| 1258 |
+
},
|
| 1259 |
+
"128157": {
|
| 1260 |
+
"content": "<|reserved_special_token_152|>",
|
| 1261 |
+
"lstrip": false,
|
| 1262 |
+
"normalized": false,
|
| 1263 |
+
"rstrip": false,
|
| 1264 |
+
"single_word": false,
|
| 1265 |
+
"special": true
|
| 1266 |
+
},
|
| 1267 |
+
"128158": {
|
| 1268 |
+
"content": "<|reserved_special_token_153|>",
|
| 1269 |
+
"lstrip": false,
|
| 1270 |
+
"normalized": false,
|
| 1271 |
+
"rstrip": false,
|
| 1272 |
+
"single_word": false,
|
| 1273 |
+
"special": true
|
| 1274 |
+
},
|
| 1275 |
+
"128159": {
|
| 1276 |
+
"content": "<|reserved_special_token_154|>",
|
| 1277 |
+
"lstrip": false,
|
| 1278 |
+
"normalized": false,
|
| 1279 |
+
"rstrip": false,
|
| 1280 |
+
"single_word": false,
|
| 1281 |
+
"special": true
|
| 1282 |
+
},
|
| 1283 |
+
"128160": {
|
| 1284 |
+
"content": "<|reserved_special_token_155|>",
|
| 1285 |
+
"lstrip": false,
|
| 1286 |
+
"normalized": false,
|
| 1287 |
+
"rstrip": false,
|
| 1288 |
+
"single_word": false,
|
| 1289 |
+
"special": true
|
| 1290 |
+
},
|
| 1291 |
+
"128161": {
|
| 1292 |
+
"content": "<|reserved_special_token_156|>",
|
| 1293 |
+
"lstrip": false,
|
| 1294 |
+
"normalized": false,
|
| 1295 |
+
"rstrip": false,
|
| 1296 |
+
"single_word": false,
|
| 1297 |
+
"special": true
|
| 1298 |
+
},
|
| 1299 |
+
"128162": {
|
| 1300 |
+
"content": "<|reserved_special_token_157|>",
|
| 1301 |
+
"lstrip": false,
|
| 1302 |
+
"normalized": false,
|
| 1303 |
+
"rstrip": false,
|
| 1304 |
+
"single_word": false,
|
| 1305 |
+
"special": true
|
| 1306 |
+
},
|
| 1307 |
+
"128163": {
|
| 1308 |
+
"content": "<|reserved_special_token_158|>",
|
| 1309 |
+
"lstrip": false,
|
| 1310 |
+
"normalized": false,
|
| 1311 |
+
"rstrip": false,
|
| 1312 |
+
"single_word": false,
|
| 1313 |
+
"special": true
|
| 1314 |
+
},
|
| 1315 |
+
"128164": {
|
| 1316 |
+
"content": "<|reserved_special_token_159|>",
|
| 1317 |
+
"lstrip": false,
|
| 1318 |
+
"normalized": false,
|
| 1319 |
+
"rstrip": false,
|
| 1320 |
+
"single_word": false,
|
| 1321 |
+
"special": true
|
| 1322 |
+
},
|
| 1323 |
+
"128165": {
|
| 1324 |
+
"content": "<|reserved_special_token_160|>",
|
| 1325 |
+
"lstrip": false,
|
| 1326 |
+
"normalized": false,
|
| 1327 |
+
"rstrip": false,
|
| 1328 |
+
"single_word": false,
|
| 1329 |
+
"special": true
|
| 1330 |
+
},
|
| 1331 |
+
"128166": {
|
| 1332 |
+
"content": "<|reserved_special_token_161|>",
|
| 1333 |
+
"lstrip": false,
|
| 1334 |
+
"normalized": false,
|
| 1335 |
+
"rstrip": false,
|
| 1336 |
+
"single_word": false,
|
| 1337 |
+
"special": true
|
| 1338 |
+
},
|
| 1339 |
+
"128167": {
|
| 1340 |
+
"content": "<|reserved_special_token_162|>",
|
| 1341 |
+
"lstrip": false,
|
| 1342 |
+
"normalized": false,
|
| 1343 |
+
"rstrip": false,
|
| 1344 |
+
"single_word": false,
|
| 1345 |
+
"special": true
|
| 1346 |
+
},
|
| 1347 |
+
"128168": {
|
| 1348 |
+
"content": "<|reserved_special_token_163|>",
|
| 1349 |
+
"lstrip": false,
|
| 1350 |
+
"normalized": false,
|
| 1351 |
+
"rstrip": false,
|
| 1352 |
+
"single_word": false,
|
| 1353 |
+
"special": true
|
| 1354 |
+
},
|
| 1355 |
+
"128169": {
|
| 1356 |
+
"content": "<|reserved_special_token_164|>",
|
| 1357 |
+
"lstrip": false,
|
| 1358 |
+
"normalized": false,
|
| 1359 |
+
"rstrip": false,
|
| 1360 |
+
"single_word": false,
|
| 1361 |
+
"special": true
|
| 1362 |
+
},
|
| 1363 |
+
"128170": {
|
| 1364 |
+
"content": "<|reserved_special_token_165|>",
|
| 1365 |
+
"lstrip": false,
|
| 1366 |
+
"normalized": false,
|
| 1367 |
+
"rstrip": false,
|
| 1368 |
+
"single_word": false,
|
| 1369 |
+
"special": true
|
| 1370 |
+
},
|
| 1371 |
+
"128171": {
|
| 1372 |
+
"content": "<|reserved_special_token_166|>",
|
| 1373 |
+
"lstrip": false,
|
| 1374 |
+
"normalized": false,
|
| 1375 |
+
"rstrip": false,
|
| 1376 |
+
"single_word": false,
|
| 1377 |
+
"special": true
|
| 1378 |
+
},
|
| 1379 |
+
"128172": {
|
| 1380 |
+
"content": "<|reserved_special_token_167|>",
|
| 1381 |
+
"lstrip": false,
|
| 1382 |
+
"normalized": false,
|
| 1383 |
+
"rstrip": false,
|
| 1384 |
+
"single_word": false,
|
| 1385 |
+
"special": true
|
| 1386 |
+
},
|
| 1387 |
+
"128173": {
|
| 1388 |
+
"content": "<|reserved_special_token_168|>",
|
| 1389 |
+
"lstrip": false,
|
| 1390 |
+
"normalized": false,
|
| 1391 |
+
"rstrip": false,
|
| 1392 |
+
"single_word": false,
|
| 1393 |
+
"special": true
|
| 1394 |
+
},
|
| 1395 |
+
"128174": {
|
| 1396 |
+
"content": "<|reserved_special_token_169|>",
|
| 1397 |
+
"lstrip": false,
|
| 1398 |
+
"normalized": false,
|
| 1399 |
+
"rstrip": false,
|
| 1400 |
+
"single_word": false,
|
| 1401 |
+
"special": true
|
| 1402 |
+
},
|
| 1403 |
+
"128175": {
|
| 1404 |
+
"content": "<|reserved_special_token_170|>",
|
| 1405 |
+
"lstrip": false,
|
| 1406 |
+
"normalized": false,
|
| 1407 |
+
"rstrip": false,
|
| 1408 |
+
"single_word": false,
|
| 1409 |
+
"special": true
|
| 1410 |
+
},
|
| 1411 |
+
"128176": {
|
| 1412 |
+
"content": "<|reserved_special_token_171|>",
|
| 1413 |
+
"lstrip": false,
|
| 1414 |
+
"normalized": false,
|
| 1415 |
+
"rstrip": false,
|
| 1416 |
+
"single_word": false,
|
| 1417 |
+
"special": true
|
| 1418 |
+
},
|
| 1419 |
+
"128177": {
|
| 1420 |
+
"content": "<|reserved_special_token_172|>",
|
| 1421 |
+
"lstrip": false,
|
| 1422 |
+
"normalized": false,
|
| 1423 |
+
"rstrip": false,
|
| 1424 |
+
"single_word": false,
|
| 1425 |
+
"special": true
|
| 1426 |
+
},
|
| 1427 |
+
"128178": {
|
| 1428 |
+
"content": "<|reserved_special_token_173|>",
|
| 1429 |
+
"lstrip": false,
|
| 1430 |
+
"normalized": false,
|
| 1431 |
+
"rstrip": false,
|
| 1432 |
+
"single_word": false,
|
| 1433 |
+
"special": true
|
| 1434 |
+
},
|
| 1435 |
+
"128179": {
|
| 1436 |
+
"content": "<|reserved_special_token_174|>",
|
| 1437 |
+
"lstrip": false,
|
| 1438 |
+
"normalized": false,
|
| 1439 |
+
"rstrip": false,
|
| 1440 |
+
"single_word": false,
|
| 1441 |
+
"special": true
|
| 1442 |
+
},
|
| 1443 |
+
"128180": {
|
| 1444 |
+
"content": "<|reserved_special_token_175|>",
|
| 1445 |
+
"lstrip": false,
|
| 1446 |
+
"normalized": false,
|
| 1447 |
+
"rstrip": false,
|
| 1448 |
+
"single_word": false,
|
| 1449 |
+
"special": true
|
| 1450 |
+
},
|
| 1451 |
+
"128181": {
|
| 1452 |
+
"content": "<|reserved_special_token_176|>",
|
| 1453 |
+
"lstrip": false,
|
| 1454 |
+
"normalized": false,
|
| 1455 |
+
"rstrip": false,
|
| 1456 |
+
"single_word": false,
|
| 1457 |
+
"special": true
|
| 1458 |
+
},
|
| 1459 |
+
"128182": {
|
| 1460 |
+
"content": "<|reserved_special_token_177|>",
|
| 1461 |
+
"lstrip": false,
|
| 1462 |
+
"normalized": false,
|
| 1463 |
+
"rstrip": false,
|
| 1464 |
+
"single_word": false,
|
| 1465 |
+
"special": true
|
| 1466 |
+
},
|
| 1467 |
+
"128183": {
|
| 1468 |
+
"content": "<|reserved_special_token_178|>",
|
| 1469 |
+
"lstrip": false,
|
| 1470 |
+
"normalized": false,
|
| 1471 |
+
"rstrip": false,
|
| 1472 |
+
"single_word": false,
|
| 1473 |
+
"special": true
|
| 1474 |
+
},
|
| 1475 |
+
"128184": {
|
| 1476 |
+
"content": "<|reserved_special_token_179|>",
|
| 1477 |
+
"lstrip": false,
|
| 1478 |
+
"normalized": false,
|
| 1479 |
+
"rstrip": false,
|
| 1480 |
+
"single_word": false,
|
| 1481 |
+
"special": true
|
| 1482 |
+
},
|
| 1483 |
+
"128185": {
|
| 1484 |
+
"content": "<|reserved_special_token_180|>",
|
| 1485 |
+
"lstrip": false,
|
| 1486 |
+
"normalized": false,
|
| 1487 |
+
"rstrip": false,
|
| 1488 |
+
"single_word": false,
|
| 1489 |
+
"special": true
|
| 1490 |
+
},
|
| 1491 |
+
"128186": {
|
| 1492 |
+
"content": "<|reserved_special_token_181|>",
|
| 1493 |
+
"lstrip": false,
|
| 1494 |
+
"normalized": false,
|
| 1495 |
+
"rstrip": false,
|
| 1496 |
+
"single_word": false,
|
| 1497 |
+
"special": true
|
| 1498 |
+
},
|
| 1499 |
+
"128187": {
|
| 1500 |
+
"content": "<|reserved_special_token_182|>",
|
| 1501 |
+
"lstrip": false,
|
| 1502 |
+
"normalized": false,
|
| 1503 |
+
"rstrip": false,
|
| 1504 |
+
"single_word": false,
|
| 1505 |
+
"special": true
|
| 1506 |
+
},
|
| 1507 |
+
"128188": {
|
| 1508 |
+
"content": "<|reserved_special_token_183|>",
|
| 1509 |
+
"lstrip": false,
|
| 1510 |
+
"normalized": false,
|
| 1511 |
+
"rstrip": false,
|
| 1512 |
+
"single_word": false,
|
| 1513 |
+
"special": true
|
| 1514 |
+
},
|
| 1515 |
+
"128189": {
|
| 1516 |
+
"content": "<|reserved_special_token_184|>",
|
| 1517 |
+
"lstrip": false,
|
| 1518 |
+
"normalized": false,
|
| 1519 |
+
"rstrip": false,
|
| 1520 |
+
"single_word": false,
|
| 1521 |
+
"special": true
|
| 1522 |
+
},
|
| 1523 |
+
"128190": {
|
| 1524 |
+
"content": "<|reserved_special_token_185|>",
|
| 1525 |
+
"lstrip": false,
|
| 1526 |
+
"normalized": false,
|
| 1527 |
+
"rstrip": false,
|
| 1528 |
+
"single_word": false,
|
| 1529 |
+
"special": true
|
| 1530 |
+
},
|
| 1531 |
+
"128191": {
|
| 1532 |
+
"content": "<|reserved_special_token_186|>",
|
| 1533 |
+
"lstrip": false,
|
| 1534 |
+
"normalized": false,
|
| 1535 |
+
"rstrip": false,
|
| 1536 |
+
"single_word": false,
|
| 1537 |
+
"special": true
|
| 1538 |
+
},
|
| 1539 |
+
"128192": {
|
| 1540 |
+
"content": "<|reserved_special_token_187|>",
|
| 1541 |
+
"lstrip": false,
|
| 1542 |
+
"normalized": false,
|
| 1543 |
+
"rstrip": false,
|
| 1544 |
+
"single_word": false,
|
| 1545 |
+
"special": true
|
| 1546 |
+
},
|
| 1547 |
+
"128193": {
|
| 1548 |
+
"content": "<|reserved_special_token_188|>",
|
| 1549 |
+
"lstrip": false,
|
| 1550 |
+
"normalized": false,
|
| 1551 |
+
"rstrip": false,
|
| 1552 |
+
"single_word": false,
|
| 1553 |
+
"special": true
|
| 1554 |
+
},
|
| 1555 |
+
"128194": {
|
| 1556 |
+
"content": "<|reserved_special_token_189|>",
|
| 1557 |
+
"lstrip": false,
|
| 1558 |
+
"normalized": false,
|
| 1559 |
+
"rstrip": false,
|
| 1560 |
+
"single_word": false,
|
| 1561 |
+
"special": true
|
| 1562 |
+
},
|
| 1563 |
+
"128195": {
|
| 1564 |
+
"content": "<|reserved_special_token_190|>",
|
| 1565 |
+
"lstrip": false,
|
| 1566 |
+
"normalized": false,
|
| 1567 |
+
"rstrip": false,
|
| 1568 |
+
"single_word": false,
|
| 1569 |
+
"special": true
|
| 1570 |
+
},
|
| 1571 |
+
"128196": {
|
| 1572 |
+
"content": "<|reserved_special_token_191|>",
|
| 1573 |
+
"lstrip": false,
|
| 1574 |
+
"normalized": false,
|
| 1575 |
+
"rstrip": false,
|
| 1576 |
+
"single_word": false,
|
| 1577 |
+
"special": true
|
| 1578 |
+
},
|
| 1579 |
+
"128197": {
|
| 1580 |
+
"content": "<|reserved_special_token_192|>",
|
| 1581 |
+
"lstrip": false,
|
| 1582 |
+
"normalized": false,
|
| 1583 |
+
"rstrip": false,
|
| 1584 |
+
"single_word": false,
|
| 1585 |
+
"special": true
|
| 1586 |
+
},
|
| 1587 |
+
"128198": {
|
| 1588 |
+
"content": "<|reserved_special_token_193|>",
|
| 1589 |
+
"lstrip": false,
|
| 1590 |
+
"normalized": false,
|
| 1591 |
+
"rstrip": false,
|
| 1592 |
+
"single_word": false,
|
| 1593 |
+
"special": true
|
| 1594 |
+
},
|
| 1595 |
+
"128199": {
|
| 1596 |
+
"content": "<|reserved_special_token_194|>",
|
| 1597 |
+
"lstrip": false,
|
| 1598 |
+
"normalized": false,
|
| 1599 |
+
"rstrip": false,
|
| 1600 |
+
"single_word": false,
|
| 1601 |
+
"special": true
|
| 1602 |
+
},
|
| 1603 |
+
"128200": {
|
| 1604 |
+
"content": "<|reserved_special_token_195|>",
|
| 1605 |
+
"lstrip": false,
|
| 1606 |
+
"normalized": false,
|
| 1607 |
+
"rstrip": false,
|
| 1608 |
+
"single_word": false,
|
| 1609 |
+
"special": true
|
| 1610 |
+
},
|
| 1611 |
+
"128201": {
|
| 1612 |
+
"content": "<|reserved_special_token_196|>",
|
| 1613 |
+
"lstrip": false,
|
| 1614 |
+
"normalized": false,
|
| 1615 |
+
"rstrip": false,
|
| 1616 |
+
"single_word": false,
|
| 1617 |
+
"special": true
|
| 1618 |
+
},
|
| 1619 |
+
"128202": {
|
| 1620 |
+
"content": "<|reserved_special_token_197|>",
|
| 1621 |
+
"lstrip": false,
|
| 1622 |
+
"normalized": false,
|
| 1623 |
+
"rstrip": false,
|
| 1624 |
+
"single_word": false,
|
| 1625 |
+
"special": true
|
| 1626 |
+
},
|
| 1627 |
+
"128203": {
|
| 1628 |
+
"content": "<|reserved_special_token_198|>",
|
| 1629 |
+
"lstrip": false,
|
| 1630 |
+
"normalized": false,
|
| 1631 |
+
"rstrip": false,
|
| 1632 |
+
"single_word": false,
|
| 1633 |
+
"special": true
|
| 1634 |
+
},
|
| 1635 |
+
"128204": {
|
| 1636 |
+
"content": "<|reserved_special_token_199|>",
|
| 1637 |
+
"lstrip": false,
|
| 1638 |
+
"normalized": false,
|
| 1639 |
+
"rstrip": false,
|
| 1640 |
+
"single_word": false,
|
| 1641 |
+
"special": true
|
| 1642 |
+
},
|
| 1643 |
+
"128205": {
|
| 1644 |
+
"content": "<|reserved_special_token_200|>",
|
| 1645 |
+
"lstrip": false,
|
| 1646 |
+
"normalized": false,
|
| 1647 |
+
"rstrip": false,
|
| 1648 |
+
"single_word": false,
|
| 1649 |
+
"special": true
|
| 1650 |
+
},
|
| 1651 |
+
"128206": {
|
| 1652 |
+
"content": "<|reserved_special_token_201|>",
|
| 1653 |
+
"lstrip": false,
|
| 1654 |
+
"normalized": false,
|
| 1655 |
+
"rstrip": false,
|
| 1656 |
+
"single_word": false,
|
| 1657 |
+
"special": true
|
| 1658 |
+
},
|
| 1659 |
+
"128207": {
|
| 1660 |
+
"content": "<|reserved_special_token_202|>",
|
| 1661 |
+
"lstrip": false,
|
| 1662 |
+
"normalized": false,
|
| 1663 |
+
"rstrip": false,
|
| 1664 |
+
"single_word": false,
|
| 1665 |
+
"special": true
|
| 1666 |
+
},
|
| 1667 |
+
"128208": {
|
| 1668 |
+
"content": "<|reserved_special_token_203|>",
|
| 1669 |
+
"lstrip": false,
|
| 1670 |
+
"normalized": false,
|
| 1671 |
+
"rstrip": false,
|
| 1672 |
+
"single_word": false,
|
| 1673 |
+
"special": true
|
| 1674 |
+
},
|
| 1675 |
+
"128209": {
|
| 1676 |
+
"content": "<|reserved_special_token_204|>",
|
| 1677 |
+
"lstrip": false,
|
| 1678 |
+
"normalized": false,
|
| 1679 |
+
"rstrip": false,
|
| 1680 |
+
"single_word": false,
|
| 1681 |
+
"special": true
|
| 1682 |
+
},
|
| 1683 |
+
"128210": {
|
| 1684 |
+
"content": "<|reserved_special_token_205|>",
|
| 1685 |
+
"lstrip": false,
|
| 1686 |
+
"normalized": false,
|
| 1687 |
+
"rstrip": false,
|
| 1688 |
+
"single_word": false,
|
| 1689 |
+
"special": true
|
| 1690 |
+
},
|
| 1691 |
+
"128211": {
|
| 1692 |
+
"content": "<|reserved_special_token_206|>",
|
| 1693 |
+
"lstrip": false,
|
| 1694 |
+
"normalized": false,
|
| 1695 |
+
"rstrip": false,
|
| 1696 |
+
"single_word": false,
|
| 1697 |
+
"special": true
|
| 1698 |
+
},
|
| 1699 |
+
"128212": {
|
| 1700 |
+
"content": "<|reserved_special_token_207|>",
|
| 1701 |
+
"lstrip": false,
|
| 1702 |
+
"normalized": false,
|
| 1703 |
+
"rstrip": false,
|
| 1704 |
+
"single_word": false,
|
| 1705 |
+
"special": true
|
| 1706 |
+
},
|
| 1707 |
+
"128213": {
|
| 1708 |
+
"content": "<|reserved_special_token_208|>",
|
| 1709 |
+
"lstrip": false,
|
| 1710 |
+
"normalized": false,
|
| 1711 |
+
"rstrip": false,
|
| 1712 |
+
"single_word": false,
|
| 1713 |
+
"special": true
|
| 1714 |
+
},
|
| 1715 |
+
"128214": {
|
| 1716 |
+
"content": "<|reserved_special_token_209|>",
|
| 1717 |
+
"lstrip": false,
|
| 1718 |
+
"normalized": false,
|
| 1719 |
+
"rstrip": false,
|
| 1720 |
+
"single_word": false,
|
| 1721 |
+
"special": true
|
| 1722 |
+
},
|
| 1723 |
+
"128215": {
|
| 1724 |
+
"content": "<|reserved_special_token_210|>",
|
| 1725 |
+
"lstrip": false,
|
| 1726 |
+
"normalized": false,
|
| 1727 |
+
"rstrip": false,
|
| 1728 |
+
"single_word": false,
|
| 1729 |
+
"special": true
|
| 1730 |
+
},
|
| 1731 |
+
"128216": {
|
| 1732 |
+
"content": "<|reserved_special_token_211|>",
|
| 1733 |
+
"lstrip": false,
|
| 1734 |
+
"normalized": false,
|
| 1735 |
+
"rstrip": false,
|
| 1736 |
+
"single_word": false,
|
| 1737 |
+
"special": true
|
| 1738 |
+
},
|
| 1739 |
+
"128217": {
|
| 1740 |
+
"content": "<|reserved_special_token_212|>",
|
| 1741 |
+
"lstrip": false,
|
| 1742 |
+
"normalized": false,
|
| 1743 |
+
"rstrip": false,
|
| 1744 |
+
"single_word": false,
|
| 1745 |
+
"special": true
|
| 1746 |
+
},
|
| 1747 |
+
"128218": {
|
| 1748 |
+
"content": "<|reserved_special_token_213|>",
|
| 1749 |
+
"lstrip": false,
|
| 1750 |
+
"normalized": false,
|
| 1751 |
+
"rstrip": false,
|
| 1752 |
+
"single_word": false,
|
| 1753 |
+
"special": true
|
| 1754 |
+
},
|
| 1755 |
+
"128219": {
|
| 1756 |
+
"content": "<|reserved_special_token_214|>",
|
| 1757 |
+
"lstrip": false,
|
| 1758 |
+
"normalized": false,
|
| 1759 |
+
"rstrip": false,
|
| 1760 |
+
"single_word": false,
|
| 1761 |
+
"special": true
|
| 1762 |
+
},
|
| 1763 |
+
"128220": {
|
| 1764 |
+
"content": "<|reserved_special_token_215|>",
|
| 1765 |
+
"lstrip": false,
|
| 1766 |
+
"normalized": false,
|
| 1767 |
+
"rstrip": false,
|
| 1768 |
+
"single_word": false,
|
| 1769 |
+
"special": true
|
| 1770 |
+
},
|
| 1771 |
+
"128221": {
|
| 1772 |
+
"content": "<|reserved_special_token_216|>",
|
| 1773 |
+
"lstrip": false,
|
| 1774 |
+
"normalized": false,
|
| 1775 |
+
"rstrip": false,
|
| 1776 |
+
"single_word": false,
|
| 1777 |
+
"special": true
|
| 1778 |
+
},
|
| 1779 |
+
"128222": {
|
| 1780 |
+
"content": "<|reserved_special_token_217|>",
|
| 1781 |
+
"lstrip": false,
|
| 1782 |
+
"normalized": false,
|
| 1783 |
+
"rstrip": false,
|
| 1784 |
+
"single_word": false,
|
| 1785 |
+
"special": true
|
| 1786 |
+
},
|
| 1787 |
+
"128223": {
|
| 1788 |
+
"content": "<|reserved_special_token_218|>",
|
| 1789 |
+
"lstrip": false,
|
| 1790 |
+
"normalized": false,
|
| 1791 |
+
"rstrip": false,
|
| 1792 |
+
"single_word": false,
|
| 1793 |
+
"special": true
|
| 1794 |
+
},
|
| 1795 |
+
"128224": {
|
| 1796 |
+
"content": "<|reserved_special_token_219|>",
|
| 1797 |
+
"lstrip": false,
|
| 1798 |
+
"normalized": false,
|
| 1799 |
+
"rstrip": false,
|
| 1800 |
+
"single_word": false,
|
| 1801 |
+
"special": true
|
| 1802 |
+
},
|
| 1803 |
+
"128225": {
|
| 1804 |
+
"content": "<|reserved_special_token_220|>",
|
| 1805 |
+
"lstrip": false,
|
| 1806 |
+
"normalized": false,
|
| 1807 |
+
"rstrip": false,
|
| 1808 |
+
"single_word": false,
|
| 1809 |
+
"special": true
|
| 1810 |
+
},
|
| 1811 |
+
"128226": {
|
| 1812 |
+
"content": "<|reserved_special_token_221|>",
|
| 1813 |
+
"lstrip": false,
|
| 1814 |
+
"normalized": false,
|
| 1815 |
+
"rstrip": false,
|
| 1816 |
+
"single_word": false,
|
| 1817 |
+
"special": true
|
| 1818 |
+
},
|
| 1819 |
+
"128227": {
|
| 1820 |
+
"content": "<|reserved_special_token_222|>",
|
| 1821 |
+
"lstrip": false,
|
| 1822 |
+
"normalized": false,
|
| 1823 |
+
"rstrip": false,
|
| 1824 |
+
"single_word": false,
|
| 1825 |
+
"special": true
|
| 1826 |
+
},
|
| 1827 |
+
"128228": {
|
| 1828 |
+
"content": "<|reserved_special_token_223|>",
|
| 1829 |
+
"lstrip": false,
|
| 1830 |
+
"normalized": false,
|
| 1831 |
+
"rstrip": false,
|
| 1832 |
+
"single_word": false,
|
| 1833 |
+
"special": true
|
| 1834 |
+
},
|
| 1835 |
+
"128229": {
|
| 1836 |
+
"content": "<|reserved_special_token_224|>",
|
| 1837 |
+
"lstrip": false,
|
| 1838 |
+
"normalized": false,
|
| 1839 |
+
"rstrip": false,
|
| 1840 |
+
"single_word": false,
|
| 1841 |
+
"special": true
|
| 1842 |
+
},
|
| 1843 |
+
"128230": {
|
| 1844 |
+
"content": "<|reserved_special_token_225|>",
|
| 1845 |
+
"lstrip": false,
|
| 1846 |
+
"normalized": false,
|
| 1847 |
+
"rstrip": false,
|
| 1848 |
+
"single_word": false,
|
| 1849 |
+
"special": true
|
| 1850 |
+
},
|
| 1851 |
+
"128231": {
|
| 1852 |
+
"content": "<|reserved_special_token_226|>",
|
| 1853 |
+
"lstrip": false,
|
| 1854 |
+
"normalized": false,
|
| 1855 |
+
"rstrip": false,
|
| 1856 |
+
"single_word": false,
|
| 1857 |
+
"special": true
|
| 1858 |
+
},
|
| 1859 |
+
"128232": {
|
| 1860 |
+
"content": "<|reserved_special_token_227|>",
|
| 1861 |
+
"lstrip": false,
|
| 1862 |
+
"normalized": false,
|
| 1863 |
+
"rstrip": false,
|
| 1864 |
+
"single_word": false,
|
| 1865 |
+
"special": true
|
| 1866 |
+
},
|
| 1867 |
+
"128233": {
|
| 1868 |
+
"content": "<|reserved_special_token_228|>",
|
| 1869 |
+
"lstrip": false,
|
| 1870 |
+
"normalized": false,
|
| 1871 |
+
"rstrip": false,
|
| 1872 |
+
"single_word": false,
|
| 1873 |
+
"special": true
|
| 1874 |
+
},
|
| 1875 |
+
"128234": {
|
| 1876 |
+
"content": "<|reserved_special_token_229|>",
|
| 1877 |
+
"lstrip": false,
|
| 1878 |
+
"normalized": false,
|
| 1879 |
+
"rstrip": false,
|
| 1880 |
+
"single_word": false,
|
| 1881 |
+
"special": true
|
| 1882 |
+
},
|
| 1883 |
+
"128235": {
|
| 1884 |
+
"content": "<|reserved_special_token_230|>",
|
| 1885 |
+
"lstrip": false,
|
| 1886 |
+
"normalized": false,
|
| 1887 |
+
"rstrip": false,
|
| 1888 |
+
"single_word": false,
|
| 1889 |
+
"special": true
|
| 1890 |
+
},
|
| 1891 |
+
"128236": {
|
| 1892 |
+
"content": "<|reserved_special_token_231|>",
|
| 1893 |
+
"lstrip": false,
|
| 1894 |
+
"normalized": false,
|
| 1895 |
+
"rstrip": false,
|
| 1896 |
+
"single_word": false,
|
| 1897 |
+
"special": true
|
| 1898 |
+
},
|
| 1899 |
+
"128237": {
|
| 1900 |
+
"content": "<|reserved_special_token_232|>",
|
| 1901 |
+
"lstrip": false,
|
| 1902 |
+
"normalized": false,
|
| 1903 |
+
"rstrip": false,
|
| 1904 |
+
"single_word": false,
|
| 1905 |
+
"special": true
|
| 1906 |
+
},
|
| 1907 |
+
"128238": {
|
| 1908 |
+
"content": "<|reserved_special_token_233|>",
|
| 1909 |
+
"lstrip": false,
|
| 1910 |
+
"normalized": false,
|
| 1911 |
+
"rstrip": false,
|
| 1912 |
+
"single_word": false,
|
| 1913 |
+
"special": true
|
| 1914 |
+
},
|
| 1915 |
+
"128239": {
|
| 1916 |
+
"content": "<|reserved_special_token_234|>",
|
| 1917 |
+
"lstrip": false,
|
| 1918 |
+
"normalized": false,
|
| 1919 |
+
"rstrip": false,
|
| 1920 |
+
"single_word": false,
|
| 1921 |
+
"special": true
|
| 1922 |
+
},
|
| 1923 |
+
"128240": {
|
| 1924 |
+
"content": "<|reserved_special_token_235|>",
|
| 1925 |
+
"lstrip": false,
|
| 1926 |
+
"normalized": false,
|
| 1927 |
+
"rstrip": false,
|
| 1928 |
+
"single_word": false,
|
| 1929 |
+
"special": true
|
| 1930 |
+
},
|
| 1931 |
+
"128241": {
|
| 1932 |
+
"content": "<|reserved_special_token_236|>",
|
| 1933 |
+
"lstrip": false,
|
| 1934 |
+
"normalized": false,
|
| 1935 |
+
"rstrip": false,
|
| 1936 |
+
"single_word": false,
|
| 1937 |
+
"special": true
|
| 1938 |
+
},
|
| 1939 |
+
"128242": {
|
| 1940 |
+
"content": "<|reserved_special_token_237|>",
|
| 1941 |
+
"lstrip": false,
|
| 1942 |
+
"normalized": false,
|
| 1943 |
+
"rstrip": false,
|
| 1944 |
+
"single_word": false,
|
| 1945 |
+
"special": true
|
| 1946 |
+
},
|
| 1947 |
+
"128243": {
|
| 1948 |
+
"content": "<|reserved_special_token_238|>",
|
| 1949 |
+
"lstrip": false,
|
| 1950 |
+
"normalized": false,
|
| 1951 |
+
"rstrip": false,
|
| 1952 |
+
"single_word": false,
|
| 1953 |
+
"special": true
|
| 1954 |
+
},
|
| 1955 |
+
"128244": {
|
| 1956 |
+
"content": "<|reserved_special_token_239|>",
|
| 1957 |
+
"lstrip": false,
|
| 1958 |
+
"normalized": false,
|
| 1959 |
+
"rstrip": false,
|
| 1960 |
+
"single_word": false,
|
| 1961 |
+
"special": true
|
| 1962 |
+
},
|
| 1963 |
+
"128245": {
|
| 1964 |
+
"content": "<|reserved_special_token_240|>",
|
| 1965 |
+
"lstrip": false,
|
| 1966 |
+
"normalized": false,
|
| 1967 |
+
"rstrip": false,
|
| 1968 |
+
"single_word": false,
|
| 1969 |
+
"special": true
|
| 1970 |
+
},
|
| 1971 |
+
"128246": {
|
| 1972 |
+
"content": "<|reserved_special_token_241|>",
|
| 1973 |
+
"lstrip": false,
|
| 1974 |
+
"normalized": false,
|
| 1975 |
+
"rstrip": false,
|
| 1976 |
+
"single_word": false,
|
| 1977 |
+
"special": true
|
| 1978 |
+
},
|
| 1979 |
+
"128247": {
|
| 1980 |
+
"content": "<|reserved_special_token_242|>",
|
| 1981 |
+
"lstrip": false,
|
| 1982 |
+
"normalized": false,
|
| 1983 |
+
"rstrip": false,
|
| 1984 |
+
"single_word": false,
|
| 1985 |
+
"special": true
|
| 1986 |
+
},
|
| 1987 |
+
"128248": {
|
| 1988 |
+
"content": "<|reserved_special_token_243|>",
|
| 1989 |
+
"lstrip": false,
|
| 1990 |
+
"normalized": false,
|
| 1991 |
+
"rstrip": false,
|
| 1992 |
+
"single_word": false,
|
| 1993 |
+
"special": true
|
| 1994 |
+
},
|
| 1995 |
+
"128249": {
|
| 1996 |
+
"content": "<|reserved_special_token_244|>",
|
| 1997 |
+
"lstrip": false,
|
| 1998 |
+
"normalized": false,
|
| 1999 |
+
"rstrip": false,
|
| 2000 |
+
"single_word": false,
|
| 2001 |
+
"special": true
|
| 2002 |
+
},
|
| 2003 |
+
"128250": {
|
| 2004 |
+
"content": "<|reserved_special_token_245|>",
|
| 2005 |
+
"lstrip": false,
|
| 2006 |
+
"normalized": false,
|
| 2007 |
+
"rstrip": false,
|
| 2008 |
+
"single_word": false,
|
| 2009 |
+
"special": true
|
| 2010 |
+
},
|
| 2011 |
+
"128251": {
|
| 2012 |
+
"content": "<|reserved_special_token_246|>",
|
| 2013 |
+
"lstrip": false,
|
| 2014 |
+
"normalized": false,
|
| 2015 |
+
"rstrip": false,
|
| 2016 |
+
"single_word": false,
|
| 2017 |
+
"special": true
|
| 2018 |
+
},
|
| 2019 |
+
"128252": {
|
| 2020 |
+
"content": "<|reserved_special_token_247|>",
|
| 2021 |
+
"lstrip": false,
|
| 2022 |
+
"normalized": false,
|
| 2023 |
+
"rstrip": false,
|
| 2024 |
+
"single_word": false,
|
| 2025 |
+
"special": true
|
| 2026 |
+
},
|
| 2027 |
+
"128253": {
|
| 2028 |
+
"content": "<|reserved_special_token_248|>",
|
| 2029 |
+
"lstrip": false,
|
| 2030 |
+
"normalized": false,
|
| 2031 |
+
"rstrip": false,
|
| 2032 |
+
"single_word": false,
|
| 2033 |
+
"special": true
|
| 2034 |
+
},
|
| 2035 |
+
"128254": {
|
| 2036 |
+
"content": "<|reserved_special_token_249|>",
|
| 2037 |
+
"lstrip": false,
|
| 2038 |
+
"normalized": false,
|
| 2039 |
+
"rstrip": false,
|
| 2040 |
+
"single_word": false,
|
| 2041 |
+
"special": true
|
| 2042 |
+
},
|
| 2043 |
+
"128255": {
|
| 2044 |
+
"content": "<|reserved_special_token_250|>",
|
| 2045 |
+
"lstrip": false,
|
| 2046 |
+
"normalized": false,
|
| 2047 |
+
"rstrip": false,
|
| 2048 |
+
"single_word": false,
|
| 2049 |
+
"special": true
|
| 2050 |
+
},
|
| 2051 |
+
"128256": {
|
| 2052 |
+
"content": "<Prompt0>",
|
| 2053 |
+
"lstrip": false,
|
| 2054 |
+
"normalized": false,
|
| 2055 |
+
"rstrip": false,
|
| 2056 |
+
"single_word": false,
|
| 2057 |
+
"special": true
|
| 2058 |
+
},
|
| 2059 |
+
"128257": {
|
| 2060 |
+
"content": "<Prompt1>",
|
| 2061 |
+
"lstrip": false,
|
| 2062 |
+
"normalized": false,
|
| 2063 |
+
"rstrip": false,
|
| 2064 |
+
"single_word": false,
|
| 2065 |
+
"special": true
|
| 2066 |
+
},
|
| 2067 |
+
"128258": {
|
| 2068 |
+
"content": "<Prompt2>",
|
| 2069 |
+
"lstrip": false,
|
| 2070 |
+
"normalized": false,
|
| 2071 |
+
"rstrip": false,
|
| 2072 |
+
"single_word": false,
|
| 2073 |
+
"special": true
|
| 2074 |
+
},
|
| 2075 |
+
"128259": {
|
| 2076 |
+
"content": "<Prompt3>",
|
| 2077 |
+
"lstrip": false,
|
| 2078 |
+
"normalized": false,
|
| 2079 |
+
"rstrip": false,
|
| 2080 |
+
"single_word": false,
|
| 2081 |
+
"special": true
|
| 2082 |
+
},
|
| 2083 |
+
"128260": {
|
| 2084 |
+
"content": "<Prompt4>",
|
| 2085 |
+
"lstrip": false,
|
| 2086 |
+
"normalized": false,
|
| 2087 |
+
"rstrip": false,
|
| 2088 |
+
"single_word": false,
|
| 2089 |
+
"special": true
|
| 2090 |
+
},
|
| 2091 |
+
"128261": {
|
| 2092 |
+
"content": "<NO_Prompt>",
|
| 2093 |
+
"lstrip": false,
|
| 2094 |
+
"normalized": false,
|
| 2095 |
+
"rstrip": false,
|
| 2096 |
+
"single_word": false,
|
| 2097 |
+
"special": true
|
| 2098 |
+
}
|
| 2099 |
+
},
|
| 2100 |
+
"bos_token": "<|begin_of_text|>",
|
| 2101 |
+
"clean_up_tokenization_spaces": true,
|
| 2102 |
+
"eos_token": "<|eot_id|>",
|
| 2103 |
+
"extra_special_tokens": {
|
| 2104 |
+
"image_token": "<|image|>",
|
| 2105 |
+
"pad_token": "<|end_of_text|>",
|
| 2106 |
+
"video_token": "<|video|>"
|
| 2107 |
+
},
|
| 2108 |
+
"image_token": "<|image|>",
|
| 2109 |
+
"model_input_names": [
|
| 2110 |
+
"input_ids",
|
| 2111 |
+
"attention_mask"
|
| 2112 |
+
],
|
| 2113 |
+
"model_max_length": 11520,
|
| 2114 |
+
"pad_token": "<|end_of_text|>",
|
| 2115 |
+
"processor_class": "GARPerceptionLMProcessor",
|
| 2116 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 2117 |
+
"video_token": "<|video|>"
|
| 2118 |
+
}
|
video_preprocessor_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"crop_size": null,
|
| 3 |
+
"data_format": "channels_first",
|
| 4 |
+
"default_to_square": true,
|
| 5 |
+
"device": null,
|
| 6 |
+
"do_center_crop": false,
|
| 7 |
+
"do_convert_rgb": true,
|
| 8 |
+
"do_normalize": true,
|
| 9 |
+
"do_pad": null,
|
| 10 |
+
"do_rescale": true,
|
| 11 |
+
"do_resize": true,
|
| 12 |
+
"do_sample_frames": null,
|
| 13 |
+
"fps": null,
|
| 14 |
+
"image_mean": [
|
| 15 |
+
0.5,
|
| 16 |
+
0.5,
|
| 17 |
+
0.5
|
| 18 |
+
],
|
| 19 |
+
"image_std": [
|
| 20 |
+
0.5,
|
| 21 |
+
0.5,
|
| 22 |
+
0.5
|
| 23 |
+
],
|
| 24 |
+
"input_data_format": null,
|
| 25 |
+
"num_frames": null,
|
| 26 |
+
"processor_class": "GARPerceptionLMProcessor",
|
| 27 |
+
"resample": 3,
|
| 28 |
+
"rescale_factor": 0.00392156862745098,
|
| 29 |
+
"return_metadata": false,
|
| 30 |
+
"size": {
|
| 31 |
+
"height": 448,
|
| 32 |
+
"width": 448
|
| 33 |
+
},
|
| 34 |
+
"size_divisor": null,
|
| 35 |
+
"video_metadata": null,
|
| 36 |
+
"video_processor_type": "PerceptionLMVideoProcessor"
|
| 37 |
+
}
|