Search

Search papers and lessons

Qwen2.5-VL Technical Report

Shuai Bai, Keqin Chen, Xuejing Liu et al. · 2025

Bai and colleagues build a vision-language model that reads images at their native size, uses window attention to keep the visual encoder fast, and reports strong document, grounding and video results at 3B, 7B and 72B.

On this page

  • Colour = topic mix
  • Linear algebra
  • Neural network basics
  • Calculus
  • Discrete math
  • Probability
  • Architectures
  • ReadReady to readNot yet

TL;DR

Bai and colleagues describe Qwen2.5-VL, a model that reads an image or video with a language model in the loop. Its visual encoder takes images at their own resolution instead of squashing them to a fixed size, and it uses window attention so that cost grows in proportion to the number of patches. Its position encoding is tied to absolute time for video. The authors report strong results on document parsing, object grounding and video tasks at three sizes (3B, 7B and 72B parameters), with the 72B model matching closed models such as GPT-4o on several benchmarks.

Builds on: Vision-Language Model, Multimodal Rotary Position Embedding, Instruction Tuning, Rejection Sampling · Leads to: the open Qwen vision-language line and the practice of native-resolution visual input.

Why it mattered

Document reading, chart understanding and screen-based agents all need a model to read small text and precise layouts. A fixed input size, which the paper argues against, loses detail on a long invoice or a phone screenshot. Qwen2.5-VL is an open report that treats native resolution, precise coordinates and video timing as core design choices. The paper's own examples include parsing invoices, forms and tables into structured data, locating UI elements on screens for agent tasks, and finding events in hours-long video.

The problem

A vision-language model has to turn pixels into tokens that a language model can use. Three things go wrong with the usual approach.

First, resizing. A fixed input size distorts the aspect ratio and destroys small text. The paper wants the model to see each image at its native size, so the same model can handle a phone screenshot and a wide poster.

Second, cost. Standard self-attention costs grow with the square of the number of tokens. A native-resolution image produces many visual tokens, so full attention over all of them becomes expensive quickly.

Third, time. For video, the model must know not only which frame an event is in but how far apart in real time two frames are. Earlier positional schemes tied time to the frame count, which ignores how fast the content changes.

The paper's approach addresses each problem: native-resolution patches with a windowed visual encoder, a merger that shortens the visual sequence, and a multimodal position encoding aligned to absolute time.

How it works

Trace one image through the model. Take a 224 by 224 picture.

  1. Resize to a legal size. The paper resizes height and width to multiples of 28 before the visual encoder. A 224 by 224 image already qualifies. Check: 224 divided by 28 is 8, so both sides are legal.
  2. Cut the image into patches. The vision encoder splits the image into patches with a stride of 14, so each patch is 14 by 14 pixels. A 224 by 224 image gives 16 by 16 = 256 patches. Check: 224 divided by 14 is 16.
  3. Run the visual encoder with mostly windowed attention. The encoder is a Vision Transformer with 32 layers. Four of them (layers 7, 15, 23 and 31 in the paper's indexing) use full self-attention over all patches. The rest use windows of at most 112 by 112 pixels, which is 8 by 8 patches. Check: the windowed layers attend over at most 64 patches each, not all 256.
  4. Merge neighbouring patches. Group each 2 by 2 block of adjacent patch features, concatenate the four, and pass them through a two-layer MLP that projects them to the language model's width. Check: 256 patches become 64 tokens.
  5. Add positions and read with the language model. The language model is initialised from Qwen2.5 and uses the multimodal rotary position embedding. The 64 visual tokens are placed among the text tokens of the prompt, and the model writes its answer. Check: the answer is text, and any box or point in it uses the image's own pixel coordinates.
  6. For video, group frames and tie time to the clock. Two consecutive frames form one temporal group, and the temporal position IDs follow absolute time rather than the frame count. Check: the same event at two different frame rates gets the same time IDs.
flowchart LR
  A[Image or video at native size] --> B[Patches of 14 by 14]
  B --> C[ViT: windowed attention, 4 full layers]
  C --> D[Merge 2 by 2 patches with MLP]
  D --> E[Visual tokens]
  E --> F[Qwen2.5 LLM with MRoPE]
  F --> G[Text, boxes, points, JSON]

Training in three pre-training stages, then post-training

Pre-training has three phases, listed in the paper's Table 2. In phase one (1.5 trillion tokens, sequence length 8192) only the vision encoder is trained, on captions, knowledge and OCR. In phase two (2 trillion tokens, length 8192) everything is unfrozen and the model sees interleaved, VQA, grounding, agent, video and pure-text data. In phase three (0.6 trillion tokens, length 32768) longer video, agent and long-document data are added. Post-training runs supervised fine-tuning on about 2 million instruction entries, half pure text and half multimodal, and then Direct Preference Optimization. The vision encoder stays frozen in post-training.

Worked example

Example
Counting tokens for three image sizes

Use the rule from the walkthrough: patches = (height divided by 14) times (width divided by 14), then tokens = patches divided by 4.

  1. A 224 by 224 image: 16 times 16 = 256 patches. Tokens: 256 divided by 4 = 64.
  2. A 896 by 588 image (both multiples of 28): 896 divided by 14 = 64 and 588 divided by 14 = 42, so 64 times 42 = 2688 patches. Tokens: 2688 divided by 4 = 672.
  3. A video of 8 frames, each 224 by 224, grouped in pairs (4 groups). Each group is one 256-patch grid, merged to 64 tokens. Tokens: 4 times 64 = 256.

Interpretation: the number of tokens grows with the image area, not with a fixed input size, and the 2 by 2 merge cuts the visual sequence by a factor of four before the language model sees it.

Try it: how many tokens does a 448 by 448 image give? Answer: 448 divided by 14 is 32, so 32 times 32 = 1024 patches, and 1024 divided by 4 = 256 tokens.

The math

Definition: Visual token count

For an image of height H and width W, both multiples of 28, the number of patches is (H divided by 14) times (W divided by 14). The merger groups 2 by 2 adjacent patches, so the number of visual tokens is that count divided by 4.

Step 2 in symbols: patches

Npatch=H14⋅W14N_{\text{patch}} = \frac{H}{14} \cdot \frac{W}{14}

The factor 14 is the patch stride. For a 224 by 224 image, N equals 256.

Step 4 in symbols: merging

Ntoken=Npatch4N_{\text{token}} = \frac{N_{\text{patch}}}{4}

Each token is the concatenation of four patch features, passed through the two-layer MLP. The merge is what keeps long visual sequences affordable for the language model.

Step 3 in symbols: why windows are cheaper

With full self-attention over N patches, the attention score matrix has N squared entries. With windows of w patches, each patch attends only inside its window, so the cost is about N times w. The paper's window is 112 by 112 pixels, or 8 by 8 = 64 patches. For the 256-patch example, full attention needs 256 squared = 65536 score entries per head, and a windowed layer needs about 256 times 64 = 16384. The paper keeps four full layers so information can still travel across the whole image.

Step 6 in symbols: time

The paper aligns the temporal position IDs with absolute time, so the spacing between IDs reflects the real time between frames. Two clips of the same event at different frame rates then get temporal IDs spaced according to real time, not according to frame count. The paper uses this with dynamic frame-rate sampling.

Results

These are the paper's own reported numbers, copied from its tables. The comparisons are self-reported.

  • Document and OCR. On DocVQA (test), the 72B model scores 96.4, the 7B model 95.7 and the 3B model 93.9. Claude-3.5 Sonnet scores 95.2, GPT-4o 91.1. On InfoVQA, the 72B model scores 87.3 against 84.1 for InternVL2.5-78B.
  • Multimodal reasoning. On MMMU (validation), the 72B model scores 70.2. On MathVista (mini), it scores 74.8, against 72.3 for the previous open-source best listed in the table.
  • Grounding. On ODinW, the 72B model scores 43.1. The paper's own table shows Grounding DINO at 55.0, so the claim is about generalist models, not specialist detectors. On CountBench, it scores 93.6, against 91.2 for Molmo-72B.
  • Video. On Video-MME without subtitles, the 72B model scores 73.3, against 71.9 for GPT-4o; Gemini 1.5 Pro scores higher, at 75.0. On Charades-STA temporal grounding, the 72B model scores 50.9 mIoU, against 35.7 for GPT-4o.
  • GUI agents. On ScreenSpot, the 72B model scores 87.1, against 84.0 for Gemini 2.0 and 83.0 for Claude; the Aguvis-72B model scores higher, at 89.2. On ScreenSpot Pro it scores 43.6, against 23.6 for Aguvis-72B and 1.6 for its predecessor Qwen2-VL-72B.
  • Overall. The abstract says the 72B model matches GPT-4o and Claude 3.5 Sonnet, especially on document and diagram understanding.

Limits. The benchmark tables mix comparison sets: some models have no entry for some rows, and the paper reports its own evaluation settings. Some results depend on prompts (CountBench) or on added aids (the paper applies Set-of-Mark to baselines on the online agent tests). The pre-training corpus grew from 1.2 trillion to about 4 trillion tokens relative to Qwen2-VL, and the data, training stages and architecture changed together, so the paper's gains cannot be attributed to any single change. The report describes methods at the level of data types and stages, so the exact mixtures and filters cannot be reproduced from the text alone.

Reading guide

Check yourself

QuestionRecall: what does the 2 by 2 merger do, and why is it there?Show answer

It groups each 2 by 2 block of neighbouring patch features, concatenates the four, and projects them to the language model's width with a small MLP. It cuts the number of visual tokens by a factor of four, which keeps long visual sequences affordable for the language model.

QuestionComputation: a 672 by 448 image is fed to the model. How many patches and how many visual tokens does it produce?Show answer

Both sides are multiples of 28 (672 is 24 times 28, 448 is 16 times 28). Patches: (672 divided by 14) times (448 divided by 14) = 48 times 32 = 1536. Tokens: 1536 divided by 4 = 384.

QuestionWhy: why does the paper use four full-attention layers among 32 layers, rather than windowed attention everywhere?Show answer

Windowed attention keeps cost roughly linear in the number of patches, which is the efficiency goal. But a window only sees its local 8 by 8 patches. The four full layers let information move across the whole image, so the encoder can still relate distant parts of a picture. This is a trade-off between speed and global context, and the paper chooses a mostly windowed design with a few global layers.

QuestionApplied: a team wants to use Qwen2.5-VL to read scanned invoices for an accounting product. Based on the paper, what should they test before trusting the output?Show answer

The paper reports strong document results on public benchmarks, but those are self-reported and do not cover their invoices. They should test the model on a sample of their own scanned invoices, measuring exact-match accuracy of the fields they need, and check that the layout output is correct for their templates. A benchmark score is evidence about the benchmark, not a guarantee for their documents.

Sources

Read the full paper

Shuai Bai, Keqin Chen, Xuejing Liu et al., 2025. arXiv:2502.13923