MCPcopy Create free account
hub / github.com/ZBayes/basic_rag / __init__

Method __init__

src/models/vec_model/simcse_model.py:9–19  ·  view source on GitHub ↗
(self, pretrained_bert_path, pooling="cls")

Source from the content-addressed store, hash-verified

7class 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)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected