最值得抓住的一条主线:language generation + pixel grounding
即:模型一边生成自然语言,一边把语言里提到的实体/短语,直接绑定到图像中的像素级区域。
论文并不是单纯“LLM 后面接一个 SAM”,而是专门设计了一套语言 token → 分割 prompt → mask的连接机制,把“说什么”和“分哪里”统一到同一次生成过程中。
1. 论文想解决什么问题
(1)缺少pixel-level grounding
以前的多模态大模型,如 LLaVA、MiniGPT-4 等,主要解决的是:image → language
输入一张图,问:“这张图里有什么?”
模型回答:“一栋白色建筑,红色屋顶,周围有草坪和树木。”
模型虽然“说对了”,但没有说:“建筑”、“红色屋顶”、“草坪”、“树木”具体在哪些像素,有语言理解,但语言和图像空间没有真正绑定。
(2)缺少自然语言生成和复杂对话能力
传统 segmentation 模型,如 SAM,可以输出 mask,但不具备自然语言生成和复杂对话能力。
GLaMM 想做的就是:既让模型会说,又让它知道自己说的东西到底对应图像中的哪一片像素。
2. GLaMM 最核心的输出形式
可以把 GLaMM 想成LMM + segmentation decoder,但不是简单并列,是通过特殊 token 联系起来。如模型生成:
A <p>man</p><SEG> and a <p>boy</p><SEG> sit on a <p>bench</p><SEG>.
这里有两个非常重要的概念:
(1)<p> ... </p>
表示:这个文本片段是需要被视觉 grounding 的 phrase。如:
<p>man</p>表示“man”这个短语需要对应图像中的某个区域。
(2)<SEG>
表示:请为前面这个 phrase 生成一个 segmentation mask。
论文在 GCG(Grounded Conversation Generation)输出表示中采用<p>、</p>和<SEG>这些特殊 token,用来把语言片段和对应的区域 mask 联系起来。
整个生成过程可以理解成:生成语言 → 遇到<SEG>→ 同时触发像素级分割。
这就是 language generation 和 pixel grounding 最直接的接口。
grounding 是“建立文本和视觉区域之间的对应关系”,
生成 mask 是“把这个对应关系具体落实成像素级区域”。
比如一句话:
<p>man</p><SEG>这里可以拆成两件事:
<p>man</p>:“man”是一个需要被定位到图像中的 phrase,也就是要 grounding。<SEG>:要求模型进一步输出这个 “man” 对应的像素级 segmentation mask。
grounding = 找到“这个词说的是图里的谁/哪里”
mask generation = 把“哪里”精确到每一个像素grounding 可以用很多方式表达,如:bounding box、point、region、segmentation mask
因此grounding 是一个更大的概念,mask 只是 grounding 的一种更精细的表示形式。
GLaMM 里做的是pixel-level grounding,所以最终 grounding 的结果就是 segmentation mask。也就是说,这篇论文里两者关系可以写成:
grounding 是目标,mask 是实现 grounding 的像素级形式。
3. 整个 GLaMM 架构
论文把 GLaMM 分为五个核心组件:
- Global Image Encoder
- Region Encoder
- LLM
- Grounding Image Encoder
- Pixel Decoder
可以简单画成:
┌───────────────┐ Image ────────────► Global Encoder │ └───────┬───────┘ │ ▼ LLM │ natural language tokens │ <SEG> │ ▼ L-P Projection │ ▼ Image ───► Grounding Image Encoder ───► Pixel Decoder │ ▼ Mask这里真正完成统一的是中间这一条:
LLM hidden state of<SEG>→ segmentation prompt → Pixel Decoder
4. language generation
语言部分先用一个全局图像编码器:ViT-H/14 CLIP将输入图像编码成视觉特征。
记为:
然后通过一个Vision-to-Language projection layer,V-L projection:把视觉特征映射到 LLM 的语言特征空间。
最后 LLM 同时接收:image features 和 text instruction,并生成文本:
Image ↓ CLIP ↓ Visual features ↓ V-L Projection ↓ LLM embedding space ↓ LLM ↓ language tokens这一部分跟普通 LMM 很像。
如:
Image + “Describe this image.” ↓ LLM ↓ “A large hot air balloon is flying over the river...”因此单看这一部分,GLaMM 本质上仍然是一个 image-conditioned language model。
5. pixel grounding
为了得到像素级 mask,GLaMM另外引入:Grounding Image Encoder、Pixel Decoder
Grounding Image Encoder 用pretrained SAM encoder,Pixel Decoder 用类似 SAM decoder 的架构。
Image → SAM image encoder → dense visual feature map这套视觉特征与 CLIP 的作用完全不同。
CLIP 主要负责:“图里有什么?”SAM image encoder 主要负责:“这些东西具体在哪些像素?”
可以粗略理解成:
CLIP feature → semantic understanding SAM feature → spatial / pixel representation6. 语言是怎么变成 segmentation mask 的?
GLaMM 在 LLM 的 vocabulary 里面新增了一个:<SEG>token
如用户问:
Please segment the man in red.LLM 可能生成:
Sure, it is <SEG>.这里的<SEG>不是普通 token。
模型取出<SEG>在 LLM 最后一层对应的 hidden embedding:,然后通过一个Language-to-Prompt Projection,L-P projection,记作:
,把语言 embedding 映射到 segmentation decoder 能理解的 prompt space。
最后:
其中:
:LLM 中
<SEG>token 的 hidden state:language-to-prompt projection
:SAM grounding image encoder 特征
- P:pixel decoder
- M:最终 segmentation mask
论文就是这样定义 pixel-level grounding 的。
整个核心过程其实可以压缩成:
language meaning ↓ <SEG> hidden state ↓ L-P projection ↓ segmentation prompt ↓ SAM-like mask decoder ↓ pixel mask这就是language generation + pixel grounding 的真正连接点。
7. 为什么<SEG>hidden state 能表示“要分割谁”?
假设模型生成:
A <p>red car</p><SEG>虽然<SEG>本身只是一个 token,但它前面的 language context 是:
A red carTransformer 的 self-attention后,<SEG>的 hidden state 并不是“SEG 这个符号”的静态 embedding。它实际上已经吸收了上下文信息:red、car、当前图像内容、前面所有文本、多模态视觉信息
所以:可以理解成:“当前这次 segmentation 到底应该找什么”的语义表示。
如:
<p>red car</p><SEG>得到一个 hidden state:
representation of: “the red car referred to in this image”而:
<p>person wearing blue</p><SEG>得到的是另一个 hidden state:
representation of: “the person wearing blue”然后 L-P projection 把这个语言语义表示变成 SAM decoder 能理解的 prompt。
所以本质上LLM 负责决定“要找什么”,SAM decoder 负责决定“它具体在哪”。
8. 这与直接使用文本 prompt 做 segmentation 有什么区别
与“ 把‘red car’直接输入 SAM 吗?”的区别:
SAM 原始的 prompt 主要是:point、box、mask,并不是复杂自然语言。
而 GLaMM 是:
整段自然语言上下文 ↓ LLM ↓ <SEG> contextual hidden state ↓ projection ↓ SAM decoder prompt所以真正送给 decoder 的不是字符串:"red car",而是已经经过 LLM 多模态推理后的语义 embedding。因此理论上它可以表达更复杂的东西。
如:
the smaller cup它不是单纯类别“cup”。模型需要理解:
cup + multiple cups + size comparison + which one is smaller然后<SEG>hidden state 承载这个经过上下文消歧后的语义,再交给 pixel decoder。
论文的 Figure 5 就展示了类似的多轮对话:
先问:“Can you segment the McDonald's cup?” ,然后继续问:“Can you please segment the smaller cup now?”,说明 segmentation target 可以受到对话上下文影响。
9. “统一”到底统一在哪里?
这里可以分成三个层次理解。
第一层:输出形式统一
传统:
VLM: image → text Segmentation: image + prompt → maskGLaMM:
image + text → language sequence + segmentation masks即:文本和 mask 出现在同一个 response 里。
第二层:语义表示统一
更关键的是:mask 的 prompt 来自 LLM 的 token hidden state。
也就是说:语言模型中的语义直接变成视觉分割的 prompt:
所以 language space 和 segmentation space 被连接起来:
LLM language space ↓ L-P projection ↓ segmentation prompt space这才是架构意义上的统一。
第三层:任务统一
GLaMM 提出的Grounded Conversation Generation, GCG更进一步。
它不再把这些任务分别处理:
captioning、referring segmentation、phrase grounding、region understanding、conversation而是统一成:
image + natural language interaction ↓ grounded natural language response例如:
A <man><SEG> and a <boy><SEG> sit on a <bench><SEG> next to an <old white car><SEG>.一句 caption 本身同时完成:image captioning、phrase grounding、segmentation、dense scene understanding
10. 两套 image encoder
Global Image Encoder
CLIP ViT-H/14:
Image → CLIP → high-level semantic features → LLM主要服务:language generation / scene understanding,如:“这里有一栋建筑,旁边有树。”
Grounding Image Encoder
SAM encoder:
Image → SAM encoder → dense spatial feature map → mask decoder主要服务:pixel grounding
如:“建筑到底是哪几个 pixel。” 所以可以把它理解为:
┌── semantic branch ──► language Image ────┤ └── spatial branch ───► segmentation而<SEG>hidden state 是连接这两个 branch 的桥梁。<SEG>hidden state 把 LLM 中“要分割什么”的语义信息传递给 Pixel Decoder,让像素分支知道应该在图像中寻找哪个目标。
11. Region Encoder
除此之外,还有一个Region Encoder。它解决的是用户指出某个区域,让模型理解这个区域。
如:
Can you describe this region?然后用户给一个 bounding box。GLaMM 会:
CLIP intermediate features ↓ feature pyramid ↓ RoIAlign ↓ region feature ↓ V-L projection ↓ LLM论文用四个CLIP层构建hierarchical feature pyramid,再通过RoIAlign得到的区域特征。
所以 GLaMM 实际上有三个粒度(对应三个encoder):
Scene-level → Global Image Encoder Region-level → Region Encoder Pixel-level → SAM encoder + Pixel Decoder这也是这篇论文设计很完整的一点。
12. GCG 任务为什么重要
作者认为,只做:
“segment the dog”还不能真正体现 LMM 的优势。因为这实际上还是传统 referring segmentation。
所以他们提出了:Grounded Conversation Generation,GCG
要求模型:生成自然语言,同时把语言中重要的 phrase 都对应到 mask。
例如:
A man and a boy sit on a bench next to an old white car.不只是输出这句话,而是变成:
<p>A man</p><SEG> and <p>a boy</p><SEG> sit on <p>a bench</p><SEG> next to <p>an old white car</p><SEG>每个<SEG>都有自己的 pixel mask。
所以 GCG 实际上要求语言生成过程中持续发生 grounding。而不是先生成整句话,再用另一个模型去 phrase grounding
13. 怎么理解它的“统一”
语言负责语义,分割负责空间,<SEG>token 负责桥接。
更具体一点:
Image semantic features ↓ LLM ↓ “what should be segmented?” ↓ <SEG> hidden state ↓ L-P projection ↓ segmentation prompt ↓ SAM visual features ↓ Pixel Decoder ↓ “where is it?”LLM 解决 WHAT,SAM-like decoder 解决 WHERE。
但是二者不是独立运行,而是通过<SEG>的 contextual representation 连接。
14. 和之前看的 LISA 有什么关系
如果之前已经理解了 LISA,那么 GLaMM 就很好理解。
LISA 的核心也是:
LLM → <SEG> → hidden embedding → SAM decoder → maskGLaMM 延续了这个核心范式,但做得更进一步:
LISA 更偏 reasoning segmentation / referring segmentation:
question → determine target → one segmentation mask而 GLaMM 把它扩展成:
自然语言生成 + 多个 phrase + 多个 masks + region input + multi-turn conversation所以从任务上看,LISA:language → mask
而 GLaMM 更强调:language generation ↔ pixel grounding
也就是在一整段自然语言生成过程中,可以不断插入 grounding。
15. 有一个值得注意的地方
虽然论文称之为“统一”,但是从 architecture 上看,其实不是:一个完全统一的视觉表示模型。
因为仍然有:
CLIP image encoder + SAM image encoder两套视觉 backbone。
所以更准确地说:GLaMM 统一的是 language generation 和 segmentation 的交互接口与训练目标,而不是彻底统一底层视觉表示。
也就是说它做的是:
language representation ↓ shared semantic interface ↓ pixel decoder而不是:
one universal representation simultaneously generates text and pixels这个区别对你后面看更现代的 pixel-grounded VLM 很重要。
16. 最后给一个最精炼的理解
如果只记住这篇论文的核心机制,建议记这条链:
Image ↓ CLIP → LLM → natural language ↓ <SEG> ↓ <SEG> hidden state ↓ L-P projection ↓ Image → SAM Encoder → Pixel Decoder ↓ mask所以所谓:language generation + pixel grounding
真正实现统一的关键就是:
让 LLM 在生成语言时产生一个特殊<SEG>token,并把该 token 的上下文化 hidden state 当成 segmentation prompt,送入 SAM-like pixel decoder,从而让“生成的语言语义”直接驱动“对应目标的像素级分割”。
而 GCG 则进一步把这种机制扩展到一段自然语言中的多个 phrase:
phrase₁ → <SEG>₁ → mask₁ phrase₂ → <SEG>₂ → mask₂ phrase₃ → <SEG>₃ → mask₃ ...因此,GLaMM 的真正贡献可以理解为:
不再让模型只回答“图里是什么”,而是让模型在回答“是什么”的同时,也回答“它在哪里”。
网络结构图解释
这张图基本就是把 GLaMM 的三层能力串起来了:
scene-level understanding → region-level understanding → pixel-level grounding
它最核心的主线还是:
图像/区域 → LLM 生成语言 → 语言中的特定语义再去驱动 mask 生成。
左侧输入:模型接收一张图像,同时也可额外接收用户指定的区域,比如图中的红框区域。整张图像会先送入Global Image Encoder,提取全局视觉语义;如果用户还指定了某个 region,这个区域会通过Region Encoder得到更细粒度的区域特征。
Global Image Encoder:看整张图是什么场景。
Region Encoder:重点看用户圈出来的这一块是什么。
这些图像特征和区域特征会形成Image-region prompts。但由于视觉和语言空间的特征维度、语义分布不同,这些特征不能直接送进 LLM,要经过V-L(Vision-to-Language)projection:visual features → LLM 能理解的 language-space embeddings
于是 LLM 接收到的输入就可以写成:
图像特征 / 区域特征 + 用户文本问题 → LLM例如图里的问题:
Can you give a detailed description of this image?
LLM 就可以生成:
A large, colorful hot air balloon is flying over the river.
The sky is overarching the river, trees, and buildings.
到这里为止,和普通 VLM 比较接近:图像 → 语言生成。
真正体现 GLaMM 特点的是右半部分:Grounding Image Encoder + Pixel Decoder。
同一张原始图像还会走另一条视觉分支:
Image → Grounding Image Encoder → dense image featuresGrounding Image Encoder 使用适合像素级定位的视觉编码器,负责保留更细致的空间信息,为后面生成 segmentation mask 做准备。
两套 encoder:
Global Image Encoder → 偏语义理解 → 给 LLM 用 Grounding Image Encoder → 偏空间 / 像素信息 → 给 Pixel Decoder 用接下来就是整张图最重要的连接:L-P(Language-to-Prompt)projection。
LLM 在生成语言时,如果某个 phrase 需要对应到图像区域,比如:
hot air balloon、river、sky、trees、buildings模型为需要 grounding 的内容产生相应的 segmentation-related token,本质上就是<SEG>。
LLM 中<SEG>对应的 hidden embedding,包含了当前语言上下文的语义,比如:
“我要找的是那个 hot air balloon”再通过L-P projection把语言 embedding 转成 Pixel Decoder 可接受的 prompt embedding。
所以右侧可以理解为:
LLM → <SEG> hidden state → L-P projection → Output prompt → Pixel Decoder而 Pixel Decoder 同时还接收:
Grounding Image Encoder 提取的图像特征于是最终它做的是:
“我要找什么” + “整张图每个位置长什么样” ↓ Pixel Decoder ↓ segmentation mask语言负责告诉 decoder:找谁。
Grounding Image Encoder 负责告诉 decoder:图像空间在哪里。
这两者共同决定最终的 mask。
把整条主流程压缩一下,就是:
┌→ Global Image Encoder Image ──────────────────┤ │ ↓ │ V-L projection │ ↓ Text question ───────────────→ LLM ↓ language response ↓ <SEG> ↓ L-P projection ↓ mask prompt ↓ Image → Grounding Image Encoder → Pixel Decoder ↓ mask这里V-L和L-P是两个非常关键、方向相反的桥梁:
V-L: Vision → Language 让 LLM 看懂图像 L-P: Language → Prompt 让 segmentation decoder 看懂语言意图可以把 GLaMM 的整个结构理解成一个闭环:Vision → Language → Pixel
这也正是它把 language generation 和 pixel grounding 统一起来的地方。
再看图下方的几个任务会更容易理解为什么设计成这样。
Image Level Captioning只需要:
Global Image Encoder → LLM → text不需要生成 mask。
Region Level Captioning则多了用户指定区域:
Image → Region Encoder → LLM → region description比如用户框住热气球,问:
Could you tell me more about this region?
模型回答:
A yellow, red and blue hot air balloon.
Referring Expression Segmentation则正好反过来:
“segment the balloon” ↓ LLM ↓ <SEG> ↓ L-P projection ↓ Pixel Decoder ↓ balloon mask这时候语言只是为了确定目标,最终主要输出 mask。
Phrase Grounding则是:
“A <hot air balloon> over the <river>”要分别把 hot air balloon、river 对应到图像中的区域,所以一段文本中可能产生多个 grounding。
而图中央橙色框里的Grounded Conversation Generation(GCG),其实就是把这些能力全部合在一起。生成一句自然语言:
A large, colorful hot air balloon is flying over the river. The sky is overarching the river, trees, and buildings.
同时其中多个 phrase:
hot air balloon、river、sky、trees、buildings都可以产生各自的 segmentation mask。
所以它不是:
生成一句话,然后另一个模型再去分析这句话,然后再分割而是更接近:
LLM 一边生成 ↓ 遇到需要 grounding 的 phrase ↓ 产生 <SEG> ↓ 立刻把对应 hidden state 送给 Pixel Decoder ↓ 生成对应 mask这就是图里所谓的interleaved language and masks。
如果你现在在读这篇论文,我建议你重点记住这四个模块之间的分工:
| 模块 | 主要作用 |
|---|---|
| Global Image Encoder | 提供整图高级语义 |
| Region Encoder | 提供用户指定区域的细粒度语义 |
| LLM | 理解问题、生成语言、确定要 grounding 的概念 |
| Grounding Image Encoder + Pixel Decoder | 把语言概念落实到具体像素 |
两个 projection 就是整个系统的桥:
V-L:图像语义进入语言模型。L-P:语言语义进入分割模型。
这张结构图最核心的一句话就是:
GLaMM 先让视觉信息进入 LLM 完成语义生成,再把 LLM 中与 grounding 相关的语义表示转成 segmentation prompt,由像素解码器输出 mask。
也就是:Image → Language → Pixel。