Instructions to use array/Qwen2.5-VL-Mull with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use array/Qwen2.5-VL-Mull with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="array/Qwen2.5-VL-Mull", trust_remote_code=True) 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("array/Qwen2.5-VL-Mull", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("array/Qwen2.5-VL-Mull", trust_remote_code=True, 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use array/Qwen2.5-VL-Mull with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "array/Qwen2.5-VL-Mull" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "array/Qwen2.5-VL-Mull", "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/array/Qwen2.5-VL-Mull
- SGLang
How to use array/Qwen2.5-VL-Mull 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 "array/Qwen2.5-VL-Mull" \ --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": "array/Qwen2.5-VL-Mull", "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 "array/Qwen2.5-VL-Mull" \ --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": "array/Qwen2.5-VL-Mull", "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 array/Qwen2.5-VL-Mull with Docker Model Runner:
docker model run hf.co/array/Qwen2.5-VL-Mull
Serve correctly on vLLM: fix image_processor_type, pre-fill latent block in chat template, pin vision_config
Browse files- preprocessor_config.json: image_processor_type Qwen2_5_VLImageProcessor -> Qwen2VLImageProcessor.
The old name is the transformers-fork class and is not in the auto map, so stock
transformers raised 'Unrecognized image processor'. The two classes produce
bit-identical pixel_values.
- chat_template: the add_generation_prompt branch now pre-fills the assistant turn with
<think> + 20 x <|latent_pad|> + </think>. Without it a served model receives zero latent
tokens and reverts to thinking in text (~11x the decode cost). Guarded by
add_generation_prompt, so training and lmms-eval render byte-identically to before.
Override per request with chat_template_kwargs {"num_latents": N}; 0 disables.
- config.json: vision_config written out explicitly rather than relying on transformers
class defaults. auto_map is kept.
- chat_template.jinja +2 -1
- chat_template.json +2 -2
- config.json +16 -1
- preprocessor_config.json +1 -1
|
@@ -4,4 +4,5 @@ You are a helpful assistant.<|im_end|>
|
|
| 4 |
{% if message['content'] is string %}{{ message['content'] }}<|im_end|>
|
| 5 |
{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>
|
| 6 |
{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
| 7 |
-
{%
|
|
|
|
|
|
| 4 |
{% if message['content'] is string %}{{ message['content'] }}<|im_end|>
|
| 5 |
{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>
|
| 6 |
{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
| 7 |
+
{% set n = num_latents if num_latents is defined else 20 %}{% if n > 0 %}<think>{{ '<|latent_pad|>' * n }}</think>
|
| 8 |
+
{% endif %}{% endif %}
|
|
@@ -1,3 +1,3 @@
|
|
| 1 |
{
|
| 2 |
-
"chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}"
|
| 3 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% set n = num_latents if num_latents is defined else 20 %}{% if n > 0 %}<think>{{ '<|latent_pad|>' * n }}</think>\n{% endif %}{% endif %}"
|
| 3 |
+
}
|
|
@@ -48,14 +48,29 @@
|
|
| 48 |
"use_sliding_window": false,
|
| 49 |
"video_token_id": 151656,
|
| 50 |
"vision_config": {
|
|
|
|
| 51 |
"dtype": "bfloat16",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
"hidden_size": 1280,
|
| 53 |
"in_chans": 3,
|
| 54 |
"initializer_range": 0.02,
|
|
|
|
| 55 |
"model_type": "qwen2_5_vl",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
"spatial_patch_size": 14,
|
|
|
|
| 57 |
"tokens_per_second": 2,
|
| 58 |
-
"torch_dtype": "bfloat16"
|
|
|
|
| 59 |
},
|
| 60 |
"vision_end_token_id": 151653,
|
| 61 |
"vision_start_token_id": 151652,
|
|
|
|
| 48 |
"use_sliding_window": false,
|
| 49 |
"video_token_id": 151656,
|
| 50 |
"vision_config": {
|
| 51 |
+
"depth": 32,
|
| 52 |
"dtype": "bfloat16",
|
| 53 |
+
"fullatt_block_indexes": [
|
| 54 |
+
7,
|
| 55 |
+
15,
|
| 56 |
+
23,
|
| 57 |
+
31
|
| 58 |
+
],
|
| 59 |
+
"hidden_act": "silu",
|
| 60 |
"hidden_size": 1280,
|
| 61 |
"in_chans": 3,
|
| 62 |
"initializer_range": 0.02,
|
| 63 |
+
"intermediate_size": 3420,
|
| 64 |
"model_type": "qwen2_5_vl",
|
| 65 |
+
"num_heads": 16,
|
| 66 |
+
"out_hidden_size": 3584,
|
| 67 |
+
"patch_size": 14,
|
| 68 |
+
"spatial_merge_size": 2,
|
| 69 |
"spatial_patch_size": 14,
|
| 70 |
+
"temporal_patch_size": 2,
|
| 71 |
"tokens_per_second": 2,
|
| 72 |
+
"torch_dtype": "bfloat16",
|
| 73 |
+
"window_size": 112
|
| 74 |
},
|
| 75 |
"vision_end_token_id": 151653,
|
| 76 |
"vision_start_token_id": 151652,
|
|
@@ -8,7 +8,7 @@
|
|
| 8 |
0.4578275,
|
| 9 |
0.40821073
|
| 10 |
],
|
| 11 |
-
"image_processor_type": "
|
| 12 |
"image_std": [
|
| 13 |
0.26862954,
|
| 14 |
0.26130258,
|
|
|
|
| 8 |
0.4578275,
|
| 9 |
0.40821073
|
| 10 |
],
|
| 11 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 12 |
"image_std": [
|
| 13 |
0.26862954,
|
| 14 |
0.26130258,
|