Image-Text-to-Text
Transformers
Safetensors
English
qwen2_5_vl
multimodal
unsloth
conversational
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit") 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("unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit") model = AutoModelForMultimodalLM.from_pretrained("unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit", "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/unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit
- SGLang
How to use unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit 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 "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit" \ --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": "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit", "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 "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit" \ --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": "unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit", "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" } } ] } ] }' - Unsloth Desktop
- Docker Model Runner
How to use unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit with Docker Model Runner:
docker model run hf.co/unsloth/Qwen2.5-VL-32B-Instruct-unsloth-bnb-4bit
Upload folder using huggingface_hub
Browse files- config.json +1 -41
- generation_config.json +1 -1
- tokenizer_config.json +2 -2
config.json
CHANGED
|
@@ -121,48 +121,9 @@
|
|
| 121 |
},
|
| 122 |
"rope_theta": 1000000.0,
|
| 123 |
"sliding_window": 32768,
|
| 124 |
-
"text_config": {
|
| 125 |
-
"architectures": [
|
| 126 |
-
"Qwen2_5_VLForConditionalGeneration"
|
| 127 |
-
],
|
| 128 |
-
"attention_dropout": 0.0,
|
| 129 |
-
"eos_token_id": 151645,
|
| 130 |
-
"hidden_act": "silu",
|
| 131 |
-
"hidden_size": 5120,
|
| 132 |
-
"image_token_id": null,
|
| 133 |
-
"initializer_range": 0.02,
|
| 134 |
-
"intermediate_size": 27648,
|
| 135 |
-
"max_position_embeddings": 128000,
|
| 136 |
-
"max_window_layers": 64,
|
| 137 |
-
"model_type": "qwen2_5_vl_text",
|
| 138 |
-
"num_attention_heads": 40,
|
| 139 |
-
"num_hidden_layers": 64,
|
| 140 |
-
"num_key_value_heads": 8,
|
| 141 |
-
"pad_token_id": 151643,
|
| 142 |
-
"rms_norm_eps": 1e-06,
|
| 143 |
-
"rope_scaling": {
|
| 144 |
-
"mrope_section": [
|
| 145 |
-
16,
|
| 146 |
-
24,
|
| 147 |
-
24
|
| 148 |
-
],
|
| 149 |
-
"rope_type": "default",
|
| 150 |
-
"type": "default"
|
| 151 |
-
},
|
| 152 |
-
"rope_theta": 1000000.0,
|
| 153 |
-
"sliding_window": 32768,
|
| 154 |
-
"torch_dtype": "bfloat16",
|
| 155 |
-
"use_cache": true,
|
| 156 |
-
"use_sliding_window": false,
|
| 157 |
-
"video_token_id": null,
|
| 158 |
-
"vision_end_token_id": 151653,
|
| 159 |
-
"vision_start_token_id": 151652,
|
| 160 |
-
"vision_token_id": 151654,
|
| 161 |
-
"vocab_size": 152064
|
| 162 |
-
},
|
| 163 |
"tie_word_embeddings": false,
|
| 164 |
"torch_dtype": "bfloat16",
|
| 165 |
-
"transformers_version": "4.
|
| 166 |
"unsloth_fixed": true,
|
| 167 |
"use_cache": true,
|
| 168 |
"use_sliding_window": false,
|
|
@@ -179,7 +140,6 @@
|
|
| 179 |
"hidden_size": 1280,
|
| 180 |
"in_channels": 3,
|
| 181 |
"in_chans": 3,
|
| 182 |
-
"initializer_range": 0.02,
|
| 183 |
"intermediate_size": 3456,
|
| 184 |
"model_type": "qwen2_5_vl",
|
| 185 |
"num_heads": 16,
|
|
|
|
| 121 |
},
|
| 122 |
"rope_theta": 1000000.0,
|
| 123 |
"sliding_window": 32768,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
"tie_word_embeddings": false,
|
| 125 |
"torch_dtype": "bfloat16",
|
| 126 |
+
"transformers_version": "4.51.3",
|
| 127 |
"unsloth_fixed": true,
|
| 128 |
"use_cache": true,
|
| 129 |
"use_sliding_window": false,
|
|
|
|
| 140 |
"hidden_size": 1280,
|
| 141 |
"in_channels": 3,
|
| 142 |
"in_chans": 3,
|
|
|
|
| 143 |
"intermediate_size": 3456,
|
| 144 |
"model_type": "qwen2_5_vl",
|
| 145 |
"num_heads": 16,
|
generation_config.json
CHANGED
|
@@ -9,5 +9,5 @@
|
|
| 9 |
"pad_token_id": 151654,
|
| 10 |
"repetition_penalty": 1.05,
|
| 11 |
"temperature": 1e-06,
|
| 12 |
-
"transformers_version": "4.
|
| 13 |
}
|
|
|
|
| 9 |
"pad_token_id": 151654,
|
| 10 |
"repetition_penalty": 1.05,
|
| 11 |
"temperature": 1e-06,
|
| 12 |
+
"transformers_version": "4.51.3"
|
| 13 |
}
|
tokenizer_config.json
CHANGED
|
@@ -195,6 +195,7 @@
|
|
| 195 |
"<|video_pad|>"
|
| 196 |
],
|
| 197 |
"bos_token": null,
|
|
|
|
| 198 |
"clean_up_tokenization_spaces": false,
|
| 199 |
"eos_token": "<|im_end|>",
|
| 200 |
"errors": "replace",
|
|
@@ -205,6 +206,5 @@
|
|
| 205 |
"processor_class": "Qwen2_5_VLProcessor",
|
| 206 |
"split_special_tokens": false,
|
| 207 |
"tokenizer_class": "Qwen2Tokenizer",
|
| 208 |
-
"unk_token": null
|
| 209 |
-
"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 %}"
|
| 210 |
}
|
|
|
|
| 195 |
"<|video_pad|>"
|
| 196 |
],
|
| 197 |
"bos_token": null,
|
| 198 |
+
"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 %}",
|
| 199 |
"clean_up_tokenization_spaces": false,
|
| 200 |
"eos_token": "<|im_end|>",
|
| 201 |
"errors": "replace",
|
|
|
|
| 206 |
"processor_class": "Qwen2_5_VLProcessor",
|
| 207 |
"split_special_tokens": false,
|
| 208 |
"tokenizer_class": "Qwen2Tokenizer",
|
| 209 |
+
"unk_token": null
|
|
|
|
| 210 |
}
|