MCPcopy Create free account
hub / github.com/Atrovast/THGS / set_positives

Method set_positives

scripts/image_encoding.py:88–93  ·  view source on GitHub ↗
(self, text_list)

Source from the content-addressed store, hash-verified

86 self.set_positives(element.value.split(";"))
87
88 def set_positives(self, text_list):
89 self.positives = text_list
90 with torch.no_grad():
91 tok_phrases = torch.cat([self.tokenizer(phrase) for phrase in self.positives]).to("cuda")
92 self.pos_embeds = self.model.encode_text(tok_phrases)
93 self.pos_embeds /= self.pos_embeds.norm(dim=-1, keepdim=True)
94
95 def get_relevancy(self, embed: torch.Tensor, positive_id: int) -> torch.Tensor:
96 phrases_embeds = torch.cat([self.pos_embeds, self.neg_embeds], dim=0)

Callers 1

gui_cbMethod · 0.95

Calls 2

toMethod · 0.45
encode_textMethod · 0.45

Tested by

no test coverage detected