MCPcopy Index your code
hub / github.com/ZBayes/basic_rag / predict_vec

Method predict_vec

src/models/vec_model/vec_model.py:23–31  ·  view source on GitHub ↗
(self,query)

Source from the content-addressed store, hash-verified

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')
25 with torch.no_grad():
26 q_id_input_ids = q_id["input_ids"].squeeze(1).to(self.DEVICE)
27 q_id_attention_mask = q_id["attention_mask"].squeeze(1).to(self.DEVICE)
28 q_id_token_type_ids = q_id["token_type_ids"].squeeze(1).to(self.DEVICE)
29 q_id_pred = self.model(q_id_input_ids, q_id_attention_mask, q_id_token_type_ids)
30
31 return q_id_pred
32
33 def predict_vec_request(self, query):
34 q_id_pred = self.predict_vec(query)

Callers 5

predict_vec_requestMethod · 0.95
predict_simMethod · 0.95
build_vec_index.pyFile · 0.80
vec_model.pyFile · 0.80
searchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected