hf-transformers-bot commited on
Commit
cae65f6
·
verified ·
1 Parent(s): 56363b1

Update tiny models for QianfanOCRVisionModel

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
chat_template.jinja ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if messages[0]['role'] == 'system' %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['content'] is string %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {%- for item in messages[0]['content'] %}
7
+ {%- if item['type'] == 'text' %}
8
+ {{- item['text'] }}
9
+ {%- endif %}
10
+ {%- endfor %}
11
+ {%- endif %}
12
+ {{- '<|im_end|>\n' }}
13
+ {%- else %}
14
+ {{- '<|im_start|>system\n你是Qianfan-VL,由百度智能云研发的多模态大语言模型。<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- set ns = namespace(found_last_user=false, last_query_index=messages|length - 1) %}
17
+ {%- for message in messages[::-1] %}
18
+ {%- set index = (messages|length - 1) - loop.index0 %}
19
+ {%- if not ns.found_last_user and message['role'] == 'user' %}
20
+ {%- set ns.found_last_user = true %}
21
+ {%- set ns.last_query_index = index %}
22
+ {%- endif %}
23
+ {%- endfor %}
24
+ {%- for message in messages %}
25
+ {%- if messages[0]['role'] != 'system' or not loop.first %}
26
+ {%- if message['role'] == 'user' or (message['role'] == 'system' and not loop.first) %}
27
+ {%- set append_think = (enable_thinking is defined and enable_thinking and message['role'] == 'user' and loop.index0 == ns.last_query_index) %}
28
+ {{- '<|im_start|>' + message['role'] + '\n' }}
29
+ {%- if message['content'] is string %}
30
+ {{- message['content'] }}
31
+ {%- else %}
32
+ {%- for item in message['content'] %}
33
+ {%- if item['type'] == 'image' %}
34
+ {{- '<image>\n' }}
35
+ {%- elif item['type'] == 'video' %}
36
+ {{- '<video>\n' }}
37
+ {%- elif item['type'] == 'text' %}
38
+ {{- item['text'] }}
39
+ {%- endif %}
40
+ {%- endfor %}
41
+ {%- endif %}
42
+ {%- if append_think %}
43
+ {{- '<think>' }}
44
+ {%- endif %}
45
+ {{- '<|im_end|>\n' }}
46
+ {%- elif message['role'] == 'assistant' %}
47
+ {%- if message['content'] is string %}
48
+ {%- set raw_content = message['content'] %}
49
+ {%- else %}
50
+ {%- set content_ns = namespace(raw='') %}
51
+ {%- for item in message['content'] %}
52
+ {%- if item['type'] == 'text' %}
53
+ {%- set content_ns.raw = content_ns.raw + item['text'] %}
54
+ {%- endif %}
55
+ {%- endfor %}
56
+ {%- set raw_content = content_ns.raw %}
57
+ {%- endif %}
58
+ {%- set content = raw_content %}
59
+ {%- set reasoning_content = '' %}
60
+ {%- if 'reasoning_content' in message and message['reasoning_content'] is not none %}
61
+ {%- set reasoning_content = message['reasoning_content'] %}
62
+ {%- elif '</think>' in raw_content %}
63
+ {%- set content = raw_content.split('</think>')[-1].lstrip('\n') %}
64
+ {%- set reasoning_content = raw_content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
65
+ {%- endif %}
66
+ {%- if loop.index0 > ns.last_query_index and reasoning_content %}
67
+ {{- '<|im_start|>' + message['role'] + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
68
+ {%- else %}
69
+ {{- '<|im_start|>' + message['role'] + '\n' + content }}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- endif %}
73
+ {%- endif %}
74
+ {%- endfor %}
75
+ {%- if add_generation_prompt %}
76
+ {{- '<|im_start|>assistant\n' }}
77
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "QianfanOCRVisionModel"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "drop_path_rate": 0.0,
8
+ "dtype": "float32",
9
+ "hidden_act": "quick_gelu",
10
+ "hidden_dropout_prob": 0.0,
11
+ "hidden_size": 32,
12
+ "image_size": [
13
+ 32,
14
+ 32
15
+ ],
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 128,
18
+ "layer_norm_eps": 1e-06,
19
+ "layer_scale_init_value": 0.1,
20
+ "model_type": "qianfan_ocr_vision",
21
+ "norm_type": "layer_norm",
22
+ "num_attention_heads": 4,
23
+ "num_channels": 3,
24
+ "num_hidden_layers": 2,
25
+ "patch_size": [
26
+ 4,
27
+ 4
28
+ ],
29
+ "projection_dropout": 0.0,
30
+ "transformers_version": "5.16.0.dev0",
31
+ "use_absolute_position_embeddings": true,
32
+ "use_mask_token": false,
33
+ "use_mean_pooling": true,
34
+ "use_qk_norm": false
35
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09fa96a6206b49d1bde9066a1e12301b488164866823ded620d61b12bc9c1c5e
3
+ size 120560
preprocessor_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": {
3
+ "height": [
4
+ 32,
5
+ 32
6
+ ],
7
+ "width": [
8
+ 32,
9
+ 32
10
+ ]
11
+ },
12
+ "crop_to_patches": false,
13
+ "do_convert_rgb": true,
14
+ "do_normalize": true,
15
+ "do_rescale": true,
16
+ "do_resize": true,
17
+ "image_mean": [
18
+ 0.48145466,
19
+ 0.4578275,
20
+ 0.40821073
21
+ ],
22
+ "image_processor_type": "GotOcr2ImageProcessor",
23
+ "image_std": [
24
+ 0.26862954,
25
+ 0.26130258,
26
+ 0.27577711
27
+ ],
28
+ "max_patches": 12,
29
+ "min_patches": 1,
30
+ "resample": 3,
31
+ "rescale_factor": 0.00392156862745098,
32
+ "size": {
33
+ "height": [
34
+ 32,
35
+ 32
36
+ ],
37
+ "width": [
38
+ 32,
39
+ 32
40
+ ]
41
+ }
42
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91c686341cbb6ff3bfd9ddea3a2e2477418ddccadcd7ad7d5ddca9741342c8d7
3
+ size 11615167
tokenizer_config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "context_image_token": "<IMG_CONTEXT>",
7
+ "end_image_token": "</img>",
8
+ "eos_token": "<|im_end|>",
9
+ "errors": "replace",
10
+ "is_local": true,
11
+ "local_files_only": false,
12
+ "model_max_length": 1010000,
13
+ "model_specific_special_tokens": {
14
+ "context_image_token": "<IMG_CONTEXT>",
15
+ "end_image_token": "</img>",
16
+ "start_image_token": "<img>"
17
+ },
18
+ "pad_token": "<|endoftext|>",
19
+ "split_special_tokens": false,
20
+ "start_image_token": "<img>",
21
+ "tokenizer_class": "Qwen2Tokenizer",
22
+ "unk_token": null
23
+ }
video_preprocessor_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": {
3
+ "height": [
4
+ 32,
5
+ 32
6
+ ],
7
+ "width": [
8
+ 32,
9
+ 32
10
+ ]
11
+ },
12
+ "do_convert_rgb": true,
13
+ "do_normalize": true,
14
+ "do_rescale": true,
15
+ "do_resize": true,
16
+ "do_sample_frames": false,
17
+ "image_mean": [
18
+ 0.48145466,
19
+ 0.4578275,
20
+ 0.40821073
21
+ ],
22
+ "image_std": [
23
+ 0.26862954,
24
+ 0.26130258,
25
+ 0.27577711
26
+ ],
27
+ "initial_shift": true,
28
+ "resample": 3,
29
+ "rescale_factor": 0.00392156862745098,
30
+ "return_metadata": false,
31
+ "size": {
32
+ "height": [
33
+ 32,
34
+ 32
35
+ ],
36
+ "width": [
37
+ 32,
38
+ 32
39
+ ]
40
+ },
41
+ "video_processor_type": "InternVLVideoProcessor"
42
+ }