Downloads · 30 days
31
6% of all-time downloads
wangkanai/qwen3-vl-4b-thinking
qwen3-vl-4b-thinking is a image-text-to-text model from wangkanai. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
Qwen3-VL-4B-Thinking is a 4-billion-parameter multimodal vision-language model developed by the Qwen team at Alibaba Cloud. This "Thinking" variant emphasizes deeper multi-step reasoning, analysis, and planning with d…
Downloads · 30 days
31
6% of all-time downloads
All-time downloads
509
Public
Repo size
16.9 GB
Likes
1
Public
Click a slice to open those files.
.safetensors8.9 GB · 52%
From the Hugging Face model README
Qwen3-VL-4B-Thinking is a 4-billion-parameter multimodal vision-language model developed by the Qwen team at Alibaba Cloud. This "Thinking" variant emphasizes deeper multi-step reasoning, analysis, and planning with detailed chain-of-thought generation, making it ideal for advanced visual reasoning tasks across images, text, and video inputs.
Qwen3-VL-4B-Thinking represents the latest advancement in the Qwen vision-language model series, designed to deliver superior text understanding, deeper visual perception, and extended reasoning capabilities. The model excels at producing structured outputs that expose intermediate reasoning steps, making it particularly valuable for research applications, multimodal understanding tasks, and agentic workflows.
The model employs three key architectural innovations:
Vision Encoder: Enhanced Vision Transformer with window attention, optimized using SwiGLU and RMSNorm
Video Processing: Dynamic frame rate sampling with updated mRoPE using temporal IDs and absolute time alignment
Note: This directory is prepared for model storage. Download model files from the official Hugging Face repository.
When downloaded, this repository will contain:
| File | Purpose | Approximate Size |
|---|---|---|
model.safetensors or sharded files | Model weights (BF16) | ~8-9 GB |
config.json | Model configuration | ~2 KB |
tokenizer.json | Tokenizer vocabulary | ~7 MB |
tokenizer_config.json | Tokenizer configuration | ~1 KB |
generation_config.json | Generation parameters | ~1 KB |
preprocessor_config.json | Vision preprocessor config | ~1 KB |
merges.txt | BPE merge rules | ~2 MB |
vocab.json | Vocabulary mapping | ~5 MB |
Total Repository Size: ~8-10 GB
For reduced VRAM usage, consider:
Install the latest Transformers library from source:
pip install git+https://github.com/huggingface/transformers
pip install qwen-vl-utils # Optional: for advanced visual input handling
pip install accelerate pillow torch torchvision
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
from PIL import Image
import torch
# Load model and processor
model_path = "E:/huggingface/qwen3-vl-4b-thinking"
model = Qwen3VLForConditionalGeneration.from_pretrained(
model_path,
torch_dtype=torch.bfloat16,
device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_path)
# Load and process image
image = Image.open("your_image.jpg")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Describe this image in detail with reasoning steps."}
]
}
]
# Prepare inputs
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt", padding=True)
inputs = inputs.to(model.device)
# Generate with thinking parameters
output_ids = model.generate(
**inputs,
max_new_tokens=4096,
top_p=0.95,
top_k=20,
temperature=1.0
)
# Decode output
generated_text = processor.batch_decode(
output_ids[:, inputs.input_ids.shape[1]:],
skip_special_tokens=True
)[0]
print(generated_text)
import cv2
from qwen_vl_utils import process_vision_info
# Extract video frames
video_path = "your_video.mp4"
cap = cv2.VideoCapture(video_path)
frames = []
while len(frames) < 16: # Sample 16 frames
ret, frame = cap.read()
if not ret:
break
frames.append(Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)))
cap.release()
# Create video message
messages = [
{
"role": "user",
"content": [
{"type": "video", "video": frames},
{"type": "text", "text": "Analyze the events in this video and explain your reasoning."}
]
}
]
# Process and generate
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], videos=[frames], return_tensors="pt")
inputs = inputs.to(model.device)
output_ids = model.generate(**inputs, max_new_tokens=4096, top_p=0.95)
result = processor.batch_decode(output_ids[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]
print(result)
# Load document image
document_image = Image.open("invoice.jpg")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": document_image},
{"type": "text", "text": "Extract all text from this document and structure it as JSON. Explain your extraction process."}
]
}
]
# Process with thinking approach
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[document_image], return_tensors="pt")
inputs = inputs.to(model.device)
output_ids = model.generate(**inputs, max_new_tokens=4096)
extracted_text = processor.batch_decode(output_ids[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]
print(extracted_text)
| Specification | Details |
|---|---|
| Parameters | 4 billion |
| Precision | BF16 (bfloat16) |
| Context Length | 256K tokens (expandable to 1M) |
| Languages (OCR) | 32 languages |
| Max Output Tokens | 40,960 (vision-language), 32,768 (text-only) |
| Architecture | Vision Transformer + Qwen3 LLM with Interleaved-MRoPE |
| License | Apache 2.0 |
| Release Date | October 15, 2025 |
| Format | Safetensors |
Vision-Language Tasks:
generation_config = {
"top_p": 0.95,
"top_k": 20,
"temperature": 1.0,
"max_new_tokens": 4096,
"do_sample": True
}
Text-Only Tasks:
generation_config = {
"top_p": 0.95,
"top_k": 20,
"temperature": 1.0,
"presence_penalty": 1.5,
"max_new_tokens": 32768,
"do_sample": True
}
# Enable memory-efficient attention
model = Qwen3VLForConditionalGeneration.from_pretrained(
model_path,
torch_dtype=torch.bfloat16,
device_map="auto",
attn_implementation="flash_attention_2" # Requires flash-attn package
)
# Or use 8-bit quantization
from transformers import BitsAndBytesConfig
quantization_config = BitsAndBytesConfig(
load_in_8bit=True,
bnb_8bit_compute_dtype=torch.bfloat16
)
model = Qwen3VLForConditionalGeneration.from_pretrained(
model_path,
quantization_config=quantization_config,
device_map="auto"
)
This model is released under the Apache License 2.0.
Copyright 2025 Qwen Team, Alibaba Cloud
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
If you use Qwen3-VL-4B-Thinking in your research, please cite:
@article{qwen3vl2025,
title={Qwen3-VL: Superior Text Understanding \& Generation, Deeper Visual Perception \& Reasoning},
author={Qwen Team},
journal={arXiv preprint},
year={2025},
url={https://huggingface.co/Qwen/Qwen3-VL-4B-Thinking}
}
Developed by the Qwen team at Alibaba Cloud. Special thanks to the Hugging Face Transformers team for integration support and the open-source community for feedback and contributions.
Downloads: 29,713+ | Fine-Tunes: 6+ | Quantized Versions: 23+