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-3B-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-3B-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-3B-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-3B-Instruct-unsloth-bnb-4bit") model = AutoModelForMultimodalLM.from_pretrained("unsloth/Qwen2.5-VL-3B-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-3B-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-3B-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-3B-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-3B-Instruct-unsloth-bnb-4bit
- SGLang
How to use unsloth/Qwen2.5-VL-3B-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-3B-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-3B-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-3B-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-3B-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-3B-Instruct-unsloth-bnb-4bit with Docker Model Runner:
docker model run hf.co/unsloth/Qwen2.5-VL-3B-Instruct-unsloth-bnb-4bit
| { | |
| "architectures": [ | |
| "Qwen2_5_VLForConditionalGeneration" | |
| ], | |
| "attention_dropout": 0.0, | |
| "eos_token_id": 151645, | |
| "hidden_act": "silu", | |
| "hidden_size": 2048, | |
| "image_token_id": 151655, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 11008, | |
| "max_position_embeddings": 128000, | |
| "max_window_layers": 70, | |
| "model_type": "qwen2_5_vl", | |
| "num_attention_heads": 16, | |
| "num_hidden_layers": 36, | |
| "num_key_value_heads": 2, | |
| "pad_token_id": 151654, | |
| "quantization_config": { | |
| "_load_in_4bit": true, | |
| "_load_in_8bit": false, | |
| "bnb_4bit_compute_dtype": "bfloat16", | |
| "bnb_4bit_quant_storage": "uint8", | |
| "bnb_4bit_quant_type": "nf4", | |
| "bnb_4bit_use_double_quant": true, | |
| "llm_int8_enable_fp32_cpu_offload": false, | |
| "llm_int8_has_fp16_weight": false, | |
| "llm_int8_skip_modules": [ | |
| "lm_head", | |
| "multi_modal_projector", | |
| "merger", | |
| "modality_projection", | |
| "model.layers.5.mlp", | |
| "visual.blocks.25.attn", | |
| "visual.merger.mlp", | |
| "visual.blocks.24.attn", | |
| "visual.blocks.29.attn", | |
| "visual.blocks.30.attn", | |
| "visual.blocks.26.attn", | |
| "visual.blocks.22.attn", | |
| "visual.blocks.31.attn", | |
| "visual.blocks.27.attn", | |
| "model.layers.30.mlp", | |
| "visual.blocks.30.mlp", | |
| "visual.blocks.28.attn", | |
| "visual.blocks.29.mlp", | |
| "visual.blocks.25.mlp", | |
| "visual.blocks.21.attn", | |
| "visual.blocks.18.attn", | |
| "visual.blocks.20.attn", | |
| "visual.blocks.26.mlp", | |
| "visual.blocks.16.attn", | |
| "visual.blocks.31.mlp", | |
| "visual.blocks.28.mlp", | |
| "visual.blocks.27.mlp", | |
| "visual.blocks.24.mlp", | |
| "visual.blocks.19.attn", | |
| "visual.blocks.23.mlp", | |
| "visual.blocks.19.mlp", | |
| "visual.blocks.17.attn", | |
| "visual.blocks.20.mlp", | |
| "visual.blocks.23.attn", | |
| "visual.blocks.13.attn", | |
| "visual.blocks.22.mlp", | |
| "visual.blocks.9.mlp", | |
| "visual.blocks.10.mlp", | |
| "visual.blocks.16.mlp", | |
| "visual.blocks.12.attn", | |
| "visual.blocks.18.mlp", | |
| "visual.blocks.21.mlp", | |
| "visual.blocks.6.mlp", | |
| "model.layers.1.mlp", | |
| "visual.blocks.14.attn", | |
| "visual.blocks.11.mlp", | |
| "visual.blocks.11.attn", | |
| "visual.blocks.9.attn", | |
| "model.layers.2.mlp", | |
| "visual.blocks.12.mlp", | |
| "visual.blocks.10.attn", | |
| "visual.blocks.6.attn", | |
| "visual.blocks.13.mlp", | |
| "visual.blocks.8.mlp", | |
| "visual.blocks.14.mlp", | |
| "visual.blocks.7.mlp", | |
| "visual.blocks.5.attn", | |
| "visual.blocks.8.attn", | |
| "visual.blocks.15.mlp", | |
| "visual.blocks.5.mlp", | |
| "visual.blocks.3.mlp", | |
| "visual.blocks.2.mlp", | |
| "visual.blocks.4.mlp", | |
| "visual.blocks.2.attn", | |
| "visual.blocks.7.attn", | |
| "visual.blocks.1.attn", | |
| "visual.blocks.17.mlp", | |
| "visual.blocks.15.attn", | |
| "visual.blocks.4.attn", | |
| "visual.blocks.1.mlp", | |
| "visual.blocks.0.attn", | |
| "visual.blocks.0.mlp", | |
| "visual.blocks.3.attn", | |
| "visual.blocks.31.mlp.down_proj" | |
| ], | |
| "llm_int8_threshold": 6.0, | |
| "load_in_4bit": true, | |
| "load_in_8bit": false, | |
| "quant_method": "bitsandbytes" | |
| }, | |
| "rms_norm_eps": 1e-06, | |
| "rope_scaling": { | |
| "mrope_section": [ | |
| 16, | |
| 24, | |
| 24 | |
| ], | |
| "rope_type": "default", | |
| "type": "default" | |
| }, | |
| "rope_theta": 1000000.0, | |
| "sliding_window": 32768, | |
| "tie_word_embeddings": true, | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.51.3", | |
| "unsloth_fixed": true, | |
| "use_cache": true, | |
| "use_sliding_window": false, | |
| "video_token_id": 151656, | |
| "vision_config": { | |
| "depth": 32, | |
| "fullatt_block_indexes": [ | |
| 7, | |
| 15, | |
| 23, | |
| 31 | |
| ], | |
| "hidden_act": "silu", | |
| "hidden_size": 1280, | |
| "in_channels": 3, | |
| "in_chans": 3, | |
| "intermediate_size": 3420, | |
| "model_type": "qwen2_5_vl", | |
| "num_heads": 16, | |
| "out_hidden_size": 2048, | |
| "patch_size": 14, | |
| "spatial_merge_size": 2, | |
| "spatial_patch_size": 14, | |
| "temporal_patch_size": 2, | |
| "tokens_per_second": 2, | |
| "torch_dtype": "bfloat16", | |
| "window_size": 112 | |
| }, | |
| "vision_end_token_id": 151653, | |
| "vision_start_token_id": 151652, | |
| "vision_token_id": 151654, | |
| "vocab_size": 151936 | |
| } | |