MCPcopy Create free account
hub / github.com/RUC-NLPIR/SmartSearch / multi_gpu_encode

Method multi_gpu_encode

src/flashrag/retriever/encoder.py:128–142  ·  view source on GitHub ↗
(self, query_list: Union[List[str], str], batch_size=None, is_query=True)

Source from the content-addressed store, hash-verified

126
127 @torch.inference_mode()
128 def multi_gpu_encode(self, query_list: Union[List[str], str], batch_size=None, is_query=True) -> np.ndarray:
129 query_list = parse_query(self.model_name, query_list, self.instruction, is_query)
130 pool = self.model.start_multi_process_pool()
131 query_emb = self.model.encode_multi_process(
132 query_list,
133 pool,
134 convert_to_numpy=True,
135 normalize_embeddings=True,
136 batch_size=batch_size,
137 show_progress_bar=True,
138 )
139 self.model.stop_multi_process_pool(pool)
140 query_emb = query_emb.astype(np.float32, order="C")
141
142 return query_emb
143
144
145class ClipEncoder:

Callers

nothing calls this directly

Calls 1

parse_queryFunction · 0.90

Tested by

no test coverage detected