openvino-ci commited on
Commit
e079b2e
·
verified ·
1 Parent(s): d708b62

Upload folder using huggingface_hub

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
README.md ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: image-text-to-text
5
+ base_model:
6
+ - mistral-community/pixtral-12b
7
+ base_model_relation: quantized
8
+ ---
9
+
10
+ # pixtral-12b-fp16-ov
11
+
12
+ * Model creator: [mistral-community](https://huggingface.co/mistral-community)
13
+ * Original model: [mistral-community/pixtral-12b](https://huggingface.co/mistral-community/pixtral-12b)
14
+
15
+ ## Description
16
+
17
+ This is [mistral-community/pixtral-12b](https://huggingface.co/mistral-community/pixtral-12b) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2025/documentation/openvino-ir-format.html) (Intermediate Representation) format.
18
+
19
+ ## Compatibility
20
+
21
+ The provided OpenVINO™ IR model is compatible with:
22
+
23
+ * OpenVINO version 2025.2.0 and higher
24
+ * Optimum Intel 1.26.0 and higher
25
+
26
+ ## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
27
+
28
+ 1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
29
+
30
+ ```
31
+ pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino_tokenizers openvino
32
+
33
+ pip install git+https://github.com/huggingface/optimum-intel.git
34
+ ```
35
+
36
+ 2. Run model inference
37
+
38
+ ```
39
+ from PIL import Image
40
+ import requests
41
+ from optimum.intel.openvino import OVModelForVisualCausalLM
42
+ from transformers import AutoTokenizer, TextStreamer
43
+
44
+ model_id = "OpenVINO/pixtral-12b-fp16-ov"
45
+
46
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
47
+
48
+ ov_model = OVModelForVisualCausalLM.from_pretrained(model_id, trust_remote_code=True)
49
+ prompt = "What is unusual on this picture?"
50
+
51
+ url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
52
+ image = Image.open(requests.get(url, stream=True).raw)
53
+
54
+ inputs = ov_model.preprocess_inputs(text=prompt, image=image, tokenizer=tokenizer, config=ov_model.config)
55
+
56
+ generation_args = {
57
+ "max_new_tokens": 100,
58
+ "streamer": TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
59
+ }
60
+
61
+ generate_ids = ov_model.generate(**inputs, **generation_args)
62
+
63
+ generate_ids = generate_ids[:, inputs['input_ids'].shape[1]:]
64
+ response = tokenizer.batch_decode(generate_ids, skip_special_tokens=True)[0]
65
+
66
+ ```
67
+
68
+ ## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
69
+
70
+ 1. Install packages required for using OpenVINO GenAI.
71
+ ```
72
+ pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino openvino-tokenizers openvino-genai
73
+
74
+ pip install huggingface_hub
75
+ ```
76
+
77
+ 2. Download model from HuggingFace Hub
78
+
79
+ ```
80
+ import huggingface_hub as hf_hub
81
+
82
+ model_id = "OpenVINO/pixtral-12b-fp16-ov"
83
+ model_path = "pixtral-12b-fp16-ov"
84
+
85
+ hf_hub.snapshot_download(model_id, local_dir=model_path)
86
+
87
+ ```
88
+
89
+ 1. Run model inference:
90
+
91
+ ```
92
+ import openvino_genai as ov_genai
93
+ import requests
94
+ from PIL import Image
95
+ from io import BytesIO
96
+ import numpy as np
97
+ import openvino as ov
98
+
99
+ device = "CPU"
100
+ pipe = ov_genai.VLMPipeline(model_path, device)
101
+
102
+ def load_image(image_file):
103
+ if isinstance(image_file, str) and (image_file.startswith("http") or image_file.startswith("https")):
104
+ response = requests.get(image_file)
105
+ image = Image.open(BytesIO(response.content)).convert("RGB")
106
+ else:
107
+ image = Image.open(image_file).convert("RGB")
108
+ image_data = np.array(image.getdata()).reshape(1, image.size[1], image.size[0], 3).astype(np.byte)
109
+ return ov.Tensor(image_data)
110
+
111
+ prompt = "What is unusual on this picture?"
112
+
113
+ url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
114
+ image_tensor = load_image(url)
115
+
116
+ def streamer(subword: str) -> bool:
117
+ print(subword, end="", flush=True)
118
+ return False
119
+
120
+ pipe.start_chat()
121
+ output = pipe.generate(prompt, image=image_tensor, max_new_tokens=100, streamer=streamer)
122
+ pipe.finish_chat()
123
+ ```
124
+
125
+ 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)
126
+
127
+
128
+ ## Limitations
129
+
130
+ Check the original [model card](https://huggingface.co/mistral-community/pixtral-12b) for limitations.
131
+
132
+ ## Legal information
133
+
134
+ The original model is distributed under [apache-2.0](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/apache-2.0.md) license. More details can be found in [original model card](https://huggingface.co/mistral-community/pixtral-12b).
135
+
136
+ ## Disclaimer
137
+
138
+ Intel is committed to respecting human rights and avoiding causing or contributing to adverse impacts on human rights. See [Intel’s Global Human Rights Principles](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/policy-human-rights.pdf). Intel’s products and software are intended only to be used in applications that do not cause or contribute to adverse impacts on human rights.
139
+
chat_template.jinja ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {%- if messages[0]["role"] == "system" %}{%- set system_message = messages[0]["content"] %}{%- set loop_messages = messages[1:] %}
2
+ {%- else %}{%- set loop_messages = messages %}{%- endif %}{{- bos_token }}{%- for message in loop_messages %}{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }}{%- endif %}{%- if message["role"] == "user" %}{%- if loop.last and system_message is defined %}{{- "[INST]" + system_message + "
3
+
4
+ " }}{%- else %}{{ "[INST]" }}{%- endif %}{%- endif %}{%- if message["content"] is not string %}{%- for chunk in message["content"] %}{%- if chunk["type"] == "text" %}{%- if "content" in chunk %}{{- chunk["content"] }}{%- elif "text" in chunk %}{{- chunk["text"] }}{%- endif %}{%- elif chunk["type"] == "image" %}{{- "[IMG]" }}{%- else %}{{- raise_exception("Unrecognized content type!") }}{%- endif %}{%- endfor %}{%- else %}{{- message["content"] }}{%- endif %}{%- if message["role"] == "user" %}{{- "[/INST]" }}{%- elif message["role"] == "assistant" %}{{- eos_token}}{%- else %}{{- raise_exception("Only user and assistant roles are supported, with the exception of an initial optional system message!") }}{%- endif %}{%- endfor %}
config.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlavaForConditionalGeneration"
4
+ ],
5
+ "ignore_index": -100,
6
+ "image_seq_length": 1,
7
+ "image_token_index": 10,
8
+ "model_type": "llava",
9
+ "multimodal_projector_bias": true,
10
+ "projector_hidden_act": "gelu",
11
+ "text_config": {
12
+ "attention_dropout": 0.0,
13
+ "head_dim": 128,
14
+ "hidden_act": "silu",
15
+ "hidden_size": 5120,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 14336,
18
+ "is_composition": true,
19
+ "max_position_embeddings": 1024000,
20
+ "model_type": "mistral",
21
+ "num_attention_heads": 32,
22
+ "num_hidden_layers": 40,
23
+ "num_key_value_heads": 8,
24
+ "rms_norm_eps": 1e-05,
25
+ "rope_theta": 1000000000.0,
26
+ "sliding_window": null,
27
+ "torch_dtype": "float16",
28
+ "use_cache": true,
29
+ "vocab_size": 131072
30
+ },
31
+ "torch_dtype": "float16",
32
+ "transformers_version": "4.53.3",
33
+ "vision_config": {
34
+ "attention_dropout": 0.0,
35
+ "head_dim": 64,
36
+ "hidden_act": "silu",
37
+ "hidden_size": 1024,
38
+ "image_size": 1024,
39
+ "initializer_range": 0.02,
40
+ "intermediate_size": 4096,
41
+ "is_composition": true,
42
+ "model_type": "pixtral",
43
+ "num_attention_heads": 16,
44
+ "num_channels": 3,
45
+ "num_hidden_layers": 24,
46
+ "patch_size": 16,
47
+ "rope_theta": 10000.0,
48
+ "tie_word_embeddings": false,
49
+ "torch_dtype": "float16"
50
+ },
51
+ "vision_feature_layer": -1,
52
+ "vision_feature_select_strategy": "full"
53
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.53.3"
6
+ }
openvino_language_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:93562f464ce55b916d29f205d22da064f028f17994101e87765ba3d238686fc1
3
+ size 23153387917
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:ca8bd9f31ce9cf3396684e2ca06b57b120078ae9e6f0dcd5fb6e3ff3e17b9fd1
3
+ size 1342177284
openvino_text_embeddings_model.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <net name="Model3" 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="f16" shape="131072, 5120" offset="0" size="1342177280" />
15
+ <output>
16
+ <port id="0" precision="FP16" names="self.weight">
17
+ <dim>131072</dim>
18
+ <dim>5120</dim>
19
+ </port>
20
+ </output>
21
+ </layer>
22
+ <layer id="2" name="ov_ext::embedding/Convert" type="Convert" version="opset1">
23
+ <data destination_type="f32" />
24
+ <rt_info>
25
+ <attribute name="decompression" version="0" />
26
+ </rt_info>
27
+ <input>
28
+ <port id="0" precision="FP16">
29
+ <dim>131072</dim>
30
+ <dim>5120</dim>
31
+ </port>
32
+ </input>
33
+ <output>
34
+ <port id="1" precision="FP32">
35
+ <dim>131072</dim>
36
+ <dim>5120</dim>
37
+ </port>
38
+ </output>
39
+ </layer>
40
+ <layer id="3" name="ov_ext::embedding/Convert_1" type="Convert" version="opset1">
41
+ <data destination_type="i32" />
42
+ <input>
43
+ <port id="0" precision="I64">
44
+ <dim>-1</dim>
45
+ <dim>-1</dim>
46
+ </port>
47
+ </input>
48
+ <output>
49
+ <port id="1" precision="I32">
50
+ <dim>-1</dim>
51
+ <dim>-1</dim>
52
+ </port>
53
+ </output>
54
+ </layer>
55
+ <layer id="4" name="ov_ext::embedding/Constant" type="Const" version="opset1">
56
+ <data element_type="i32" shape="" offset="1342177280" size="4" />
57
+ <output>
58
+ <port id="0" precision="I32" />
59
+ </output>
60
+ </layer>
61
+ <layer id="5" name="ov_ext::embedding/Gather" type="Gather" version="opset8">
62
+ <data batch_dims="0" />
63
+ <input>
64
+ <port id="0" precision="FP32">
65
+ <dim>131072</dim>
66
+ <dim>5120</dim>
67
+ </port>
68
+ <port id="1" precision="I32">
69
+ <dim>-1</dim>
70
+ <dim>-1</dim>
71
+ </port>
72
+ <port id="2" precision="I32" />
73
+ </input>
74
+ <output>
75
+ <port id="3" precision="FP32" names="inputs_embeds">
76
+ <dim>-1</dim>
77
+ <dim>-1</dim>
78
+ <dim>5120</dim>
79
+ </port>
80
+ </output>
81
+ </layer>
82
+ <layer id="6" name="Result_40440" type="Result" version="opset1" output_names="inputs_embeds">
83
+ <input>
84
+ <port id="0" precision="FP32">
85
+ <dim>-1</dim>
86
+ <dim>-1</dim>
87
+ <dim>5120</dim>
88
+ </port>
89
+ </input>
90
+ </layer>
91
+ </layers>
92
+ <edges>
93
+ <edge from-layer="0" from-port="0" to-layer="3" to-port="0" />
94
+ <edge from-layer="1" from-port="0" to-layer="2" to-port="0" />
95
+ <edge from-layer="2" from-port="1" to-layer="5" to-port="0" />
96
+ <edge from-layer="3" from-port="1" to-layer="5" to-port="1" />
97
+ <edge from-layer="4" from-port="0" to-layer="5" to-port="2" />
98
+ <edge from-layer="5" from-port="3" to-layer="6" to-port="0" />
99
+ </edges>
100
+ <rt_info>
101
+ <Runtime_version value="2025.2.0-19140-c01cd93e24d-releases/2025/2" />
102
+ <conversion_parameters>
103
+ <framework value="pytorch" />
104
+ <is_python_object value="True" />
105
+ </conversion_parameters>
106
+ <optimum>
107
+ <optimum_intel_version value="1.26.0.dev0+e9c57b9" />
108
+ <optimum_version value="1.27.0" />
109
+ <pytorch_version value="2.8.0+cpu" />
110
+ <transformers_version value="4.53.3" />
111
+ </optimum>
112
+ </rt_info>
113
+ </net>
openvino_vision_embeddings_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8c3e3bcc1ed315d9c712d77ee40cd4a054d52ebeec46d106fd90bbb49197f94
3
+ size 870439222
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
+ "do_convert_rgb": true,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.48145466,
8
+ 0.4578275,
9
+ 0.40821073
10
+ ],
11
+ "image_processor_type": "PixtralImageProcessor",
12
+ "image_std": [
13
+ 0.26862954,
14
+ 0.26130258,
15
+ 0.27577711
16
+ ],
17
+ "patch_size": {
18
+ "height": 16,
19
+ "width": 16
20
+ },
21
+ "processor_class": "PixtralProcessor",
22
+ "resample": 3,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "size": {
25
+ "longest_edge": 1024
26
+ }
27
+ }
processor_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_break_token": "[IMG_BREAK]",
3
+ "image_end_token": "[IMG_END]",
4
+ "image_token": "[IMG]",
5
+ "patch_size": 16,
6
+ "processor_class": "PixtralProcessor",
7
+ "spatial_merge_size": 1
8
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcdf3e6b96371b9a5c8673bdf2f1bc838b994b73a6fa995dca62196346aaddb5
3
+ size 17077311
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff