Skip to content

Commit cc90770

Browse files
committed
updates
1 parent 5a8b154 commit cc90770

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/MMLLM/庖丁解牛BLIP2.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,21 @@ class BertLMHeadModel(BertPreTrainedModel):
659659
cross_attentions=outputs.cross_attentions,
660660
)
661661
```
662+
> BertModel 的 forward 方法中,当is_decoder=True时,会在get_extended_attention_mask方法中,构建一个下三角矩阵作为因果掩码矩阵。
663+
664+
### Stage 2: Generative Learning(生成学习)
665+
666+
Stage 2 是为了把 Q-Former 和冻结参数的 LLM 连接起来,以利用 LLM 的文本生成能力。
667+
668+
支持两种LLM(decoder only、encoder-decoder based):
669+
670+
![Generative Learning](庖丁解牛BLIP2/11.png)
671+
672+
1. 首先输入图片,直接输入冻结参数的 Image Encoder,得到图像的表征。
673+
674+
2. 然后图像的表征和 Queries 一起送入 Q-Former,得到 Queries 的输出 $Z$ ,使用全连接 (FC) 层将 $Z$ 线性投影到与 LLM 的text embedding相同维度。
675+
676+
3. 后将投影后的 $Z$ 添加到 input text embeddings前面,Queries 的输出蕴含了视觉信息,送入LLM时,充当了soft visual prompts 。
677+
678+
4. 由于 Q-Former 已经过预训练以提取语言信息视觉表示,因此它有效地充当信息瓶颈,将最有用的信息提供给 LLM,同时删除不相关的视觉信息。这减少了LLM学习视觉语言对齐的负担,从而缓解了灾难性的遗忘问题。
679+

src/MMLLM/庖丁解牛BLIP2/11.png

185 KB
Loading

0 commit comments

Comments
 (0)