Instructions to use Qwen/Qwen2.5-VL-72B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen2.5-VL-72B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Qwen/Qwen2.5-VL-72B-Instruct") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-72B-Instruct") model = AutoModelForMultimodalLM.from_pretrained("Qwen/Qwen2.5-VL-72B-Instruct", device_map="auto") 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwen/Qwen2.5-VL-72B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen2.5-VL-72B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen2.5-VL-72B-Instruct", "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/Qwen/Qwen2.5-VL-72B-Instruct
- SGLang
How to use Qwen/Qwen2.5-VL-72B-Instruct 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 "Qwen/Qwen2.5-VL-72B-Instruct" \ --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": "Qwen/Qwen2.5-VL-72B-Instruct", "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 "Qwen/Qwen2.5-VL-72B-Instruct" \ --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": "Qwen/Qwen2.5-VL-72B-Instruct", "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 Qwen/Qwen2.5-VL-72B-Instruct with Docker Model Runner:
docker model run hf.co/Qwen/Qwen2.5-VL-72B-Instruct
Error in preprocessing prompt inputs
I started an vllm service using
vllm serve Qwen/Qwen2.5-VL-72B-Instruct
--host 0.0.0.0
--tensor-parallel-size 2
--max-model-len 32768
--gpu-memory-utilization 0.9
--port 8001 > logs/vllm/qwen-vl.log 2>&1 &
Then I use
def get_answer_vl(path):
url = "http://localhost:8001/v1/chat/completions"
headers = {
"Content-Type": "application/json"
}
data = {
"model": "Qwen/Qwen2.5-VL-72B-Instruct",
"messages": [
{
"role": "user",
"content": [
{
"type": "image",
"image": path,
},
{"type": "text", "text": 'Please describe the image'}
]
}
],
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print(response.json()['choices'][0]['message']['content'])
return response.json()['choices'][0]['message']['content']
else:
print(f"Error: {response.status_code}, {response.text}")
and I get the following error:
ERROR 02-20 16:18:22 serving_chat.py:193] Error in preprocessing prompt inputs
ERROR 02-20 16:18:22 serving_chat.py:193] Traceback (most recent call last):
ERROR 02-20 16:18:22 serving_chat.py:193] File "/data/l00929485/.local/lib/python3.12/site-packages/vllm/entrypoints/openai/serving_chat.py", line 177, in create_chat_completion
ERROR 02-20 16:18:22 serving_chat.py:193] ) = await self._preprocess_chat(
ERROR 02-20 16:18:22 serving_chat.py:193] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 02-20 16:18:22 serving_chat.py:193] File "/data/l00929485/.local/lib/python3.12/site-packages/vllm/entrypoints/openai/serving_engine.py", line 386, in _preprocess_chat
ERROR 02-20 16:18:22 serving_chat.py:193] conversation, mm_data_future = parse_chat_messages_futures(
ERROR 02-20 16:18:22 serving_chat.py:193] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 02-20 16:18:22 serving_chat.py:193] File "/data/l00929485/.local/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 951, in parse_chat_messages_futures
ERROR 02-20 16:18:22 serving_chat.py:193] sub_messages = _parse_chat_message_content(
ERROR 02-20 16:18:22 serving_chat.py:193] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 02-20 16:18:22 serving_chat.py:193] File "/data/l00929485/.local/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 879, in _parse_chat_message_content
ERROR 02-20 16:18:22 serving_chat.py:193] result = _parse_chat_message_content_parts(
ERROR 02-20 16:18:22 serving_chat.py:193] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 02-20 16:18:22 serving_chat.py:193] File "/data/l00929485/.local/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 781, in _parse_chat_message_content_parts
ERROR 02-20 16:18:22 serving_chat.py:193] for part in parts:
ERROR 02-20 16:18:22 serving_chat.py:193] ^^^^^
ERROR 02-20 16:18:22 serving_chat.py:193] pydantic_core._pydantic_core.ValidationError: 6 validation errors for ValidatorIterator
ERROR 02-20 16:18:22 serving_chat.py:193] 0.typed-dict.text
ERROR 02-20 16:18:22 serving_chat.py:193] Field required [type=missing, input_value={'type': 'image', 'image': 'test.png'}, input_type=dict]
ERROR 02-20 16:18:22 serving_chat.py:193] For further information visit https://errors.pydantic.dev/2.10/v/missing
ERROR 02-20 16:18:22 serving_chat.py:193] 0.typed-dict.type
ERROR 02-20 16:18:22 serving_chat.py:193] Input should be 'text' [type=literal_error, input_value='image', input_type=str]
ERROR 02-20 16:18:22 serving_chat.py:193] For further information visit https://errors.pydantic.dev/2.10/v/literal_error
ERROR 02-20 16:18:22 serving_chat.py:193] 0.typed-dict.image_url
ERROR 02-20 16:18:22 serving_chat.py:193] Field required [type=missing, input_value={'type': 'image', 'image': 'test.png'}, input_type=dict]
ERROR 02-20 16:18:22 serving_chat.py:193] For further information visit https://errors.pydantic.dev/2.10/v/missing
ERROR 02-20 16:18:22 serving_chat.py:193] 0.typed-dict.type
ERROR 02-20 16:18:22 serving_chat.py:193] Input should be 'image_url' [type=literal_error, input_value='image', input_type=str]
ERROR 02-20 16:18:22 serving_chat.py:193] For further information visit https://errors.pydantic.dev/2.10/v/literal_error
ERROR 02-20 16:18:22 serving_chat.py:193] 0.typed-dict.input_audio
ERROR 02-20 16:18:22 serving_chat.py:193] Field required [type=missing, input_value={'type': 'image', 'image': 'test.png'}, input_type=dict]
ERROR 02-20 16:18:22 serving_chat.py:193] For further information visit https://errors.pydantic.dev/2.10/v/missing
ERROR 02-20 16:18:22 serving_chat.py:193] 0.typed-dict.type
ERROR 02-20 16:18:22 serving_chat.py:193] Input should be 'input_audio' [type=literal_error, input_value='image', input_type=str]
ERROR 02-20 16:18:22 serving_chat.py:193] For further information visit https://errors.pydantic.dev/2.10/v/literal_error