(self, pretrained_bert_path, pooling="cls")
| 7 | class SimcseModel(nn.Module): |
| 8 | # https://blog.csdn.net/qq_44193969/article/details/126981581 |
| 9 | def __init__(self, pretrained_bert_path, pooling="cls") -> None: |
| 10 | super(SimcseModel, self).__init__() |
| 11 | |
| 12 | self.pretrained_bert_path = pretrained_bert_path |
| 13 | self.config = BertConfig.from_pretrained(self.pretrained_bert_path) |
| 14 | |
| 15 | self.model = BertModel.from_pretrained(self.pretrained_bert_path, config=self.config) |
| 16 | self.model.eval() |
| 17 | |
| 18 | # self.model = None |
| 19 | self.pooling = pooling |
| 20 | |
| 21 | def forward(self, input_ids, attention_mask, token_type_ids): |
| 22 | out = self.model(input_ids, attention_mask=attention_mask, token_type_ids=token_type_ids) |
nothing calls this directly
no outgoing calls
no test coverage detected