Upload 24 files
Browse files- README.md +148 -0
- added_tokens.json +11 -0
- config.json +202 -0
- configuration_intern_vit.py +120 -0
- configuration_internlm2.py +150 -0
- configuration_internvl_chat.py +96 -0
- generation_config.json +8 -0
- modeling_internvl_chat.py +349 -0
- openvino_config.json +28 -0
- openvino_detokenizer.bin +3 -0
- openvino_detokenizer.xml +148 -0
- openvino_language_model.bin +3 -0
- openvino_language_model.xml +0 -0
- openvino_text_embeddings_model.bin +3 -0
- openvino_text_embeddings_model.xml +173 -0
- openvino_tokenizer.bin +3 -0
- openvino_tokenizer.xml +1025 -0
- openvino_vision_embeddings_model.bin +3 -0
- openvino_vision_embeddings_model.xml +0 -0
- preprocessor_config.json +27 -0
- special_tokens_map.json +47 -0
- tokenization_internlm2.py +235 -0
- tokenizer.model +3 -0
- tokenizer_config.json +180 -0
README.md
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- multilingual
|
5 |
+
pipeline_tag: image-text-to-text
|
6 |
+
tags:
|
7 |
+
- nlp
|
8 |
+
- vision
|
9 |
+
- internvl
|
10 |
+
base_model:
|
11 |
+
- OpenGVLab/InternVL2-2B
|
12 |
+
base_model_relation: quantized
|
13 |
+
---
|
14 |
+
|
15 |
+
# InternVL2-2B-int8-ov
|
16 |
+
|
17 |
+
* Model creator: [OpenGVLab](https://huggingface.co/OpenGVLab)
|
18 |
+
* Original model: [InternVL2-2B](https://huggingface.co/OpenGVLab/InternVL2-2B)
|
19 |
+
|
20 |
+
## Description
|
21 |
+
|
22 |
+
This is [OpenGVLab/InternVL2-2B](https://huggingface.co/OpenGVLab/InternVL2-2B) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2024/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to INT8 by [NNCF](https://github.com/openvinotoolkit/nncf).
|
23 |
+
|
24 |
+
|
25 |
+
## Quantization Parameters
|
26 |
+
|
27 |
+
Weight compression was performed using `nncf.compress_weights` with the following parameters:
|
28 |
+
|
29 |
+
* mode: **INT8_ASYM**
|
30 |
+
|
31 |
+
|
32 |
+
## Compatibility
|
33 |
+
|
34 |
+
The provided OpenVINO™ IR model is compatible with:
|
35 |
+
|
36 |
+
* OpenVINO version 2025.0.0 and higher
|
37 |
+
* Optimum Intel 1.21.0 and higher
|
38 |
+
|
39 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
40 |
+
|
41 |
+
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
42 |
+
|
43 |
+
```
|
44 |
+
pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino_tokenizers openvino
|
45 |
+
|
46 |
+
pip install git+https://github.com/huggingface/optimum-intel.git
|
47 |
+
```
|
48 |
+
|
49 |
+
2. Run model inference
|
50 |
+
|
51 |
+
```
|
52 |
+
from PIL import Image
|
53 |
+
import requests
|
54 |
+
from optimum.intel.openvino import OVModelForVisualCausalLM
|
55 |
+
from transformers import AutoTokenizer, TextStreamer
|
56 |
+
|
57 |
+
model_id = "OpenVINO/InternVL2-2B-int8-ov"
|
58 |
+
|
59 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
60 |
+
|
61 |
+
ov_model = OVModelForVisualCausalLM.from_pretrained(model_id, trust_remote_code=True)
|
62 |
+
prompt = "What is unusual on this picture?"
|
63 |
+
|
64 |
+
url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
|
65 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
66 |
+
|
67 |
+
inputs = ov_model.preprocess_inputs(text=prompt, image=image, tokenizer=tokenizer, config=ov_model.config)
|
68 |
+
|
69 |
+
generation_args = {
|
70 |
+
"max_new_tokens": 100,
|
71 |
+
"streamer": TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
72 |
+
}
|
73 |
+
|
74 |
+
generate_ids = ov_model.generate(**inputs, **generation_args)
|
75 |
+
|
76 |
+
generate_ids = generate_ids[:, inputs['input_ids'].shape[1]:]
|
77 |
+
response = tokenizer.batch_decode(generate_ids, skip_special_tokens=True)[0]
|
78 |
+
|
79 |
+
```
|
80 |
+
|
81 |
+
## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
|
82 |
+
|
83 |
+
1. Install packages required for using OpenVINO GenAI.
|
84 |
+
```
|
85 |
+
pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino openvino-tokenizers openvino-genai
|
86 |
+
|
87 |
+
pip install huggingface_hub
|
88 |
+
```
|
89 |
+
|
90 |
+
2. Download model from HuggingFace Hub
|
91 |
+
|
92 |
+
```
|
93 |
+
import huggingface_hub as hf_hub
|
94 |
+
|
95 |
+
model_id = "OpenVINO/InternVL2-2B-int8-ov"
|
96 |
+
model_path = "InternVL2-2B-int8-ov"
|
97 |
+
|
98 |
+
hf_hub.snapshot_download(model_id, local_dir=model_path)
|
99 |
+
|
100 |
+
```
|
101 |
+
|
102 |
+
1. Run model inference:
|
103 |
+
|
104 |
+
```
|
105 |
+
import openvino_genai as ov_genai
|
106 |
+
import requests
|
107 |
+
from PIL import Image
|
108 |
+
from io import BytesIO
|
109 |
+
import numpy as np
|
110 |
+
import openvino as ov
|
111 |
+
|
112 |
+
device = "CPU"
|
113 |
+
pipe = ov_genai.VLMPipeline(model_path, device)
|
114 |
+
|
115 |
+
def load_image(image_file):
|
116 |
+
if isinstance(image_file, str) and (image_file.startswith("http") or image_file.startswith("https")):
|
117 |
+
response = requests.get(image_file)
|
118 |
+
image = Image.open(BytesIO(response.content)).convert("RGB")
|
119 |
+
else:
|
120 |
+
image = Image.open(image_file).convert("RGB")
|
121 |
+
image_data = np.array(image.getdata()).reshape(1, image.size[1], image.size[0], 3).astype(np.byte)
|
122 |
+
return ov.Tensor(image_data)
|
123 |
+
|
124 |
+
prompt = "What is unusual on this picture?"
|
125 |
+
|
126 |
+
url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
|
127 |
+
image_tensor = load_image(url)
|
128 |
+
|
129 |
+
def streamer(subword: str) -> bool:
|
130 |
+
print(subword, end="", flush=True)
|
131 |
+
return False
|
132 |
+
|
133 |
+
pipe.start_chat()
|
134 |
+
output = pipe.generate(prompt, image=image_tensor, max_new_tokens=100, streamer=streamer)
|
135 |
+
pipe.finish_chat()
|
136 |
+
```
|
137 |
+
|
138 |
+
More GenAI usage examples can be found in OpenVINO GenAI library [docs](https://github.com/openvinotoolkit/openvino.genai/blob/master/src/README.md) and [samples](https://github.com/openvinotoolkit/openvino.genai?tab=readme-ov-file#openvino-genai-samples)
|
139 |
+
|
140 |
+
|
141 |
+
## Limitations
|
142 |
+
|
143 |
+
|
144 |
+
Check the original [model card](https://huggingface.co/OpenGVLab/InternVL2-2B) for limitations.
|
145 |
+
|
146 |
+
## Legal information
|
147 |
+
|
148 |
+
The original model is distributed under [MIT](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/mit.md) license. More details can be found in [original model card](https://huggingface.co/OpenGVLab/InternVL2-2B).
|
added_tokens.json
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"</box>": 92552,
|
3 |
+
"</img>": 92545,
|
4 |
+
"</quad>": 92548,
|
5 |
+
"</ref>": 92550,
|
6 |
+
"<IMG_CONTEXT>": 92546,
|
7 |
+
"<box>": 92551,
|
8 |
+
"<img>": 92544,
|
9 |
+
"<quad>": 92547,
|
10 |
+
"<ref>": 92549
|
11 |
+
}
|
config.json
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_attn_implementation_autoset": true,
|
3 |
+
"_commit_hash": null,
|
4 |
+
"_name_or_path": "/tmp/tmp8yfpc5si",
|
5 |
+
"architectures": [
|
6 |
+
"InternVLChatModel"
|
7 |
+
],
|
8 |
+
"auto_map": {
|
9 |
+
"AutoConfig": "configuration_internvl_chat.InternVLChatConfig",
|
10 |
+
"AutoModel": "modeling_internvl_chat.InternVLChatModel",
|
11 |
+
"AutoModelForCausalLM": "modeling_internvl_chat.InternVLChatModel"
|
12 |
+
},
|
13 |
+
"downsample_ratio": 0.5,
|
14 |
+
"dynamic_image_size": true,
|
15 |
+
"force_image_size": 448,
|
16 |
+
"img_context_token_id": 92546,
|
17 |
+
"llm_config": {
|
18 |
+
"_attn_implementation_autoset": true,
|
19 |
+
"_name_or_path": "internlm/internlm2-chat-1_8b",
|
20 |
+
"add_cross_attention": false,
|
21 |
+
"architectures": [
|
22 |
+
"InternLM2ForCausalLM"
|
23 |
+
],
|
24 |
+
"attn_implementation": "eager",
|
25 |
+
"auto_map": {
|
26 |
+
"AutoConfig": "configuration_internlm2.InternLM2Config",
|
27 |
+
"AutoModel": "modeling_internlm2.InternLM2ForCausalLM",
|
28 |
+
"AutoModelForCausalLM": "modeling_internlm2.InternLM2ForCausalLM"
|
29 |
+
},
|
30 |
+
"bad_words_ids": null,
|
31 |
+
"begin_suppress_tokens": null,
|
32 |
+
"bias": false,
|
33 |
+
"bos_token_id": 1,
|
34 |
+
"chunk_size_feed_forward": 0,
|
35 |
+
"cross_attention_hidden_size": null,
|
36 |
+
"decoder_start_token_id": null,
|
37 |
+
"diversity_penalty": 0.0,
|
38 |
+
"do_sample": false,
|
39 |
+
"early_stopping": false,
|
40 |
+
"encoder_no_repeat_ngram_size": 0,
|
41 |
+
"eos_token_id": 2,
|
42 |
+
"exponential_decay_length_penalty": null,
|
43 |
+
"finetuning_task": null,
|
44 |
+
"forced_bos_token_id": null,
|
45 |
+
"forced_eos_token_id": null,
|
46 |
+
"hidden_act": "silu",
|
47 |
+
"hidden_size": 2048,
|
48 |
+
"id2label": {
|
49 |
+
"0": "LABEL_0",
|
50 |
+
"1": "LABEL_1"
|
51 |
+
},
|
52 |
+
"initializer_range": 0.02,
|
53 |
+
"intermediate_size": 8192,
|
54 |
+
"is_decoder": false,
|
55 |
+
"is_encoder_decoder": false,
|
56 |
+
"label2id": {
|
57 |
+
"LABEL_0": 0,
|
58 |
+
"LABEL_1": 1
|
59 |
+
},
|
60 |
+
"length_penalty": 1.0,
|
61 |
+
"max_length": 20,
|
62 |
+
"max_position_embeddings": 32768,
|
63 |
+
"min_length": 0,
|
64 |
+
"model_type": "internlm2",
|
65 |
+
"no_repeat_ngram_size": 0,
|
66 |
+
"num_attention_heads": 16,
|
67 |
+
"num_beam_groups": 1,
|
68 |
+
"num_beams": 1,
|
69 |
+
"num_hidden_layers": 24,
|
70 |
+
"num_key_value_heads": 8,
|
71 |
+
"num_return_sequences": 1,
|
72 |
+
"output_attentions": false,
|
73 |
+
"output_hidden_states": false,
|
74 |
+
"output_scores": false,
|
75 |
+
"pad_token_id": 2,
|
76 |
+
"prefix": null,
|
77 |
+
"problem_type": null,
|
78 |
+
"pruned_heads": {},
|
79 |
+
"remove_invalid_values": false,
|
80 |
+
"repetition_penalty": 1.0,
|
81 |
+
"return_dict": true,
|
82 |
+
"return_dict_in_generate": false,
|
83 |
+
"rms_norm_eps": 1e-05,
|
84 |
+
"rope_scaling": {
|
85 |
+
"factor": 2.0,
|
86 |
+
"type": "dynamic"
|
87 |
+
},
|
88 |
+
"rope_theta": 1000000,
|
89 |
+
"sep_token_id": null,
|
90 |
+
"suppress_tokens": null,
|
91 |
+
"task_specific_params": null,
|
92 |
+
"temperature": 1.0,
|
93 |
+
"tf_legacy_loss": false,
|
94 |
+
"tie_encoder_decoder": false,
|
95 |
+
"tie_word_embeddings": false,
|
96 |
+
"tokenizer_class": null,
|
97 |
+
"top_k": 50,
|
98 |
+
"top_p": 1.0,
|
99 |
+
"torch_dtype": "bfloat16",
|
100 |
+
"torchscript": false,
|
101 |
+
"transformers_version": "4.47.0",
|
102 |
+
"typical_p": 1.0,
|
103 |
+
"use_bfloat16": true,
|
104 |
+
"use_cache": true,
|
105 |
+
"vocab_size": 92553
|
106 |
+
},
|
107 |
+
"max_dynamic_patch": 12,
|
108 |
+
"min_dynamic_patch": 1,
|
109 |
+
"model_type": "internvl_chat",
|
110 |
+
"ps_version": "v2",
|
111 |
+
"select_layer": -1,
|
112 |
+
"template": "internlm2-chat",
|
113 |
+
"transformers_version": null,
|
114 |
+
"use_backbone_lora": 0,
|
115 |
+
"use_llm_lora": 0,
|
116 |
+
"use_thumbnail": true,
|
117 |
+
"vision_config": {
|
118 |
+
"_attn_implementation_autoset": true,
|
119 |
+
"_name_or_path": "",
|
120 |
+
"add_cross_attention": false,
|
121 |
+
"architectures": [
|
122 |
+
"InternVisionModel"
|
123 |
+
],
|
124 |
+
"attention_dropout": 0.0,
|
125 |
+
"bad_words_ids": null,
|
126 |
+
"begin_suppress_tokens": null,
|
127 |
+
"bos_token_id": null,
|
128 |
+
"chunk_size_feed_forward": 0,
|
129 |
+
"cross_attention_hidden_size": null,
|
130 |
+
"decoder_start_token_id": null,
|
131 |
+
"diversity_penalty": 0.0,
|
132 |
+
"do_sample": false,
|
133 |
+
"drop_path_rate": 0.0,
|
134 |
+
"dropout": 0.0,
|
135 |
+
"early_stopping": false,
|
136 |
+
"encoder_no_repeat_ngram_size": 0,
|
137 |
+
"eos_token_id": null,
|
138 |
+
"exponential_decay_length_penalty": null,
|
139 |
+
"finetuning_task": null,
|
140 |
+
"forced_bos_token_id": null,
|
141 |
+
"forced_eos_token_id": null,
|
142 |
+
"hidden_act": "gelu",
|
143 |
+
"hidden_size": 1024,
|
144 |
+
"id2label": {
|
145 |
+
"0": "LABEL_0",
|
146 |
+
"1": "LABEL_1"
|
147 |
+
},
|
148 |
+
"image_size": 448,
|
149 |
+
"initializer_factor": 1.0,
|
150 |
+
"initializer_range": 0.02,
|
151 |
+
"intermediate_size": 4096,
|
152 |
+
"is_decoder": false,
|
153 |
+
"is_encoder_decoder": false,
|
154 |
+
"label2id": {
|
155 |
+
"LABEL_0": 0,
|
156 |
+
"LABEL_1": 1
|
157 |
+
},
|
158 |
+
"layer_norm_eps": 1e-06,
|
159 |
+
"length_penalty": 1.0,
|
160 |
+
"max_length": 20,
|
161 |
+
"min_length": 0,
|
162 |
+
"model_type": "intern_vit_6b",
|
163 |
+
"no_repeat_ngram_size": 0,
|
164 |
+
"norm_type": "layer_norm",
|
165 |
+
"num_attention_heads": 16,
|
166 |
+
"num_beam_groups": 1,
|
167 |
+
"num_beams": 1,
|
168 |
+
"num_channels": 3,
|
169 |
+
"num_hidden_layers": 24,
|
170 |
+
"num_return_sequences": 1,
|
171 |
+
"output_attentions": false,
|
172 |
+
"output_hidden_states": false,
|
173 |
+
"output_scores": false,
|
174 |
+
"pad_token_id": null,
|
175 |
+
"patch_size": 14,
|
176 |
+
"prefix": null,
|
177 |
+
"problem_type": null,
|
178 |
+
"pruned_heads": {},
|
179 |
+
"qk_normalization": false,
|
180 |
+
"qkv_bias": true,
|
181 |
+
"remove_invalid_values": false,
|
182 |
+
"repetition_penalty": 1.0,
|
183 |
+
"return_dict": true,
|
184 |
+
"return_dict_in_generate": false,
|
185 |
+
"sep_token_id": null,
|
186 |
+
"suppress_tokens": null,
|
187 |
+
"task_specific_params": null,
|
188 |
+
"temperature": 1.0,
|
189 |
+
"tf_legacy_loss": false,
|
190 |
+
"tie_encoder_decoder": false,
|
191 |
+
"tie_word_embeddings": true,
|
192 |
+
"tokenizer_class": null,
|
193 |
+
"top_k": 50,
|
194 |
+
"top_p": 1.0,
|
195 |
+
"torch_dtype": "bfloat16",
|
196 |
+
"torchscript": false,
|
197 |
+
"transformers_version": "4.47.0",
|
198 |
+
"typical_p": 1.0,
|
199 |
+
"use_bfloat16": true,
|
200 |
+
"use_flash_attn": false
|
201 |
+
}
|
202 |
+
}
|
configuration_intern_vit.py
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# --------------------------------------------------------
|
2 |
+
# InternVL
|
3 |
+
# Copyright (c) 2024 OpenGVLab
|
4 |
+
# Licensed under The MIT License [see LICENSE for details]
|
5 |
+
# --------------------------------------------------------
|
6 |
+
|
7 |
+
import os
|
8 |
+
from typing import Union
|
9 |
+
|
10 |
+
from transformers.configuration_utils import PretrainedConfig
|
11 |
+
from transformers.utils import logging
|
12 |
+
|
13 |
+
logger = logging.get_logger(__name__)
|
14 |
+
|
15 |
+
|
16 |
+
class InternVisionConfig(PretrainedConfig):
|
17 |
+
r"""
|
18 |
+
This is the configuration class to store the configuration of a [`InternVisionModel`]. It is used to
|
19 |
+
instantiate a vision encoder according to the specified arguments, defining the model architecture.
|
20 |
+
|
21 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
22 |
+
documentation from [`PretrainedConfig`] for more information.
|
23 |
+
|
24 |
+
Args:
|
25 |
+
num_channels (`int`, *optional*, defaults to 3):
|
26 |
+
Number of color channels in the input images (e.g., 3 for RGB).
|
27 |
+
patch_size (`int`, *optional*, defaults to 14):
|
28 |
+
The size (resolution) of each patch.
|
29 |
+
image_size (`int`, *optional*, defaults to 224):
|
30 |
+
The size (resolution) of each image.
|
31 |
+
qkv_bias (`bool`, *optional*, defaults to `False`):
|
32 |
+
Whether to add a bias to the queries and values in the self-attention layers.
|
33 |
+
hidden_size (`int`, *optional*, defaults to 3200):
|
34 |
+
Dimensionality of the encoder layers and the pooler layer.
|
35 |
+
num_attention_heads (`int`, *optional*, defaults to 25):
|
36 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
37 |
+
intermediate_size (`int`, *optional*, defaults to 12800):
|
38 |
+
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
|
39 |
+
qk_normalization (`bool`, *optional*, defaults to `True`):
|
40 |
+
Whether to normalize the queries and keys in the self-attention layers.
|
41 |
+
num_hidden_layers (`int`, *optional*, defaults to 48):
|
42 |
+
Number of hidden layers in the Transformer encoder.
|
43 |
+
use_flash_attn (`bool`, *optional*, defaults to `True`):
|
44 |
+
Whether to use flash attention mechanism.
|
45 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
|
46 |
+
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
|
47 |
+
`"relu"`, `"selu"` and `"gelu_new"` ``"gelu"` are supported.
|
48 |
+
layer_norm_eps (`float`, *optional*, defaults to 1e-6):
|
49 |
+
The epsilon used by the layer normalization layers.
|
50 |
+
dropout (`float`, *optional*, defaults to 0.0):
|
51 |
+
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
|
52 |
+
drop_path_rate (`float`, *optional*, defaults to 0.0):
|
53 |
+
Dropout rate for stochastic depth.
|
54 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
55 |
+
The dropout ratio for the attention probabilities.
|
56 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
57 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
58 |
+
initializer_factor (`float`, *optional*, defaults to 0.1):
|
59 |
+
A factor for layer scale.
|
60 |
+
"""
|
61 |
+
|
62 |
+
model_type = 'intern_vit_6b'
|
63 |
+
|
64 |
+
def __init__(
|
65 |
+
self,
|
66 |
+
num_channels=3,
|
67 |
+
patch_size=14,
|
68 |
+
image_size=224,
|
69 |
+
qkv_bias=False,
|
70 |
+
hidden_size=3200,
|
71 |
+
num_attention_heads=25,
|
72 |
+
intermediate_size=12800,
|
73 |
+
qk_normalization=True,
|
74 |
+
num_hidden_layers=48,
|
75 |
+
use_flash_attn=True,
|
76 |
+
hidden_act='gelu',
|
77 |
+
norm_type='rms_norm',
|
78 |
+
layer_norm_eps=1e-6,
|
79 |
+
dropout=0.0,
|
80 |
+
drop_path_rate=0.0,
|
81 |
+
attention_dropout=0.0,
|
82 |
+
initializer_range=0.02,
|
83 |
+
initializer_factor=0.1,
|
84 |
+
**kwargs,
|
85 |
+
):
|
86 |
+
super().__init__(**kwargs)
|
87 |
+
|
88 |
+
self.hidden_size = hidden_size
|
89 |
+
self.intermediate_size = intermediate_size
|
90 |
+
self.dropout = dropout
|
91 |
+
self.drop_path_rate = drop_path_rate
|
92 |
+
self.num_hidden_layers = num_hidden_layers
|
93 |
+
self.num_attention_heads = num_attention_heads
|
94 |
+
self.num_channels = num_channels
|
95 |
+
self.patch_size = patch_size
|
96 |
+
self.image_size = image_size
|
97 |
+
self.initializer_range = initializer_range
|
98 |
+
self.initializer_factor = initializer_factor
|
99 |
+
self.attention_dropout = attention_dropout
|
100 |
+
self.layer_norm_eps = layer_norm_eps
|
101 |
+
self.hidden_act = hidden_act
|
102 |
+
self.norm_type = norm_type
|
103 |
+
self.qkv_bias = qkv_bias
|
104 |
+
self.qk_normalization = qk_normalization
|
105 |
+
self.use_flash_attn = use_flash_attn
|
106 |
+
|
107 |
+
@classmethod
|
108 |
+
def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) -> 'PretrainedConfig':
|
109 |
+
config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
|
110 |
+
|
111 |
+
if 'vision_config' in config_dict:
|
112 |
+
config_dict = config_dict['vision_config']
|
113 |
+
|
114 |
+
if 'model_type' in config_dict and hasattr(cls, 'model_type') and config_dict['model_type'] != cls.model_type:
|
115 |
+
logger.warning(
|
116 |
+
f"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
|
117 |
+
f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'
|
118 |
+
)
|
119 |
+
|
120 |
+
return cls.from_dict(config_dict, **kwargs)
|
configuration_internlm2.py
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) The InternLM team and The HuggingFace Inc. team. All rights reserved.
|
2 |
+
#
|
3 |
+
# This code is based on transformers/src/transformers/models/llama/configuration_llama.py
|
4 |
+
#
|
5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
# you may not use this file except in compliance with the License.
|
7 |
+
# You may obtain a copy of the License at
|
8 |
+
#
|
9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the License for the specific language governing permissions and
|
15 |
+
# limitations under the License.
|
16 |
+
""" InternLM2 model configuration"""
|
17 |
+
|
18 |
+
from transformers.configuration_utils import PretrainedConfig
|
19 |
+
from transformers.utils import logging
|
20 |
+
|
21 |
+
logger = logging.get_logger(__name__)
|
22 |
+
|
23 |
+
INTERNLM2_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
24 |
+
|
25 |
+
|
26 |
+
# Modified from transformers.model.llama.configuration_llama.LlamaConfig
|
27 |
+
class InternLM2Config(PretrainedConfig):
|
28 |
+
r"""
|
29 |
+
This is the configuration class to store the configuration of a [`InternLM2Model`]. It is used to instantiate
|
30 |
+
an InternLM2 model according to the specified arguments, defining the model architecture. Instantiating a
|
31 |
+
configuration with the defaults will yield a similar configuration to that of the InternLM2-7B.
|
32 |
+
|
33 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
34 |
+
documentation from [`PretrainedConfig`] for more information.
|
35 |
+
|
36 |
+
|
37 |
+
Args:
|
38 |
+
vocab_size (`int`, *optional*, defaults to 32000):
|
39 |
+
Vocabulary size of the InternLM2 model. Defines the number of different tokens that can be represented by the
|
40 |
+
`inputs_ids` passed when calling [`InternLM2Model`]
|
41 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
42 |
+
Dimension of the hidden representations.
|
43 |
+
intermediate_size (`int`, *optional*, defaults to 11008):
|
44 |
+
Dimension of the MLP representations.
|
45 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
46 |
+
Number of hidden layers in the Transformer encoder.
|
47 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
48 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
49 |
+
num_key_value_heads (`int`, *optional*):
|
50 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
51 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
52 |
+
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
53 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
54 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
55 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
|
56 |
+
`num_attention_heads`.
|
57 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
58 |
+
The non-linear activation function (function or string) in the decoder.
|
59 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
60 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
61 |
+
just in case (e.g., 512 or 1024 or 2048).
|
62 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
63 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
64 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-12):
|
65 |
+
The epsilon used by the rms normalization layers.
|
66 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
67 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
68 |
+
relevant if `config.is_decoder=True`.
|
69 |
+
tie_word_embeddings(`bool`, *optional*, defaults to `False`):
|
70 |
+
Whether to tie weight embeddings
|
71 |
+
Example:
|
72 |
+
|
73 |
+
"""
|
74 |
+
model_type = 'internlm2'
|
75 |
+
_auto_class = 'AutoConfig'
|
76 |
+
|
77 |
+
def __init__( # pylint: disable=W0102
|
78 |
+
self,
|
79 |
+
vocab_size=103168,
|
80 |
+
hidden_size=4096,
|
81 |
+
intermediate_size=11008,
|
82 |
+
num_hidden_layers=32,
|
83 |
+
num_attention_heads=32,
|
84 |
+
num_key_value_heads=None,
|
85 |
+
hidden_act='silu',
|
86 |
+
max_position_embeddings=2048,
|
87 |
+
initializer_range=0.02,
|
88 |
+
rms_norm_eps=1e-6,
|
89 |
+
use_cache=True,
|
90 |
+
pad_token_id=0,
|
91 |
+
bos_token_id=1,
|
92 |
+
eos_token_id=2,
|
93 |
+
tie_word_embeddings=False,
|
94 |
+
bias=True,
|
95 |
+
rope_theta=10000,
|
96 |
+
rope_scaling=None,
|
97 |
+
attn_implementation='eager',
|
98 |
+
**kwargs,
|
99 |
+
):
|
100 |
+
self.vocab_size = vocab_size
|
101 |
+
self.max_position_embeddings = max_position_embeddings
|
102 |
+
self.hidden_size = hidden_size
|
103 |
+
self.intermediate_size = intermediate_size
|
104 |
+
self.num_hidden_layers = num_hidden_layers
|
105 |
+
self.num_attention_heads = num_attention_heads
|
106 |
+
self.bias = bias
|
107 |
+
|
108 |
+
if num_key_value_heads is None:
|
109 |
+
num_key_value_heads = num_attention_heads
|
110 |
+
self.num_key_value_heads = num_key_value_heads
|
111 |
+
|
112 |
+
self.hidden_act = hidden_act
|
113 |
+
self.initializer_range = initializer_range
|
114 |
+
self.rms_norm_eps = rms_norm_eps
|
115 |
+
self.use_cache = use_cache
|
116 |
+
self.rope_theta = rope_theta
|
117 |
+
self.rope_scaling = rope_scaling
|
118 |
+
self._rope_scaling_validation()
|
119 |
+
|
120 |
+
self.attn_implementation = attn_implementation
|
121 |
+
if self.attn_implementation is None:
|
122 |
+
self.attn_implementation = 'eager'
|
123 |
+
super().__init__(
|
124 |
+
pad_token_id=pad_token_id,
|
125 |
+
bos_token_id=bos_token_id,
|
126 |
+
eos_token_id=eos_token_id,
|
127 |
+
tie_word_embeddings=tie_word_embeddings,
|
128 |
+
**kwargs,
|
129 |
+
)
|
130 |
+
|
131 |
+
def _rope_scaling_validation(self):
|
132 |
+
"""
|
133 |
+
Validate the `rope_scaling` configuration.
|
134 |
+
"""
|
135 |
+
if self.rope_scaling is None:
|
136 |
+
return
|
137 |
+
|
138 |
+
if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
|
139 |
+
raise ValueError(
|
140 |
+
'`rope_scaling` must be a dictionary with with two fields, `type` and `factor`, '
|
141 |
+
f'got {self.rope_scaling}'
|
142 |
+
)
|
143 |
+
rope_scaling_type = self.rope_scaling.get('type', None)
|
144 |
+
rope_scaling_factor = self.rope_scaling.get('factor', None)
|
145 |
+
if rope_scaling_type is None or rope_scaling_type not in ['linear', 'dynamic']:
|
146 |
+
raise ValueError(
|
147 |
+
f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
|
148 |
+
)
|
149 |
+
if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor < 1.0:
|
150 |
+
raise ValueError(f"`rope_scaling`'s factor field must be a float >= 1, got {rope_scaling_factor}")
|
configuration_internvl_chat.py
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# --------------------------------------------------------
|
2 |
+
# InternVL
|
3 |
+
# Copyright (c) 2024 OpenGVLab
|
4 |
+
# Licensed under The MIT License [see LICENSE for details]
|
5 |
+
# --------------------------------------------------------
|
6 |
+
|
7 |
+
import copy
|
8 |
+
|
9 |
+
from transformers import AutoConfig, LlamaConfig
|
10 |
+
from transformers.configuration_utils import PretrainedConfig
|
11 |
+
from transformers.utils import logging
|
12 |
+
|
13 |
+
from .configuration_intern_vit import InternVisionConfig
|
14 |
+
from .configuration_internlm2 import InternLM2Config
|
15 |
+
|
16 |
+
logger = logging.get_logger(__name__)
|
17 |
+
|
18 |
+
|
19 |
+
class InternVLChatConfig(PretrainedConfig):
|
20 |
+
model_type = 'internvl_chat'
|
21 |
+
is_composition = True
|
22 |
+
|
23 |
+
def __init__(
|
24 |
+
self,
|
25 |
+
vision_config=None,
|
26 |
+
llm_config=None,
|
27 |
+
use_backbone_lora=0,
|
28 |
+
use_llm_lora=0,
|
29 |
+
select_layer=-1,
|
30 |
+
force_image_size=None,
|
31 |
+
downsample_ratio=0.5,
|
32 |
+
template=None,
|
33 |
+
dynamic_image_size=False,
|
34 |
+
use_thumbnail=False,
|
35 |
+
ps_version='v1',
|
36 |
+
min_dynamic_patch=1,
|
37 |
+
max_dynamic_patch=6,
|
38 |
+
**kwargs):
|
39 |
+
super().__init__(**kwargs)
|
40 |
+
|
41 |
+
if vision_config is None:
|
42 |
+
vision_config = {'architectures': ['InternVisionModel']}
|
43 |
+
logger.info('vision_config is None. Initializing the InternVisionConfig with default values.')
|
44 |
+
|
45 |
+
if llm_config is None:
|
46 |
+
llm_config = {'architectures': ['InternLM2ForCausalLM']}
|
47 |
+
logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')
|
48 |
+
|
49 |
+
self.vision_config = InternVisionConfig(**vision_config)
|
50 |
+
if llm_config.get('architectures')[0] == 'LlamaForCausalLM':
|
51 |
+
self.llm_config = LlamaConfig(**llm_config)
|
52 |
+
elif llm_config.get('architectures')[0] == 'InternLM2ForCausalLM':
|
53 |
+
self.llm_config = InternLM2Config(**llm_config)
|
54 |
+
else:
|
55 |
+
raise ValueError('Unsupported architecture: {}'.format(llm_config.get('architectures')[0]))
|
56 |
+
self.use_backbone_lora = use_backbone_lora
|
57 |
+
self.use_llm_lora = use_llm_lora
|
58 |
+
self.select_layer = select_layer
|
59 |
+
self.force_image_size = force_image_size
|
60 |
+
self.downsample_ratio = downsample_ratio
|
61 |
+
self.template = template
|
62 |
+
self.dynamic_image_size = dynamic_image_size
|
63 |
+
self.use_thumbnail = use_thumbnail
|
64 |
+
self.ps_version = ps_version # pixel shuffle version
|
65 |
+
self.min_dynamic_patch = min_dynamic_patch
|
66 |
+
self.max_dynamic_patch = max_dynamic_patch
|
67 |
+
|
68 |
+
logger.info(f'vision_select_layer: {self.select_layer}')
|
69 |
+
logger.info(f'ps_version: {self.ps_version}')
|
70 |
+
logger.info(f'min_dynamic_patch: {self.min_dynamic_patch}')
|
71 |
+
logger.info(f'max_dynamic_patch: {self.max_dynamic_patch}')
|
72 |
+
|
73 |
+
def to_dict(self):
|
74 |
+
"""
|
75 |
+
Serializes this instance to a Python dictionary. Override the default [`~PretrainedConfig.to_dict`].
|
76 |
+
|
77 |
+
Returns:
|
78 |
+
`Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance,
|
79 |
+
"""
|
80 |
+
output = copy.deepcopy(self.__dict__)
|
81 |
+
output['vision_config'] = self.vision_config.to_dict()
|
82 |
+
output['llm_config'] = self.llm_config.to_dict()
|
83 |
+
output['model_type'] = self.__class__.model_type
|
84 |
+
output['use_backbone_lora'] = self.use_backbone_lora
|
85 |
+
output['use_llm_lora'] = self.use_llm_lora
|
86 |
+
output['select_layer'] = self.select_layer
|
87 |
+
output['force_image_size'] = self.force_image_size
|
88 |
+
output['downsample_ratio'] = self.downsample_ratio
|
89 |
+
output['template'] = self.template
|
90 |
+
output['dynamic_image_size'] = self.dynamic_image_size
|
91 |
+
output['use_thumbnail'] = self.use_thumbnail
|
92 |
+
output['ps_version'] = self.ps_version
|
93 |
+
output['min_dynamic_patch'] = self.min_dynamic_patch
|
94 |
+
output['max_dynamic_patch'] = self.max_dynamic_patch
|
95 |
+
|
96 |
+
return output
|
generation_config.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"eos_token_id": [
|
4 |
+
92542,
|
5 |
+
92543
|
6 |
+
],
|
7 |
+
"transformers_version": "4.47.0"
|
8 |
+
}
|
modeling_internvl_chat.py
ADDED
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# --------------------------------------------------------
|
2 |
+
# InternVL
|
3 |
+
# Copyright (c) 2024 OpenGVLab
|
4 |
+
# Licensed under The MIT License [see LICENSE for details]
|
5 |
+
# --------------------------------------------------------
|
6 |
+
|
7 |
+
import warnings
|
8 |
+
from typing import List, Optional, Tuple, Union
|
9 |
+
|
10 |
+
import torch.utils.checkpoint
|
11 |
+
import transformers
|
12 |
+
from torch import nn
|
13 |
+
from torch.nn import CrossEntropyLoss
|
14 |
+
from transformers import (AutoModel, GenerationConfig, LlamaForCausalLM,
|
15 |
+
LlamaTokenizer)
|
16 |
+
from transformers.modeling_outputs import CausalLMOutputWithPast
|
17 |
+
from transformers.modeling_utils import PreTrainedModel
|
18 |
+
from transformers.utils import ModelOutput, logging
|
19 |
+
|
20 |
+
from .configuration_internvl_chat import InternVLChatConfig
|
21 |
+
from .conversation import get_conv_template
|
22 |
+
from .modeling_intern_vit import InternVisionModel, has_flash_attn
|
23 |
+
from .modeling_internlm2 import InternLM2ForCausalLM
|
24 |
+
|
25 |
+
logger = logging.get_logger(__name__)
|
26 |
+
|
27 |
+
|
28 |
+
def version_cmp(v1, v2, op='eq'):
|
29 |
+
import operator
|
30 |
+
|
31 |
+
from packaging import version
|
32 |
+
op_func = getattr(operator, op)
|
33 |
+
return op_func(version.parse(v1), version.parse(v2))
|
34 |
+
|
35 |
+
|
36 |
+
class InternVLChatModel(PreTrainedModel):
|
37 |
+
config_class = InternVLChatConfig
|
38 |
+
main_input_name = 'pixel_values'
|
39 |
+
base_model_prefix = 'language_model'
|
40 |
+
_supports_flash_attn_2 = True
|
41 |
+
_no_split_modules = ['InternVisionModel', 'LlamaDecoderLayer', 'InternLM2DecoderLayer']
|
42 |
+
|
43 |
+
def __init__(self, config: InternVLChatConfig, vision_model=None, language_model=None, use_flash_attn=True):
|
44 |
+
super().__init__(config)
|
45 |
+
|
46 |
+
assert version_cmp(transformers.__version__, '4.37.0', 'ge')
|
47 |
+
image_size = config.force_image_size or config.vision_config.image_size
|
48 |
+
patch_size = config.vision_config.patch_size
|
49 |
+
self.patch_size = patch_size
|
50 |
+
self.select_layer = config.select_layer
|
51 |
+
self.template = config.template
|
52 |
+
self.num_image_token = int((image_size // patch_size) ** 2 * (config.downsample_ratio ** 2))
|
53 |
+
self.downsample_ratio = config.downsample_ratio
|
54 |
+
self.ps_version = config.ps_version
|
55 |
+
use_flash_attn = use_flash_attn if has_flash_attn else False
|
56 |
+
config.vision_config.use_flash_attn = True if use_flash_attn else False
|
57 |
+
config.llm_config.attn_implementation = 'flash_attention_2' if use_flash_attn else 'eager'
|
58 |
+
|
59 |
+
logger.info(f'num_image_token: {self.num_image_token}')
|
60 |
+
logger.info(f'ps_version: {self.ps_version}')
|
61 |
+
if vision_model is not None:
|
62 |
+
self.vision_model = vision_model
|
63 |
+
else:
|
64 |
+
self.vision_model = InternVisionModel(config.vision_config)
|
65 |
+
if language_model is not None:
|
66 |
+
self.language_model = language_model
|
67 |
+
else:
|
68 |
+
if config.llm_config.architectures[0] == 'LlamaForCausalLM':
|
69 |
+
self.language_model = LlamaForCausalLM(config.llm_config)
|
70 |
+
elif config.llm_config.architectures[0] == 'InternLM2ForCausalLM':
|
71 |
+
self.language_model = InternLM2ForCausalLM(config.llm_config)
|
72 |
+
else:
|
73 |
+
raise NotImplementedError(f'{config.llm_config.architectures[0]} is not implemented.')
|
74 |
+
|
75 |
+
vit_hidden_size = config.vision_config.hidden_size
|
76 |
+
llm_hidden_size = config.llm_config.hidden_size
|
77 |
+
|
78 |
+
self.mlp1 = nn.Sequential(
|
79 |
+
nn.LayerNorm(vit_hidden_size * int(1 / self.downsample_ratio) ** 2),
|
80 |
+
nn.Linear(vit_hidden_size * int(1 / self.downsample_ratio) ** 2, llm_hidden_size),
|
81 |
+
nn.GELU(),
|
82 |
+
nn.Linear(llm_hidden_size, llm_hidden_size)
|
83 |
+
)
|
84 |
+
|
85 |
+
self.img_context_token_id = None
|
86 |
+
self.conv_template = get_conv_template(self.template)
|
87 |
+
self.system_message = self.conv_template.system_message
|
88 |
+
|
89 |
+
def forward(
|
90 |
+
self,
|
91 |
+
pixel_values: torch.FloatTensor,
|
92 |
+
input_ids: torch.LongTensor = None,
|
93 |
+
attention_mask: Optional[torch.Tensor] = None,
|
94 |
+
position_ids: Optional[torch.LongTensor] = None,
|
95 |
+
image_flags: Optional[torch.LongTensor] = None,
|
96 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
97 |
+
labels: Optional[torch.LongTensor] = None,
|
98 |
+
use_cache: Optional[bool] = None,
|
99 |
+
output_attentions: Optional[bool] = None,
|
100 |
+
output_hidden_states: Optional[bool] = None,
|
101 |
+
return_dict: Optional[bool] = None,
|
102 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
103 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
104 |
+
|
105 |
+
image_flags = image_flags.squeeze(-1)
|
106 |
+
input_embeds = self.language_model.get_input_embeddings()(input_ids).clone()
|
107 |
+
|
108 |
+
vit_embeds = self.extract_feature(pixel_values)
|
109 |
+
vit_embeds = vit_embeds[image_flags == 1]
|
110 |
+
vit_batch_size = pixel_values.shape[0]
|
111 |
+
|
112 |
+
B, N, C = input_embeds.shape
|
113 |
+
input_embeds = input_embeds.reshape(B * N, C)
|
114 |
+
|
115 |
+
if torch.distributed.is_initialized() and torch.distributed.get_rank() == 0:
|
116 |
+
print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
|
117 |
+
|
118 |
+
input_ids = input_ids.reshape(B * N)
|
119 |
+
selected = (input_ids == self.img_context_token_id)
|
120 |
+
try:
|
121 |
+
input_embeds[selected] = input_embeds[selected] * 0.0 + vit_embeds.reshape(-1, C)
|
122 |
+
except Exception as e:
|
123 |
+
vit_embeds = vit_embeds.reshape(-1, C)
|
124 |
+
print(f'warning: {e}, input_embeds[selected].shape={input_embeds[selected].shape}, '
|
125 |
+
f'vit_embeds.shape={vit_embeds.shape}')
|
126 |
+
n_token = selected.sum()
|
127 |
+
input_embeds[selected] = input_embeds[selected] * 0.0 + vit_embeds[:n_token]
|
128 |
+
|
129 |
+
input_embeds = input_embeds.reshape(B, N, C)
|
130 |
+
|
131 |
+
outputs = self.language_model(
|
132 |
+
inputs_embeds=input_embeds,
|
133 |
+
attention_mask=attention_mask,
|
134 |
+
position_ids=position_ids,
|
135 |
+
past_key_values=past_key_values,
|
136 |
+
use_cache=use_cache,
|
137 |
+
output_attentions=output_attentions,
|
138 |
+
output_hidden_states=output_hidden_states,
|
139 |
+
return_dict=return_dict,
|
140 |
+
)
|
141 |
+
logits = outputs.logits
|
142 |
+
|
143 |
+
loss = None
|
144 |
+
if labels is not None:
|
145 |
+
# Shift so that tokens < n predict n
|
146 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
147 |
+
shift_labels = labels[..., 1:].contiguous()
|
148 |
+
# Flatten the tokens
|
149 |
+
loss_fct = CrossEntropyLoss()
|
150 |
+
shift_logits = shift_logits.view(-1, self.language_model.config.vocab_size)
|
151 |
+
shift_labels = shift_labels.view(-1)
|
152 |
+
# Enable model parallelism
|
153 |
+
shift_labels = shift_labels.to(shift_logits.device)
|
154 |
+
loss = loss_fct(shift_logits, shift_labels)
|
155 |
+
|
156 |
+
if not return_dict:
|
157 |
+
output = (logits,) + outputs[1:]
|
158 |
+
return (loss,) + output if loss is not None else output
|
159 |
+
|
160 |
+
return CausalLMOutputWithPast(
|
161 |
+
loss=loss,
|
162 |
+
logits=logits,
|
163 |
+
past_key_values=outputs.past_key_values,
|
164 |
+
hidden_states=outputs.hidden_states,
|
165 |
+
attentions=outputs.attentions,
|
166 |
+
)
|
167 |
+
|
168 |
+
def pixel_shuffle(self, x, scale_factor=0.5):
|
169 |
+
n, w, h, c = x.size()
|
170 |
+
# N, W, H, C --> N, W, H * scale, C // scale
|
171 |
+
x = x.view(n, w, int(h * scale_factor), int(c / scale_factor))
|
172 |
+
# N, W, H * scale, C // scale --> N, H * scale, W, C // scale
|
173 |
+
x = x.permute(0, 2, 1, 3).contiguous()
|
174 |
+
# N, H * scale, W, C // scale --> N, H * scale, W * scale, C // (scale ** 2)
|
175 |
+
x = x.view(n, int(h * scale_factor), int(w * scale_factor),
|
176 |
+
int(c / (scale_factor * scale_factor)))
|
177 |
+
if self.ps_version == 'v1':
|
178 |
+
warnings.warn("In ps_version 'v1', the height and width have not been swapped back, "
|
179 |
+
'which results in a transposed image.')
|
180 |
+
else:
|
181 |
+
x = x.permute(0, 2, 1, 3).contiguous()
|
182 |
+
return x
|
183 |
+
|
184 |
+
def extract_feature(self, pixel_values):
|
185 |
+
if self.select_layer == -1:
|
186 |
+
vit_embeds = self.vision_model(
|
187 |
+
pixel_values=pixel_values,
|
188 |
+
output_hidden_states=False,
|
189 |
+
return_dict=True).last_hidden_state
|
190 |
+
else:
|
191 |
+
vit_embeds = self.vision_model(
|
192 |
+
pixel_values=pixel_values,
|
193 |
+
output_hidden_states=True,
|
194 |
+
return_dict=True).hidden_states[self.select_layer]
|
195 |
+
vit_embeds = vit_embeds[:, 1:, :]
|
196 |
+
|
197 |
+
h = w = int(vit_embeds.shape[1] ** 0.5)
|
198 |
+
vit_embeds = vit_embeds.reshape(vit_embeds.shape[0], h, w, -1)
|
199 |
+
vit_embeds = self.pixel_shuffle(vit_embeds, scale_factor=self.downsample_ratio)
|
200 |
+
vit_embeds = vit_embeds.reshape(vit_embeds.shape[0], -1, vit_embeds.shape[-1])
|
201 |
+
vit_embeds = self.mlp1(vit_embeds)
|
202 |
+
return vit_embeds
|
203 |
+
|
204 |
+
def batch_chat(self, tokenizer, pixel_values, questions, generation_config, num_patches_list=None,
|
205 |
+
history=None, return_history=False, IMG_START_TOKEN='<img>', IMG_END_TOKEN='</img>',
|
206 |
+
IMG_CONTEXT_TOKEN='<IMG_CONTEXT>', verbose=False, image_counts=None):
|
207 |
+
if history is not None or return_history:
|
208 |
+
print('Now multi-turn chat is not supported in batch_chat.')
|
209 |
+
raise NotImplementedError
|
210 |
+
|
211 |
+
if image_counts is not None:
|
212 |
+
num_patches_list = image_counts
|
213 |
+
print('Warning: `image_counts` is deprecated. Please use `num_patches_list` instead.')
|
214 |
+
|
215 |
+
img_context_token_id = tokenizer.convert_tokens_to_ids(IMG_CONTEXT_TOKEN)
|
216 |
+
self.img_context_token_id = img_context_token_id
|
217 |
+
|
218 |
+
if verbose and pixel_values is not None:
|
219 |
+
image_bs = pixel_values.shape[0]
|
220 |
+
print(f'dynamic ViT batch size: {image_bs}')
|
221 |
+
|
222 |
+
queries = []
|
223 |
+
for idx, num_patches in enumerate(num_patches_list):
|
224 |
+
question = questions[idx]
|
225 |
+
if pixel_values is not None and '<image>' not in question:
|
226 |
+
question = '<image>\n' + question
|
227 |
+
template = get_conv_template(self.template)
|
228 |
+
template.system_message = self.system_message
|
229 |
+
template.append_message(template.roles[0], question)
|
230 |
+
template.append_message(template.roles[1], None)
|
231 |
+
query = template.get_prompt()
|
232 |
+
|
233 |
+
image_tokens = IMG_START_TOKEN + IMG_CONTEXT_TOKEN * self.num_image_token * num_patches + IMG_END_TOKEN
|
234 |
+
query = query.replace('<image>', image_tokens, 1)
|
235 |
+
queries.append(query)
|
236 |
+
|
237 |
+
tokenizer.padding_side = 'left'
|
238 |
+
model_inputs = tokenizer(queries, return_tensors='pt', padding=True)
|
239 |
+
input_ids = model_inputs['input_ids'].to(self.device)
|
240 |
+
attention_mask = model_inputs['attention_mask'].to(self.device)
|
241 |
+
eos_token_id = tokenizer.convert_tokens_to_ids(template.sep.strip())
|
242 |
+
generation_config['eos_token_id'] = eos_token_id
|
243 |
+
generation_output = self.generate(
|
244 |
+
pixel_values=pixel_values,
|
245 |
+
input_ids=input_ids,
|
246 |
+
attention_mask=attention_mask,
|
247 |
+
**generation_config
|
248 |
+
)
|
249 |
+
responses = tokenizer.batch_decode(generation_output, skip_special_tokens=True)
|
250 |
+
responses = [response.split(template.sep.strip())[0].strip() for response in responses]
|
251 |
+
return responses
|
252 |
+
|
253 |
+
def chat(self, tokenizer, pixel_values, question, generation_config, history=None, return_history=False,
|
254 |
+
num_patches_list=None, IMG_START_TOKEN='<img>', IMG_END_TOKEN='</img>', IMG_CONTEXT_TOKEN='<IMG_CONTEXT>',
|
255 |
+
verbose=False):
|
256 |
+
|
257 |
+
if history is None and pixel_values is not None and '<image>' not in question:
|
258 |
+
question = '<image>\n' + question
|
259 |
+
|
260 |
+
if num_patches_list is None:
|
261 |
+
num_patches_list = [pixel_values.shape[0]] if pixel_values is not None else []
|
262 |
+
assert pixel_values is None or len(pixel_values) == sum(num_patches_list)
|
263 |
+
|
264 |
+
img_context_token_id = tokenizer.convert_tokens_to_ids(IMG_CONTEXT_TOKEN)
|
265 |
+
self.img_context_token_id = img_context_token_id
|
266 |
+
|
267 |
+
template = get_conv_template(self.template)
|
268 |
+
template.system_message = self.system_message
|
269 |
+
eos_token_id = tokenizer.convert_tokens_to_ids(template.sep.strip())
|
270 |
+
|
271 |
+
history = [] if history is None else history
|
272 |
+
for (old_question, old_answer) in history:
|
273 |
+
template.append_message(template.roles[0], old_question)
|
274 |
+
template.append_message(template.roles[1], old_answer)
|
275 |
+
template.append_message(template.roles[0], question)
|
276 |
+
template.append_message(template.roles[1], None)
|
277 |
+
query = template.get_prompt()
|
278 |
+
|
279 |
+
if verbose and pixel_values is not None:
|
280 |
+
image_bs = pixel_values.shape[0]
|
281 |
+
print(f'dynamic ViT batch size: {image_bs}')
|
282 |
+
|
283 |
+
for num_patches in num_patches_list:
|
284 |
+
image_tokens = IMG_START_TOKEN + IMG_CONTEXT_TOKEN * self.num_image_token * num_patches + IMG_END_TOKEN
|
285 |
+
query = query.replace('<image>', image_tokens, 1)
|
286 |
+
|
287 |
+
model_inputs = tokenizer(query, return_tensors='pt')
|
288 |
+
input_ids = model_inputs['input_ids'].to(self.device)
|
289 |
+
attention_mask = model_inputs['attention_mask'].to(self.device)
|
290 |
+
generation_config['eos_token_id'] = eos_token_id
|
291 |
+
generation_output = self.generate(
|
292 |
+
pixel_values=pixel_values,
|
293 |
+
input_ids=input_ids,
|
294 |
+
attention_mask=attention_mask,
|
295 |
+
**generation_config
|
296 |
+
)
|
297 |
+
response = tokenizer.batch_decode(generation_output, skip_special_tokens=True)[0]
|
298 |
+
response = response.split(template.sep.strip())[0].strip()
|
299 |
+
history.append((question, response))
|
300 |
+
if return_history:
|
301 |
+
return response, history
|
302 |
+
else:
|
303 |
+
query_to_print = query.replace(IMG_CONTEXT_TOKEN, '')
|
304 |
+
query_to_print = query_to_print.replace(f'{IMG_START_TOKEN}{IMG_END_TOKEN}', '<image>')
|
305 |
+
if verbose:
|
306 |
+
print(query_to_print, response)
|
307 |
+
return response
|
308 |
+
|
309 |
+
@torch.no_grad()
|
310 |
+
def generate(
|
311 |
+
self,
|
312 |
+
pixel_values: Optional[torch.FloatTensor] = None,
|
313 |
+
input_ids: Optional[torch.FloatTensor] = None,
|
314 |
+
attention_mask: Optional[torch.LongTensor] = None,
|
315 |
+
visual_features: Optional[torch.FloatTensor] = None,
|
316 |
+
generation_config: Optional[GenerationConfig] = None,
|
317 |
+
output_hidden_states: Optional[bool] = None,
|
318 |
+
**generate_kwargs,
|
319 |
+
) -> torch.LongTensor:
|
320 |
+
|
321 |
+
assert self.img_context_token_id is not None
|
322 |
+
if pixel_values is not None:
|
323 |
+
if visual_features is not None:
|
324 |
+
vit_embeds = visual_features
|
325 |
+
else:
|
326 |
+
vit_embeds = self.extract_feature(pixel_values)
|
327 |
+
input_embeds = self.language_model.get_input_embeddings()(input_ids)
|
328 |
+
B, N, C = input_embeds.shape
|
329 |
+
input_embeds = input_embeds.reshape(B * N, C)
|
330 |
+
|
331 |
+
input_ids = input_ids.reshape(B * N)
|
332 |
+
selected = (input_ids == self.img_context_token_id)
|
333 |
+
assert selected.sum() != 0
|
334 |
+
input_embeds[selected] = vit_embeds.reshape(-1, C).to(input_embeds.device)
|
335 |
+
|
336 |
+
input_embeds = input_embeds.reshape(B, N, C)
|
337 |
+
else:
|
338 |
+
input_embeds = self.language_model.get_input_embeddings()(input_ids)
|
339 |
+
|
340 |
+
outputs = self.language_model.generate(
|
341 |
+
inputs_embeds=input_embeds,
|
342 |
+
attention_mask=attention_mask,
|
343 |
+
generation_config=generation_config,
|
344 |
+
output_hidden_states=output_hidden_states,
|
345 |
+
use_cache=True,
|
346 |
+
**generate_kwargs,
|
347 |
+
)
|
348 |
+
|
349 |
+
return outputs
|
openvino_config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compression": null,
|
3 |
+
"dtype": "int8",
|
4 |
+
"input_info": null,
|
5 |
+
"optimum_version": "1.24.0.dev0",
|
6 |
+
"quantization_config": {
|
7 |
+
"all_layers": null,
|
8 |
+
"backup_precision": null,
|
9 |
+
"bits": 8,
|
10 |
+
"dataset": null,
|
11 |
+
"gptq": null,
|
12 |
+
"group_size": -1,
|
13 |
+
"ignored_scope": null,
|
14 |
+
"lora_correction": null,
|
15 |
+
"num_samples": null,
|
16 |
+
"processor": null,
|
17 |
+
"quant_method": "default",
|
18 |
+
"ratio": 1,
|
19 |
+
"scale_estimation": null,
|
20 |
+
"sensitivity_metric": null,
|
21 |
+
"sym": false,
|
22 |
+
"tokenizer": null,
|
23 |
+
"trust_remote_code": false,
|
24 |
+
"weight_format": "int8"
|
25 |
+
},
|
26 |
+
"save_onnx_model": false,
|
27 |
+
"transformers_version": "4.47.0"
|
28 |
+
}
|
openvino_detokenizer.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9d99982bd38cc642f98134aabf7650a1ce0d28e7978c945c238d7620a8260d29
|
3 |
+
size 1477889
|
openvino_detokenizer.xml
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<net name="detokenizer" version="11">
|
3 |
+
<layers>
|
4 |
+
<layer id="0" name="Parameter_204236" type="Parameter" version="opset1">
|
5 |
+
<data shape="?,?" element_type="i64" />
|
6 |
+
<output>
|
7 |
+
<port id="0" precision="I64" names="Parameter_204236">
|
8 |
+
<dim>-1</dim>
|
9 |
+
<dim>-1</dim>
|
10 |
+
</port>
|
11 |
+
</output>
|
12 |
+
</layer>
|
13 |
+
<layer id="1" name="Constant_204156" type="Const" version="opset1">
|
14 |
+
<data element_type="u8" shape="1477889" offset="0" size="1477889" />
|
15 |
+
<output>
|
16 |
+
<port id="0" precision="U8">
|
17 |
+
<dim>1477889</dim>
|
18 |
+
</port>
|
19 |
+
</output>
|
20 |
+
</layer>
|
21 |
+
<layer id="2" name="Convert_204245" type="Convert" version="opset1">
|
22 |
+
<data destination_type="i32" />
|
23 |
+
<input>
|
24 |
+
<port id="0" precision="I64">
|
25 |
+
<dim>-1</dim>
|
26 |
+
<dim>-1</dim>
|
27 |
+
</port>
|
28 |
+
</input>
|
29 |
+
<output>
|
30 |
+
<port id="1" precision="I32">
|
31 |
+
<dim>-1</dim>
|
32 |
+
<dim>-1</dim>
|
33 |
+
</port>
|
34 |
+
</output>
|
35 |
+
</layer>
|
36 |
+
<layer id="3" name="SentencepieceDetokenizer_204237" type="SentencepieceDetokenizer" version="extension">
|
37 |
+
<input>
|
38 |
+
<port id="0" precision="U8">
|
39 |
+
<dim>1477889</dim>
|
40 |
+
</port>
|
41 |
+
<port id="1" precision="I32">
|
42 |
+
<dim>-1</dim>
|
43 |
+
<dim>-1</dim>
|
44 |
+
</port>
|
45 |
+
</input>
|
46 |
+
<output>
|
47 |
+
<port id="2" precision="I32">
|
48 |
+
<dim>-1</dim>
|
49 |
+
</port>
|
50 |
+
<port id="3" precision="I32">
|
51 |
+
<dim>-1</dim>
|
52 |
+
</port>
|
53 |
+
<port id="4" precision="U8">
|
54 |
+
<dim>-1</dim>
|
55 |
+
</port>
|
56 |
+
</output>
|
57 |
+
</layer>
|
58 |
+
<layer id="4" name="UTF8Validate_204238" type="UTF8Validate" version="extension">
|
59 |
+
<data replace_mode="true" />
|
60 |
+
<input>
|
61 |
+
<port id="0" precision="I32">
|
62 |
+
<dim>-1</dim>
|
63 |
+
</port>
|
64 |
+
<port id="1" precision="I32">
|
65 |
+
<dim>-1</dim>
|
66 |
+
</port>
|
67 |
+
<port id="2" precision="U8">
|
68 |
+
<dim>-1</dim>
|
69 |
+
</port>
|
70 |
+
</input>
|
71 |
+
<output>
|
72 |
+
<port id="3" precision="I32">
|
73 |
+
<dim>-1</dim>
|
74 |
+
</port>
|
75 |
+
<port id="4" precision="I32">
|
76 |
+
<dim>-1</dim>
|
77 |
+
</port>
|
78 |
+
<port id="5" precision="U8">
|
79 |
+
<dim>-1</dim>
|
80 |
+
</port>
|
81 |
+
</output>
|
82 |
+
</layer>
|
83 |
+
<layer id="5" name="StringTensorPack_204239" type="StringTensorPack" version="opset15">
|
84 |
+
<input>
|
85 |
+
<port id="0" precision="I32">
|
86 |
+
<dim>-1</dim>
|
87 |
+
</port>
|
88 |
+
<port id="1" precision="I32">
|
89 |
+
<dim>-1</dim>
|
90 |
+
</port>
|
91 |
+
<port id="2" precision="U8">
|
92 |
+
<dim>-1</dim>
|
93 |
+
</port>
|
94 |
+
</input>
|
95 |
+
<output>
|
96 |
+
<port id="3" precision="STRING" names="string_output">
|
97 |
+
<dim>-1</dim>
|
98 |
+
</port>
|
99 |
+
</output>
|
100 |
+
</layer>
|
101 |
+
<layer id="6" name="Result_204240" type="Result" version="opset1">
|
102 |
+
<input>
|
103 |
+
<port id="0" precision="STRING">
|
104 |
+
<dim>-1</dim>
|
105 |
+
</port>
|
106 |
+
</input>
|
107 |
+
</layer>
|
108 |
+
</layers>
|
109 |
+
<edges>
|
110 |
+
<edge from-layer="0" from-port="0" to-layer="2" to-port="0" />
|
111 |
+
<edge from-layer="1" from-port="0" to-layer="3" to-port="0" />
|
112 |
+
<edge from-layer="2" from-port="1" to-layer="3" to-port="1" />
|
113 |
+
<edge from-layer="3" from-port="2" to-layer="4" to-port="0" />
|
114 |
+
<edge from-layer="3" from-port="3" to-layer="4" to-port="1" />
|
115 |
+
<edge from-layer="3" from-port="4" to-layer="4" to-port="2" />
|
116 |
+
<edge from-layer="4" from-port="3" to-layer="5" to-port="0" />
|
117 |
+
<edge from-layer="4" from-port="4" to-layer="5" to-port="1" />
|
118 |
+
<edge from-layer="4" from-port="5" to-layer="5" to-port="2" />
|
119 |
+
<edge from-layer="5" from-port="3" to-layer="6" to-port="0" />
|
120 |
+
</edges>
|
121 |
+
<rt_info>
|
122 |
+
<add_attention_mask value="True" />
|
123 |
+
<add_prefix_space />
|
124 |
+
<add_special_tokens value="True" />
|
125 |
+
<bos_token_id value="1" />
|
126 |
+
<chat_template value="{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + ' ' + message['content'] + '<|im_end|>' + ' '}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant ' }}{% endif %}" />
|
127 |
+
<clean_up_tokenization_spaces value="False" />
|
128 |
+
<detokenizer_input_type value="i64" />
|
129 |
+
<eos_token_id value="2" />
|
130 |
+
<handle_special_tokens_with_re value="True" />
|
131 |
+
<number_of_inputs value="1" />
|
132 |
+
<openvino_tokenizers_version value="2025.0.0.0-471-7f2ac4f9648" />
|
133 |
+
<openvino_version value="2025.0.0-17908-513dcc5c7b7-releases/2025/0" />
|
134 |
+
<original_tokenizer_class value="<class 'transformers_modules.OpenGVLab.InternVL2-2B.aec61df8c99ba7c81271877485e038a7b823a399.tokenization_internlm2.InternLM2Tokenizer'>" />
|
135 |
+
<pad_token_id value="2" />
|
136 |
+
<sentencepiece_version value="0.2.0" />
|
137 |
+
<skip_special_tokens value="True" />
|
138 |
+
<streaming_detokenizer value="False" />
|
139 |
+
<tiktoken_version value="0.7.0" />
|
140 |
+
<tokenizer_output_type value="i64" />
|
141 |
+
<tokenizers_version value="0.21.0" />
|
142 |
+
<transformers_version value="4.47.0" />
|
143 |
+
<use_max_padding value="False" />
|
144 |
+
<use_sentencepiece_backend value="False" />
|
145 |
+
<utf8_replace_mode value="replace" />
|
146 |
+
<with_detokenizer value="True" />
|
147 |
+
</rt_info>
|
148 |
+
</net>
|
openvino_language_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:716e6314910c1db5a8e71551ff10006f0b12290c47f0bc7fdd1c0aaed0e27b73
|
3 |
+
size 1752278435
|
openvino_language_model.xml
ADDED
The diff for this file is too large to render.
See raw diff
|
|
openvino_text_embeddings_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ebdb511e3d90fc6560bf49883ecead8f05562d83311fdcc806f464b6bed82fc6
|
3 |
+
size 189733654
|
openvino_text_embeddings_model.xml
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<net name="Model6" version="11">
|
3 |
+
<layers>
|
4 |
+
<layer id="0" name="input" type="Parameter" version="opset1">
|
5 |
+
<data shape="?,?" element_type="i64" />
|
6 |
+
<output>
|
7 |
+
<port id="0" precision="I64" names="input">
|
8 |
+
<dim>-1</dim>
|
9 |
+
<dim>-1</dim>
|
10 |
+
</port>
|
11 |
+
</output>
|
12 |
+
</layer>
|
13 |
+
<layer id="1" name="self.weight" type="Const" version="opset1">
|
14 |
+
<data element_type="i8" shape="92553, 2048" offset="0" size="189548544" />
|
15 |
+
<output>
|
16 |
+
<port id="0" precision="I8">
|
17 |
+
<dim>92553</dim>
|
18 |
+
<dim>2048</dim>
|
19 |
+
</port>
|
20 |
+
</output>
|
21 |
+
</layer>
|
22 |
+
<layer id="2" name="Convert_198497" type="Convert" version="opset1">
|
23 |
+
<data destination_type="f16" />
|
24 |
+
<input>
|
25 |
+
<port id="0" precision="I8">
|
26 |
+
<dim>92553</dim>
|
27 |
+
<dim>2048</dim>
|
28 |
+
</port>
|
29 |
+
</input>
|
30 |
+
<output>
|
31 |
+
<port id="1" precision="FP16">
|
32 |
+
<dim>92553</dim>
|
33 |
+
<dim>2048</dim>
|
34 |
+
</port>
|
35 |
+
</output>
|
36 |
+
</layer>
|
37 |
+
<layer id="3" name="self.weight/scale" type="Const" version="opset1">
|
38 |
+
<data element_type="f16" shape="92553, 1" offset="189548544" size="185106" />
|
39 |
+
<output>
|
40 |
+
<port id="0" precision="FP16">
|
41 |
+
<dim>92553</dim>
|
42 |
+
<dim>1</dim>
|
43 |
+
</port>
|
44 |
+
</output>
|
45 |
+
</layer>
|
46 |
+
<layer id="4" name="self.weight/fq_weights_0" type="Multiply" version="opset1">
|
47 |
+
<data auto_broadcast="numpy" />
|
48 |
+
<input>
|
49 |
+
<port id="0" precision="FP16">
|
50 |
+
<dim>92553</dim>
|
51 |
+
<dim>2048</dim>
|
52 |
+
</port>
|
53 |
+
<port id="1" precision="FP16">
|
54 |
+
<dim>92553</dim>
|
55 |
+
<dim>1</dim>
|
56 |
+
</port>
|
57 |
+
</input>
|
58 |
+
<output>
|
59 |
+
<port id="2" precision="FP16">
|
60 |
+
<dim>92553</dim>
|
61 |
+
<dim>2048</dim>
|
62 |
+
</port>
|
63 |
+
</output>
|
64 |
+
</layer>
|
65 |
+
<layer id="5" name="self.weight/fq_weights_0/convert" type="Convert" version="opset1">
|
66 |
+
<data destination_type="f32" />
|
67 |
+
<input>
|
68 |
+
<port id="0" precision="FP16">
|
69 |
+
<dim>92553</dim>
|
70 |
+
<dim>2048</dim>
|
71 |
+
</port>
|
72 |
+
</input>
|
73 |
+
<output>
|
74 |
+
<port id="1" precision="FP32">
|
75 |
+
<dim>92553</dim>
|
76 |
+
<dim>2048</dim>
|
77 |
+
</port>
|
78 |
+
</output>
|
79 |
+
</layer>
|
80 |
+
<layer id="6" name="aten::embedding/Convert" type="Convert" version="opset1">
|
81 |
+
<data destination_type="i32" />
|
82 |
+
<input>
|
83 |
+
<port id="0" precision="I64">
|
84 |
+
<dim>-1</dim>
|
85 |
+
<dim>-1</dim>
|
86 |
+
</port>
|
87 |
+
</input>
|
88 |
+
<output>
|
89 |
+
<port id="1" precision="I32">
|
90 |
+
<dim>-1</dim>
|
91 |
+
<dim>-1</dim>
|
92 |
+
</port>
|
93 |
+
</output>
|
94 |
+
</layer>
|
95 |
+
<layer id="7" name="aten::embedding/Constant" type="Const" version="opset1">
|
96 |
+
<data element_type="i32" shape="" offset="189733650" size="4" />
|
97 |
+
<output>
|
98 |
+
<port id="0" precision="I32" />
|
99 |
+
</output>
|
100 |
+
</layer>
|
101 |
+
<layer id="8" name="aten::embedding/Gather" type="Gather" version="opset8">
|
102 |
+
<data batch_dims="0" />
|
103 |
+
<input>
|
104 |
+
<port id="0" precision="FP32">
|
105 |
+
<dim>92553</dim>
|
106 |
+
<dim>2048</dim>
|
107 |
+
</port>
|
108 |
+
<port id="1" precision="I32">
|
109 |
+
<dim>-1</dim>
|
110 |
+
<dim>-1</dim>
|
111 |
+
</port>
|
112 |
+
<port id="2" precision="I32" />
|
113 |
+
</input>
|
114 |
+
<output>
|
115 |
+
<port id="3" precision="FP32" names="inputs_embeds">
|
116 |
+
<dim>-1</dim>
|
117 |
+
<dim>-1</dim>
|
118 |
+
<dim>2048</dim>
|
119 |
+
</port>
|
120 |
+
</output>
|
121 |
+
</layer>
|
122 |
+
<layer id="9" name="Result_172414" type="Result" version="opset1">
|
123 |
+
<input>
|
124 |
+
<port id="0" precision="FP32">
|
125 |
+
<dim>-1</dim>
|
126 |
+
<dim>-1</dim>
|
127 |
+
<dim>2048</dim>
|
128 |
+
</port>
|
129 |
+
</input>
|
130 |
+
</layer>
|
131 |
+
</layers>
|
132 |
+
<edges>
|
133 |
+
<edge from-layer="0" from-port="0" to-layer="6" to-port="0" />
|
134 |
+
<edge from-layer="1" from-port="0" to-layer="2" to-port="0" />
|
135 |
+
<edge from-layer="2" from-port="1" to-layer="4" to-port="0" />
|
136 |
+
<edge from-layer="3" from-port="0" to-layer="4" to-port="1" />
|
137 |
+
<edge from-layer="4" from-port="2" to-layer="5" to-port="0" />
|
138 |
+
<edge from-layer="5" from-port="1" to-layer="8" to-port="0" />
|
139 |
+
<edge from-layer="6" from-port="1" to-layer="8" to-port="1" />
|
140 |
+
<edge from-layer="7" from-port="0" to-layer="8" to-port="2" />
|
141 |
+
<edge from-layer="8" from-port="3" to-layer="9" to-port="0" />
|
142 |
+
</edges>
|
143 |
+
<rt_info>
|
144 |
+
<Runtime_version value="2025.0.0-17908-513dcc5c7b7-releases/2025/0" />
|
145 |
+
<conversion_parameters>
|
146 |
+
<framework value="pytorch" />
|
147 |
+
<is_python_object value="True" />
|
148 |
+
</conversion_parameters>
|
149 |
+
<nncf>
|
150 |
+
<friendly_names_were_updated value="True" />
|
151 |
+
<weight_compression>
|
152 |
+
<advanced_parameters value="{'statistics_path': None, 'awq_params': {'subset_size': 32, 'percent_to_apply': 0.002, 'alpha_min': 0.0, 'alpha_max': 1.0, 'steps': 100}, 'scale_estimation_params': {'subset_size': 64, 'initial_steps': 5, 'scale_steps': 5, 'weight_penalty': -1.0}, 'gptq_params': {'damp_percent': 0.1, 'block_size': 128, 'subset_size': 128}, 'lora_correction_params': {'adapter_rank': 8, 'num_iterations': 3, 'apply_regularization': True, 'subset_size': 128, 'use_int8_adapters': True}}" />
|
153 |
+
<all_layers value="False" />
|
154 |
+
<awq value="False" />
|
155 |
+
<backup_mode value="int8_asym" />
|
156 |
+
<gptq value="False" />
|
157 |
+
<group_size value="-1" />
|
158 |
+
<ignored_scope value="[]" />
|
159 |
+
<lora_correction value="False" />
|
160 |
+
<mode value="int8_sym" />
|
161 |
+
<ratio value="1.0" />
|
162 |
+
<scale_estimation value="False" />
|
163 |
+
<sensitivity_metric value="weight_quantization_error" />
|
164 |
+
</weight_compression>
|
165 |
+
</nncf>
|
166 |
+
<optimum>
|
167 |
+
<optimum_intel_version value="1.22.0.dev0+2b0d642" />
|
168 |
+
<optimum_version value="1.24.0.dev0" />
|
169 |
+
<pytorch_version value="2.5.1+cpu" />
|
170 |
+
<transformers_version value="4.47.0" />
|
171 |
+
</optimum>
|
172 |
+
</rt_info>
|
173 |
+
</net>
|
openvino_tokenizer.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9fad8c0beff6594baa96a3708212fa756d46ac7237933c590c3565dc120cb4eb
|
3 |
+
size 1478345
|
openvino_tokenizer.xml
ADDED
@@ -0,0 +1,1025 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<net name="tokenizer" version="11">
|
3 |
+
<layers>
|
4 |
+
<layer id="0" name="string_input" type="Parameter" version="opset1">
|
5 |
+
<data shape="?" element_type="string" />
|
6 |
+
<output>
|
7 |
+
<port id="0" precision="STRING" names="string_input">
|
8 |
+
<dim>-1</dim>
|
9 |
+
</port>
|
10 |
+
</output>
|
11 |
+
</layer>
|
12 |
+
<layer id="1" name="Constant_204214" type="Const" version="opset1">
|
13 |
+
<data element_type="i32" shape="" offset="0" size="4" />
|
14 |
+
<output>
|
15 |
+
<port id="0" precision="I32" />
|
16 |
+
</output>
|
17 |
+
</layer>
|
18 |
+
<layer id="2" name="Constant_204155" type="Const" version="opset1">
|
19 |
+
<data element_type="u8" shape="1477889" offset="4" size="1477889" />
|
20 |
+
<output>
|
21 |
+
<port id="0" precision="U8">
|
22 |
+
<dim>1477889</dim>
|
23 |
+
</port>
|
24 |
+
</output>
|
25 |
+
</layer>
|
26 |
+
<layer id="3" name="Constant_204159" type="Const" version="opset1">
|
27 |
+
<data element_type="i32" shape="18" offset="1477893" size="72" />
|
28 |
+
<output>
|
29 |
+
<port id="0" precision="I32">
|
30 |
+
<dim>18</dim>
|
31 |
+
</port>
|
32 |
+
</output>
|
33 |
+
</layer>
|
34 |
+
<layer id="4" name="Constant_204161" type="Const" version="opset1">
|
35 |
+
<data element_type="i32" shape="18" offset="1477965" size="72" />
|
36 |
+
<output>
|
37 |
+
<port id="0" precision="I32">
|
38 |
+
<dim>18</dim>
|
39 |
+
</port>
|
40 |
+
</output>
|
41 |
+
</layer>
|
42 |
+
<layer id="5" name="Constant_204163" type="Const" version="opset1">
|
43 |
+
<data element_type="u8" shape="148" offset="1478037" size="148" />
|
44 |
+
<output>
|
45 |
+
<port id="0" precision="U8">
|
46 |
+
<dim>148</dim>
|
47 |
+
</port>
|
48 |
+
</output>
|
49 |
+
</layer>
|
50 |
+
<layer id="6" name="Constant_204164" type="Const" version="opset1">
|
51 |
+
<data element_type="i32" shape="18" offset="1478185" size="72" />
|
52 |
+
<output>
|
53 |
+
<port id="0" precision="I32">
|
54 |
+
<dim>18</dim>
|
55 |
+
</port>
|
56 |
+
</output>
|
57 |
+
</layer>
|
58 |
+
<layer id="7" name="SentencepieceTokenizer_204165" type="SentencepieceTokenizer" version="extension">
|
59 |
+
<data nbest_size="0" alpha="0" add_bos="false" add_eos="false" reverse="false" />
|
60 |
+
<input>
|
61 |
+
<port id="0" precision="U8">
|
62 |
+
<dim>1477889</dim>
|
63 |
+
</port>
|
64 |
+
<port id="1" precision="STRING">
|
65 |
+
<dim>-1</dim>
|
66 |
+
</port>
|
67 |
+
<port id="2" precision="I32">
|
68 |
+
<dim>18</dim>
|
69 |
+
</port>
|
70 |
+
<port id="3" precision="I32">
|
71 |
+
<dim>18</dim>
|
72 |
+
</port>
|
73 |
+
<port id="4" precision="U8">
|
74 |
+
<dim>148</dim>
|
75 |
+
</port>
|
76 |
+
<port id="5" precision="I32">
|
77 |
+
<dim>18</dim>
|
78 |
+
</port>
|
79 |
+
</input>
|
80 |
+
<output>
|
81 |
+
<port id="6" precision="I64">
|
82 |
+
<dim>-1</dim>
|
83 |
+
<dim>2</dim>
|
84 |
+
</port>
|
85 |
+
<port id="7" precision="I32">
|
86 |
+
<dim>-1</dim>
|
87 |
+
</port>
|
88 |
+
<port id="8" precision="I64">
|
89 |
+
<dim>2</dim>
|
90 |
+
</port>
|
91 |
+
</output>
|
92 |
+
</layer>
|
93 |
+
<layer id="8" name="Constant_204174" type="Const" version="opset1">
|
94 |
+
<data element_type="i64" shape="2" offset="1478257" size="16" />
|
95 |
+
<output>
|
96 |
+
<port id="0" precision="I64">
|
97 |
+
<dim>2</dim>
|
98 |
+
</port>
|
99 |
+
</output>
|
100 |
+
</layer>
|
101 |
+
<layer id="9" name="Convert_204175" type="Convert" version="opset1">
|
102 |
+
<data destination_type="i64" />
|
103 |
+
<input>
|
104 |
+
<port id="0" precision="I64">
|
105 |
+
<dim>2</dim>
|
106 |
+
</port>
|
107 |
+
</input>
|
108 |
+
<output>
|
109 |
+
<port id="1" precision="I64">
|
110 |
+
<dim>2</dim>
|
111 |
+
</port>
|
112 |
+
</output>
|
113 |
+
</layer>
|
114 |
+
<layer id="10" name="Add_204176" type="Add" version="opset1">
|
115 |
+
<data auto_broadcast="numpy" />
|
116 |
+
<input>
|
117 |
+
<port id="0" precision="I64">
|
118 |
+
<dim>2</dim>
|
119 |
+
</port>
|
120 |
+
<port id="1" precision="I64">
|
121 |
+
<dim>2</dim>
|
122 |
+
</port>
|
123 |
+
</input>
|
124 |
+
<output>
|
125 |
+
<port id="2" precision="I64">
|
126 |
+
<dim>2</dim>
|
127 |
+
</port>
|
128 |
+
</output>
|
129 |
+
</layer>
|
130 |
+
<layer id="11" name="Constant_204181" type="Const" version="opset1">
|
131 |
+
<data element_type="i64" shape="1" offset="1478273" size="8" />
|
132 |
+
<output>
|
133 |
+
<port id="0" precision="I64">
|
134 |
+
<dim>1</dim>
|
135 |
+
</port>
|
136 |
+
</output>
|
137 |
+
</layer>
|
138 |
+
<layer id="12" name="Constant_204182" type="Const" version="opset1">
|
139 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
140 |
+
<output>
|
141 |
+
<port id="0" precision="I64">
|
142 |
+
<dim>1</dim>
|
143 |
+
</port>
|
144 |
+
</output>
|
145 |
+
</layer>
|
146 |
+
<layer id="13" name="Constant_204183" type="Const" version="opset1">
|
147 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
148 |
+
<output>
|
149 |
+
<port id="0" precision="I64">
|
150 |
+
<dim>1</dim>
|
151 |
+
</port>
|
152 |
+
</output>
|
153 |
+
</layer>
|
154 |
+
<layer id="14" name="Constant_204185" type="Const" version="opset1">
|
155 |
+
<data element_type="i64" shape="1" offset="1478273" size="8" />
|
156 |
+
<output>
|
157 |
+
<port id="0" precision="I64">
|
158 |
+
<dim>1</dim>
|
159 |
+
</port>
|
160 |
+
</output>
|
161 |
+
</layer>
|
162 |
+
<layer id="15" name="Slice_204184" type="Slice" version="opset8">
|
163 |
+
<input>
|
164 |
+
<port id="0" precision="I64">
|
165 |
+
<dim>2</dim>
|
166 |
+
</port>
|
167 |
+
<port id="1" precision="I64">
|
168 |
+
<dim>1</dim>
|
169 |
+
</port>
|
170 |
+
<port id="2" precision="I64">
|
171 |
+
<dim>1</dim>
|
172 |
+
</port>
|
173 |
+
<port id="3" precision="I64">
|
174 |
+
<dim>1</dim>
|
175 |
+
</port>
|
176 |
+
<port id="4" precision="I64">
|
177 |
+
<dim>1</dim>
|
178 |
+
</port>
|
179 |
+
</input>
|
180 |
+
<output>
|
181 |
+
<port id="5" precision="I64">
|
182 |
+
<dim>1</dim>
|
183 |
+
</port>
|
184 |
+
</output>
|
185 |
+
</layer>
|
186 |
+
<layer id="16" name="Constant_204215" type="Const" version="opset1">
|
187 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
188 |
+
<output>
|
189 |
+
<port id="0" precision="I64">
|
190 |
+
<dim>1</dim>
|
191 |
+
</port>
|
192 |
+
</output>
|
193 |
+
</layer>
|
194 |
+
<layer id="17" name="Concat_204216" type="Concat" version="opset1">
|
195 |
+
<data axis="0" />
|
196 |
+
<input>
|
197 |
+
<port id="0" precision="I64">
|
198 |
+
<dim>1</dim>
|
199 |
+
</port>
|
200 |
+
<port id="1" precision="I64">
|
201 |
+
<dim>1</dim>
|
202 |
+
</port>
|
203 |
+
</input>
|
204 |
+
<output>
|
205 |
+
<port id="2" precision="I64">
|
206 |
+
<dim>2</dim>
|
207 |
+
</port>
|
208 |
+
</output>
|
209 |
+
</layer>
|
210 |
+
<layer id="18" name="Broadcast_204217" type="Broadcast" version="opset3">
|
211 |
+
<data mode="numpy" />
|
212 |
+
<input>
|
213 |
+
<port id="0" precision="I32" />
|
214 |
+
<port id="1" precision="I64">
|
215 |
+
<dim>2</dim>
|
216 |
+
</port>
|
217 |
+
</input>
|
218 |
+
<output>
|
219 |
+
<port id="2" precision="I32">
|
220 |
+
<dim>-1</dim>
|
221 |
+
<dim>1</dim>
|
222 |
+
</port>
|
223 |
+
</output>
|
224 |
+
</layer>
|
225 |
+
<layer id="19" name="Constant_204166" type="Const" version="opset1">
|
226 |
+
<data element_type="i32" shape="" offset="1478289" size="4" />
|
227 |
+
<output>
|
228 |
+
<port id="0" precision="I32" />
|
229 |
+
</output>
|
230 |
+
</layer>
|
231 |
+
<layer id="20" name="Broadcast_204167" type="Broadcast" version="opset3">
|
232 |
+
<data mode="numpy" />
|
233 |
+
<input>
|
234 |
+
<port id="0" precision="I32" />
|
235 |
+
<port id="1" precision="I64">
|
236 |
+
<dim>2</dim>
|
237 |
+
</port>
|
238 |
+
</input>
|
239 |
+
<output>
|
240 |
+
<port id="2" precision="I32">
|
241 |
+
<dim>-1</dim>
|
242 |
+
<dim>-1</dim>
|
243 |
+
</port>
|
244 |
+
</output>
|
245 |
+
</layer>
|
246 |
+
<layer id="21" name="Constant_204168" type="Const" version="opset1">
|
247 |
+
<data element_type="i32" shape="" offset="0" size="4" />
|
248 |
+
<output>
|
249 |
+
<port id="0" precision="I32" />
|
250 |
+
</output>
|
251 |
+
</layer>
|
252 |
+
<layer id="22" name="ShapeOf_204169" type="ShapeOf" version="opset3">
|
253 |
+
<data output_type="i64" />
|
254 |
+
<input>
|
255 |
+
<port id="0" precision="I32">
|
256 |
+
<dim>-1</dim>
|
257 |
+
</port>
|
258 |
+
</input>
|
259 |
+
<output>
|
260 |
+
<port id="1" precision="I64">
|
261 |
+
<dim>1</dim>
|
262 |
+
</port>
|
263 |
+
</output>
|
264 |
+
</layer>
|
265 |
+
<layer id="23" name="Broadcast_204170" type="Broadcast" version="opset3">
|
266 |
+
<data mode="numpy" />
|
267 |
+
<input>
|
268 |
+
<port id="0" precision="I32" />
|
269 |
+
<port id="1" precision="I64">
|
270 |
+
<dim>1</dim>
|
271 |
+
</port>
|
272 |
+
</input>
|
273 |
+
<output>
|
274 |
+
<port id="2" precision="I32">
|
275 |
+
<dim>-1</dim>
|
276 |
+
</port>
|
277 |
+
</output>
|
278 |
+
</layer>
|
279 |
+
<layer id="24" name="ScatterNDUpdate_204173" type="ScatterNDUpdate" version="opset4">
|
280 |
+
<input>
|
281 |
+
<port id="0" precision="I32">
|
282 |
+
<dim>-1</dim>
|
283 |
+
<dim>-1</dim>
|
284 |
+
</port>
|
285 |
+
<port id="1" precision="I64">
|
286 |
+
<dim>-1</dim>
|
287 |
+
<dim>2</dim>
|
288 |
+
</port>
|
289 |
+
<port id="2" precision="I32">
|
290 |
+
<dim>-1</dim>
|
291 |
+
</port>
|
292 |
+
</input>
|
293 |
+
<output>
|
294 |
+
<port id="3" precision="I32">
|
295 |
+
<dim>-1</dim>
|
296 |
+
<dim>-1</dim>
|
297 |
+
</port>
|
298 |
+
</output>
|
299 |
+
</layer>
|
300 |
+
<layer id="25" name="Concat_204218" type="Concat" version="opset1">
|
301 |
+
<data axis="1" />
|
302 |
+
<input>
|
303 |
+
<port id="0" precision="I32">
|
304 |
+
<dim>-1</dim>
|
305 |
+
<dim>1</dim>
|
306 |
+
</port>
|
307 |
+
<port id="1" precision="I32">
|
308 |
+
<dim>-1</dim>
|
309 |
+
<dim>-1</dim>
|
310 |
+
</port>
|
311 |
+
</input>
|
312 |
+
<output>
|
313 |
+
<port id="2" precision="I32">
|
314 |
+
<dim>-1</dim>
|
315 |
+
<dim>-1</dim>
|
316 |
+
</port>
|
317 |
+
</output>
|
318 |
+
</layer>
|
319 |
+
<layer id="26" name="Constant_204227" type="Const" version="opset1">
|
320 |
+
<data element_type="i64" shape="1" offset="1478273" size="8" />
|
321 |
+
<output>
|
322 |
+
<port id="0" precision="I64">
|
323 |
+
<dim>1</dim>
|
324 |
+
</port>
|
325 |
+
</output>
|
326 |
+
</layer>
|
327 |
+
<layer id="27" name="Constant_204228" type="Const" version="opset1">
|
328 |
+
<data element_type="i64" shape="1" offset="1478293" size="8" />
|
329 |
+
<output>
|
330 |
+
<port id="0" precision="I64">
|
331 |
+
<dim>1</dim>
|
332 |
+
</port>
|
333 |
+
</output>
|
334 |
+
</layer>
|
335 |
+
<layer id="28" name="Constant_204229" type="Const" version="opset1">
|
336 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
337 |
+
<output>
|
338 |
+
<port id="0" precision="I64">
|
339 |
+
<dim>1</dim>
|
340 |
+
</port>
|
341 |
+
</output>
|
342 |
+
</layer>
|
343 |
+
<layer id="29" name="Constant_204230" type="Const" version="opset1">
|
344 |
+
<data element_type="i64" shape="1" offset="1478301" size="8" />
|
345 |
+
<output>
|
346 |
+
<port id="0" precision="I64">
|
347 |
+
<dim>1</dim>
|
348 |
+
</port>
|
349 |
+
</output>
|
350 |
+
</layer>
|
351 |
+
<layer id="30" name="Slice_204231" type="Slice" version="opset8">
|
352 |
+
<input>
|
353 |
+
<port id="0" precision="I32">
|
354 |
+
<dim>-1</dim>
|
355 |
+
<dim>-1</dim>
|
356 |
+
</port>
|
357 |
+
<port id="1" precision="I64">
|
358 |
+
<dim>1</dim>
|
359 |
+
</port>
|
360 |
+
<port id="2" precision="I64">
|
361 |
+
<dim>1</dim>
|
362 |
+
</port>
|
363 |
+
<port id="3" precision="I64">
|
364 |
+
<dim>1</dim>
|
365 |
+
</port>
|
366 |
+
<port id="4" precision="I64">
|
367 |
+
<dim>1</dim>
|
368 |
+
</port>
|
369 |
+
</input>
|
370 |
+
<output>
|
371 |
+
<port id="5" precision="I32">
|
372 |
+
<dim>-1</dim>
|
373 |
+
<dim>-1</dim>
|
374 |
+
</port>
|
375 |
+
</output>
|
376 |
+
</layer>
|
377 |
+
<layer id="31" name="Slice_204231.0" type="Convert" version="opset1">
|
378 |
+
<data destination_type="i64" />
|
379 |
+
<input>
|
380 |
+
<port id="0" precision="I32">
|
381 |
+
<dim>-1</dim>
|
382 |
+
<dim>-1</dim>
|
383 |
+
</port>
|
384 |
+
</input>
|
385 |
+
<output>
|
386 |
+
<port id="1" precision="I64" names="attention_mask">
|
387 |
+
<dim>-1</dim>
|
388 |
+
<dim>-1</dim>
|
389 |
+
</port>
|
390 |
+
</output>
|
391 |
+
</layer>
|
392 |
+
<layer id="33" name="Constant_204219" type="Const" version="opset1">
|
393 |
+
<data element_type="i32" shape="" offset="1478309" size="4" />
|
394 |
+
<output>
|
395 |
+
<port id="0" precision="I32" />
|
396 |
+
</output>
|
397 |
+
</layer>
|
398 |
+
<layer id="34" name="Broadcast_204220" type="Broadcast" version="opset3">
|
399 |
+
<data mode="bidirectional" />
|
400 |
+
<input>
|
401 |
+
<port id="0" precision="I32" />
|
402 |
+
<port id="1" precision="I64">
|
403 |
+
<dim>2</dim>
|
404 |
+
</port>
|
405 |
+
</input>
|
406 |
+
<output>
|
407 |
+
<port id="2" precision="I32">
|
408 |
+
<dim>-1</dim>
|
409 |
+
<dim>-1</dim>
|
410 |
+
</port>
|
411 |
+
</output>
|
412 |
+
</layer>
|
413 |
+
<layer id="35" name="Add_204209" type="Add" version="opset1">
|
414 |
+
<data auto_broadcast="numpy" />
|
415 |
+
<input>
|
416 |
+
<port id="0" precision="I64">
|
417 |
+
<dim>-1</dim>
|
418 |
+
<dim>2</dim>
|
419 |
+
</port>
|
420 |
+
<port id="1" precision="I64">
|
421 |
+
<dim>2</dim>
|
422 |
+
</port>
|
423 |
+
</input>
|
424 |
+
<output>
|
425 |
+
<port id="2" precision="I64">
|
426 |
+
<dim>-1</dim>
|
427 |
+
<dim>2</dim>
|
428 |
+
</port>
|
429 |
+
</output>
|
430 |
+
</layer>
|
431 |
+
<layer id="36" name="Constant_204196" type="Const" version="opset1">
|
432 |
+
<data element_type="i64" shape="" offset="1478273" size="8" />
|
433 |
+
<output>
|
434 |
+
<port id="0" precision="I64" />
|
435 |
+
</output>
|
436 |
+
</layer>
|
437 |
+
<layer id="37" name="Constant_204178" type="Const" version="opset1">
|
438 |
+
<data element_type="i64" shape="" offset="1478273" size="8" />
|
439 |
+
<output>
|
440 |
+
<port id="0" precision="I64" />
|
441 |
+
</output>
|
442 |
+
</layer>
|
443 |
+
<layer id="38" name="Constant_204179" type="Const" version="opset1">
|
444 |
+
<data element_type="i64" shape="" offset="1478273" size="8" />
|
445 |
+
<output>
|
446 |
+
<port id="0" precision="I64" />
|
447 |
+
</output>
|
448 |
+
</layer>
|
449 |
+
<layer id="39" name="Gather_204180" type="Gather" version="opset8">
|
450 |
+
<data batch_dims="0" />
|
451 |
+
<input>
|
452 |
+
<port id="0" precision="I64">
|
453 |
+
<dim>2</dim>
|
454 |
+
</port>
|
455 |
+
<port id="1" precision="I64" />
|
456 |
+
<port id="2" precision="I64" />
|
457 |
+
</input>
|
458 |
+
<output>
|
459 |
+
<port id="3" precision="I64" />
|
460 |
+
</output>
|
461 |
+
</layer>
|
462 |
+
<layer id="40" name="Constant_204197" type="Const" version="opset1">
|
463 |
+
<data element_type="i64" shape="" offset="1478281" size="8" />
|
464 |
+
<output>
|
465 |
+
<port id="0" precision="I64" />
|
466 |
+
</output>
|
467 |
+
</layer>
|
468 |
+
<layer id="41" name="Range_204198" type="Range" version="opset4">
|
469 |
+
<data output_type="i64" />
|
470 |
+
<input>
|
471 |
+
<port id="0" precision="I64" />
|
472 |
+
<port id="1" precision="I64" />
|
473 |
+
<port id="2" precision="I64" />
|
474 |
+
</input>
|
475 |
+
<output>
|
476 |
+
<port id="3" precision="I64">
|
477 |
+
<dim>-1</dim>
|
478 |
+
</port>
|
479 |
+
</output>
|
480 |
+
</layer>
|
481 |
+
<layer id="42" name="Constant_204199" type="Const" version="opset1">
|
482 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
483 |
+
<output>
|
484 |
+
<port id="0" precision="I64">
|
485 |
+
<dim>1</dim>
|
486 |
+
</port>
|
487 |
+
</output>
|
488 |
+
</layer>
|
489 |
+
<layer id="43" name="Concat_204200" type="Concat" version="opset1">
|
490 |
+
<data axis="0" />
|
491 |
+
<input>
|
492 |
+
<port id="0" precision="I64">
|
493 |
+
<dim>1</dim>
|
494 |
+
</port>
|
495 |
+
<port id="1" precision="I64">
|
496 |
+
<dim>1</dim>
|
497 |
+
</port>
|
498 |
+
</input>
|
499 |
+
<output>
|
500 |
+
<port id="2" precision="I64">
|
501 |
+
<dim>2</dim>
|
502 |
+
</port>
|
503 |
+
</output>
|
504 |
+
</layer>
|
505 |
+
<layer id="44" name="Broadcast_204201" type="Broadcast" version="opset3">
|
506 |
+
<data mode="bidirectional" />
|
507 |
+
<input>
|
508 |
+
<port id="0" precision="I64">
|
509 |
+
<dim>-1</dim>
|
510 |
+
</port>
|
511 |
+
<port id="1" precision="I64">
|
512 |
+
<dim>2</dim>
|
513 |
+
</port>
|
514 |
+
</input>
|
515 |
+
<output>
|
516 |
+
<port id="2" precision="I64">
|
517 |
+
<dim>1</dim>
|
518 |
+
<dim>-1</dim>
|
519 |
+
</port>
|
520 |
+
</output>
|
521 |
+
</layer>
|
522 |
+
<layer id="45" name="Constant_204202" type="Const" version="opset1">
|
523 |
+
<data element_type="i64" shape="2" offset="1478313" size="16" />
|
524 |
+
<output>
|
525 |
+
<port id="0" precision="I64">
|
526 |
+
<dim>2</dim>
|
527 |
+
</port>
|
528 |
+
</output>
|
529 |
+
</layer>
|
530 |
+
<layer id="46" name="Transpose_204203" type="Transpose" version="opset1">
|
531 |
+
<input>
|
532 |
+
<port id="0" precision="I64">
|
533 |
+
<dim>1</dim>
|
534 |
+
<dim>-1</dim>
|
535 |
+
</port>
|
536 |
+
<port id="1" precision="I64">
|
537 |
+
<dim>2</dim>
|
538 |
+
</port>
|
539 |
+
</input>
|
540 |
+
<output>
|
541 |
+
<port id="2" precision="I64">
|
542 |
+
<dim>-1</dim>
|
543 |
+
<dim>1</dim>
|
544 |
+
</port>
|
545 |
+
</output>
|
546 |
+
</layer>
|
547 |
+
<layer id="47" name="Constant_204204" type="Const" version="opset1">
|
548 |
+
<data element_type="i64" shape="2" offset="1478329" size="16" />
|
549 |
+
<output>
|
550 |
+
<port id="0" precision="I64">
|
551 |
+
<dim>2</dim>
|
552 |
+
</port>
|
553 |
+
</output>
|
554 |
+
</layer>
|
555 |
+
<layer id="48" name="Reshape_204205" type="Reshape" version="opset1">
|
556 |
+
<data special_zero="false" />
|
557 |
+
<input>
|
558 |
+
<port id="0" precision="I64">
|
559 |
+
<dim>-1</dim>
|
560 |
+
<dim>1</dim>
|
561 |
+
</port>
|
562 |
+
<port id="1" precision="I64">
|
563 |
+
<dim>2</dim>
|
564 |
+
</port>
|
565 |
+
</input>
|
566 |
+
<output>
|
567 |
+
<port id="2" precision="I64">
|
568 |
+
<dim>-1</dim>
|
569 |
+
<dim>1</dim>
|
570 |
+
</port>
|
571 |
+
</output>
|
572 |
+
</layer>
|
573 |
+
<layer id="49" name="Constant_204192" type="Const" version="opset1">
|
574 |
+
<data element_type="i64" shape="" offset="1478273" size="8" />
|
575 |
+
<output>
|
576 |
+
<port id="0" precision="I64" />
|
577 |
+
</output>
|
578 |
+
</layer>
|
579 |
+
<layer id="50" name="Constant_204193" type="Const" version="opset1">
|
580 |
+
<data element_type="i64" shape="" offset="1478281" size="8" />
|
581 |
+
<output>
|
582 |
+
<port id="0" precision="I64" />
|
583 |
+
</output>
|
584 |
+
</layer>
|
585 |
+
<layer id="51" name="Constant_204194" type="Const" version="opset1">
|
586 |
+
<data element_type="i64" shape="" offset="1478281" size="8" />
|
587 |
+
<output>
|
588 |
+
<port id="0" precision="I64" />
|
589 |
+
</output>
|
590 |
+
</layer>
|
591 |
+
<layer id="52" name="Range_204195" type="Range" version="opset4">
|
592 |
+
<data output_type="i64" />
|
593 |
+
<input>
|
594 |
+
<port id="0" precision="I64" />
|
595 |
+
<port id="1" precision="I64" />
|
596 |
+
<port id="2" precision="I64" />
|
597 |
+
</input>
|
598 |
+
<output>
|
599 |
+
<port id="3" precision="I64">
|
600 |
+
<dim>1</dim>
|
601 |
+
</port>
|
602 |
+
</output>
|
603 |
+
</layer>
|
604 |
+
<layer id="53" name="Constant_204206" type="Const" version="opset1">
|
605 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
606 |
+
<output>
|
607 |
+
<port id="0" precision="I64">
|
608 |
+
<dim>1</dim>
|
609 |
+
</port>
|
610 |
+
</output>
|
611 |
+
</layer>
|
612 |
+
<layer id="54" name="Concat_204207" type="Concat" version="opset1">
|
613 |
+
<data axis="0" />
|
614 |
+
<input>
|
615 |
+
<port id="0" precision="I64">
|
616 |
+
<dim>1</dim>
|
617 |
+
</port>
|
618 |
+
<port id="1" precision="I64">
|
619 |
+
<dim>1</dim>
|
620 |
+
</port>
|
621 |
+
</input>
|
622 |
+
<output>
|
623 |
+
<port id="2" precision="I64">
|
624 |
+
<dim>2</dim>
|
625 |
+
</port>
|
626 |
+
</output>
|
627 |
+
</layer>
|
628 |
+
<layer id="55" name="Broadcast_204208" type="Broadcast" version="opset3">
|
629 |
+
<data mode="bidirectional" />
|
630 |
+
<input>
|
631 |
+
<port id="0" precision="I64">
|
632 |
+
<dim>1</dim>
|
633 |
+
</port>
|
634 |
+
<port id="1" precision="I64">
|
635 |
+
<dim>2</dim>
|
636 |
+
</port>
|
637 |
+
</input>
|
638 |
+
<output>
|
639 |
+
<port id="2" precision="I64">
|
640 |
+
<dim>-1</dim>
|
641 |
+
<dim>1</dim>
|
642 |
+
</port>
|
643 |
+
</output>
|
644 |
+
</layer>
|
645 |
+
<layer id="56" name="Constant_204210" type="Const" version="opset1">
|
646 |
+
<data element_type="i64" shape="2" offset="1478329" size="16" />
|
647 |
+
<output>
|
648 |
+
<port id="0" precision="I64">
|
649 |
+
<dim>2</dim>
|
650 |
+
</port>
|
651 |
+
</output>
|
652 |
+
</layer>
|
653 |
+
<layer id="57" name="Reshape_204211" type="Reshape" version="opset1">
|
654 |
+
<data special_zero="false" />
|
655 |
+
<input>
|
656 |
+
<port id="0" precision="I64">
|
657 |
+
<dim>-1</dim>
|
658 |
+
<dim>1</dim>
|
659 |
+
</port>
|
660 |
+
<port id="1" precision="I64">
|
661 |
+
<dim>2</dim>
|
662 |
+
</port>
|
663 |
+
</input>
|
664 |
+
<output>
|
665 |
+
<port id="2" precision="I64">
|
666 |
+
<dim>-1</dim>
|
667 |
+
<dim>1</dim>
|
668 |
+
</port>
|
669 |
+
</output>
|
670 |
+
</layer>
|
671 |
+
<layer id="58" name="Concat_204212" type="Concat" version="opset1">
|
672 |
+
<data axis="1" />
|
673 |
+
<input>
|
674 |
+
<port id="0" precision="I64">
|
675 |
+
<dim>-1</dim>
|
676 |
+
<dim>1</dim>
|
677 |
+
</port>
|
678 |
+
<port id="1" precision="I64">
|
679 |
+
<dim>-1</dim>
|
680 |
+
<dim>1</dim>
|
681 |
+
</port>
|
682 |
+
</input>
|
683 |
+
<output>
|
684 |
+
<port id="2" precision="I64">
|
685 |
+
<dim>-1</dim>
|
686 |
+
<dim>2</dim>
|
687 |
+
</port>
|
688 |
+
</output>
|
689 |
+
</layer>
|
690 |
+
<layer id="59" name="Concat_204213" type="Concat" version="opset1">
|
691 |
+
<data axis="0" />
|
692 |
+
<input>
|
693 |
+
<port id="0" precision="I64">
|
694 |
+
<dim>-1</dim>
|
695 |
+
<dim>2</dim>
|
696 |
+
</port>
|
697 |
+
<port id="1" precision="I64">
|
698 |
+
<dim>-1</dim>
|
699 |
+
<dim>2</dim>
|
700 |
+
</port>
|
701 |
+
</input>
|
702 |
+
<output>
|
703 |
+
<port id="2" precision="I64">
|
704 |
+
<dim>-1</dim>
|
705 |
+
<dim>2</dim>
|
706 |
+
</port>
|
707 |
+
</output>
|
708 |
+
</layer>
|
709 |
+
<layer id="60" name="Constant_204177" type="Const" version="opset1">
|
710 |
+
<data element_type="i32" shape="1, 1" offset="0" size="4" />
|
711 |
+
<output>
|
712 |
+
<port id="0" precision="I32">
|
713 |
+
<dim>1</dim>
|
714 |
+
<dim>1</dim>
|
715 |
+
</port>
|
716 |
+
</output>
|
717 |
+
</layer>
|
718 |
+
<layer id="61" name="Constant_204186" type="Const" version="opset1">
|
719 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
720 |
+
<output>
|
721 |
+
<port id="0" precision="I64">
|
722 |
+
<dim>1</dim>
|
723 |
+
</port>
|
724 |
+
</output>
|
725 |
+
</layer>
|
726 |
+
<layer id="62" name="Concat_204187" type="Concat" version="opset1">
|
727 |
+
<data axis="0" />
|
728 |
+
<input>
|
729 |
+
<port id="0" precision="I64">
|
730 |
+
<dim>1</dim>
|
731 |
+
</port>
|
732 |
+
<port id="1" precision="I64">
|
733 |
+
<dim>1</dim>
|
734 |
+
</port>
|
735 |
+
</input>
|
736 |
+
<output>
|
737 |
+
<port id="2" precision="I64">
|
738 |
+
<dim>2</dim>
|
739 |
+
</port>
|
740 |
+
</output>
|
741 |
+
</layer>
|
742 |
+
<layer id="63" name="Broadcast_204188" type="Broadcast" version="opset3">
|
743 |
+
<data mode="bidirectional" />
|
744 |
+
<input>
|
745 |
+
<port id="0" precision="I32">
|
746 |
+
<dim>1</dim>
|
747 |
+
<dim>1</dim>
|
748 |
+
</port>
|
749 |
+
<port id="1" precision="I64">
|
750 |
+
<dim>2</dim>
|
751 |
+
</port>
|
752 |
+
</input>
|
753 |
+
<output>
|
754 |
+
<port id="2" precision="I32">
|
755 |
+
<dim>-1</dim>
|
756 |
+
<dim>1</dim>
|
757 |
+
</port>
|
758 |
+
</output>
|
759 |
+
</layer>
|
760 |
+
<layer id="64" name="Constant_204189" type="Const" version="opset1">
|
761 |
+
<data element_type="i64" shape="1" offset="1478301" size="8" />
|
762 |
+
<output>
|
763 |
+
<port id="0" precision="I64">
|
764 |
+
<dim>1</dim>
|
765 |
+
</port>
|
766 |
+
</output>
|
767 |
+
</layer>
|
768 |
+
<layer id="65" name="Reshape_204190" type="Reshape" version="opset1">
|
769 |
+
<data special_zero="false" />
|
770 |
+
<input>
|
771 |
+
<port id="0" precision="I32">
|
772 |
+
<dim>-1</dim>
|
773 |
+
<dim>1</dim>
|
774 |
+
</port>
|
775 |
+
<port id="1" precision="I64">
|
776 |
+
<dim>1</dim>
|
777 |
+
</port>
|
778 |
+
</input>
|
779 |
+
<output>
|
780 |
+
<port id="2" precision="I32">
|
781 |
+
<dim>-1</dim>
|
782 |
+
</port>
|
783 |
+
</output>
|
784 |
+
</layer>
|
785 |
+
<layer id="66" name="Concat_204191" type="Concat" version="opset1">
|
786 |
+
<data axis="0" />
|
787 |
+
<input>
|
788 |
+
<port id="0" precision="I32">
|
789 |
+
<dim>-1</dim>
|
790 |
+
</port>
|
791 |
+
<port id="1" precision="I32">
|
792 |
+
<dim>-1</dim>
|
793 |
+
</port>
|
794 |
+
</input>
|
795 |
+
<output>
|
796 |
+
<port id="2" precision="I32">
|
797 |
+
<dim>-1</dim>
|
798 |
+
</port>
|
799 |
+
</output>
|
800 |
+
</layer>
|
801 |
+
<layer id="67" name="ScatterNDUpdate_204221" type="ScatterNDUpdate" version="opset4">
|
802 |
+
<input>
|
803 |
+
<port id="0" precision="I32">
|
804 |
+
<dim>-1</dim>
|
805 |
+
<dim>-1</dim>
|
806 |
+
</port>
|
807 |
+
<port id="1" precision="I64">
|
808 |
+
<dim>-1</dim>
|
809 |
+
<dim>2</dim>
|
810 |
+
</port>
|
811 |
+
<port id="2" precision="I32">
|
812 |
+
<dim>-1</dim>
|
813 |
+
</port>
|
814 |
+
</input>
|
815 |
+
<output>
|
816 |
+
<port id="3" precision="I32">
|
817 |
+
<dim>-1</dim>
|
818 |
+
<dim>-1</dim>
|
819 |
+
</port>
|
820 |
+
</output>
|
821 |
+
</layer>
|
822 |
+
<layer id="68" name="Constant_204222" type="Const" version="opset1">
|
823 |
+
<data element_type="i64" shape="1" offset="1478273" size="8" />
|
824 |
+
<output>
|
825 |
+
<port id="0" precision="I64">
|
826 |
+
<dim>1</dim>
|
827 |
+
</port>
|
828 |
+
</output>
|
829 |
+
</layer>
|
830 |
+
<layer id="69" name="Constant_204223" type="Const" version="opset1">
|
831 |
+
<data element_type="i64" shape="1" offset="1478293" size="8" />
|
832 |
+
<output>
|
833 |
+
<port id="0" precision="I64">
|
834 |
+
<dim>1</dim>
|
835 |
+
</port>
|
836 |
+
</output>
|
837 |
+
</layer>
|
838 |
+
<layer id="70" name="Constant_204224" type="Const" version="opset1">
|
839 |
+
<data element_type="i64" shape="1" offset="1478281" size="8" />
|
840 |
+
<output>
|
841 |
+
<port id="0" precision="I64">
|
842 |
+
<dim>1</dim>
|
843 |
+
</port>
|
844 |
+
</output>
|
845 |
+
</layer>
|
846 |
+
<layer id="71" name="Constant_204225" type="Const" version="opset1">
|
847 |
+
<data element_type="i64" shape="1" offset="1478301" size="8" />
|
848 |
+
<output>
|
849 |
+
<port id="0" precision="I64">
|
850 |
+
<dim>1</dim>
|
851 |
+
</port>
|
852 |
+
</output>
|
853 |
+
</layer>
|
854 |
+
<layer id="72" name="Slice_204226" type="Slice" version="opset8">
|
855 |
+
<input>
|
856 |
+
<port id="0" precision="I32">
|
857 |
+
<dim>-1</dim>
|
858 |
+
<dim>-1</dim>
|
859 |
+
</port>
|
860 |
+
<port id="1" precision="I64">
|
861 |
+
<dim>1</dim>
|
862 |
+
</port>
|
863 |
+
<port id="2" precision="I64">
|
864 |
+
<dim>1</dim>
|
865 |
+
</port>
|
866 |
+
<port id="3" precision="I64">
|
867 |
+
<dim>1</dim>
|
868 |
+
</port>
|
869 |
+
<port id="4" precision="I64">
|
870 |
+
<dim>1</dim>
|
871 |
+
</port>
|
872 |
+
</input>
|
873 |
+
<output>
|
874 |
+
<port id="5" precision="I32">
|
875 |
+
<dim>-1</dim>
|
876 |
+
<dim>-1</dim>
|
877 |
+
</port>
|
878 |
+
</output>
|
879 |
+
</layer>
|
880 |
+
<layer id="73" name="Slice_204226.0" type="Convert" version="opset1">
|
881 |
+
<data destination_type="i64" />
|
882 |
+
<input>
|
883 |
+
<port id="0" precision="I32">
|
884 |
+
<dim>-1</dim>
|
885 |
+
<dim>-1</dim>
|
886 |
+
</port>
|
887 |
+
</input>
|
888 |
+
<output>
|
889 |
+
<port id="1" precision="I64" names="input_ids">
|
890 |
+
<dim>-1</dim>
|
891 |
+
<dim>-1</dim>
|
892 |
+
</port>
|
893 |
+
</output>
|
894 |
+
</layer>
|
895 |
+
<layer id="74" name="Result_204232" type="Result" version="opset1">
|
896 |
+
<input>
|
897 |
+
<port id="0" precision="I64">
|
898 |
+
<dim>-1</dim>
|
899 |
+
<dim>-1</dim>
|
900 |
+
</port>
|
901 |
+
</input>
|
902 |
+
</layer>
|
903 |
+
<layer id="32" name="Result_204233" type="Result" version="opset1">
|
904 |
+
<input>
|
905 |
+
<port id="0" precision="I64">
|
906 |
+
<dim>-1</dim>
|
907 |
+
<dim>-1</dim>
|
908 |
+
</port>
|
909 |
+
</input>
|
910 |
+
</layer>
|
911 |
+
</layers>
|
912 |
+
<edges>
|
913 |
+
<edge from-layer="0" from-port="0" to-layer="7" to-port="1" />
|
914 |
+
<edge from-layer="1" from-port="0" to-layer="18" to-port="0" />
|
915 |
+
<edge from-layer="2" from-port="0" to-layer="7" to-port="0" />
|
916 |
+
<edge from-layer="3" from-port="0" to-layer="7" to-port="2" />
|
917 |
+
<edge from-layer="4" from-port="0" to-layer="7" to-port="3" />
|
918 |
+
<edge from-layer="5" from-port="0" to-layer="7" to-port="4" />
|
919 |
+
<edge from-layer="6" from-port="0" to-layer="7" to-port="5" />
|
920 |
+
<edge from-layer="7" from-port="8" to-layer="10" to-port="0" />
|
921 |
+
<edge from-layer="7" from-port="6" to-layer="24" to-port="1" />
|
922 |
+
<edge from-layer="7" from-port="6" to-layer="35" to-port="0" />
|
923 |
+
<edge from-layer="7" from-port="7" to-layer="22" to-port="0" />
|
924 |
+
<edge from-layer="7" from-port="8" to-layer="20" to-port="1" />
|
925 |
+
<edge from-layer="7" from-port="7" to-layer="66" to-port="0" />
|
926 |
+
<edge from-layer="8" from-port="0" to-layer="9" to-port="0" />
|
927 |
+
<edge from-layer="8" from-port="0" to-layer="35" to-port="1" />
|
928 |
+
<edge from-layer="9" from-port="1" to-layer="10" to-port="1" />
|
929 |
+
<edge from-layer="10" from-port="2" to-layer="39" to-port="0" />
|
930 |
+
<edge from-layer="10" from-port="2" to-layer="34" to-port="1" />
|
931 |
+
<edge from-layer="10" from-port="2" to-layer="15" to-port="0" />
|
932 |
+
<edge from-layer="11" from-port="0" to-layer="15" to-port="1" />
|
933 |
+
<edge from-layer="12" from-port="0" to-layer="15" to-port="2" />
|
934 |
+
<edge from-layer="13" from-port="0" to-layer="15" to-port="3" />
|
935 |
+
<edge from-layer="14" from-port="0" to-layer="15" to-port="4" />
|
936 |
+
<edge from-layer="15" from-port="5" to-layer="62" to-port="0" />
|
937 |
+
<edge from-layer="15" from-port="5" to-layer="54" to-port="0" />
|
938 |
+
<edge from-layer="15" from-port="5" to-layer="43" to-port="1" />
|
939 |
+
<edge from-layer="15" from-port="5" to-layer="17" to-port="0" />
|
940 |
+
<edge from-layer="16" from-port="0" to-layer="17" to-port="1" />
|
941 |
+
<edge from-layer="17" from-port="2" to-layer="18" to-port="1" />
|
942 |
+
<edge from-layer="18" from-port="2" to-layer="25" to-port="0" />
|
943 |
+
<edge from-layer="19" from-port="0" to-layer="20" to-port="0" />
|
944 |
+
<edge from-layer="20" from-port="2" to-layer="24" to-port="0" />
|
945 |
+
<edge from-layer="21" from-port="0" to-layer="23" to-port="0" />
|
946 |
+
<edge from-layer="22" from-port="1" to-layer="23" to-port="1" />
|
947 |
+
<edge from-layer="23" from-port="2" to-layer="24" to-port="2" />
|
948 |
+
<edge from-layer="24" from-port="3" to-layer="25" to-port="1" />
|
949 |
+
<edge from-layer="25" from-port="2" to-layer="30" to-port="0" />
|
950 |
+
<edge from-layer="26" from-port="0" to-layer="30" to-port="1" />
|
951 |
+
<edge from-layer="27" from-port="0" to-layer="30" to-port="2" />
|
952 |
+
<edge from-layer="28" from-port="0" to-layer="30" to-port="3" />
|
953 |
+
<edge from-layer="29" from-port="0" to-layer="30" to-port="4" />
|
954 |
+
<edge from-layer="30" from-port="5" to-layer="31" to-port="0" />
|
955 |
+
<edge from-layer="31" from-port="1" to-layer="32" to-port="0" />
|
956 |
+
<edge from-layer="33" from-port="0" to-layer="34" to-port="0" />
|
957 |
+
<edge from-layer="34" from-port="2" to-layer="67" to-port="0" />
|
958 |
+
<edge from-layer="35" from-port="2" to-layer="59" to-port="0" />
|
959 |
+
<edge from-layer="36" from-port="0" to-layer="41" to-port="0" />
|
960 |
+
<edge from-layer="37" from-port="0" to-layer="39" to-port="1" />
|
961 |
+
<edge from-layer="38" from-port="0" to-layer="39" to-port="2" />
|
962 |
+
<edge from-layer="39" from-port="3" to-layer="41" to-port="1" />
|
963 |
+
<edge from-layer="40" from-port="0" to-layer="41" to-port="2" />
|
964 |
+
<edge from-layer="41" from-port="3" to-layer="44" to-port="0" />
|
965 |
+
<edge from-layer="42" from-port="0" to-layer="43" to-port="0" />
|
966 |
+
<edge from-layer="43" from-port="2" to-layer="44" to-port="1" />
|
967 |
+
<edge from-layer="44" from-port="2" to-layer="46" to-port="0" />
|
968 |
+
<edge from-layer="45" from-port="0" to-layer="46" to-port="1" />
|
969 |
+
<edge from-layer="46" from-port="2" to-layer="48" to-port="0" />
|
970 |
+
<edge from-layer="47" from-port="0" to-layer="48" to-port="1" />
|
971 |
+
<edge from-layer="48" from-port="2" to-layer="58" to-port="0" />
|
972 |
+
<edge from-layer="49" from-port="0" to-layer="52" to-port="0" />
|
973 |
+
<edge from-layer="50" from-port="0" to-layer="52" to-port="1" />
|
974 |
+
<edge from-layer="51" from-port="0" to-layer="52" to-port="2" />
|
975 |
+
<edge from-layer="52" from-port="3" to-layer="55" to-port="0" />
|
976 |
+
<edge from-layer="53" from-port="0" to-layer="54" to-port="1" />
|
977 |
+
<edge from-layer="54" from-port="2" to-layer="55" to-port="1" />
|
978 |
+
<edge from-layer="55" from-port="2" to-layer="57" to-port="0" />
|
979 |
+
<edge from-layer="56" from-port="0" to-layer="57" to-port="1" />
|
980 |
+
<edge from-layer="57" from-port="2" to-layer="58" to-port="1" />
|
981 |
+
<edge from-layer="58" from-port="2" to-layer="59" to-port="1" />
|
982 |
+
<edge from-layer="59" from-port="2" to-layer="67" to-port="1" />
|
983 |
+
<edge from-layer="60" from-port="0" to-layer="63" to-port="0" />
|
984 |
+
<edge from-layer="61" from-port="0" to-layer="62" to-port="1" />
|
985 |
+
<edge from-layer="62" from-port="2" to-layer="63" to-port="1" />
|
986 |
+
<edge from-layer="63" from-port="2" to-layer="65" to-port="0" />
|
987 |
+
<edge from-layer="64" from-port="0" to-layer="65" to-port="1" />
|
988 |
+
<edge from-layer="65" from-port="2" to-layer="66" to-port="1" />
|
989 |
+
<edge from-layer="66" from-port="2" to-layer="67" to-port="2" />
|
990 |
+
<edge from-layer="67" from-port="3" to-layer="72" to-port="0" />
|
991 |
+
<edge from-layer="68" from-port="0" to-layer="72" to-port="1" />
|
992 |
+
<edge from-layer="69" from-port="0" to-layer="72" to-port="2" />
|
993 |
+
<edge from-layer="70" from-port="0" to-layer="72" to-port="3" />
|
994 |
+
<edge from-layer="71" from-port="0" to-layer="72" to-port="4" />
|
995 |
+
<edge from-layer="72" from-port="5" to-layer="73" to-port="0" />
|
996 |
+
<edge from-layer="73" from-port="1" to-layer="74" to-port="0" />
|
997 |
+
</edges>
|
998 |
+
<rt_info>
|
999 |
+
<add_attention_mask value="True" />
|
1000 |
+
<add_prefix_space />
|
1001 |
+
<add_special_tokens value="True" />
|
1002 |
+
<bos_token_id value="1" />
|
1003 |
+
<chat_template value="{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + ' ' + message['content'] + '<|im_end|>' + ' '}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant ' }}{% endif %}" />
|
1004 |
+
<clean_up_tokenization_spaces value="False" />
|
1005 |
+
<detokenizer_input_type value="i64" />
|
1006 |
+
<eos_token_id value="2" />
|
1007 |
+
<handle_special_tokens_with_re value="True" />
|
1008 |
+
<number_of_inputs value="1" />
|
1009 |
+
<openvino_tokenizers_version value="2025.0.0.0-471-7f2ac4f9648" />
|
1010 |
+
<openvino_version value="2025.0.0-17908-513dcc5c7b7-releases/2025/0" />
|
1011 |
+
<original_tokenizer_class value="<class 'transformers_modules.OpenGVLab.InternVL2-2B.aec61df8c99ba7c81271877485e038a7b823a399.tokenization_internlm2.InternLM2Tokenizer'>" />
|
1012 |
+
<pad_token_id value="2" />
|
1013 |
+
<sentencepiece_version value="0.2.0" />
|
1014 |
+
<skip_special_tokens value="True" />
|
1015 |
+
<streaming_detokenizer value="False" />
|
1016 |
+
<tiktoken_version value="0.7.0" />
|
1017 |
+
<tokenizer_output_type value="i64" />
|
1018 |
+
<tokenizers_version value="0.21.0" />
|
1019 |
+
<transformers_version value="4.47.0" />
|
1020 |
+
<use_max_padding value="False" />
|
1021 |
+
<use_sentencepiece_backend value="False" />
|
1022 |
+
<utf8_replace_mode value="replace" />
|
1023 |
+
<with_detokenizer value="True" />
|
1024 |
+
</rt_info>
|
1025 |
+
</net>
|
openvino_vision_embeddings_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b252dd84ef3ab7fa7520dfd436f8f1392345c5fe0ef7bd868292858d0c0e66b3
|
3 |
+
size 321161636
|
openvino_vision_embeddings_model.xml
ADDED
The diff for this file is too large to render.
See raw diff
|
|
preprocessor_config.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"crop_size": {
|
3 |
+
"height": 448,
|
4 |
+
"width": 448
|
5 |
+
},
|
6 |
+
"do_center_crop": true,
|
7 |
+
"do_convert_rgb": true,
|
8 |
+
"do_normalize": true,
|
9 |
+
"do_rescale": true,
|
10 |
+
"do_resize": true,
|
11 |
+
"image_mean": [
|
12 |
+
0.485,
|
13 |
+
0.456,
|
14 |
+
0.406
|
15 |
+
],
|
16 |
+
"image_processor_type": "CLIPFeatureExtractor",
|
17 |
+
"image_std": [
|
18 |
+
0.229,
|
19 |
+
0.224,
|
20 |
+
0.225
|
21 |
+
],
|
22 |
+
"resample": 3,
|
23 |
+
"rescale_factor": 0.00392156862745098,
|
24 |
+
"size": {
|
25 |
+
"shortest_edge": 448
|
26 |
+
}
|
27 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<|im_start|>",
|
4 |
+
"<|im_end|>",
|
5 |
+
"<|action_start|>",
|
6 |
+
"<|action_end|>",
|
7 |
+
"<|interpreter|>",
|
8 |
+
"<|plugin|>",
|
9 |
+
"<img>",
|
10 |
+
"</img>",
|
11 |
+
"<IMG_CONTEXT>",
|
12 |
+
"<quad>",
|
13 |
+
"</quad>",
|
14 |
+
"<ref>",
|
15 |
+
"</ref>",
|
16 |
+
"<box>",
|
17 |
+
"</box>"
|
18 |
+
],
|
19 |
+
"bos_token": {
|
20 |
+
"content": "<s>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false
|
25 |
+
},
|
26 |
+
"eos_token": {
|
27 |
+
"content": "</s>",
|
28 |
+
"lstrip": false,
|
29 |
+
"normalized": false,
|
30 |
+
"rstrip": false,
|
31 |
+
"single_word": false
|
32 |
+
},
|
33 |
+
"pad_token": {
|
34 |
+
"content": "</s>",
|
35 |
+
"lstrip": false,
|
36 |
+
"normalized": false,
|
37 |
+
"rstrip": false,
|
38 |
+
"single_word": false
|
39 |
+
},
|
40 |
+
"unk_token": {
|
41 |
+
"content": "<unk>",
|
42 |
+
"lstrip": false,
|
43 |
+
"normalized": false,
|
44 |
+
"rstrip": false,
|
45 |
+
"single_word": false
|
46 |
+
}
|
47 |
+
}
|
tokenization_internlm2.py
ADDED
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) The InternLM team and The HuggingFace Inc. team. All rights reserved.
|
2 |
+
#
|
3 |
+
# This code is based on transformers/src/transformers/models/llama/tokenization_llama.py
|
4 |
+
#
|
5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
# you may not use this file except in compliance with the License.
|
7 |
+
# You may obtain a copy of the License at
|
8 |
+
#
|
9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the License for the specific language governing permissions and
|
15 |
+
# limitations under the License.
|
16 |
+
|
17 |
+
"""Tokenization classes for InternLM."""
|
18 |
+
import os
|
19 |
+
from shutil import copyfile
|
20 |
+
from typing import Any, Dict, List, Optional, Tuple
|
21 |
+
|
22 |
+
import sentencepiece as spm
|
23 |
+
from transformers.tokenization_utils import PreTrainedTokenizer
|
24 |
+
from transformers.utils import logging
|
25 |
+
|
26 |
+
logger = logging.get_logger(__name__)
|
27 |
+
|
28 |
+
VOCAB_FILES_NAMES = {'vocab_file': './tokenizer.model'}
|
29 |
+
|
30 |
+
PRETRAINED_VOCAB_FILES_MAP = {}
|
31 |
+
|
32 |
+
|
33 |
+
# Modified from transformers.model.llama.tokenization_llama.LlamaTokenizer
|
34 |
+
class InternLM2Tokenizer(PreTrainedTokenizer):
|
35 |
+
"""
|
36 |
+
Construct a InternLM2 tokenizer. Based on byte-level Byte-Pair-Encoding.
|
37 |
+
|
38 |
+
Args:
|
39 |
+
vocab_file (`str`):
|
40 |
+
Path to the vocabulary file.
|
41 |
+
"""
|
42 |
+
|
43 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
44 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
45 |
+
model_input_names = ['input_ids', 'attention_mask']
|
46 |
+
_auto_class = 'AutoTokenizer'
|
47 |
+
|
48 |
+
def __init__(
|
49 |
+
self,
|
50 |
+
vocab_file,
|
51 |
+
unk_token='<unk>',
|
52 |
+
bos_token='<s>',
|
53 |
+
eos_token='</s>',
|
54 |
+
pad_token='</s>',
|
55 |
+
sp_model_kwargs: Optional[Dict[str, Any]] = None,
|
56 |
+
add_bos_token=True,
|
57 |
+
add_eos_token=False,
|
58 |
+
decode_with_prefix_space=False,
|
59 |
+
clean_up_tokenization_spaces=False,
|
60 |
+
**kwargs,
|
61 |
+
):
|
62 |
+
self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
|
63 |
+
self.vocab_file = vocab_file
|
64 |
+
self.add_bos_token = add_bos_token
|
65 |
+
self.add_eos_token = add_eos_token
|
66 |
+
self.decode_with_prefix_space = decode_with_prefix_space
|
67 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
68 |
+
self.sp_model.Load(vocab_file)
|
69 |
+
self._no_prefix_space_tokens = None
|
70 |
+
super().__init__(
|
71 |
+
bos_token=bos_token,
|
72 |
+
eos_token=eos_token,
|
73 |
+
unk_token=unk_token,
|
74 |
+
pad_token=pad_token,
|
75 |
+
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
76 |
+
**kwargs,
|
77 |
+
)
|
78 |
+
|
79 |
+
@property
|
80 |
+
def no_prefix_space_tokens(self):
|
81 |
+
if self._no_prefix_space_tokens is None:
|
82 |
+
vocab = self.convert_ids_to_tokens(list(range(self.vocab_size)))
|
83 |
+
self._no_prefix_space_tokens = {i for i, tok in enumerate(vocab) if not tok.startswith('▁')}
|
84 |
+
return self._no_prefix_space_tokens
|
85 |
+
|
86 |
+
@property
|
87 |
+
def vocab_size(self):
|
88 |
+
"""Returns vocab size"""
|
89 |
+
return self.sp_model.get_piece_size()
|
90 |
+
|
91 |
+
@property
|
92 |
+
def bos_token_id(self) -> Optional[int]:
|
93 |
+
return self.sp_model.bos_id()
|
94 |
+
|
95 |
+
@property
|
96 |
+
def eos_token_id(self) -> Optional[int]:
|
97 |
+
return self.sp_model.eos_id()
|
98 |
+
|
99 |
+
def get_vocab(self):
|
100 |
+
"""Returns vocab as a dict"""
|
101 |
+
vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
|
102 |
+
vocab.update(self.added_tokens_encoder)
|
103 |
+
return vocab
|
104 |
+
|
105 |
+
def _tokenize(self, text):
|
106 |
+
"""Returns a tokenized string."""
|
107 |
+
return self.sp_model.encode(text, out_type=str)
|
108 |
+
|
109 |
+
def _convert_token_to_id(self, token):
|
110 |
+
"""Converts a token (str) in an id using the vocab."""
|
111 |
+
return self.sp_model.piece_to_id(token)
|
112 |
+
|
113 |
+
def _convert_id_to_token(self, index):
|
114 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
115 |
+
token = self.sp_model.IdToPiece(index)
|
116 |
+
return token
|
117 |
+
|
118 |
+
def _maybe_add_prefix_space(self, tokens, decoded):
|
119 |
+
if tokens and tokens[0] not in self.no_prefix_space_tokens:
|
120 |
+
return ' ' + decoded
|
121 |
+
else:
|
122 |
+
return decoded
|
123 |
+
|
124 |
+
def convert_tokens_to_string(self, tokens):
|
125 |
+
"""Converts a sequence of tokens (string) in a single string."""
|
126 |
+
current_sub_tokens = []
|
127 |
+
out_string = ''
|
128 |
+
prev_is_special = False
|
129 |
+
for token in tokens:
|
130 |
+
# make sure that special tokens are not decoded using sentencepiece model
|
131 |
+
if token in self.all_special_tokens:
|
132 |
+
if not prev_is_special:
|
133 |
+
out_string += ' '
|
134 |
+
out_string += self.sp_model.decode(current_sub_tokens) + token
|
135 |
+
prev_is_special = True
|
136 |
+
current_sub_tokens = []
|
137 |
+
else:
|
138 |
+
current_sub_tokens.append(token)
|
139 |
+
prev_is_special = False
|
140 |
+
out_string += self.sp_model.decode(current_sub_tokens)
|
141 |
+
out_string = self.clean_up_tokenization(out_string)
|
142 |
+
out_string = self._maybe_add_prefix_space(tokens=tokens, decoded=out_string)
|
143 |
+
return out_string[1:]
|
144 |
+
|
145 |
+
def save_vocabulary(self, save_directory, filename_prefix: Optional[str] = None) -> Tuple[str]:
|
146 |
+
"""
|
147 |
+
Save the vocabulary and special tokens file to a directory.
|
148 |
+
|
149 |
+
Args:
|
150 |
+
save_directory (`str`):
|
151 |
+
The directory in which to save the vocabulary.
|
152 |
+
|
153 |
+
Returns:
|
154 |
+
`Tuple(str)`: Paths to the files saved.
|
155 |
+
"""
|
156 |
+
if not os.path.isdir(save_directory):
|
157 |
+
logger.error(f'Vocabulary path ({save_directory}) should be a directory')
|
158 |
+
return
|
159 |
+
out_vocab_file = os.path.join(
|
160 |
+
save_directory, (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']
|
161 |
+
)
|
162 |
+
|
163 |
+
if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file) and os.path.isfile(self.vocab_file):
|
164 |
+
copyfile(self.vocab_file, out_vocab_file)
|
165 |
+
elif not os.path.isfile(self.vocab_file):
|
166 |
+
with open(out_vocab_file, 'wb') as fi:
|
167 |
+
content_spiece_model = self.sp_model.serialized_model_proto()
|
168 |
+
fi.write(content_spiece_model)
|
169 |
+
|
170 |
+
return (out_vocab_file,)
|
171 |
+
|
172 |
+
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
|
173 |
+
if self.add_bos_token:
|
174 |
+
bos_token_ids = [self.bos_token_id]
|
175 |
+
else:
|
176 |
+
bos_token_ids = []
|
177 |
+
|
178 |
+
output = bos_token_ids + token_ids_0
|
179 |
+
|
180 |
+
if token_ids_1 is not None:
|
181 |
+
output = output + token_ids_1
|
182 |
+
|
183 |
+
if self.add_eos_token:
|
184 |
+
output = output + [self.eos_token_id]
|
185 |
+
|
186 |
+
return output
|
187 |
+
|
188 |
+
def get_special_tokens_mask(
|
189 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
|
190 |
+
) -> List[int]:
|
191 |
+
"""
|
192 |
+
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
|
193 |
+
special tokens using the tokenizer `prepare_for_model` method.
|
194 |
+
|
195 |
+
Args:
|
196 |
+
token_ids_0 (`List[int]`):
|
197 |
+
List of IDs.
|
198 |
+
token_ids_1 (`List[int]`, *optional*):
|
199 |
+
Optional second list of IDs for sequence pairs.
|
200 |
+
already_has_special_tokens (`bool`, *optional*, defaults to `False`):
|
201 |
+
Whether or not the token list is already formatted with special tokens for the model.
|
202 |
+
|
203 |
+
Returns:
|
204 |
+
`List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
|
205 |
+
"""
|
206 |
+
if already_has_special_tokens:
|
207 |
+
return super().get_special_tokens_mask(
|
208 |
+
token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
|
209 |
+
)
|
210 |
+
|
211 |
+
if token_ids_1 is None:
|
212 |
+
return [1] + ([0] * len(token_ids_0)) + [1]
|
213 |
+
return [1] + ([0] * len(token_ids_0)) + [1, 1] + ([0] * len(token_ids_1)) + [1]
|
214 |
+
|
215 |
+
def create_token_type_ids_from_sequences(
|
216 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
217 |
+
) -> List[int]:
|
218 |
+
"""
|
219 |
+
Create a mask from the two sequences passed to be used in a sequence-pair classification task. T5 does not make
|
220 |
+
use of token type ids, therefore a list of zeros is returned.
|
221 |
+
|
222 |
+
Args:
|
223 |
+
token_ids_0 (`List[int]`):
|
224 |
+
List of IDs.
|
225 |
+
token_ids_1 (`List[int]`, *optional*):
|
226 |
+
Optional second list of IDs for sequence pairs.
|
227 |
+
|
228 |
+
Returns:
|
229 |
+
`List[int]`: List of zeros.
|
230 |
+
"""
|
231 |
+
eos = [self.eos_token_id]
|
232 |
+
|
233 |
+
if token_ids_1 is None:
|
234 |
+
return len(token_ids_0 + eos) * [0]
|
235 |
+
return len(token_ids_0 + eos + token_ids_1 + eos) * [0]
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f868398fc4e05ee1e8aeba95ddf18ddcc45b8bce55d5093bead5bbf80429b48b
|
3 |
+
size 1477754
|
tokenizer_config.json
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "<unk>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"1": {
|
12 |
+
"content": "<s>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"2": {
|
20 |
+
"content": "</s>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
},
|
27 |
+
"92538": {
|
28 |
+
"content": "<|plugin|>",
|
29 |
+
"lstrip": false,
|
30 |
+
"normalized": false,
|
31 |
+
"rstrip": false,
|
32 |
+
"single_word": false,
|
33 |
+
"special": true
|
34 |
+
},
|
35 |
+
"92539": {
|
36 |
+
"content": "<|interpreter|>",
|
37 |
+
"lstrip": false,
|
38 |
+
"normalized": false,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false,
|
41 |
+
"special": true
|
42 |
+
},
|
43 |
+
"92540": {
|
44 |
+
"content": "<|action_end|>",
|
45 |
+
"lstrip": false,
|
46 |
+
"normalized": false,
|
47 |
+
"rstrip": false,
|
48 |
+
"single_word": false,
|
49 |
+
"special": true
|
50 |
+
},
|
51 |
+
"92541": {
|
52 |
+
"content": "<|action_start|>",
|
53 |
+
"lstrip": false,
|
54 |
+
"normalized": false,
|
55 |
+
"rstrip": false,
|
56 |
+
"single_word": false,
|
57 |
+
"special": true
|
58 |
+
},
|
59 |
+
"92542": {
|
60 |
+
"content": "<|im_end|>",
|
61 |
+
"lstrip": false,
|
62 |
+
"normalized": false,
|
63 |
+
"rstrip": false,
|
64 |
+
"single_word": false,
|
65 |
+
"special": true
|
66 |
+
},
|
67 |
+
"92543": {
|
68 |
+
"content": "<|im_start|>",
|
69 |
+
"lstrip": false,
|
70 |
+
"normalized": false,
|
71 |
+
"rstrip": false,
|
72 |
+
"single_word": false,
|
73 |
+
"special": true
|
74 |
+
},
|
75 |
+
"92544": {
|
76 |
+
"content": "<img>",
|
77 |
+
"lstrip": false,
|
78 |
+
"normalized": false,
|
79 |
+
"rstrip": false,
|
80 |
+
"single_word": false,
|
81 |
+
"special": true
|
82 |
+
},
|
83 |
+
"92545": {
|
84 |
+
"content": "</img>",
|
85 |
+
"lstrip": false,
|
86 |
+
"normalized": false,
|
87 |
+
"rstrip": false,
|
88 |
+
"single_word": false,
|
89 |
+
"special": true
|
90 |
+
},
|
91 |
+
"92546": {
|
92 |
+
"content": "<IMG_CONTEXT>",
|
93 |
+
"lstrip": false,
|
94 |
+
"normalized": false,
|
95 |
+
"rstrip": false,
|
96 |
+
"single_word": false,
|
97 |
+
"special": true
|
98 |
+
},
|
99 |
+
"92547": {
|
100 |
+
"content": "<quad>",
|
101 |
+
"lstrip": false,
|
102 |
+
"normalized": false,
|
103 |
+
"rstrip": false,
|
104 |
+
"single_word": false,
|
105 |
+
"special": true
|
106 |
+
},
|
107 |
+
"92548": {
|
108 |
+
"content": "</quad>",
|
109 |
+
"lstrip": false,
|
110 |
+
"normalized": false,
|
111 |
+
"rstrip": false,
|
112 |
+
"single_word": false,
|
113 |
+
"special": true
|
114 |
+
},
|
115 |
+
"92549": {
|
116 |
+
"content": "<ref>",
|
117 |
+
"lstrip": false,
|
118 |
+
"normalized": false,
|
119 |
+
"rstrip": false,
|
120 |
+
"single_word": false,
|
121 |
+
"special": true
|
122 |
+
},
|
123 |
+
"92550": {
|
124 |
+
"content": "</ref>",
|
125 |
+
"lstrip": false,
|
126 |
+
"normalized": false,
|
127 |
+
"rstrip": false,
|
128 |
+
"single_word": false,
|
129 |
+
"special": true
|
130 |
+
},
|
131 |
+
"92551": {
|
132 |
+
"content": "<box>",
|
133 |
+
"lstrip": false,
|
134 |
+
"normalized": false,
|
135 |
+
"rstrip": false,
|
136 |
+
"single_word": false,
|
137 |
+
"special": true
|
138 |
+
},
|
139 |
+
"92552": {
|
140 |
+
"content": "</box>",
|
141 |
+
"lstrip": false,
|
142 |
+
"normalized": false,
|
143 |
+
"rstrip": false,
|
144 |
+
"single_word": false,
|
145 |
+
"special": true
|
146 |
+
}
|
147 |
+
},
|
148 |
+
"additional_special_tokens": [
|
149 |
+
"<|im_start|>",
|
150 |
+
"<|im_end|>",
|
151 |
+
"<|action_start|>",
|
152 |
+
"<|action_end|>",
|
153 |
+
"<|interpreter|>",
|
154 |
+
"<|plugin|>",
|
155 |
+
"<img>",
|
156 |
+
"</img>",
|
157 |
+
"<IMG_CONTEXT>",
|
158 |
+
"<quad>",
|
159 |
+
"</quad>",
|
160 |
+
"<ref>",
|
161 |
+
"</ref>",
|
162 |
+
"<box>",
|
163 |
+
"</box>"
|
164 |
+
],
|
165 |
+
"auto_map": {
|
166 |
+
"AutoTokenizer": [
|
167 |
+
"tokenization_internlm2.InternLM2Tokenizer",
|
168 |
+
null
|
169 |
+
]
|
170 |
+
},
|
171 |
+
"bos_token": "<s>",
|
172 |
+
"chat_template": "{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
173 |
+
"clean_up_tokenization_spaces": false,
|
174 |
+
"eos_token": "</s>",
|
175 |
+
"extra_special_tokens": {},
|
176 |
+
"model_max_length": 8192,
|
177 |
+
"pad_token": "</s>",
|
178 |
+
"tokenizer_class": "InternLM2Tokenizer",
|
179 |
+
"unk_token": "<unk>"
|
180 |
+
}
|