Vision Multimodal
π Reading Time: ~16 min read
π
Updated 2026-03
Qwen2.5-VL Vision-Language Model: Dynamic Resolution, Document Extraction & Video Understanding
Analyzing Qwen2.5-VL native dynamic resolution visual transformer. Fine-grained OCR document parsing, video timeline comprehension, and vLLM multimodal serving.
ποΈ Qwen2.5-VL new breakthrough in visual architecture
Qwen2.5-VL abandons the traditional forced scaling to a fixed square size (such as 448x448) in visual feature extraction and introduces Native Dynamic Resolution:
- The image is divided into variable-length Token sequences based on the original aspect ratio. Small text and densely populated areas with graphics are no longer blurred and distorted due to downsampling.
- Supports parsing of ultra-long video sequences lasting tens of minutes, and has the ability to locate events with fine-grained timestamps.
β‘ Mirror pull 7B / 72B visual weight
export HF_ENDPOINT="https://hf-mirror.net"
# It is recommended to pull Qwen2.5-VL-7B-Instruct (suitable for single card 24G RTX 3090/4090)
huggingface-cli download Qwen/Qwen2.5-VL-7B-Instruct \
--local-dir /data/models/Qwen2.5-VL-7B-Instruct \
--local-dir-use-symlinks False
π Python end-to-end document extraction code
import torch
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
from qwen_vl_utils import process_vision_info
model_path = "/data/models/Qwen2.5-VL-7B-Instruct"
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
model_path, torch_dtype="auto", device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_path)
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "invoice.jpg"},
{"type": "text", "text": "Extract the invoice number, invoicing date, and total price and tax amount in the image and return structured JSON."}
]
}
]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(text=[text], images=image_inputs, videos=video_inputs, padding=True, return_tensors="pt").to("cuda")
generated_ids = model.generate(**inputs, max_new_tokens=512)
result = processor.batch_decode(generated_ids, skip_special_tokens=True)
print(result[0])