File size: 3,173 Bytes
1e75362 4bc2e07 1e75362 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
---
license: mit
license_link: https://huggingface.co./microsoft/Phi-3.5-vision-instruct/resolve/main/LICENSE
language:
- multilingual
pipeline_tag: image-text-to-text
tags:
- nlp
- code
- vision
base_model:
- microsoft/Phi-3.5-vision-instruct
base_model_relation: quantized
---
# Phi-3.5-vision-instruct-int8-ov
* Model creator: [Microsoft](https://huggingface.co./microsoft)
* Original model: [Phi-3.5-vision-instruct](https://huggingface.co./microsoft/Phi-3.5-vision-instruct)
## Description
This is [microsoft/Phi-3.5-vision-instruct](https://huggingface.co./microsoft/Phi-3.5-vision-instruct) 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).
## Quantization Parameters
Weight compression was performed using `nncf.compress_weights` with the following parameters:
* mode: **INT8_ASYM**
## Compatibility
The provided OpenVINO™ IR model is compatible with:
* OpenVINO version 2025.0.0 and higher
* Optimum Intel 1.21.0 and higher
## Running Model Inference with [Optimum Intel](https://huggingface.co./docs/optimum/intel/index)
1. Install packages required for using [Optimum Intel](https://huggingface.co./docs/optimum/intel/index) integration with the OpenVINO backend:
```
pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino_tokenizers openvino
pip install git+https://github.com/huggingface/optimum-intel.git
```
2. Run model inference
```
from PIL import Image
import requests
from optimum.intel.openvino import OVModelForVisualCausalLM
from transformers import AutoProcessor, TextStreamer
model_id = "OpenVINO/Phi-3.5-vision-instruct-int8-ov"
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
ov_model = OVModelForVisualCausalLM.from_pretrained(model_id, trust_remote_code=True)
prompt = "<|image_1|>\nWhat is unusual on this picture?"
url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
image = Image.open(requests.get(url, stream=True).raw)
inputs = ov_model.preprocess_inputs(text=prompt, image=image, processor=processor)
generation_args = {
"max_new_tokens": 50,
"temperature": 0.0,
"do_sample": False,
"streamer": TextStreamer(processor.tokenizer, skip_prompt=True, skip_special_tokens=True)
}
generate_ids = ov_model.generate(**inputs,
eos_token_id=processor.tokenizer.eos_token_id,
**generation_args
)
generate_ids = generate_ids[:, inputs['input_ids'].shape[1]:]
response = processor.batch_decode(generate_ids,
skip_special_tokens=True,
clean_up_tokenization_spaces=False)[0]
```
## Limitations
Check the original [model card](https://huggingface.co./microsoft/Phi-3.5-vision-instruct) for limitations.
## Legal information
The original model is distributed under [MIT](https://huggingface.co./microsoft/Phi-3.5-vision-instruct/blob/main/LICENSE) license. More details can be found in [original model card](https://huggingface.co./microsoft/Phi-3.5-vision-instruct).
|