We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fcc0be8 commit 55917afCopy full SHA for 55917af
src/MMLLM/庖丁解牛BLIP2.md
@@ -552,11 +552,14 @@ class BertEncoder(nn.Module):
552
...
553
##================= Image Captioning ========================##
554
decoder_input_ids = text_tokens.input_ids.clone()
555
+ # 将第一个 token 替换为 BOS(Begin Of Sentence)标记,表示“开始生成句子”
556
decoder_input_ids[:, 0] = self.tokenizer.bos_token_id
557
+ # 将 padding token 替换为 -100,这是 CrossEntropyLoss 默认忽略的标签值
558
labels = decoder_input_ids.masked_fill(
559
decoder_input_ids == self.tokenizer.pad_token_id, -100
560
)
-
561
+
562
563
query_atts = torch.ones(query_tokens.size()[:-1], dtype=torch.long).to(
564
image.device
565
0 commit comments