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

Method encode

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

Source from the content-addressed store, hash-verified

66
67 @torch.inference_mode()
68 def encode(self, query_list: List[str], batch_size=64, is_query=True) -> np.ndarray:
69 query_emb = []
70 for i in tqdm(range(0, len(query_list), batch_size), desc="Encoding process: "):
71 query_emb.append(self.single_batch_encode(query_list[i : i + batch_size], is_query))
72 query_emb = np.concatenate(query_emb, axis=0)
73 return query_emb
74
75 @torch.inference_mode()
76 def multi_gpu_encode(self, query_list: Union[List[str], str], batch_size=64, is_query=True) -> np.ndarray:

Callers 15

multi_gpu_encodeMethod · 0.95
encode_allMethod · 0.45
encode_all_clipMethod · 0.45
_searchMethod · 0.45
_batch_searchMethod · 0.45
_searchMethod · 0.45
_batch_searchMethod · 0.45
encodeMethod · 0.45
get_rerank_scoresMethod · 0.45
compress_promptMethod · 0.45
get_token_lengthMethod · 0.45
get_scoreMethod · 0.45

Calls 2

single_batch_encodeMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected