hf-transformers-bot commited on
Commit
8f89c5f
·
verified ·
1 Parent(s): 9370f92

Add tiny processor fixture for testing

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
+ "QianfanOCRForConditionalGeneration"
4
+ ],
5
+ "downsample_ratio": 0.5,
6
+ "dynamic_image_size": true,
7
+ "eos_token_id": 502,
8
+ "force_image_size": 448,
9
+ "image_token_id": 151671,
10
+ "text_config": {
11
+ "_name_or_path": "/root/codespace/checkpoints/Qwen3-4B",
12
+ "architectures": [
13
+ "Qwen3ForCausalLM"
14
+ ],
15
+ "attention_bias": false,
16
+ "attention_dropout": 0.0,
17
+ "bos_token_id": 151643,
18
+ "debug": false,
19
+ "eos_token_id": 151645,
20
+ "ep_size": 1,
21
+ "head_dim": 128,
22
+ "hidden_act": "silu",
23
+ "hidden_size": 2560,
24
+ "initializer_range": 0.02,
25
+ "intermediate_size": 9728,
26
+ "max_position_embeddings": 32768,
27
+ "max_window_layers": 36,
28
+ "micro_forward": false,
29
+ "model_type": "qwen3",
30
+ "num_attention_heads": 32,
31
+ "num_hidden_layers": 36,
32
+ "num_key_value_heads": 8,
33
+ "rms_norm_eps": 1e-06,
34
+ "rope_scaling": null,
35
+ "rope_theta": 5000000,
36
+ "skip_checkpoint": false,
37
+ "sliding_window": null,
38
+ "torch_dtype": "bfloat16",
39
+ "use_cache": false,
40
+ "use_deepep": false,
41
+ "use_sliding_window": false,
42
+ "vocab_size": 153678
43
+ },
44
+ "max_dynamic_patch": 12,
45
+ "min_dynamic_patch": 1,
46
+ "model_type": "qianfan_ocr",
47
+ "pad2square": false,
48
+ "pad_token_id": 500,
49
+ "ps_version": "v2",
50
+ "select_layer": -1,
51
+ "template": "internvl2_5",
52
+ "tie_word_embeddings": false,
53
+ "torch_dtype": "bfloat16",
54
+ "transformers_version": null,
55
+ "use_thumbnail": true,
56
+ "vision_config": {
57
+ "architectures": [
58
+ "QianfanOCRVisionModel"
59
+ ],
60
+ "attention_dropout": 0.0,
61
+ "drop_path_rate": 0.1,
62
+ "hidden_act": "gelu",
63
+ "hidden_size": 1024,
64
+ "image_size": 448,
65
+ "initializer_range": 0.02,
66
+ "intermediate_size": 4096,
67
+ "layer_norm_eps": 1e-06,
68
+ "model_type": "qianfan_ocr_vision",
69
+ "norm_type": "layer_norm",
70
+ "num_attention_heads": 16,
71
+ "num_channels": 3,
72
+ "num_hidden_layers": 24,
73
+ "patch_size": 14,
74
+ "qkv_bias": true,
75
+ "torch_dtype": "bfloat16"
76
+ },
77
+ "vocab_size": 500
78
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": 151645,
5
+ "transformers_version": "4.55.0"
6
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": null,
3
+ "crop_to_patches": false,
4
+ "data_format": "channels_first",
5
+ "default_to_square": true,
6
+ "device": null,
7
+ "do_center_crop": null,
8
+ "do_convert_rgb": true,
9
+ "do_normalize": true,
10
+ "do_rescale": true,
11
+ "do_resize": true,
12
+ "image_mean": [
13
+ 0.485,
14
+ 0.456,
15
+ 0.406
16
+ ],
17
+ "image_processor_type": "GotOcr2ImageProcessor",
18
+ "image_std": [
19
+ 0.229,
20
+ 0.224,
21
+ 0.225
22
+ ],
23
+ "input_data_format": null,
24
+ "max_patches": 12,
25
+ "min_patches": 1,
26
+ "processor_class": "InternVLProcessor",
27
+ "resample": 3,
28
+ "rescale_factor": 0.00392156862745098,
29
+ "return_tensors": null,
30
+ "size": {
31
+ "height": 448,
32
+ "width": 448
33
+ }
34
+ }
processor_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_seq_length": 256,
3
+ "processor_class": "QianfanOCRProcessor",
4
+ "start_image_token": "<img>",
5
+ "end_image_token": "</img>",
6
+ "context_image_token": "<IMG_CONTEXT>"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff
 
video_preprocessor_config.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_valid_kwargs_names": [
3
+ "do_convert_rgb",
4
+ "do_resize",
5
+ "size",
6
+ "size_divisor",
7
+ "default_to_square",
8
+ "resample",
9
+ "do_rescale",
10
+ "rescale_factor",
11
+ "do_normalize",
12
+ "image_mean",
13
+ "image_std",
14
+ "do_pad",
15
+ "do_center_crop",
16
+ "crop_size",
17
+ "data_format",
18
+ "input_data_format",
19
+ "device"
20
+ ],
21
+ "crop_size": null,
22
+ "data_format": "channels_first",
23
+ "default_to_square": true,
24
+ "device": null,
25
+ "do_center_crop": null,
26
+ "do_convert_rgb": true,
27
+ "do_normalize": true,
28
+ "do_pad": null,
29
+ "do_rescale": true,
30
+ "do_resize": true,
31
+ "image_mean": [
32
+ 0.48145466,
33
+ 0.4578275,
34
+ 0.40821073
35
+ ],
36
+ "image_std": [
37
+ 0.26862954,
38
+ 0.26130258,
39
+ 0.27577711
40
+ ],
41
+ "input_data_format": null,
42
+ "model_valid_processing_keys": [
43
+ "do_convert_rgb",
44
+ "do_resize",
45
+ "size",
46
+ "size_divisor",
47
+ "default_to_square",
48
+ "resample",
49
+ "do_rescale",
50
+ "rescale_factor",
51
+ "do_normalize",
52
+ "image_mean",
53
+ "image_std",
54
+ "do_pad",
55
+ "do_center_crop",
56
+ "crop_size",
57
+ "data_format",
58
+ "input_data_format",
59
+ "device"
60
+ ],
61
+ "processor_class": "InternVLProcessor",
62
+ "resample": 3,
63
+ "rescale_factor": 0.00392156862745098,
64
+ "size": {
65
+ "height": 384,
66
+ "width": 384
67
+ },
68
+ "size_divisor": null,
69
+ "video_processor_type": "InternVLVideoProcessor"
70
+ }