MCPcopy Create free account
hub / github.com/Yuan-Li-FNLP/R3-RAG / multi_gpu_encode

Method multi_gpu_encode

tool/FlashRAG/flashrag/retriever/encoder.py:125–139  ·  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

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

Callers

nothing calls this directly

Calls 1

parse_queryFunction · 0.90

Tested by

no test coverage detected