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

Method encode

tool/FlashRAG/flashrag/retriever/encoder.py:115–122  ·  view source on GitHub ↗
(self, query_list: Union[List[str], str], batch_size=64, is_query=True)

Source from the content-addressed store, hash-verified

113
114 @torch.inference_mode()
115 def encode(self, query_list: Union[List[str], str], batch_size=64, is_query=True) -> np.ndarray:
116 query_list = parse_query(self.model_name, query_list, self.instruction, is_query)
117 query_emb = self.model.encode(
118 query_list, batch_size=batch_size, convert_to_numpy=True, normalize_embeddings=True, show_progress_bar=True
119 )
120 query_emb = query_emb.astype(np.float32, order="C")
121
122 return query_emb
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:

Callers

nothing calls this directly

Calls 2

parse_queryFunction · 0.90
encodeMethod · 0.45

Tested by

no test coverage detected