hf-transformers-bot commited on
Commit
62a5acf
·
verified ·
1 Parent(s): 95d065e

Update tiny models for QianfanOCRModel

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,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "QianfanOCRModel"
4
+ ],
5
+ "downsample_ratio": 0.5,
6
+ "dtype": "float32",
7
+ "image_seq_length": 16,
8
+ "image_token_id": 1,
9
+ "model_type": "qianfan_ocr",
10
+ "pad_token_id": 151643,
11
+ "projector_hidden_act": "gelu",
12
+ "text_config": {
13
+ "attention_bias": false,
14
+ "attention_dropout": 0.0,
15
+ "bos_token_id": 3,
16
+ "eos_token_id": 151645,
17
+ "head_dim": 32,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 128,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 256,
22
+ "layer_types": [
23
+ "full_attention",
24
+ "full_attention"
25
+ ],
26
+ "max_position_embeddings": 512,
27
+ "max_window_layers": 28,
28
+ "model_type": "qwen3",
29
+ "num_attention_heads": 4,
30
+ "num_hidden_layers": 2,
31
+ "num_key_value_heads": 2,
32
+ "pad_token_id": 151643,
33
+ "rms_norm_eps": 1e-06,
34
+ "rope_parameters": {
35
+ "rope_theta": 10000.0,
36
+ "rope_type": "default"
37
+ },
38
+ "sliding_window": null,
39
+ "tie_word_embeddings": false,
40
+ "use_cache": true,
41
+ "use_sliding_window": false,
42
+ "vocab_size": 152688
43
+ },
44
+ "tie_word_embeddings": false,
45
+ "transformers_version": "5.16.0.dev0",
46
+ "vision_config": {
47
+ "attention_bias": true,
48
+ "attention_dropout": 0.0,
49
+ "drop_path_rate": 0.0,
50
+ "hidden_act": "quick_gelu",
51
+ "hidden_dropout_prob": 0.0,
52
+ "hidden_size": 32,
53
+ "image_size": [
54
+ 32,
55
+ 32
56
+ ],
57
+ "initializer_range": 0.02,
58
+ "intermediate_size": 128,
59
+ "layer_norm_eps": 1e-06,
60
+ "layer_scale_init_value": 0.1,
61
+ "model_type": "qianfan_ocr_vision",
62
+ "norm_type": "layer_norm",
63
+ "num_attention_heads": 4,
64
+ "num_channels": 3,
65
+ "num_hidden_layers": 2,
66
+ "patch_size": [
67
+ 4,
68
+ 4
69
+ ],
70
+ "projection_dropout": 0.0,
71
+ "use_absolute_position_embeddings": true,
72
+ "use_mask_token": false,
73
+ "use_mean_pooling": true,
74
+ "use_qk_norm": false
75
+ },
76
+ "vision_feature_layer": -1,
77
+ "vision_feature_select_strategy": "default"
78
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b201d82b79de9589d78d2cd9aba49ed35d56e98f5a3fd288f9535a58dabe77f9
3
+ size 79616104
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
+ }