MCPcopy Create free account
hub / github.com/BeastyZ/ConvSearch-R1 / encode

Method encode

src/retrieval/server.py:144–155  ·  view source on GitHub ↗
(self, query_list: List[str])

Source from the content-addressed store, hash-verified

142
143 @torch.no_grad()
144 def encode(self, query_list: List[str]):
145 inputs = self.tokenizer(
146 query_list,
147 max_length=self.max_length,
148 padding=True,
149 truncation=True,
150 return_tensors="pt",
151 add_special_tokens=True
152 ).to('cuda')
153 query_embs = self.model(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
154 query_embs = query_embs.detach().cpu().numpy()
155 return query_embs
156
157
158class BaseRetriever:

Callers 2

__init__Method · 0.45
_batch_searchMethod · 0.45

Calls 1

toMethod · 0.80

Tested by

no test coverage detected