Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ydshieh committed Dec 18, 2024
1 parent d1116f5 commit 6f09a51
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/transformers/models/kosmos2_5/modeling_kosmos2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,9 @@ def forward(
else:
# add zero embedding for padding tokens
bsz, seq_len, dim = positions.size()
zero_emb = self.segment_emb(torch.zeros((bsz, 1), dtype=torch.long, device=self.segment_emb.weight.device)).to(positions.device)
zero_emb = self.segment_emb(
torch.zeros((bsz, 1), dtype=torch.long, device=self.segment_emb.weight.device)
).to(positions.device)
positions += zero_emb

hidden_states = inputs_embeds + positions
Expand Down

0 comments on commit 6f09a51

Please sign in to comment.