Instructions to use wangkanai/qwen3-vl-4b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wangkanai/qwen3-vl-4b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="wangkanai/qwen3-vl-4b-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 AutoModel model = AutoModel.from_pretrained("wangkanai/qwen3-vl-4b-instruct", dtype="auto") - llama-cpp-python
How to use wangkanai/qwen3-vl-4b-instruct with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="wangkanai/qwen3-vl-4b-instruct", filename="qwen3-vl-4b-instruct-abliterated-f16.gguf", )
llm.create_chat_completion( 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" } } ] } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use wangkanai/qwen3-vl-4b-instruct with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf wangkanai/qwen3-vl-4b-instruct:F16 # Run inference directly in the terminal: llama-cli -hf wangkanai/qwen3-vl-4b-instruct:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf wangkanai/qwen3-vl-4b-instruct:F16 # Run inference directly in the terminal: llama-cli -hf wangkanai/qwen3-vl-4b-instruct:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf wangkanai/qwen3-vl-4b-instruct:F16 # Run inference directly in the terminal: ./llama-cli -hf wangkanai/qwen3-vl-4b-instruct:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf wangkanai/qwen3-vl-4b-instruct:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf wangkanai/qwen3-vl-4b-instruct:F16
Use Docker
docker model run hf.co/wangkanai/qwen3-vl-4b-instruct:F16
- LM Studio
- Jan
- vLLM
How to use wangkanai/qwen3-vl-4b-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wangkanai/qwen3-vl-4b-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": "wangkanai/qwen3-vl-4b-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/wangkanai/qwen3-vl-4b-instruct:F16
- SGLang
How to use wangkanai/qwen3-vl-4b-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 "wangkanai/qwen3-vl-4b-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": "wangkanai/qwen3-vl-4b-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 "wangkanai/qwen3-vl-4b-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": "wangkanai/qwen3-vl-4b-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" } } ] } ] }' - Ollama
How to use wangkanai/qwen3-vl-4b-instruct with Ollama:
ollama run hf.co/wangkanai/qwen3-vl-4b-instruct:F16
- Unsloth Studio new
How to use wangkanai/qwen3-vl-4b-instruct with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for wangkanai/qwen3-vl-4b-instruct to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for wangkanai/qwen3-vl-4b-instruct to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for wangkanai/qwen3-vl-4b-instruct to start chatting
- Pi new
How to use wangkanai/qwen3-vl-4b-instruct with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf wangkanai/qwen3-vl-4b-instruct:F16
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "wangkanai/qwen3-vl-4b-instruct:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use wangkanai/qwen3-vl-4b-instruct with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf wangkanai/qwen3-vl-4b-instruct:F16
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default wangkanai/qwen3-vl-4b-instruct:F16
Run Hermes
hermes
- Docker Model Runner
How to use wangkanai/qwen3-vl-4b-instruct with Docker Model Runner:
docker model run hf.co/wangkanai/qwen3-vl-4b-instruct:F16
- Lemonade
How to use wangkanai/qwen3-vl-4b-instruct with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull wangkanai/qwen3-vl-4b-instruct:F16
Run and chat with the model
lemonade run user.qwen3-vl-4b-instruct-F16
List all available models
lemonade list
llm.create_chat_completion(
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"
}
}
]
}
]
)Qwen3-VL-4B-Instruct
Qwen3-VL-4B-Instruct is a powerful vision-language model with 4 billion parameters, developed by Qwen team at Alibaba Cloud. This model represents the latest generation in the Qwen series, offering superior text understanding, deeper visual perception, extended context length, and enhanced spatial and video comprehension capabilities.
Model Description
Qwen3-VL-4B-Instruct is a multimodal large language model that seamlessly integrates visual and textual understanding. Key capabilities include:
- Visual Agent Capabilities: Operates PC/mobile GUIs, recognizes elements, understands functions, invokes tools, and completes tasks
- Code Generation from Visuals: Generates Draw.io diagrams, HTML/CSS/JS code from images and videos
- Advanced Spatial Reasoning: 2D and 3D grounding for spatial perception and embodied AI applications
- OCR Excellence: Supports 32 languages with robust handling of low-light and blurred images
- Video Understanding: Full recall and second-level indexing with timestamp-grounded event localization
- Extended Context: 256K native context length (expandable to 1M tokens)
- STEM/Math Reasoning: Advanced causal analysis and mathematical reasoning capabilities
Repository Contents
This repository contains model files in both SafeTensors and GGUF formats:
| File | Size | Format | Description |
|---|---|---|---|
qwen3-vl-4b-instruct-abliterated.safetensors |
~8GB | SafeTensors | Main model weights (abliterated version) |
qwen3-vl-4b-instruct-abliterated-f16.gguf |
~8GB | GGUF FP16 | Quantized format for efficient inference |
Total Repository Size: ~16GB
Note: Model files are currently being downloaded. File sizes are estimates based on the 4B parameter count.
Hardware Requirements
Minimum Requirements
- VRAM: 12GB GPU (for FP16 inference)
- RAM: 16GB system memory
- Disk Space: 20GB available storage
Recommended Requirements
- VRAM: 16GB+ GPU (NVIDIA RTX 4070 or better)
- RAM: 32GB system memory
- Disk Space: 30GB available storage
- GPU: CUDA-compatible GPU with compute capability 7.0+
Performance Notes
- Enable
flash_attention_2for better acceleration and memory efficiency - Multi-image and video scenarios benefit significantly from flash attention
- BF16 precision recommended for optimal quality-performance balance
Usage Examples
Basic Image Understanding
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
from PIL import Image
# Load model and processor
model = Qwen3VLForConditionalGeneration.from_pretrained(
"E:/huggingface/qwen3-vl-4b-instruct",
torch_dtype="auto",
device_map="auto",
attn_implementation="flash_attention_2"
)
processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-4B-Instruct")
# Prepare image and text input
image = Image.open("path/to/your/image.jpg")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Describe this image in detail."}
]
}
]
# Process and generate
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
# Generate response
outputs = model.generate(
**inputs,
max_new_tokens=512,
top_p=0.8,
temperature=0.7
)
response = processor.batch_decode(outputs, skip_special_tokens=True)[0]
print(response)
Video Understanding
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
import cv2
# Load model
model = Qwen3VLForConditionalGeneration.from_pretrained(
"E:/huggingface/qwen3-vl-4b-instruct",
torch_dtype="auto",
device_map="auto"
)
processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-4B-Instruct")
# Extract video frames
def extract_frames(video_path, num_frames=8):
cap = cv2.VideoCapture(video_path)
frames = []
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
indices = [int(i * frame_count / num_frames) for i in range(num_frames)]
for idx in indices:
cap.set(cv2.CAP_PROP_POS_FRAMES, idx)
ret, frame = cap.read()
if ret:
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
cap.release()
return frames
# Process video
frames = extract_frames("path/to/video.mp4")
messages = [
{
"role": "user",
"content": [
{"type": "video", "video": frames},
{"type": "text", "text": "What happens in this video? Provide timestamps."}
]
}
]
# Generate analysis
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], videos=[frames], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1024)
print(processor.decode(outputs[0], skip_special_tokens=True))
GUI Agent Interaction
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
from PIL import ImageGrab
# Load model
model = Qwen3VLForConditionalGeneration.from_pretrained(
"E:/huggingface/qwen3-vl-4b-instruct",
torch_dtype="auto",
device_map="auto"
)
processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-4B-Instruct")
# Capture screenshot
screenshot = ImageGrab.grab()
# Analyze UI
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": screenshot},
{"type": "text", "text": "Identify all clickable elements and their functions."}
]
}
]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[screenshot], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(processor.decode(outputs[0], skip_special_tokens=True))
Model Specifications
Architecture
- Parameters: 4 billion (dense architecture)
- Precision: BF16 tensor type
- Context Length: 256K tokens (native), expandable to 1M
- Vision Encoder: DeepStack multi-level ViT with fine-grained feature fusion
- Positional Encoding: Interleaved-MRoPE for temporal, spatial dimensions
- Video Processing: Text-Timestamp Alignment for precise event localization
Supported Languages (OCR)
32 languages including English, Chinese, Japanese, Korean, Arabic, French, German, Spanish, and more.
Model Innovations
- Interleaved-MRoPE: Full-frequency coverage across temporal, width, and height dimensions
- DeepStack: Multi-level ViT feature fusion for enhanced image-text alignment
- Text-Timestamp Alignment: Precise timestamp-grounded event localization in videos
Performance Tips
Optimization Strategies
Enable Flash Attention 2: Significantly improves memory efficiency and speed
attn_implementation="flash_attention_2"Batch Processing: Process multiple images/videos in batches when possible
inputs = processor(text=texts, images=images, return_tensors="pt", padding=True)Quantization: Use GGUF format for reduced memory footprint
- FP16: ~8GB (included in repository)
- Consider INT8/INT4 quantization for edge deployment
Context Management: For long contexts, use sliding window or chunking strategies
Generation Parameters:
- Vision-Language Tasks:
top_p=0.8,temperature=0.7 - Code Generation:
top_p=0.9,temperature=0.3 - Creative Tasks:
top_p=0.95,temperature=0.9
- Vision-Language Tasks:
Memory Optimization
- Use
device_map="auto"for automatic multi-GPU distribution - Enable gradient checkpointing for training/fine-tuning
- Clear cache between inference runs:
torch.cuda.empty_cache()
License
This model is licensed under Apache License 2.0.
Key Points:
- ✅ Commercial use permitted
- ✅ Private use permitted
- ✅ Modification and distribution allowed
- ⚠️ Must include copyright notice and license
- ⚠️ Must state significant changes
- ❌ No trademark use
- ❌ No warranty provided
Full license text: https://www.apache.org/licenses/LICENSE-2.0
Citation
If you use Qwen3-VL-4B-Instruct in your research or applications, please cite:
@article{qwen3vl2025,
title={Qwen3-VL: The Next Generation Vision-Language Model},
author={Qwen Team},
journal={arXiv preprint},
year={2025},
organization={Alibaba Cloud}
}
Official Resources
- Hugging Face: https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct
- GitHub Repository: https://github.com/QwenLM/Qwen3-VL
- Documentation: https://huggingface.co/docs/transformers/main/model_doc/qwen3_vl
- Model Card: https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct#model-card
- Technical Report: Check GitHub repository for latest research papers
Support
For issues, questions, or contributions:
- GitHub Issues: https://github.com/QwenLM/Qwen3-VL/issues
- Hugging Face Discussions: https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct/discussions
- Official Documentation: https://qwenlm.github.io/
Release Date: October 15, 2025 Model Version: Qwen3-VL-4B-Instruct (Abliterated) Last Updated: November 5, 2025
- Downloads last month
- 25
16-bit
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="wangkanai/qwen3-vl-4b-instruct", filename="qwen3-vl-4b-instruct-abliterated-f16.gguf", )