TL;DR
Qwen-VL is a vision-language model built from a pretrained 7-billion-parameter language model, Qwen-7B. A vision transformer reads the image, and a small adapter compresses its features into a fixed 256 tokens that the language model reads like words. Training runs in three stages: image-text pre-training with the language model frozen, multi-task pre-training at higher resolution with everything unfrozen, and instruction tuning for chat. The authors report strong results on captioning, visual question answering, text reading and object localisation, and they release the models as open weights.
Builds on: Vision-Language Model, Vision Transformer (ViT), Language Model, Attention Mechanism · Compare with: LLaVA and BLIP-2, which took related routes to the same goal around the same time
Why it mattered
By 2023, large language models could follow instructions well, but they could not see. Vision-language models existed, yet the paper argues that most open-source ones were trained too little and perceived images only coarsely. They could describe a picture but could not reliably point to an object or read the text on a sign. Qwen-VL aimed at that gap in the open-source community.
Its practical contribution is a recipe that others could follow. The architecture is simple, the input and output format is explicit, and the three training stages are described in enough detail to reproduce the shape of the pipeline. The paper also reports that the same base model handles several languages, multiple images in one conversation, and video by sampling a few frames.
The problem
A language model takes a sequence of tokens. An image, at a useful resolution, becomes thousands of patch features. Feeding all of them into the language model is slow, because the cost of attention grows with the square of the sequence length. Compressing them too hard throws away the detail needed to read small text or to locate an object.
So a vision-language model has to solve three things at once: turn pixels into a manageable number of tokens, keep positional detail so that "left" and "top" still mean something after compression, and teach the language model to speak about regions as well as whole images. Qwen-VL addresses each of these in its architecture and in its input format.
How it works
Follow one image and one question through the model.
- Resize. The image is resized to a fixed resolution. Stage 1 uses 224 by 224, and later stages use 448 by 448.
- Patch and encode. A vision transformer, initialised from OpenCLIP's ViT-bigG, cuts the image into patches with stride 14 and produces one feature per patch. This encoder has 1.9 billion parameters.
- Compress. The adapter holds a fixed set of 256 learned query vectors. A single cross-attention layer lets these queries read the patch features, so the output is always exactly 256 vectors, whatever the image size. 2D positional encodings are added to the queries and keys, so the compressed tokens still carry where each patch was.
- Wrap. Two special tokens, image start and image end, surround the 256 image tokens, so the language model knows where the image sits in the text.
- Read the question. The question's text tokens follow. The language model, Qwen-7B, processes image and text together as one sequence.
- Answer. The model writes its answer as text. For a location question, it writes the box as text too, in the form "(X,Y),(X,Y)", with coordinates normalised to a range of 0 to 1000.
The adapter is the step that makes the rest affordable. Whatever the resolution, the language model always sees 256 image tokens. The box format is what lets the same model answer "where is the red cup?" in plain text.
flowchart LR I[Image] --> V[ViT encoder, patch stride 14] V --> A[Adapter: 256 learned queries, cross-attention] A --> W["Image start and end tokens"] Q[Question text] --> L[Qwen-7B language model] W --> L L --> R[Text answer, or box in 0 to 1000 coordinates]
The math
Let be the patch features from the vision encoder, and let be the learned query matrix. The adapter computes one cross-attention layer:
where and are 2D positional encodings for the queries and the keys, and are learned projections, and is the usual scaling. The output has shape whatever is. Each row of the softmax says how much one query attends to each patch, and each output row is a weighted average of the patch values.
Step 1 in symbols: a query reads the patches
For one query with scores against each patch , the weights are
where is the value vector of patch . The weights are positive and sum to 1.
Step 2 in symbols: box coordinates
A box with pixel corners and in an image of width and height is written in normalised coordinates:
and the string is "". Because the scale is fixed at 1000, the same string means the same relative position whatever the image size.
Worked examples
Take one query whose scores against three patches are , and whose scalar values are .
- Exponentials: , , .
- Sum: .
- Weights: , , . Check: they sum to about 1.000.
- Output: .
Interpretation: the output sits closest to the value of the patch with the highest score, but it is pulled a little toward the others.
Answer: about 14.25.
Take an image 640 pixels wide and 480 pixels high, with a box from to .
- Left edge: .
- Top edge: .
- Right edge: .
- Bottom edge: .
- The string is "(200,200),(600,600)".
- Check: the box spans units across, which is percent of the width. The pixel width is , and percent. The two agree.
Answer: "(200,200),(600,600)".
The paper moves from 224 by 224 to 448 by 448 input resolution in stage 2.
- Patches at 448 by 448 with stride 14: patch features.
- The adapter outputs 256 tokens, so the compression is times.
- The paper reports that the 448 by 448 setting trains at about 10 seconds per iteration with global attention, and about 60 seconds at 896 by 896.
Try it: how many patch features does an 896 by 896 image give, and by what factor does the adapter compress them to 256? Answer: patches, compressed by times. The language model sees the same 256 tokens as before, so the cost of the answer stays flat while the image gets sharper.
Results
The paper reports results on the authors' benchmark suite, and on general visual question answering it reports these numbers for the pretrained Qwen-VL model: VQAv2 79.5, OKVQA 58.6, GQA 59.3, ScienceQA image split 67.1, and VizWiz 35.2. On zero-shot captioning on the Flickr30K test split it reports a CIDEr score of 85.8, the best in the paper's table among the generalist models, and well above the 67.2 reported for Flamingo-80B.
On text-oriented question answering, the pretrained model's TextVQA score is 63.8. On referring expression comprehension, it reports 89.36 on RefCOCO validation. These are the paper's figures, and they were measured on the paper's own evaluation settings, so a direct comparison with a later paper's numbers needs care.
For the chat model, Qwen-VL-Chat, the paper reports 645.2 in English and 401.2 in Chinese on the TouchStone instruction benchmark, and 58.2 overall on SEED-Bench, against several other instruction-tuned vision-language models. On the MME benchmark it reports 1487.58 for perception and 360.71 for cognition.
The limits are worth stating plainly. Many of the comparisons are against models of similar size, not against the strongest proprietary systems. The benchmarks are the authors' chosen set, and several are English-centric. The chat model's scores depend on the instruction data the authors built, including the manually annotated dialogue set.
Reading guide
The paper's sections, and the lessons each one needs:
- Introduction and Related Work: needs Vision-Language Model and Language Model. The comparison with LLaVA, BLIP-2 and Flamingo is easier after reading their lessons.
- 2.1 Model Architecture: needs Vision Transformer (ViT) for the encoder, Attention Mechanism for the adapter, and Positional Encoding for the 2D encodings. The adapter is the part to re-read slowly.
- 2.2 Inputs and Outputs: needs no further lessons. Read it with the box-format example above.
- 3.1 Pre-training: needs Contrastive Learning for the background to image-text pairs, and Image Captioning for the caption objective. The training objective is the cross-entropy of the text tokens, which is the standard Language Model loss.
- 3.2 Multi-task pre-training: needs VQA: Visual Question Answering for the question-answering tasks, and the grounding tasks build on the box format from 2.2.
- 3.3 Supervised fine-tuning: needs Instruction Tuning.
- 4 Evaluation: needs the metrics only; the benchmark names are defined in the paper's appendix table.