type
status
date
slug
summary
tags
category
icon
password
paper
github
Org.
Salesforce AI Research
个人博客地址
前置阅读:BLIP系列总结

1 核心思路

虽然过去BLIP系列对LMM发展起到至关重要的作用,但从效果上来说,已经远落后于当下的SOTA模型,主要有一下3点原因:
1)数据上,训练数据数量少、质量不高、多样性不强。
2)训练策略上,多个stage(ITMITCITG)训练流程冗长,up scale的训练开销大
3)模型架构上,BLIP系列仅支持单图输入,应用范围相对较窄
BLIP3针对以上3个方面进行改进:
1)数据上,构造了更大的、质量更高、多样性更强的数据集。
2)训练策略上,提出3 stage 的训练范式,并统一用next token prediction作为训练目标,提升训练效率和模型效果。
3)模型架构上,支持交错图文输入。
notion image

2 方法

2.1 模型架构

多模态两种主流架构:
  • cross-attention style;通过给LLM引入交叉注意力机制,融合不同模态的信息;代表方法:FlamingoLlama 3.1
  • decoder-only style;通过VL-connector,将visual token转为LLM可以“理解”的token,无需改动LLM的架构。代表方法:BLIP-2LLAVAQwen-vlPali-xKosmos-2phi3-vision
BLIP3也是decoder-only style。区别于早先的BLIP2BLIP3支持交错式的图文输入。
训练阶段:图片用visual tokenizer转为visual token,文本用text tokenizer转为text token,最后按序拼接起来送入LLM,用causal mask做并行,仅对文本token处计算自回归损失。
推理阶段:图片用visual tokenizer转为visual token,文本用text tokenizer转为text token,最后按序拼接起来送入LLM,按照next token prediction的范式做生成。
BLIP3架构只能解决多模态图文交错输入,单模态文本输出。
notion image
BLIP3的架构包含3部分

2.1.1 image transforme(image encoder)

这个部分不参与训练,所用模型为SigLIPViT-SO400M-14-SigLIP-384),用于提取图片embedding。

2.1.2 VL-Connector

BLIP3中没有沿用BLIP2QFormer,而是用了FlamingoPerceiver Resampler。二者核心思路其实都差不多——以learnable queries的方式,将image encoder提取的image embedding转为固定长度的image token。
Perceiver Reampler的核心计算逻辑如图所示:
notion image

2.1.3 LLM

BLIP3中,LLM也参与训练。所用的LLMphi3-mini

2.2 Any-Resolution Vision Token Sampling

为了强化模型对细粒度信息的捕获能力。BLIP3也引入了Llava next中的Any-Resolution Vision Token Sampling 策略,具体过程如下:
step1: 找到最优分辨率
预设了一些模版,通过下面的目标找到输入图片最适合的分辨率
其中t为模版的索引,一共有个预设模版
step2: 切分patch
每个patch的size为vision transformer的输入size,blip3所用的ViT-SO400M-14-SigLIP-384 的输入size为(384x384)。假设输入图片所映射的模板size为(768x768),将图片resize到(768x768)后进行切分,得到5个patch,4个切分patch加上一个包含全局信息的patch,如下图所示。
notion image
 
step3: 计算每个patch的image embedding。
一个384x384的图片经过ViT-SO400M-14-SigLIP-384后得到576个token
notion image
step4: 分别提取每个patch的vision token再拼接
从下图可见,不同模版分辨率的image token是不同的。通常来说,token数越多,包含的细粒度信息就越多。对于下游感知密集型的推理任务会有更大优势(如DocQA)。
notion image

2.3 训练recipe

training-stage
训练模块
训练目标
dataset
dataset size
训练时长
是否采用any-resolution Vision Token Sampling 的策略
stage1: pre-training
VL connector, LLM
next token prediction
交错图文数据,caption类数据
-
100 billion multi-modal token
stage2-part1. 常规instruct-following SFT
VL connector, LLM
next token prediction
开源数据:1)多模态会话 2) image caption;3)VQA;4) document QA;5)science and math understand等
1M
1 epoch
stage2-part2. multi-image instruction tuning
VL connector, LLM
next token prediction
MANTIS,Mmdu,及stage 2.1中的交错图文数据
-
-
post-training—Improving Truthfulness by Direct Preference Optimization
LLM-backbone Lora 2.5%参数。
DPO
VLFeedback
62.6k
1 epoch
post-training—Improving Harmlessness by Safety Fine-tuning
LLM-backbone Lora 2.5%参数
next token prediction
VLGuard-2k,5k additional examples from the instruction fine-tuning dataset
2k
3 epoch
从模型架构来看,BLIP3需要训练模块有两个:1)VL-connector (perceiver sampler);2) LLM
BLIP3的训练分为了3个stage
  • pre-training
  • SFT
  • post-training

2.3.1 stage1: pre-training

notion image
 
数据集格式如:
notion image
stage1训练了约100 billion 多模态token。此外,stage1没有用Any-Resolution Vision Token Sampling的策略。
简单介绍BLIP3自建的3个数据集
(一) BLIP3-KALE
论文暂时未给出细节。
论文原话:Details will be discussed in another paper, and the dataset will be made public very soon
(二) BLIP3-OCR-200M
作者从Datacomp-1B中搜集了200M张高分辨率图片。用paddleOCR提取里面的文字信息。虽然BLIP3中并没有用到文本的bounding box,作者说可以尝试,会提升OCR QA类任务的效果。
notion image
(三) BLIP3-GROUNDING-50M
作者从Datacomp-1B中搜集50M图片(图文信息都要)。用开源的open-set目标检测模型Grounding-DINORecognize Anything进行识别。将caption中的对应的object替换为包含位置信息的object。
notion image

2.3.2 stage2: SFT

part1. 常规instruct-following SFT
作者搜集了一批开源数据集,从里面挑选了1M数据用Any-Resolution Vision Token Sampling的策略微调模型1个epoch。开源数据涉及的领域包括:
  • 多模态会话
  • image caption
  • VQA
  • document QA
  • science and math understand等
part2. multi-image instruction tuning
为了提升模型对多图交错图文场景的理解能力,作者用多图交错图文数据集MANTISMmdu结合2.1的单图交错图片数据对模型进行进一步微调。

2.3.3 stage3: post-training

stage3主要是为了提升模型的helpfulness,harmlessness
part1. 通过DPO提升模型的Truthfulness
训练数据:该阶段利用了开源的VLFeedback数据集的指令,VLFeedback是一个用GPT4-v构造多模态偏好数据集,总计80K。构造方式:给定指令,让多个VLM模型做生成,随后GPT4-v从helpfulness, visual faithfulness, and ethics对生成的结果进行打分。分值高的输出作为preferred responses,分值低的输出作为dispreferred responses。BLIP3进一步过滤掉首选响应得分较低的sample,最终得到62.6K数据。
训练方式BLIP3采用DPO作为训练目标,用LORA微调LLM 2.5%参数,总计训练1个epoch。
part2. 通过Safty-SFT提升模型的Harmlessness
训练数据:用VLGuard数据集+随机5K SFT数据集对BLIP3再次进行微调,在保留helpfulness的同时提升harmlessness。
训练方式LORA微调LLM 2.5%参数

3 结果

3.1 Pre-Training模型的few-shot能力

notion image

3.2 SFT 模型评估

3.2.1 单图benchmark评估

notion image

3.2.2 多图benchmark评估

notion image
notion image

3.3 Post-training 模型评估

notion image

4 一些关键的消融实验

4.1 Pre-Training阶段消融实验

4.1.1 scaling pre-training data

caption类任务在训练token数达到60B后精度增长放缓;相对复杂的text VQA类任务精度还有较大提升。
notion image

4.1.2 visual backbone & number of visual token

SigLip模型作为backbone有较大的优势,尤其在OCR任务上。
notion image
作者方向将visual token从128降到64后,精度并没有明显下降。
notion image

4.2 SFT训练阶段消融实验

4.2.1 Any-Resolution Vision Token Sampling

base resolution pipeline
notion image
anyres-fixed-sampling pipeline
notion image
anyres-patch-sampling pipeline
notion image
从消融实验看,Any-Resolution Vision Token Sampling 对强感知类任务增益很大。
notion image

5 小结

BLIP3从dataset curation, training recipe, model architectures对BLIP2进行了一系列改进,使BLIP系列达到目前开源SOTA水平。
 
Feeling after reading The Little Prince Data Filtering Network论文浅析
  • Twikoo