跳至主要内容
读书笔记约 45 分钟

Qwen-VL:中英对照阅读笔记

左侧英文原文,右侧中文译文,逐段对照阅读 Qwen-VL 的模型架构、三阶段训练、实验与附录,保留原图并直链文内引用。

#59#Qwen-VL#多模态#视觉语言模型#论文阅读
笔记目录 →
PAPER READING · 2023

Qwen-VL: A Versatile Vision-Language Model for Understanding, Localization, Text Reading, and Beyond

Jinze Bai、Shuai Bai、Shusheng Yang 等 · Alibaba Group · v3,2023-10-13

正文与附录逐段对照。图表取自所提供的 PDF;右栏表格译为中文。引用在正文中直接链接至文献页面。实验中的“最优”均指论文发表时的比较范围。B = 十亿,M = 百万。

章节导航 正文 1—6 · 附录 A—E
ENGLISH 英文原文中文译文 按段落对应

Abstract

摘要

In this work, we introduce the Qwen-VL series, a set of large-scale vision-language models (LVLMs) designed to perceive and understand both texts and images. Starting from the Qwen-LM as a foundation, we endow it with visual capacity by the meticulously designed (i) visual receptor, (ii) input-output interface, (iii) 3-stage training pipeline, and (iv) multilingual multimodal cleaned corpus. Beyond the conventional image description and question-answering, we implement the grounding and text-reading ability of Qwen-VLs by aligning image-caption-box tuples. The resulting models, including Qwen-VL and Qwen-VL-Chat, set new records for generalist models under similar model scales on a broad range of visual-centric benchmarks (e.g., image captioning, question answering, visual grounding) and different settings (e.g., zero-shot, few-shot). Moreover, on real-world dialog benchmarks, our instruction-tuned Qwen-VL-Chat also demonstrates superiority compared to existing vision-language chatbots. All models are public to facilitate future research.

本文介绍 Qwen-VL 系列,这是一组旨在感知和理解文本与图像的大规模视觉语言模型(LVLM)。以 Qwen-LM 为基础,我们通过精心设计的(i)视觉感知模块、(ii)输入输出接口、(iii)三阶段训练流程以及(iv)经过清洗的多语言、多模态语料,赋予模型视觉能力。除了常规的图像描述和问答,我们还通过对齐图像—描述—边界框三元组,实现 Qwen-VL 的视觉定位和文字读取能力。得到的 Qwen-VL 和 Qwen-VL-Chat 在多种以视觉为中心的基准(例如图像描述、问答和视觉定位)及不同设置(例如零样本、少样本)下,刷新了相近规模通用模型的成绩。此外,在真实场景对话基准上,经过指令微调的 Qwen-VL-Chat 也优于已有视觉语言聊天机器人。所有模型均已公开,以支持后续研究。

Qwen-VL 原论文图 1
图 1 · 原文第 1 页 · 点击放大

Figure 1: Qwen-VL achieves state-of-the-art performance on a broad range of tasks compared with other generalist models.

图 1:与其他通用模型相比,Qwen-VL 在多种任务上取得当时的最优性能。

Qwen-VL 原论文图 2
图 2 · 原文第 2 页 · 点击放大

Figure 2: Some qualitative examples generated by our Qwen-VL-Chat. Qwen-VL-Chat supports multiple image inputs, multi-round dialogue, multilingual conversation, text-reading, localization, fine-grained recognition and understanding ability.

图 2:Qwen-VL-Chat 生成的部分定性示例。模型支持多图输入、多轮对话、多语言交流、文字读取、定位,以及细粒度识别与理解。

1 Introduction

1 引言

Recently, Large Language Models (LLMs) (Brown et al., 2020; OpenAI, 2023; Anil et al., 2023; Gao et al., 2023; Qwen, 2023) have attracted wide attention due to their powerful capabilities in text generation and comprehension. These models can be further aligned with user intent through fine-tuning instructions, showcasing strong interactive capabilities and the potential to enhance productivity as intelligent assistants. However, native large language models only live in the pure-text world, lacking the ability to handle other common modalities (such as images, speech, and videos), resulting in great restrictions on their application scope. Motivated by this, a group of Large Vision Language Models (LVLMs) (Alayrac et al., 2022; Chen et al., 2022; Li et al., 2023c; Dai et al., 2023; Huang et al., 2023; Peng et al., 2023; Zhu et al., 2023; Liu et al., 2023; Ye et al., 2023b,a; Chen et al., 2023a; Li et al., 2023a; Zhang et al., 2023; Sun et al., 2023; OpenAI, 2023) have been developed to enhance large language models with the ability to perceive and understand visual signals. These large-scale vision-language models demonstrate promising potential in solving real-world vision-central problems.

近年来,大语言模型(LLM)凭借强大的文本生成和理解能力受到广泛关注。这些模型可通过指令微调进一步与用户意图对齐,表现出很强的交互能力,并具有作为智能助手提升生产力的潜力。然而,原生大语言模型只存在于纯文本世界中,无法处理其他常见模态(如图像、语音和视频),应用范围因此受到很大限制。受此推动,研究者开发了一系列大规模视觉语言模型(LVLM),以增强大语言模型对视觉信号的感知和理解能力。这些模型在解决现实世界中以视觉为核心的问题上展现出可观潜力。

(Brown et al., 2020;OpenAI, 2023;Anil et al., 2023;Gao et al., 2023;Qwen, 2023;Alayrac et al., 2022;Chen et al., 2022;Li et al., 2023c;Dai et al., 2023;Huang et al., 2023;Peng et al., 2023;Zhu et al., 2023;Liu et al., 2023;Ye et al., 2023b;Ye et al., 2023a;Chen et al., 2023a;Li et al., 2023a;Zhang et al., 2023;Sun et al., 2023)

Nevertheless, despite that lots of works have been conducted to explore the limitation and potency of LVLMs, current open-source LVLMs always suffer from inadequate training and optimization, thus lag far behind the proprietary models (Chen et al., 2022, 2023b; OpenAI, 2023), which hinders further exploration and application of LVLMs in open-source community. What’s more, as real-world visual scenarios are quite complicated, fine-grained visual understanding plays a crucial role for LVLMs to assist people effectively and precisely. But only a few attempts had been made toward this direction (Peng et al., 2023; Chen et al., 2023a), the majority of open-source LVLMs remain perceiving the image in a coarse-grained approach and lacking the ability to execute fine-grained perception such as object grounding or text reading.

尽管已有大量研究探索 LVLM 的局限与潜力,目前的开源 LVLM 往往仍缺乏充分训练与优化,因而远落后于闭源模型,阻碍了开源社区的进一步探索和应用。此外,现实视觉场景十分复杂,细粒度视觉理解对于 LVLM 有效、准确地帮助人们至关重要。但目前只有少量工作尝试这一方向,大多数开源 LVLM 仍以粗粒度方式感知图像,缺乏目标定位、文字读取等细粒度感知能力。

(Chen et al., 2022;Chen et al., 2023b;OpenAI, 2023;Peng et al., 2023;Chen et al., 2023a)

In this paper, we explore a way out and present the newest members of the open-sourced Qwen families: Qwen-VL series. Qwen-VLs are a series of highly performant and versatile vision-language foundation models based on Qwen-7B (Qwen, 2023) language model. We empower the LLM basement with visual capacity by introducing a new visual receptor including a language-aligned visual encoder and a position-aware adapter. The overall model architecture as well as the input-output interface are quite concise and we elaboratedly design a 3-stage training pipeline to optimize the whole model upon a vast collection of image-text corpus.

本文探索解决这些问题的方法,并推出开源 Qwen 家族的新成员:Qwen-VL 系列。Qwen-VL 是一系列基于 Qwen-7B 语言模型、性能强且用途广泛的视觉语言基础模型。我们引入新的视觉感知模块,其中包含与语言对齐的视觉编码器和位置感知适配器,为语言模型底座赋予视觉能力。整体模型架构及输入输出接口都很简洁;我们还精心设计三阶段训练流程,在大规模图文语料上优化整个模型。

(Qwen, 2023)

Our pre-trained checkpoint, termed Qwen-VL, is capable of perceiving and understanding visual inputs, generating desired responses according to given prompts, and accomplishing various vision-language tasks such as image captioning, question answering, text-oriented question answering, and visual grounding. Qwen-VL-Chat is the instruction-tuned vision-language chatbot based on Qwen-VL. As shown in Fig. 2, Qwen-VL-Chat is able to interact with users and perceive the input images following the intention of users.

预训练检查点称为 Qwen-VL,能够感知和理解视觉输入,根据给定提示生成所需回复,并完成图像描述、问答、面向文字的问答和视觉定位等任务。Qwen-VL-Chat 是在 Qwen-VL 基础上经过指令微调的视觉语言聊天机器人。如图 2 所示,它能够按照用户意图与用户交互并理解输入图像。

Specifically, the features of the Qwen-VL series models include:

具体而言,Qwen-VL 系列具有以下特点:

• Leading performance: Qwen-VLs achieve top-tier accuracy on a vast of vision-centric understanding benchmarks compared to counterparts with similar scales. Besides, Qwen-VL’s stuning performance covers not only the conventional benchmarks e.g., captioning, question-answering, grounding), but also some recently introduced dialogue benchmarks.

• 领先的性能:与相近规模模型相比,Qwen-VL 在众多以视觉为中心的理解基准上达到一流水平。其突出表现不仅覆盖图像描述、问答和定位等传统基准,也覆盖近期提出的对话基准。

• Multi-lingual: Similar to Qwen-LM, Qwen-VLs are trained upon multilingual image-text data with a considerable amount of corpus being in English and Chinese. In this way, Qwen-VLs naturally support English, Chinese, and multilingual instructions.

• 多语言:与 Qwen-LM 类似,Qwen-VL 在多语言图文数据上训练,其中很大一部分语料为英文和中文。因此,Qwen-VL 自然支持英语、中文和多语言指令。

• Multi-image: In the training phase, we allow arbitrary interleaved image-text data as Qwen-VL’s inputs. This feature allows our Qwen-Chat-VL to compare, understand, and analyze the context when multiple images are given.

• 多图像:训练时允许任意交错排列的图文数据作为输入。这使得模型能够在给定多张图像时,对上下文进行比较、理解和分析。

• Fine-grained visual understanding: Thanks to the higher-resolution input size and fine-grained corpus we used in training, Qwen-VLs exhibit highly competitive fine-grained visual understanding ability. Compared to existing vision-language generalists, our Qwen-VLs possess much better grounding, text-reading, text-oriented question answering, and fine-grained dialog performance.

• 细粒度视觉理解:得益于更高的输入分辨率和细粒度训练语料,Qwen-VL 展现出很强的细粒度视觉理解能力。与已有通用视觉语言模型相比,它在定位、文字读取、面向文字的问答及细粒度对话方面表现更好。

2 Methodology

2 方法

2.1 Model Architecture

2.1 模型架构

The overall network architecture of Qwen-VL consists of three components and the details of model parameters are shown in Table 1:

Qwen-VL 的整体网络架构包含三个组件,参数细节见表 1:

Large Language Model: Qwen-VL adopts a large language model as its foundation component. The model is initialized with pre-trained weights from Qwen-7B (Qwen, 2023).

大语言模型:Qwen-VL 采用大语言模型作为基础组件,使用 Qwen-7B 的预训练权重初始化。

(Qwen, 2023)

Visual Encoder: The visual encoder of Qwen-VL uses the Vision Transformer (ViT) (Dosovitskiy et al., 2021) architecture, initialized with pre-trained weights from Openclip’s ViT-bigG (Ilharco et al., 2021). During both training and inference, input images are resized to a specific resolution. The visual encoder processes images by splitting them into patches with a stride of 14, generating a set of image features.

视觉编码器:采用 Vision Transformer(ViT)架构,以 OpenCLIP 的 ViT-bigG 预训练权重初始化。训练和推理时,输入图像均调整到指定分辨率。视觉编码器以 14 为步幅将图像划分成图像块,生成一组图像特征。

(Dosovitskiy et al., 2021;Ilharco et al., 2021)

Position-aware Vision-Language Adapter: To alleviate the efficiency issues arising from long image feature sequences, Qwen-VL introduces a vision-language adapter that compresses the image features. This adapter comprises a single-layer cross-attention module initialized randomly. The module uses a group of trainable vectors (Embeddings) as query vectors and the image features from the visual encoder as keys for cross-attention operations. This mechanism compresses the visual feature sequence to a fixed length of 256. The ablation about the number of queries is shown in Appendix E.2. Additionally, considering the significance of positional information for fine-grained image comprehension, 2D absolute positional encodings are incorporated into the cross-attention mechanism’s query-key pairs to mitigate the potential loss of positional details during compression. The compressed image feature sequence of length 256 is subsequently fed into the large language model.

位置感知视觉语言适配器:为缓解图像特征序列过长带来的效率问题,Qwen-VL 引入适配器压缩图像特征。适配器由随机初始化的单层交叉注意力模块组成,使用一组可训练向量(嵌入)作为查询,将视觉编码器输出的图像特征作为键进行交叉注意力计算,将视觉特征序列压缩到固定长度 256。查询数量的消融实验见附录 E.2。此外,考虑到位置信息对于细粒度图像理解的重要性,我们在交叉注意力的查询—键对中加入二维绝对位置编码,以减轻压缩过程可能造成的位置细节损失。压缩后的长度为 256 的图像特征序列随后输入大语言模型。

Table 1: Details of Qwen-VL model parameters.

表 1:Qwen-VL 的模型参数细节。

Qwen-VL 原论文表 1
表 1 · 原文第 4 页 · 点击放大
视觉编码器视觉语言适配器大语言模型总计
1.9B0.08B7.7B9.6B
Qwen-VL 原论文图 3
图 3 · 原文第 4 页 · 点击放大

Figure 3: The training pipeline of the Qwen-VL series.

图 3:Qwen-VL 系列的训练流程。左:低分辨率图文对预训练;中:高分辨率、多任务与交错图文预训练;右:高分辨率、交错图文对话的监督微调。ViT 表示视觉编码器,CrossAttn 表示交叉注意力,Learnable Query Embs 表示可学习查询嵌入。

2.2 Inputs and Outputs

2.2 输入与输出

Image Input: Images are processed through the visual encoder and adapter, yielding fixed-length sequences of image features. To differentiate between image feature input and text feature input, two special tokens (<img> and </img>) are appended to the beginning and end of the image feature sequence respectively, signifying the start and end of image content.

图像输入:图像经过视觉编码器与适配器,得到固定长度的图像特征序列。为区分图像特征输入与文本特征输入,分别在图像特征序列的首尾添加特殊标记 <img> 和 </img>,表示图像内容的开始和结束。

Bounding Box Input and Output: To enhance the model’s capacity for fine-grained visual understanding and grounding, Qwen-VL’s training involves data in the form of region descriptions, questions, and detections. Differing from conventional tasks involving image-text descriptions or questions, this task necessitates the model’s accurate understanding and generation of region descriptions in a designated format. For any given bounding box, a normalization process is applied (within the range [0, 1000)) and transformed into a specified string format: "(Xtopleft, Ytopleft), (Xbottomright, Ybottomright)". The string is tokenized as text and does not require an additional positional vocabulary. To distinguish between detection strings and regular text strings, two special tokens (<box> and </box> are added at the beginning and end of the bounding box string. Additionally, to appropriately associate bounding boxes with their corresponding descriptive words or sentences, another set of special tokens (<ref> and </ref>) is introduced, marking the content referred to by the bounding box.

边界框输入与输出:为增强细粒度视觉理解与定位能力,Qwen-VL 使用区域描述、问题和检测等形式的数据训练。这不同于常规图文描述或问答任务,需要模型准确理解并以指定格式生成区域描述。对于任意边界框,将其坐标归一化到 [0, 1000) 范围,并转换为字符串“(X左上, Y左上), (X右下, Y右下)”。该字符串按文本进行分词,无需额外的位置词表。为区分检测字符串与普通文本,在边界框字符串首尾添加 <box> 和 </box>。此外,引入 <ref> 和 </ref> 标记边界框所指代的词语或句子,使边界框与相应描述关联。

3 Training

3 训练

As illustrated in Fig. 3, the training process of the Qwen-VL model consists of three stages: two stages of pre-training and a final stage of instruction fine-tuning training.

如图 3 所示,Qwen-VL 的训练分为三个阶段:两个预训练阶段,以及最后的指令微调阶段。

3.1 Pre-training

3.1 预训练

In the first stage of pre-training, we mainly utilize a large-scale, weakly labeled, web-crawled set of image-text pairs. Our pre-training dataset is composed of several publicly accessible sources and some in-house data. We made an effort to clean the dataset of certain patterns. As summarized in Table 2, the original dataset contains a total of 5 billion image-text pairs, and after cleaning, 1.4 billion data remain, with 77.3% English (text) data and 22.7% Chinese (text) data.

第一阶段主要使用从网页抓取的大规模弱标注图文对。数据来自多个公开来源及部分内部数据,并针对特定模式进行清洗。如表 2 所示,原始数据共 50 亿图文对,清洗后剩余 14 亿,其中英文文本占 77.3%,中文文本占 22.7%。

Table 2: Details of Qwen-VL pre-training data. LAION-en and LAION-zh are the English and Chinese language subset of LAION-5B (Schuhmann et al., 2022a). LAION-COCO (Schuhmann et al., 2022b) is a synthetic dataset generated from LAION-en. DataComp (Gadre et al., 2023) and Coyo (Byeon et al., 2022) are collections of image-text pairs. CC12M (Changpinyo et al., 2021), CC3M (Sharma et al., 2018), SBU (Ordonez et al., 2011) and COCO Caption (Chen et al., 2015) are academic caption datasets.

表 2:Qwen-VL 预训练数据细节。LAION-en 和 LAION-zh 是 LAION-5B 的英文和中文子集;LAION-COCO 是基于 LAION-en 生成的合成数据集;DataComp 和 Coyo 是图文对集合;CC12M、CC3M、SBU 和 COCO Caption 是学术图像描述数据集。

(Schuhmann et al., 2022a;Schuhmann et al., 2022b;Gadre et al., 2023;Byeon et al., 2022;Changpinyo et al., 2021;Sharma et al., 2018;Ordonez et al., 2011;Chen et al., 2015)

Qwen-VL 原论文表 2
表 2 · 原文第 5 页 · 点击放大
语言数据集原始数量清洗后保留率
英文LAION-en2B280M14%
英文LAION-COCO600M300M50%
英文DataComp1.4B300M21%
英文Coyo700M200M28%
英文CC12M12M8M66%
英文CC3M3M3M100%
英文SBU1M0.8M80%
英文COCO Caption0.6M0.6M100%
中文LAION-zh108M105M97%
中文内部数据220M220M100%
合计—5B1.4B28%

We freeze the large language model and only optimize the vision encoder and VL adapter in this stage. The input images are resized to 224 × 224. The training objective is to minimize the cross-entropy of the text tokens. The maximum learning rate is 2e−4 and the training process uses a batch size of 30720 for the image-text pairs, and the entire first stage of pre-training lasts for 50,000 steps, consuming approximately 1.5 billion image-text samples. More hyperparameters are detailed in Appendix C and the convergence curve of this stage is shown in Figure 6.

该阶段冻结大语言模型,仅优化视觉编码器与视觉语言适配器。输入图像调整为 224 × 224,训练目标是最小化文本 token 的交叉熵。最大学习率为 2e−4,图文对批大小为 30720,第一阶段共训练 50000 步,消耗约 15 亿图文样本。更多超参数见附录 C,收敛曲线见图 6。

3.2 Multi-task Pre-training

3.2 多任务预训练

In the second stage of multi-task pre-training, we introduce high-quality and fine-grained VL annotation data with a larger input resolution and interleaved image-text data. As summarized in Table 3, we trained Qwen-VL on 7 tasks simultaneously. For text generation, we use the in-house collected corpus to maintain the LLM’s ability. Captioning data is the same with Table 2 except for far fewer samples and excluding LAION-COCO. We use a mixture of publicly available data for the VQA task which includes GQA (Hudson and Manning, 2019), VGQA (Krishna et al., 2017), VQAv2 (Goyal et al., 2017), DVQA (Kafle et al., 2018), OCRVQA (Mishra et al., 2019) and DocVQA (Mathew et al., 2021). We follow Kosmos-2 to use the GRIT (Peng et al., 2023) dataset for the grounding task with minor modifications. For the reference grounding and grounded captioning duality tasks, we construct training samples from GRIT (Peng et al., 2023), Visual Genome (Krishna et al., 2017), RefCOCO (Kazemzadeh et al., 2014), RefCOCO+, and RefCOCOg (Mao et al., 2016). In order to improve the text-oriented tasks, we collect pdf and HTML format data from Common Crawl1 and generate synthetic OCR data in English and Chinese language with natural scenery background, following (Kim et al., 2022). Finally, we simply construct interleaved image-text data by packing the same task data into sequences of length 2048.

第二阶段引入高质量、细粒度的视觉语言标注数据、更大的输入分辨率,以及交错图文数据。如表 3 所示,同时训练 7 类任务。对于文本生成,使用内部收集的语料维持 LLM 的能力。图像描述数据与表 2 相同,但样本数大幅减少,且不包含 LAION-COCO。VQA 任务混合使用 GQA、VGQA、VQAv2、DVQA、OCR-VQA 和 DocVQA 等公开数据。定位任务沿用 Kosmos-2 的 GRIT 数据集并略作修改。对于互为对偶的指代表达定位和指定区域描述任务,从 GRIT、Visual Genome、RefCOCO、RefCOCO+ 和 RefCOCOg 构建训练样本。为提高面向文字的任务表现,我们从 Common Crawl 收集 PDF 和 HTML 数据,并参考 Kim 等人的方法,生成以自然场景为背景的中英文合成 OCR 数据。最后,将同一任务的数据打包为长度 2048 的序列,以简单方式构建交错图文数据。

(Hudson and Manning, 2019;Krishna et al., 2017;Goyal et al., 2017;Kafle et al., 2018;Mishra et al., 2019;Mathew et al., 2021;Peng et al., 2023;Kazemzadeh et al., 2014;Mao et al., 2016;Kim et al., 2022)

Table 3: Details of Qwen-VL multi-task pre-training data.

表 3:Qwen-VL 多任务预训练数据细节。

Qwen-VL 原论文表 3
表 3 · 原文第 6 页 · 点击放大
任务样本数数据集
图像描述19.7MLAION-en/zh、DataComp、Coyo、CC12M/3M、SBU、COCO、内部数据
视觉问答3.6MGQA、VGQA、VQAv2、DVQA、OCR-VQA、DocVQA、TextVQA、ChartQA、AI2D
带定位的图像描述3.5MGRIT
指代表达定位8.7MGRIT、Visual Genome、RefCOCO、RefCOCO+、RefCOCOg
指定区域描述8.7MGRIT、Visual Genome、RefCOCO、RefCOCO+、RefCOCOg
OCR24.8MSynthDoG-en/zh、Common Crawl PDF/HTML
纯文本自回归7.8M内部数据

We increase the input resolution of the visual encoder from 224 × 224 to 448 × 448, reducing the information loss caused by image down-sampling. Besides, we ablate the window attention and global attention for higher resolutions of the vision transformer in Appendix E.3. We unlocked the large language model and trained the whole model. The training objective is the same as the pre-training stage.

将视觉编码器的输入分辨率从 224 × 224 提升至 448 × 448,以减少图像下采样造成的信息损失。附录 E.3 还对较高分辨率下 ViT 的窗口注意力和全局注意力进行消融比较。本阶段解冻大语言模型,训练整个模型,训练目标与第一阶段相同。

3.3 Supervised Fine-tuning

3.3 监督微调

During this stage, we finetuned the Qwen-VL pre-trained model through instruction fine-tuning to enhance its instruction following and dialogue capabilities, resulting in the interactive Qwen-VL-Chat model. The multi-modal instruction tuning data primarily comes from caption data or dialogue data generated through LLM self-instruction, which often only addresses single-image dialogue and reasoning and is limited to image content comprehension. We construct an additional set of dialogue data through manual annotation, model generation, and strategy concatenation to incorporate localization and multi-image comprehension abilities into the Qwen-VL model. We confirm that the model effectively transfers these capabilities to a wider range of languages and question types. Additionally, we mix multi-modal and pure text dialogue data during training to ensure the model’s universality in dialogue capabilities. The instruction tuning data amounts to 350k. In this stage, we freeze the visual encoder and optimize the language model and adapter module. We demonstrate the data format of this stage in Appendix B.2.

本阶段对预训练 Qwen-VL 进行指令微调,以增强指令遵循与对话能力,得到可交互的 Qwen-VL-Chat。多模态指令数据通常来自图像描述,或通过 LLM 自指令生成的对话,往往只涉及单图对话与推理,局限于图像内容理解。我们通过人工标注、模型生成和策略拼接,额外构建对话数据,将定位和多图理解能力加入模型,并确认这些能力可以有效迁移到更广泛的语言和问题类型。此外,训练中混合多模态与纯文本对话,以保证对话能力的通用性。指令微调数据共 35 万条。该阶段冻结视觉编码器,优化语言模型和适配器。数据格式见附录 B.2。

4 Evaluation

4 评测

In this section, we conduct an overall evaluation on various multi-modal tasks to comprehensively assess our models’ visual understanding ability. In the following, Qwen-VL denotes the model after the multi-task training, and Qwen-VL-Chat denotes the model after supervised fine-tuning (SFT) stage.

本节通过多种多模态任务,全面评估模型的视觉理解能力。下文中的 Qwen-VL 指多任务训练后的模型,Qwen-VL-Chat 指监督微调(SFT)后的模型。

Table 9 provides a detailed summary of the used evaluation benchmarks and corresponding metrics.

表 9 汇总了使用的评测基准及相应指标。

4.1 Image Caption and General Visual Question Answering

4.1 图像描述与通用视觉问答

Image caption and general visual question answering (VQA) are two conventional tasks for vision-language models. Specifically, image caption requires the model to generate a description for a given image and general VQA requires the model to generate an answer for a given image-question pair.

图像描述和通用视觉问答(VQA)是视觉语言模型的两类传统任务。图像描述要求模型为给定图像生成描述;通用 VQA 要求模型针对给定的图像—问题对生成答案。

1https://digitalcorpora.org/corpora/file-corpora/cc-main-2021-31-pdf-untruncated 2This task is to generate noun/phrase grounded captions (Peng et al., 2023).

脚注 1:Common Crawl PDF 数据来源。脚注 2:该定位任务生成带名词或短语定位标注的图像描述。

(Peng et al., 2023)

Table 4: Results on Image Captioning and General VQA.

表 4:图像描述与通用 VQA 的结果。

Qwen-VL 原论文表 4
表 4 · 原文第 7 页 · 点击放大
模型Nocaps¹Flickr30K¹VQAv2OKVQAGQASciQA-Img¹VizWiz¹
Flamingo-9B—61.551.844.7——28.8
Flamingo-80B—67.256.350.6——31.6
Unified-IO-XL100.0—77.954.0———
Kosmos-1—67.151.0———29.2
Kosmos-2—80.551.1————
BLIP-2 (Vicuna-13B)103.971.665.045.932.361.019.6
InstructBLIP (Vicuna-13B)121.982.8——49.563.133.4
Shikra (Vicuna-13B)—73.977.3647.16———
Qwen-VL121.485.879.558.659.367.135.2
Qwen-VL-Chat120.281.078.256.657.568.238.9
专用模型最优—127.0 (PaLI-17B)84.5 (InstructBLIP-FlanT5-XL)86.1 (PaLI-X-55B)66.1 (PaLI-X-55B)72.1 (CFR)92.53 (LLaVA+GPT-4)70.9 (PaLI-X-55B)

¹ 零样本。前两列为图像描述(CIDEr),其余为通用视觉问答。最后一行各列来自不同专用模型。

For the image caption task, we choose Nocaps (Agrawal et al., 2019) and Flickr30K (Young et al., 2014) as benchmarks and report CIDEr score (Vedantam et al., 2015) as metric. We utilize greedy search for caption generation with a prompt of "Descripe the image in English:".

图像描述任务使用 Nocaps 和 Flickr30K 作为基准,以 CIDEr 得分为指标。通过贪心搜索生成描述,提示词为“Descripe the image in English:”(用英语描述图像;原文拼写如此)。

(Agrawal et al., 2019;Young et al., 2014;Vedantam et al., 2015)

For general VQA, we utilize five benchmarks including VQAv2 (Goyal et al., 2017), OKVQA (Marino et al., 2019), GQA (Hudson and Manning, 2019), ScienceQA (Image Set) (Lu et al., 2022b) and VizWiz VQA (Gurari et al., 2018). For VQAv2, OKVQA, GQA and VizWiz VQA, we employ open-ended answer generation with greedy decoding strategy and a prompt of "{question} Answer:", without any constrain on model’s output space. However, for ScienceQA, we constrain the model’s output to possible options (instead of open-ended), choose the option with highest confidence as model’s prediction, and report the Top-1 accuracy.

通用 VQA 使用五个基准:VQAv2、OKVQA、GQA、ScienceQA(图像子集)和 VizWiz VQA。对于 VQAv2、OKVQA、GQA 和 VizWiz VQA,使用贪心解码和提示词“{question} Answer:”生成开放式答案,不限制模型输出空间。对于 ScienceQA,则将输出限制在候选选项中,选择置信度最高的选项作为预测,并报告 Top-1 准确率。

(Goyal et al., 2017;Marino et al., 2019;Hudson and Manning, 2019;Lu et al., 2022b;Gurari et al., 2018)

The overall performance on image caption and general VQA tasks are reported in Table 4. As the results shown, our Qwen-VL and Qwen-VL-Chat both achieve obviously better results compared to previous generalist models in terms of both two tasks. Specifically, on zero-shot image caption task, Qwen-VL achieves state-of-the-art performance (i.e., 85.8 CIDEr score) on the Flickr30K karpathy-test split, even outperforms previous generalist models with much more parameters (e.g., Flamingo-80B with 80B parameters).

表 4 给出图像描述与通用 VQA 的整体结果。Qwen-VL 和 Qwen-VL-Chat 在两类任务上均明显优于此前的通用模型。具体而言,在零样本图像描述任务中,Qwen-VL 在 Flickr30K 的 karpathy-test 划分上达到当时最优的 85.8 CIDEr,甚至超过参数量大得多的通用模型,例如拥有 800 亿参数的 Flamingo-80B。

On general VQA benchmarks, our models also exhibit distinct advantages compared to others. On VQAv2, OKVQA and GQA benchmarks, Qwen-VL achieves 79.5, 58.6 and 59.3 accuracy respectively, which surpasses recent proposed LVLMs by a large margin. It’s worth noting that Qwen-VL also shows strong zero-shot performance on ScienceQA and VizWiz datasets.

在通用 VQA 基准上,模型同样表现出明显优势。Qwen-VL 在 VQAv2、OKVQA 和 GQA 上的准确率分别为 79.5、58.6 和 59.3,大幅超过近期提出的 LVLM。它在 ScienceQA 和 VizWiz 上也表现出较强的零样本能力。

4.2 Text-oriented Visual Question Answering

4.2 面向文字的视觉问答

Text-oriented visual understanding has a broad application prospect in real-world scenarios. We assess our models’ ability toward text-oriented visual question answering on several benchmarks including TextVQA (Sidorov et al., 2020), DocVQA (Mathew et al., 2021), ChartQA (Masry et al., 2022), AI2Diagram (Kembhavi et al., 2016), and OCR-VQA (Mishra et al., 2019). Similarly, the results are shown in Table 5. Compared to previous generalist models and recent LVLMs, our models show better performance on most benchmarks, frequently by a large margin.

面向文字的视觉理解在现实场景中有广泛应用前景。我们在 TextVQA、DocVQA、ChartQA、AI2Diagram 和 OCR-VQA 等基准上评估这一能力,结果见表 5。与此前的通用模型及近期 LVLM 相比,Qwen-VL 在多数基准上取得更好的结果,且经常有较大幅度的优势。

(Sidorov et al., 2020;Mathew et al., 2021;Masry et al., 2022;Kembhavi et al., 2016;Mishra et al., 2019)

4.3 Refer Expression Comprehension

4.3 指代表达理解

We show our models’ fine-grained image understanding and localization ability by evaluating on a sort of refer expression comprehension benchmarks such as RefCOCO (Kazemzadeh et al., 2014), RefCOCOg (Mao et al., 2016), RefCOCO+ (Mao et al., 2016) and GRIT (Gupta et al., 2022). Specifically, the refer expression comprehension task requires the model to localize the target object under the guidance of a description. The results are shown in Table 6. Compared to previous generalist models or recent LVLMs, our models obtain top-tier results on all benchmarks.

通过 RefCOCO、RefCOCOg、RefCOCO+ 和 GRIT 等指代表达理解基准,展示模型的细粒度图像理解与定位能力。这项任务要求模型根据给定描述定位目标物体。结果见表 6。与此前的通用模型和近期 LVLM 相比,Qwen-VL 在所有基准上均取得一流水平的结果。

(Kazemzadeh et al., 2014;Mao et al., 2016;Gupta et al., 2022)

Table 5: Results on Text-oriented VQA.

表 5:面向文字的 VQA 结果。

Qwen-VL 原论文表 5
表 5 · 原文第 8 页 · 点击放大
模型TextVQADocVQAChartQAAI2DOCR-VQA
BLIP-2 (Vicuna-13B)42.4————
InstructBLIP (Vicuna-13B)50.7————
mPLUG-DocOwl (LLaMA-7B)52.662.257.4——
Pix2Struct-Large (1.3B)—76.658.642.171.3
Qwen-VL63.865.165.762.375.7
Qwen-VL-Chat61.562.666.357.770.5
专用模型 PaLI-X-55B71.4480.070.081.275.0

PaLI-X-55B 使用单任务微调,不使用 OCR 流水线。

Table 6: Results on Referring Expression Comprehension task.

表 6:指代表达理解任务的结果。

Qwen-VL 原论文表 6
表 6 · 原文第 8 页 · 点击放大
模型RefCOCO 验证测试 A测试 BRefCOCO+ 验证测试 A测试 BRefCOCOg 验证测试GRIT refexp
GPV-2————————51.50
OFA-L*79.9683.6776.3968.2976.0061.7567.5767.5861.70
Unified-IO————————78.61
VisionLLM-H—86.70———————
Shikra-7B87.0190.6180.2481.6087.3672.1282.2782.1969.34
Shikra-13B87.8391.1181.8182.8987.7974.4182.6483.1669.03
Qwen-VL-7B89.3692.2685.3483.1288.2577.2185.5885.4878.22
Qwen-VL-7B-Chat88.5592.2784.5182.8288.5976.7985.9686.32—
G-DINO-L(专用)90.5693.1988.2482.7588.9575.9286.1387.02—
UNINEXT-H(专用)92.6494.3391.4685.2489.6379.7988.7389.37—
ONE-PEACE(专用)92.5894.1889.2688.7792.2183.2389.2289.27—

4.4 Few-shot Learning on Vision-Language Tasks

4.4 视觉语言任务中的少样本学习

Our model also exhibits satisfactory in-context learning (a.k.a., few-shot learning) ability. As shown in Figure 4, Qwen-VL achieves better performance through in-context few-shot learning on OKVQA (Marino et al., 2019), Vizwiz (Gurari et al., 2018), TextVQA (Sidorov et al., 2020), and Flickr30k (Young et al., 2014) when compared with models with similar number of parameters (Flamingo-9B(Alayrac et al., 2022), OpenFlamingo-9B(?) and IDEFICS-9B?). Qwen-VL’s performance is even comparable with much larger models (Flamingo-80B and IDEFICS-80B). Note that we adopt naïve random sample to construct the few-shot exemplars, sophisticated few-shot exemplar construction methods such as RICES (Yang et al., 2022b) are not used despite better results would be achieved.

模型也展现出良好的上下文学习(即少样本学习)能力。如图 4 所示,在 OKVQA、VizWiz、TextVQA 和 Flickr30K 上,Qwen-VL 通过上下文少样本学习,优于相近参数规模的 Flamingo-9B、OpenFlamingo-9B 和 IDEFICS-9B;其表现甚至可与更大的 Flamingo-80B 和 IDEFICS-80B 相媲美。这里仅使用简单的随机采样构建少样本示例,没有采用 RICES 等更复杂的示例构建方法,尽管这些方法可能取得更好的结果。(原文在 OpenFlamingo 与 IDEFICS 的引用处保留了问号。)

(Marino et al., 2019;Gurari et al., 2018;Sidorov et al., 2020;Young et al., 2014;Alayrac et al., 2022;Yang et al., 2022b)

Qwen-VL 原论文图 4
图 4 · 原文第 8 页 · 点击放大

Figure 4: Few-shot learning results of Qwen-VL in comparison with other models.

图 4:Qwen-VL 与其他模型的少样本学习结果比较。横轴为示例数量,纵轴为相应任务得分。

Table 7: Results on Instruction-following benchmarks.

表 7:指令遵循基准的结果。

Qwen-VL 原论文表 7
表 7 · 原文第 9 页 · 点击放大
模型TouchStone 英文中文SEED 全部图像视频MME 感知认知
VisualGLM—247.1———705.31181.79
PandaGPT488.5————642.59228.57
MiniGPT4531.7—42.847.429.9581.67144.29
InstructBLIP552.4—53.458.838.11212.82291.79
LLaMA-AdapterV2590.1—32.735.225.8972.67248.93
LLaVA602.7—33.537.023.8502.82214.64
mPLUG-Owl605.4—34.037.923.0967.34276.07
Qwen-VL——56.362.339.1——
Qwen-VL-Chat645.2401.258.265.437.81487.58360.71

4.5 Instruction Following in Real-world User Behavior

4.5 真实用户行为下的指令遵循

In addition to previous conventional vision-language evaluations, to evaluate our Qwen-VL-Chat model’s capacity under real-world user behavior, we further conduct the evaluations on the TouchStone (Bai et al., 2023), SEED-Bench (Li et al., 2023b), and MME (Fu et al., 2023). TouchStone is an open-ended vision-language instruction-following benchmark. We compare the instruction-following ability of Qwen-VL-Chat with other instruction-tuned LVLMs in both English and Chinese on the TouchStone benchmark. SEED-Bench consists of 19K multiple-choice questions with accurate human annotations for evaluating Multimodal LLMs, covering 12 evaluation dimensions including both the spatial and temporal understanding. MME measures both perception and cognition abilities on a total of 14 subtasks.

除传统视觉语言评测外,我们还在 TouchStone、SEED-Bench 和 MME 上评测 Qwen-VL-Chat,以衡量真实用户行为下的能力。TouchStone 是开放式视觉语言指令遵循基准,我们使用英文与中文,将 Qwen-VL-Chat 与其他经过指令微调的 LVLM 比较。SEED-Bench 包含 1.9 万道经准确人工标注的选择题,覆盖空间和时间理解在内的 12 个评测维度。MME 则通过 14 个子任务衡量感知与认知能力。

(Bai et al., 2023;Li et al., 2023b;Fu et al., 2023)

The results on three benchmarks are shown in Table 7. Qwen-VL-Chat has achieved obvious advantages over other LVLMs on all three datasets, indicating that our model performs better in understanding and answering diverse user instructions. In SEED-Bench, we have found that our model’s visual capabilities can be effectively transferred to video tasks by simply sampling four frames. In terms of the overall scores presented in TouchStone, our model demonstrates a clear advantage compared to other LVLMs, especially in terms of its Chinese capabilities. In terms of the broad categories of abilities, our model exhibits a more pronounced advantage in understanding and recognition, particularly in areas such as text recognition and chart analysis. For more detailed information, please refer to the TouchStone dataset.

三个基准的结果见表 7。Qwen-VL-Chat 在三个数据集上都明显优于其他 LVLM,说明它更善于理解并回答多样的用户指令。在 SEED-Bench 中,仅采样四帧图像,就能将视觉能力有效迁移到视频任务。在 TouchStone 总分上,模型表现出明显优势,中文能力尤其突出。按能力大类看,理解和识别优势更加显著,特别是文字识别与图表分析。更多细节见 TouchStone 数据集。

5 Related Work

5 相关工作

In recent years, researchers have shown considerable interest in vision-language learning (Su et al., 2019; Chen et al., 2020; Li et al., 2020; Zhang et al., 2021; Li et al., 2021b; Lin et al., 2021; Kim et al., 2021; Dou et al., 2022; Zeng et al., 2021; Li et al., 2021a, 2022), especially in the development of multi-task generalist models (Hu and Singh, 2021; Singh et al., 2022; Zhu et al., 2022; Yu et al., 2022; Wang et al., 2022a; Lu et al., 2022a; Bai et al., 2022). CoCa (Yu et al., 2022) proposes an encoder-decoder structure to address image-text retrieval and vision-language generation tasks simultaneously. OFA (Wang et al., 2022a) transforms specific vision-language tasks into sequence-to-sequence tasks using customized task instructions. Unified I/O (Lu et al., 2022a) further introduces more tasks like segmentation and depth estimation into a unified framework. Another category of research focuses on building vision-language representation models (Radford et al., 2021; Jia et al., 2021; Zhai et al., 2022; Yuan et al., 2021; Yang et al., 2022a). CLIP (Radford et al., 2021) leverages contrastive learning and large amounts of data to align images and language in a semantic space, resulting in strong generalization capabilities across a wide range of downstream tasks. BEIT-3 (Wang et al., 2022b) employs a mixture-of-experts (MOE) structure and unified masked token prediction objective, achieving state-of-the-art results on various visual-language tasks. In addition to vision-language learning, ImageBind (Girdhar et al., 2023) and ONE-PEACE (Wang et al., 2023) align more modalities such as speech into a unified semantic space, thus creating more general representation models.

近年来,研究者持续关注视觉语言学习,尤其是多任务通用模型。CoCa 提出编码器—解码器结构,同时处理图文检索和视觉语言生成;OFA 使用定制任务指令,将特定视觉语言任务转化为序列到序列任务;Unified I/O 进一步把分割和深度估计等纳入统一框架。另一类研究侧重视觉语言表示模型:CLIP 利用对比学习与大量数据,在语义空间中对齐图像与语言,从而在广泛的下游任务中具备较强泛化能力;BEIT-3 采用混合专家(MoE)结构和统一的掩码 token 预测目标,在多项视觉语言任务上达到当时最优水平。除图文外,ImageBind 和 ONE-PEACE 还将语音等更多模态对齐到统一语义空间,构建更通用的表示模型。

(Su et al., 2019;Chen et al., 2020;Li et al., 2020;Zhang et al., 2021;Li et al., 2021b;Lin et al., 2021;Kim et al., 2021;Dou et al., 2022;Zeng et al., 2021;Li et al., 2021a;Li et al., 2022;Hu and Singh, 2021;Singh et al., 2022;Zhu et al., 2022;Yu et al., 2022;Wang et al., 2022a;Lu et al., 2022a;Bai et al., 2022;Radford et al., 2021;Jia et al., 2021;Zhai et al., 2022;Yuan et al., 2021;Yang et al., 2022a;Wang et al., 2022b;Girdhar et al., 2023;Wang et al., 2023)

Despite achieving significant progress, previous vision-language models still have several limitations such as poor robustness in instruction following, limited generalization capabilities in unseen tasks, and a lack of in-context abilities. With the rapid development of large language models (LLMs) (Brown et al., 2020; OpenAI, 2023; Anil et al., 2023; Gao et al., 2023; Qwen, 2023), researchers have started building more powerful large vision-language models (LVLMs) based on LLMs (Alayrac et al., 2022; Chen et al., 2022; Li et al., 2023c; Dai et al., 2023; Huang et al., 2023; Peng et al., 2023; Zhu et al., 2023; Liu et al., 2023; Ye et al., 2023b,a; Chen et al., 2023a; Li et al., 2023a; Zhang et al., 2023; Sun et al., 2023). BLIP-2 (Li et al., 2023c) proposes Q-Former to align the frozen vision foundation models and LLMs. Meanwhile, LLAVA (Liu et al., 2023) and Mini-GPT4 (Zhu et al., 2023) introduce visual instruction tuning to enhance instruction following capabilities in LVLMs. Additionally, mPLUG-DocOwl (Ye et al., 2023a) incorporates document understanding capabilities into LVLMs by introducing digital documents data. Kosmos2 (Peng et al., 2023), Shikra (Chen et al., 2023a), and BuboGPT (Zhao et al., 2023) further enhance LVLMs with visual grounding abilities, enabling region description and localization. In this work, we integrate image captioning, visual question answering, OCR, document understanding, and visual grounding capabilities into Qwen-VL. The resulting model achieves outstanding performance on these diverse style tasks.

尽管取得显著进展,此前的视觉语言模型仍存在若干局限,例如指令遵循不够稳健、对未见任务的泛化有限,以及缺乏上下文学习能力。随着大语言模型快速发展,研究者开始基于 LLM 构建更强大的 LVLM。BLIP-2 提出 Q-Former,将冻结的视觉基础模型与 LLM 对齐。LLaVA 和 MiniGPT-4 引入视觉指令微调,增强指令遵循能力。mPLUG-DocOwl 通过数字文档数据加入文档理解能力。Kosmos-2、Shikra 和 BuboGPT 进一步加入视觉定位能力,支持区域描述和定位。本文将图像描述、视觉问答、OCR、文档理解与视觉定位整合进 Qwen-VL,使其在这些不同类型的任务上取得优异表现。

(Brown et al., 2020;OpenAI, 2023;Anil et al., 2023;Gao et al., 2023;Qwen, 2023;Alayrac et al., 2022;Chen et al., 2022;Li et al., 2023c;Dai et al., 2023;Huang et al., 2023;Peng et al., 2023;Zhu et al., 2023;Liu et al., 2023;Ye et al., 2023b;Ye et al., 2023a;Chen et al., 2023a;Li et al., 2023a;Zhang et al., 2023;Sun et al., 2023;Zhao et al., 2023)

6 Conclusion and Future Work

6 结论与未来工作

We release the Qwen-VL series, a set of large-scale multilingual vision-language models that aims to facilitate multimodal research. Qwen-VL outperforms similar models across various benchmarks, supporting multilingual conversations, multi-image interleaved conversations, grounding in Chinese, and fine-grained recognition. Moving forward, we are dedicated to further enhancing Qwen-VL’s capabilities in several key dimensions:

我们发布 Qwen-VL 系列大规模多语言视觉语言模型,以推动多模态研究。Qwen-VL 在多个基准上优于同类模型,支持多语言对话、多图交错对话、中文定位和细粒度识别。未来将从以下关键方向继续增强其能力:

• Integrating Qwen-VL with more modalities, such as speech and video.

• 将 Qwen-VL 与语音、视频等更多模态结合。

• Augmenting Qwen-VL by scaling up the model size, training data and higher resolution, enabling it to handle more complex and intricate relationships within multimodal data.

• 扩大模型规模、训练数据量和输入分辨率,使其能够处理多模态数据中更复杂、精细的关系。

• Expanding Qwen-VL’s prowess in multi-modal generation, specifically in generating high-fidelity images and fluent speech.

• 扩展多模态生成能力,尤其是生成高保真图像与流畅语音。

A Dataset details

A 数据集细节

A.1 Image-text pairs

A.1 图文对

We use web-crawled image-text pairs dataset for pre-training, which includes LAION-en (Schuhmann et al., 2022a), LAION-zh (Schuhmann et al., 2022a), LAION-COCO (Schuhmann et al., 2022b), DataComp (Gadre et al., 2023) and Coyo (Byeon et al., 2022). We clean these noisy data by several steps:

预训练使用网页抓取的图文对,包括 LAION-en、LAION-zh、LAION-COCO、DataComp 和 Coyo。通过以下步骤清洗噪声数据:

(Schuhmann et al., 2022a;Schuhmann et al., 2022b;Gadre et al., 2023;Byeon et al., 2022)

1. Removing pairs with too large aspect ratio of the image

1. 删除图像长宽比过大的图文对。

2. Removing pairs with too small image

2. 删除图像过小的图文对。

3. Removing pairs with a harsh CLIP score (dataset-specific)

3. 使用严格的 CLIP 得分阈值过滤图文对,阈值因数据集而异。

4. Removing pairs with text containing non-English or non-Chinese characters

4. 删除文本中含有非英文、非中文字符的图文对。

5. Removing pairs with text containing emoji characters

5. 删除文本含表情符号的图文对。

6. Removing pairs with text length too short or too long

6. 删除文本过短或过长的图文对。

7. Cleaning the text’s HTML-tagged part

7. 清理文本中的 HTML 标签部分。

8. Cleaning the text with certain unregular patterns

8. 清理文本中某些不规则模式。

For academic caption datasets, we remove pairs whose text contains the special tags in CC12M (Changpinyo et al., 2021) and SBU (Ordonez et al., 2011). If there is more than one text matching the same image, we select the longest one.

对于学术图像描述数据集,删除 CC12M 和 SBU 中文本含特殊标签的图文对。如果同一图像对应多条文本,则选择最长的一条。

(Changpinyo et al., 2021;Ordonez et al., 2011)

A.2 VQA

A.2 视觉问答

For the VQAv2 (Goyal et al., 2017) dataset, we select the answer annotation based on the maximum confidence. For other VQA datasets, we didn’t do anything special.

对于 VQAv2,选择置信度最高的答案标注;其他 VQA 数据集不做特殊处理。

(Goyal et al., 2017)

A.3 Grounding

A.3 视觉定位

For the GRIT (Peng et al., 2023) dataset, we found that there are many recursive grounding box labels in one caption. We use the greedy algorithm to clean the caption to make sure each image contains the most box labels with no recursive box labels. For other grounding datasets, we simply concatenate the noun/phrase with respective bounding box coordinates.

GRIT 的一条描述中常有递归嵌套的定位框标注。我们采用贪心算法清洗描述,在去除递归框标注的前提下,为每张图像保留尽可能多的框。其他定位数据集仅将名词或短语与对应边界框坐标拼接。

(Peng et al., 2023)

A.4 OCR

A.4 光学字符识别(OCR)

We generated the synthetic OCR dataset using Synthdog (Kim et al., 2022). Specifically, we use the COCO (Lin et al., 2014) train2017 and unlabeld2017 dataset split as the natural scenery background. Then we selected 41 English fonts and 11 Chinese fonts to generate text. We use the default hyperparameters as in Synthdog. We track the generated text locations in the image and convert them to quadrilateral coordinates and we also use these coordinates as training labels. The visualization example is illustrated in the second row of Fig 5.

使用 SynthDoG 生成合成 OCR 数据。具体而言,使用 COCO 的 train2017 和 unlabeld2017 划分作为自然场景背景,选择 41 种英文字体和 11 种中文字体生成文本,沿用 SynthDoG 默认超参数。记录生成文字在图像中的位置并转换为四边形坐标,同时将坐标作为训练标签。可视化示例见图 5 第二行。

(Kim et al., 2022;Lin et al., 2014)

For all the PDF data we collected, we follow the steps below to pre-process the data using PyMuPDF (Software, 2015) to get the rendering results of each page in a PDF file as well as all the text annotations with their bounding boxes.

对于收集的全部 PDF,使用 PyMuPDF,按以下步骤获取每页的渲染结果,以及全部文本和对应边界框标注。

(Software, 2015)

1. Extracting all texts and their bounding boxes for each page.

1. 提取每页全部文本及其边界框。

Qwen-VL 原论文图 5
图 5 · 原文第 17 页 · 点击放大

Figure 5: Visualization of the Grounding and OCR data used for training Qwen-VL

图 5:训练 Qwen-VL 所用视觉定位与 OCR 数据的可视化示例。

2. Rendering each page and save them as an image file.

2. 渲染每一页并保存为图像文件。

3. Removing too small image.

3. 删除过小的图像。

4. Removing images with too many or too few characters.

4. 删除字符数过多或过少的图像。

5. Removing images containing Unicode characters in the “Latin Extended-A” and “Latin Extended-B” blocks.

5. 删除含 Unicode“拉丁字母扩展 A”和“拉丁字母扩展 B”区块字符的图像。

6. Removing images containing Unicode characters in the “Private Use Area (PUA)” block.

6. 删除含 Unicode 私用区(PUA)字符的图像。

For all HTML web pages we collected, we pre-process them in a similar approach to all the PDF data we collected, but we use Puppeteer (Google, 2023) instead of PyMuPDF to render these HTML pages and get the ground truth annotation. We follow the steps below to pre-process the data.

对于收集的全部 HTML 页面,采用类似于 PDF 的预处理方法,但使用 Puppeteer 而非 PyMuPDF 进行页面渲染并获取真实标注。处理步骤如下:

(Google, 2023)

1. Extracting all texts for each webpage.

1. 提取每个网页的全部文本。

2. Rendering each page and save them as an image file.

2. 渲染每一页并保存为图像文件。

3. Removing too small image.

3. 删除过小的图像。

4. Removing images with too many or too few characters.

4. 删除字符数过多或过少的图像。

5. Removing images containing Unicode characters in the “Private Use Area (PUA)” block.

5. 删除含 Unicode 私用区(PUA)字符的图像。

B Data Format Details of Training

B 训练数据格式细节

B.1 Data Format of Multi-Task Pre-training

B.1 多任务预训练的数据格式

We visualize the Multi-Task Pre-training data format in Box B.1. The Box contains all 7 tasks with the black-colored text as the prefix sequence without loss and blue-colored text as the ground truth labels with loss.

框 B.1 展示多任务预训练数据格式,包含全部 7 类任务。黑色文本为不计算损失的前缀序列,蓝色文本为计算损失的真实标签。

Qwen-VL 原论文训练格式 B.1
训练格式 B.1 · 原文第 19 页 · 点击放大
图像描述
<img>cc3m/01581435.jpg</img>用英语生成描述:用于设计的美丽花朵。<eos>

视觉问答
<img>VG_100K_2/1.jpg</img>绷带和腕带的颜色不同吗?
答案:不,绷带和腕带都是白色。<eos>

OCR 视觉问答
<img>ocr_vqa/1.jpg</img>这本书的书名是什么?
答案:Asi Se Dice!, Volume 2: Workbook And Audio Activities (Glencoe Spanish) (Spanish Edition)<eos>

带定位的图像描述
<img>coyo700m/1.jpg</img>用英语生成带定位的描述:
<ref>蜜蜂</ref><box>(661,612),(833,812)</box><box>(120,555),(265,770)</box>从<ref>一朵杏花</ref><box>(224,13),(399,313)</box>采蜜的美丽画面。<eos>

指代表达定位
<img>VG_100K_2/3.jpg</img><ref>长颈鹿的耳朵</ref><box>(176,106),(232,160)</box><eos>

指定区域描述
<img>VG_100K_2/4.jpg</img><ref>这</ref><box>(360,542),(476,705)</box>是黄色越野滑雪比赛手套。<eos>

OCR
<img>synthdog/1.jpg</img>带定位的 OCR:<ref>It is managed(它由……管理)</ref><quad>(568,121),(625,131),(624,182),(567,172)</quad>...<eos>

B.2 Data Format of Supervised Fine-tuning

B.2 监督微调的数据格式

To better accommodate multi-image dialogue and multiple image inputs, we add the string "Picture id:" before different images, where the id corresponds to the order of image input dialogue. In terms of dialogue format, we construct our instruction tuning dataset using the ChatML (Openai) format, where each interaction’s statement is marked with two special tokens (<im_start> and <im_end>) to facilitate dialogue termination.

为更好地支持多图对话与多图输入,在不同图像前加入字符串“Picture id:”,其中 id 对应图像在输入对话中出现的顺序。对话格式使用 ChatML,以 <im_start> 和 <im_end> 两个特殊标记界定每轮发言,便于终止对话。

(Openai, ChatML)

Qwen-VL 原论文训练格式 B.2
训练格式 B.2 · 原文第 19 页 · 点击放大
<im_start>user
Picture 1: <img>vg/VG_100K_2/649.jpg</img>图中的标志是什么?<im_end>
<im_start>assistant
这个标志是橙色菱形的道路封闭标志。<im_end>
<im_start>user
图中的天气如何?<im_end>
<im_start>assistant
道路封闭标志的形状是橙色菱形。<im_end>

注:原文最后一个回答与天气问题不对应,此处如实保留。示例中的路径和特殊标记保持原样。

During training, we ensure the consistency between prediction and training distributions by only supervising answers and special tokens (blue in the example), and not supervising role names or question prompts.

训练时只监督答案和特殊标记(示例中的蓝色部分),不监督角色名称或问题提示,以保证预测分布与训练分布一致。

C Hyperparameters

C 超参数

We report the detailed training hyperparameter settings of Qwen-VL in Table 8.

表 8 给出 Qwen-VL 训练超参数的详细设置。

Table 8: Training hyperparameters of Qwen-VL

表 8:Qwen-VL 的训练超参数。

Qwen-VL 原论文表 8
表 8 · 原文第 20 页 · 点击放大
配置预训练多任务预训练监督微调
ViT 初始化Open-CLIP-bigGQwen-VL 第一阶段Qwen-VL 第二阶段
LLM 初始化Qwen-7BQwen-7BQwen-VL 第二阶段
适配器初始化随机Qwen-VL 第一阶段Qwen-VL 第二阶段
图像分辨率224²448²448²
ViT 序列长度25610241024
LLM 序列长度51220482048
可学习查询数256256256
优化器AdamWAdamWAdamW
优化器参数β1=.9, β2=.98, eps=1e−6同左同左
峰值学习率2e−45e−51e−5
最低学习率1e−61e−51e−6
ViT 学习率衰减0.950.950
ViT 随机深度丢弃率000
学习率调度余弦衰减余弦衰减余弦衰减
权重衰减0.050.050.05
梯度裁剪1.01.01.0
训练步数50k19k8k
预热步数5004003k
全局批大小307204096128
梯度累积688
数值精度bfloat16bfloat16bfloat16
优化器分片✓✓✓
激活检查点✗✗✗
模型并行✗22
流水线并行✗✗✗

In the first pre-training stage, the model is trained using AdamW optimizer with β1 = 0.9, β2 = 0.98, eps = 1e−6. We use the cosine learning rate schedule and set the maximum learning rate of 2e−4 and minimum of 1e−6 with a linear warm-up of 500 steps. We use a weight decay of 5e−2 and a gradient clipping of 1.0. For the ViT image encoder, we apply a layer-wise learning rate decay strategy with a decay factor of 0.95. The training process uses a batch size of 30720 for the image-text pairs, and the entire first stage of pre-training lasts for 50,000 steps, consuming approximately 1.5 billion image-text samples and 500 billion image-text tokens.

第一阶段使用 AdamW 优化器,β1 = 0.9、β2 = 0.98、eps = 1e−6。学习率采用余弦调度,最大学习率为 2e−4,最小为 1e−6,前 500 步线性预热。权重衰减为 5e−2,梯度裁剪为 1.0。ViT 图像编码器使用逐层学习率衰减,衰减因子为 0.95。图文对批大小为 30720,共训练 50000 步,消耗约 15 亿图文样本和 5000 亿图文 token。

In the second multi-task training stage, we increase the input resolution of the visual encoder from 224 × 224 to 448×448, reducing the information loss caused by image down-sampling. We unlocked the large language model and trained the whole model. The training objective is the same as the pre-training stage. We use AdamW optimizer with β1 = 0.9, β2 = 0.98, eps = 1e−6. We trained for 19000 steps with 400 warm-up steps and a cosine learning rate schedule. Specifically, we use the model parallelism techniques for ViT and LLM.

第二阶段将视觉编码器输入从 224 × 224 提升至 448 × 448,减少图像下采样的信息损失。解冻大语言模型并训练整个模型,目标与第一阶段相同。使用 AdamW,β1 = 0.9、β2 = 0.98、eps = 1e−6;共训练 19000 步,其中预热 400 步,并使用余弦学习率调度。ViT 和 LLM 均采用模型并行技术。

D Summary of the evaluation benchmarks

D 评测基准汇总

We provide a detailed summary of the used evaluation benchmarks and corresponding metrics in Table 9.

表 9 汇总使用的评测基准及相应指标。

Table 9: Summary of the evaluation benchmarks.

表 9:评测基准汇总。

Qwen-VL 原论文表 9
表 9 · 原文第 21 页 · 点击放大
任务数据集说明划分指标 ↑
图像描述Nocaps自然图像描述valCIDEr
图像描述Flickr30K自然图像描述karpathy-testCIDEr
通用 VQAVQAv2自然图像问答test-devVQA Score
通用 VQAOKVQA需要外部知识的自然图像问答valVQA Score
通用 VQAGQA场景理解与推理test-balancedEM
通用 VQAScienceQA-Img多种科学主题的选择题test准确率
通用 VQAVizWiz盲人拍摄照片的问答test-devVQA Score
文字 VQATextVQA含文字的自然图像问答valVQA Score
文字 VQADocVQA扫描文档图像问答testANLS
文字 VQAChartQA图表问答test宽松 EM
文字 VQAOCRVQA书籍封面问答testEM
文字 VQAAI2Diagram科学示意图问答testEM
指代表达理解RefCOCO自然图像指代定位val/testA/testB准确率
指代表达理解RefCOCO+自然图像指代定位val/testA/testB准确率
指代表达理解RefCOCOg自然图像指代定位val/test准确率
指代表达理解GRiT自然图像指代定位test准确率
指令遵循TouchStone开放式视觉语言指令英文/中文GPT-4 得分
指令遵循MME是/否问答的开放式视觉语言基准感知/认知准确率
指令遵循SEED-Bench多项选择视觉问答基准图像/视频准确率

EM:精确匹配;ANLS:平均归一化编辑相似度;↑ 表示越高越好。任务描述沿用论文。

E Additional experimental details

E 补充实验细节

E.1 Convergence of the Pre-training Stage

E.1 预训练阶段的收敛情况

In Figure 6, we show the convergence of the Pre-training Stage (stage one). The whole models are trained using BFloat16 mixed precision, the batch size is 30720, and the learning rate is 2e−4. All images are only trained once (one epoch). The training loss decreases steadily with the increase of the number of training pictures. Note that, the pre-training stage (Stage one) has no VQA data being added, but the Zero-shot VQA score increases amidst fluctuations.

图 6 展示第一阶段预训练的收敛过程。模型使用 BFloat16 混合精度,批大小为 30720,学习率为 2e−4。所有图像仅训练一次,即一个 epoch。随着训练图像数量增加,训练损失稳定下降。尽管第一阶段没有加入 VQA 数据,零样本 VQA 得分仍在波动中上升。

Qwen-VL 原论文图 6
图 6 · 原文第 21 页 · 点击放大

Figure 6: Visualization of the Convergence of the Pre-training Stage

图 6:预训练阶段的收敛可视化。左:预训练损失;中:Flickr 图像描述的 CIDEr 得分;右:VQAv2 零样本准确率。横轴均为已训练图像数,单位十亿。

E.2 Number of Learnable Queries in the Vision-Language Adapter

E.2 视觉语言适配器中的可学习查询数量

The vision-language adapter uses cross-attention to compress the visual feature sequence by a set of learning queries of length. Too few queries can lead to the loss of some visual information, while too many queries may reduce in greater convergence difficulty and computational cost.

视觉语言适配器通过一组可学习查询与交叉注意力压缩视觉特征序列。查询过少会丢失视觉信息,过多则可能增加收敛难度和计算成本。

An ablation experiment is conducted on the number of learnable queries in the vision-language adapter. We used ViT-L/14 as the visual encoder and the 224 × 224 resolution picture as input, so the sequence length of ViT’s output is (224/14)2 = 256. As shown in the left part of Figure 7, the fewer queries used at the beginning of training, the lower the initial loss. However, with convergence, too many or too few queries will cause convergence to slow down, as shown in the right part of Figure 7. Considering that the second training stage (Multi-task Pre-train) applies 448*448 resolution, where the sequence length of ViT’s output is (448/14)2 = 1024. Too few queries can result in more information being lost. We finally chose to use 256 queries for the vision-language adapter in Qwen-VL.

我们对适配器中的可学习查询数量开展消融实验。实验使用 ViT-L/14 视觉编码器和 224 × 224 输入,因此 ViT 输出长度为 (224/14)² = 256。图 7 左侧表明,训练初期查询越少,初始损失越低;但随着训练收敛,查询过多或过少都会减慢收敛,如右图所示。考虑到第二阶段采用 448 × 448 分辨率,ViT 输出序列长度为 (448/14)² = 1024,查询太少会丢失更多信息,因此最终选择 256 个查询。

Qwen-VL 原论文图 7
图 7 · 原文第 22 页 · 点击放大

Figure 7: Visualization of the training loss when using different compressed feature lengths of the vision-language adapter. The left depicts the initial training loss (within 50 steps), and the right depicts the loss in convergence (1k-5k steps). In the legend, L64 denotes that the adapter uses 64 queries to compress the visual feature sequence to a fixed length of 64, and so on. The loss curves have been smoothed to avoid shading owing to fluctuations.

图 7:视觉语言适配器采用不同压缩特征长度时的训练损失。左图为训练初期(50 步以内),右图为收敛阶段(1000—5000 步)。L64 表示使用 64 个查询,将视觉特征序列压缩至长度 64,其他标记依此类推。曲线经过平滑处理,以减轻波动的遮蔽影响。

E.3 Window Attention vs Global Attention for Vision Transformer

E.3 ViT 的窗口注意力与全局注意力

Using a high-resolution Vision Transformer in the model will significantly increase the computational cost. One possible solution to reduce the computational cost of the model is to use Window Attention in the Vision Transformer, i.e., to perform Attention only in a window of 224 × 224 in most layers of the ViT part of the model, and to perform Attention for the full 448 × 448 or 896 × 896 image in a small number of layers (e.g. 1 out of every 4 layers) of the ViT part of the model.

使用高分辨率 ViT 会显著增加计算成本。一种降低成本的方法是使用窗口注意力:在 ViT 的多数层中,仅在 224 × 224 窗口内进行注意力计算;只在少数层(例如每四层中的一层)对完整的 448 × 448 或 896 × 896 图像进行注意力计算。

To this end, we conducted ablation experiments to compare the performance of the model when using Global Attention and Window Attention for ViT. We compare the experimental results for analysing the trade-off between computational efficiency and convergence of the model.

为此,我们开展消融实验,比较 ViT 使用全局注意力与窗口注意力时的表现,分析计算效率与收敛之间的权衡。

Table 10: Training speed of Window Attention vs Global Attention for different input image resolutions

表 10:不同输入分辨率下,窗口注意力与全局注意力的训练速度比较。

Qwen-VL 原论文表 10
表 10 · 原文第 22 页 · 点击放大
输入分辨率注意力类型训练速度
448 × 448全局注意力10 秒/次迭代
448 × 448窗口注意力9 秒/次迭代
896 × 896全局注意力60 秒/次迭代
896 × 896窗口注意力25 秒/次迭代

As shown in Figure 8 and Table 10, the loss of the model is significantly higher when Window Attention instead of Vanilla Attention is used. And the training speeds for both of them are similar. Therefore, we decided to use Vanilla Attention instead of Window Attention for the Vision Transformer when training Qwen-VL.

如图 8 和表 10 所示,使用窗口注意力代替标准注意力时,模型损失明显更高,而两者的训练速度相近。因此,训练 Qwen-VL 的视觉 Transformer 时采用标准全局注意力。(这里的速度相近对应 448 × 448 设置。)

Qwen-VL 原论文图 8
图 8 · 原文第 23 页 · 点击放大

Figure 8: Visualization of the Loss when using Window Attention vs Global Attention

图 8:采用窗口注意力与全局注意力时的损失比较。

The reason we don’t use Window Attention with 896 × 896 resolution is that its training speed is too slow for us. Although it reaches a loss value similar to model with 448 × 448 resolution input at 5000 steps. It takes almost 2.5 times longer to train than the model with 448 × 448 resolution input.

不采用 896 × 896 窗口注意力的原因是训练太慢。虽然它在 5000 步时可达到与 448 × 448 输入模型相近的损失,但训练耗时几乎是后者的 2.5 倍。

E.4 Performance on Pure-text Tasks

E.4 纯文本任务表现

In order to study the effect of multi-modal training on pure-text ability, we show the performance of pure-text tasks of Qwen-VL compared to open-source LLM in Table 11.

为研究多模态训练对纯文本能力的影响,表 11 比较 Qwen-VL 与开源 LLM 在纯文本任务上的表现。

Qwen-VL uses an intermediate checkpoint of Qwen-7B as the LLM initialization. The reason why we did not use the final released checkpoint of Qwen-7B is that Qwen-VL and Qwen-7B were developed at a very similar period. Because Qwen-VL has a good initialization on LLM by Qwen-7B, it is comparable to many text-only LLMs on pure-text tasks.

Qwen-VL 使用 Qwen-7B 的一个中间检查点初始化语言模型,而非最终发布的检查点,因为两个模型的开发时间非常接近。得益于 Qwen-7B 提供的良好初始化,Qwen-VL 在纯文本任务上可与多种纯文本 LLM 相媲美。

Table 11: Performance on Pure-text Benchmarks of Qwen-VL compared to open-source LLM. Due to the introduction of pure-text data in the multi-task training and SFT stage, Qwen-VL do not compromise any pure-text ability.

表 11:Qwen-VL 与开源 LLM 在纯文本基准上的表现。由于在多任务训练与 SFT 阶段引入纯文本数据,Qwen-VL 没有损害纯文本能力。

Qwen-VL 原论文表 11
表 11 · 原文第 23 页 · 点击放大
模型MMLUCMMLUC-Eval
LLaMA-7B35.126.8—
LLaMA2-7B46.831.832.5
Baichuan-7B42.344.442.8
Baichuan2-7B54.257.154.0
ChatGLM2-6B47.948.851.7
InternLM-7B51.051.852.8
Qwen-7B(最终发布)58.262.263.5
Qwen-7B(用于初始化的中间检查点)49.9—48.5
Qwen-VL50.749.551.1

Furthermore, in the multi-task training and SFT stages, Qwen-VL not only utilizes visual and language-related data but also incorporates pure-text data for training. The purpose of this is to prevent the catastrophic forgetting of text comprehension by leveraging the information from pure-text data. The results in Table 11 indicate that the Qwen-VL model does not exhibit any degradation in terms of its pure text capability and even demonstrates improvement after multi-task training.

此外,多任务训练和 SFT 阶段不仅使用视觉语言数据,也加入纯文本数据,目的是借助纯文本信息,防止对文本理解能力的灾难性遗忘。表 11 表明,Qwen-VL 的纯文本能力没有下降,在多任务训练后甚至有所提升。

全文对照结束 · 已省略参考文献列表,文内引用可直接打开来源。