(self, length)
| 56 | self.final_layer_norm = torch.nn.LayerNorm(embed_dim) |
| 57 | |
| 58 | def attention_mask(self, length): |
| 59 | mask = torch.empty(length, length) |
| 60 | mask.fill_(float("-inf")) |
| 61 | mask.triu_(1) |
| 62 | return mask |
| 63 | |
| 64 | def forward(self, input_ids, clip_skip=1): |
| 65 | embeds = self.token_embedding(input_ids) + self.position_embeds |