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

Method __init__

src/models/vec_model/vec_model.py:11–21  ·  view source on GitHub ↗
(self, ptm_model_path, device = "cpu")

Source from the content-addressed store, hash-verified

9
10class VectorizeModel:
11 def __init__(self, ptm_model_path, device = "cpu") -> None:
12 self.tokenizer = BertTokenizer.from_pretrained(ptm_model_path)
13 self.model = SimcseModel(pretrained_bert_path=ptm_model_path, pooling="cls")
14 self.model.eval()
15
16 # self.DEVICE = torch.device('cuda' if torch.cuda.is_available() else "cpu")
17 self.DEVICE = device
18 logger.info(device)
19 self.model.to(self.DEVICE)
20
21 self.pdist = nn.PairwiseDistance(2)
22
23 def predict_vec(self,query):
24 q_id = self.tokenizer(query, max_length = 200, truncation=True, padding="max_length", return_tensors='pt')

Callers

nothing calls this directly

Calls 1

SimcseModelClass · 0.90

Tested by

no test coverage detected