Instructions to use OpenVINO/Qwen2-VL-7B-Instruct-int4-ov with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenVINO/Qwen2-VL-7B-Instruct-int4-ov with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenVINO/Qwen2-VL-7B-Instruct-int4-ov") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("OpenVINO/Qwen2-VL-7B-Instruct-int4-ov") model = AutoModelForImageTextToText.from_pretrained("OpenVINO/Qwen2-VL-7B-Instruct-int4-ov") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenVINO/Qwen2-VL-7B-Instruct-int4-ov with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenVINO/Qwen2-VL-7B-Instruct-int4-ov" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenVINO/Qwen2-VL-7B-Instruct-int4-ov", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/OpenVINO/Qwen2-VL-7B-Instruct-int4-ov
- SGLang
How to use OpenVINO/Qwen2-VL-7B-Instruct-int4-ov with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OpenVINO/Qwen2-VL-7B-Instruct-int4-ov" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenVINO/Qwen2-VL-7B-Instruct-int4-ov", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OpenVINO/Qwen2-VL-7B-Instruct-int4-ov" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenVINO/Qwen2-VL-7B-Instruct-int4-ov", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use OpenVINO/Qwen2-VL-7B-Instruct-int4-ov with Docker Model Runner:
docker model run hf.co/OpenVINO/Qwen2-VL-7B-Instruct-int4-ov
Qwen2-VL-7B-Instruct-int4-ov
- Model creator: Qwen
- Original model: Qwen/Qwen2-VL-7B-Instruct
Description
This is Qwen/Qwen2-VL-7B-Instruct model converted to the OpenVINO™ IR (Intermediate Representation) format with weights compressed to INT4 by NNCF.
Quantization Parameters
Weight compression was performed using nncf.compress_weights with the following parameters:
- mode: INT4_ASYM
Compatibility
The provided OpenVINO™ IR model is compatible with:
- OpenVINO version 2025.2.0 and higher
- Optimum Intel 1.26.0 and higher
Running Model Inference with OpenVINO GenAI
- Install packages required for using OpenVINO GenAI.
pip install --pre -U --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release openvino openvino-tokenizers openvino-genai
pip install huggingface_hub
- Download model from HuggingFace Hub
import huggingface_hub as hf_hub
model_id = "OpenVINO/Qwen2-VL-7B-Instruct-int4-ov"
model_path = "Qwen2-VL-7B-Instruct-int4-ov"
hf_hub.snapshot_download(model_id, local_dir=model_path)
- Run model inference:
import openvino_genai as ov_genai
import requests
from PIL import Image
from io import BytesIO
import numpy as np
import openvino as ov
device = "CPU"
pipe = ov_genai.VLMPipeline(model_path, device)
def load_image(image_file):
if isinstance(image_file, str) and (image_file.startswith("http") or image_file.startswith("https")):
response = requests.get(image_file)
image = Image.open(BytesIO(response.content)).convert("RGB")
else:
image = Image.open(image_file).convert("RGB")
image_data = np.array(image.getdata()).reshape(1, image.size[1], image.size[0], 3).astype(np.byte)
return ov.Tensor(image_data)
prompt = "What is unusual in this picture?"
url = "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11"
image_tensor = load_image(url)
def streamer(subword: str) -> bool:
print(subword, end="", flush=True)
return False
pipe.start_chat()
output = pipe.generate(prompt, image=image_tensor, max_new_tokens=100, streamer=streamer)
pipe.finish_chat()
More GenAI usage examples can be found in OpenVINO GenAI library docs and samples
Limitations
Check the original model card for limitations.
Legal information
The original model is distributed under apache-2.0 license. More details can be found in original model card.
Disclaimer
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. 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.
- Downloads last month
- 132