flashrag-dev 0.3.0.dev20260719__tar.gz → 0.3.0.dev20260809__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {flashrag_dev-0.3.0.dev20260719/flashrag_dev.egg-info → flashrag_dev-0.3.0.dev20260809}/PKG-INFO +1 -1
  2. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/retriever/index_builder.py +22 -7
  3. flashrag_dev-0.3.0.dev20260809/flashrag/version.py +1 -0
  4. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809/flashrag_dev.egg-info}/PKG-INFO +1 -1
  5. flashrag_dev-0.3.0.dev20260719/flashrag/version.py +0 -1
  6. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/LICENSE +0 -0
  7. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/README.md +0 -0
  8. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/__init__.py +0 -0
  9. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/config/__init__.py +0 -0
  10. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/config/basic_config.yaml +0 -0
  11. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/config/config.py +0 -0
  12. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/dataset/__init__.py +0 -0
  13. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/dataset/dataset.py +0 -0
  14. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/dataset/utils.py +0 -0
  15. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/evaluator/__init__.py +0 -0
  16. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/evaluator/_bleu.py +0 -0
  17. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/evaluator/evaluator.py +0 -0
  18. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/evaluator/metrics.py +0 -0
  19. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/evaluator/utils.py +0 -0
  20. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/generator/__init__.py +0 -0
  21. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/generator/fid.py +0 -0
  22. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/generator/generator.py +0 -0
  23. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/generator/multimodal_generator.py +0 -0
  24. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/generator/openai_generator.py +0 -0
  25. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/generator/stop_word_criteria.py +0 -0
  26. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/generator/utils.py +0 -0
  27. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/judger/__init__.py +0 -0
  28. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/judger/judger.py +0 -0
  29. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/ReaRAG_utils.py +0 -0
  30. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/__init__.py +0 -0
  31. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/active_pipeline.py +0 -0
  32. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/branching_pipeline.py +0 -0
  33. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/mm_pipeline.py +0 -0
  34. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/pipeline.py +0 -0
  35. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/reasoning_pipeline.py +0 -0
  36. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/pipeline/replug_utils.py +0 -0
  37. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/prompt/__init__.py +0 -0
  38. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/prompt/base_prompt.py +0 -0
  39. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/prompt/coRAG_prompt.py +0 -0
  40. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/prompt/mm_prompt.py +0 -0
  41. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/prompt/selfask_examplars.py +0 -0
  42. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/prompt/trace_examplars.py +0 -0
  43. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/refiner/__init__.py +0 -0
  44. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/refiner/kg_refiner.py +0 -0
  45. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/refiner/llmlingua_compressor.py +0 -0
  46. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/refiner/refiner.py +0 -0
  47. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/refiner/selective_context_compressor.py +0 -0
  48. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/retriever/__init__.py +0 -0
  49. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/retriever/__main__.py +0 -0
  50. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/retriever/encoder.py +0 -0
  51. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/retriever/reranker.py +0 -0
  52. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/retriever/retriever.py +0 -0
  53. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/retriever/utils.py +0 -0
  54. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/utils/__init__.py +0 -0
  55. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/utils/constants.py +0 -0
  56. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/utils/pred_parse.py +0 -0
  57. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag/utils/utils.py +0 -0
  58. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag_dev.egg-info/SOURCES.txt +0 -0
  59. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag_dev.egg-info/dependency_links.txt +0 -0
  60. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag_dev.egg-info/requires.txt +0 -0
  61. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/flashrag_dev.egg-info/top_level.txt +0 -0
  62. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/pyproject.toml +0 -0
  63. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/setup.cfg +0 -0
  64. {flashrag_dev-0.3.0.dev20260719 → flashrag_dev-0.3.0.dev20260809}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flashrag_dev
3
- Version: 0.3.0.dev20260719
3
+ Version: 0.3.0.dev20260809
4
4
  Summary: A library for efficient Retrieval-Augmented Generation research
5
5
  Home-page: https://github.com/RUC-NLPIR/FlashRAG
6
6
  Author: Jiajie Jin, Yutao Zhu, Chenghao Zhang, Xinyu Yang, Zhicheng Dou
@@ -481,15 +481,24 @@ class Index_Builder:
481
481
  else:
482
482
  memmap[:] = all_embeddings
483
483
 
484
- def encode_all(self):
484
+ def encode_all(self, hidden_size=None):
485
485
  encode_data = [item["contents"] for item in self.corpus]
486
486
  if self.gpu_num > 1:
487
487
  print("Use multi gpu!")
488
488
  self.batch_size = self.batch_size * self.gpu_num
489
- all_embeddings = self.encoder.multi_gpu_encode(encode_data, batch_size=self.batch_size, is_query=False)
490
- else:
491
- all_embeddings = self.encoder.encode(encode_data, batch_size=self.batch_size, is_query=False)
492
-
489
+ return self.encoder.multi_gpu_encode(encode_data, batch_size=self.batch_size, is_query=False)
490
+ if self.use_sentence_transformer:
491
+ return self.encoder.encode(encode_data, batch_size=self.batch_size, is_query=False)
492
+
493
+ # Stream each batch straight into the on-disk memmap instead of buffering the whole corpus in RAM.
494
+ corpus_size = len(encode_data)
495
+ all_embeddings = np.memmap(
496
+ self.embedding_save_path, shape=(corpus_size, hidden_size), mode="w+", dtype=np.float32
497
+ )
498
+ for i in tqdm(range(0, corpus_size, self.batch_size), desc="Encoding process: ", disable=self.encoder.silent):
499
+ batch_emb = self.encoder.single_batch_encode(encode_data[i : i + self.batch_size], is_query=False)
500
+ all_embeddings[i : i + batch_emb.shape[0]] = batch_emb
501
+ all_embeddings.flush()
493
502
  return all_embeddings
494
503
 
495
504
  def encode_all_clip(self):
@@ -549,12 +558,14 @@ class Index_Builder:
549
558
  )
550
559
  hidden_size = self.encoder.model.config.hidden_size
551
560
 
561
+ streamed_embedding_to_disk = False
552
562
  if self.embedding_path is not None:
553
563
  corpus_size = len(self.corpus)
554
564
  all_embeddings = self._load_embedding(self.embedding_path, corpus_size, hidden_size)
555
565
  else:
556
- all_embeddings = self.encode_all_clip() if self.is_clip else self.encode_all()
557
- if self.save_embedding:
566
+ streamed_embedding_to_disk = not self.is_clip and self.gpu_num <= 1 and not self.use_sentence_transformer
567
+ all_embeddings = self.encode_all_clip() if self.is_clip else self.encode_all(hidden_size)
568
+ if self.save_embedding and not streamed_embedding_to_disk:
558
569
  self._save_embedding(all_embeddings)
559
570
  del self.corpus
560
571
 
@@ -583,6 +594,10 @@ class Index_Builder:
583
594
  if os.path.exists(self.index_save_path):
584
595
  print("The index file already exists and will be overwritten.")
585
596
  self.save_faiss_index(all_embeddings, self.faiss_type, self.index_save_path)
597
+
598
+ if streamed_embedding_to_disk and not self.save_embedding:
599
+ del all_embeddings
600
+ os.remove(self.embedding_save_path)
586
601
  print("Finish!")
587
602
 
588
603
  def save_faiss_index(
@@ -0,0 +1 @@
1
+ __version__ = "0.3.0dev20260809"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flashrag_dev
3
- Version: 0.3.0.dev20260719
3
+ Version: 0.3.0.dev20260809
4
4
  Summary: A library for efficient Retrieval-Augmented Generation research
5
5
  Home-page: https://github.com/RUC-NLPIR/FlashRAG
6
6
  Author: Jiajie Jin, Yutao Zhu, Chenghao Zhang, Xinyu Yang, Zhicheng Dou
@@ -1 +0,0 @@
1
- __version__ = "0.3.0dev20260719"