flashrag-dev 0.1.4.dev20250720__tar.gz → 0.1.4.dev20250806__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 (66) hide show
  1. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/PKG-INFO +25 -10
  2. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/README.md +24 -9
  3. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/generator/generator.py +3 -2
  4. flashrag_dev-0.1.4.dev20250806/flashrag/pipeline/ReaRAG_utils.py +150 -0
  5. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/pipeline/__init__.py +2 -1
  6. flashrag_dev-0.1.4.dev20250806/flashrag/pipeline/reasoning_pipeline.py +824 -0
  7. flashrag_dev-0.1.4.dev20250806/flashrag/prompt/__init__.py +3 -0
  8. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/prompt/base_prompt.py +1 -1
  9. flashrag_dev-0.1.4.dev20250806/flashrag/prompt/coRAG_prompt.py +87 -0
  10. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/retriever/encoder.py +2 -1
  11. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/retriever/retriever.py +4 -2
  12. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/retriever/utils.py +2 -1
  13. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/utils/utils.py +4 -1
  14. flashrag_dev-0.1.4.dev20250806/flashrag/version.py +1 -0
  15. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag_dev.egg-info/PKG-INFO +25 -10
  16. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag_dev.egg-info/SOURCES.txt +2 -0
  17. flashrag_dev-0.1.4.dev20250720/flashrag/pipeline/reasoning_pipeline.py +0 -154
  18. flashrag_dev-0.1.4.dev20250720/flashrag/prompt/__init__.py +0 -2
  19. flashrag_dev-0.1.4.dev20250720/flashrag/version.py +0 -1
  20. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/LICENSE +0 -0
  21. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/__init__.py +0 -0
  22. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/config/__init__.py +0 -0
  23. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/config/basic_config.yaml +0 -0
  24. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/config/config.py +0 -0
  25. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/dataset/__init__.py +0 -0
  26. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/dataset/dataset.py +0 -0
  27. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/dataset/utils.py +0 -0
  28. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/evaluator/__init__.py +0 -0
  29. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/evaluator/_bleu.py +0 -0
  30. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/evaluator/evaluator.py +0 -0
  31. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/evaluator/metrics.py +0 -0
  32. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/evaluator/utils.py +0 -0
  33. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/generator/__init__.py +0 -0
  34. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/generator/fid.py +0 -0
  35. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/generator/multimodal_generator.py +0 -0
  36. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/generator/openai_generator.py +0 -0
  37. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/generator/stop_word_criteria.py +0 -0
  38. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/generator/utils.py +0 -0
  39. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/judger/__init__.py +0 -0
  40. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/judger/judger.py +0 -0
  41. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/pipeline/active_pipeline.py +0 -0
  42. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/pipeline/branching_pipeline.py +0 -0
  43. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/pipeline/mm_pipeline.py +0 -0
  44. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/pipeline/pipeline.py +0 -0
  45. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/pipeline/replug_utils.py +0 -0
  46. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/prompt/mm_prompt.py +0 -0
  47. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/prompt/selfask_examplars.py +0 -0
  48. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/prompt/trace_examplars.py +0 -0
  49. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/refiner/__init__.py +0 -0
  50. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/refiner/kg_refiner.py +0 -0
  51. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/refiner/llmlingua_compressor.py +0 -0
  52. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/refiner/refiner.py +0 -0
  53. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/refiner/selective_context_compressor.py +0 -0
  54. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/retriever/__init__.py +0 -0
  55. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/retriever/__main__.py +0 -0
  56. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/retriever/index_builder.py +0 -0
  57. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/retriever/reranker.py +0 -0
  58. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/utils/__init__.py +0 -0
  59. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/utils/constants.py +0 -0
  60. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag/utils/pred_parse.py +0 -0
  61. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag_dev.egg-info/dependency_links.txt +0 -0
  62. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag_dev.egg-info/requires.txt +0 -0
  63. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/flashrag_dev.egg-info/top_level.txt +0 -0
  64. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/pyproject.toml +0 -0
  65. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/setup.cfg +0 -0
  66. {flashrag_dev-0.1.4.dev20250720 → flashrag_dev-0.1.4.dev20250806}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag_dev
3
- Version: 0.1.4.dev20250720
3
+ Version: 0.1.4.dev20250806
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
@@ -42,7 +42,7 @@ License-File: LICENSE
42
42
  </h4>
43
43
 
44
44
 
45
- FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 36 pre-processed benchmark RAG datasets and 17 state-of-the-art RAG algorithms.
45
+ FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 36 pre-processed benchmark RAG datasets and **23 state-of-the-art RAG algorithms**, including **7 reasoning-based methods** that combine reasoning ability with retrieval.
46
46
 
47
47
  <p align="center">
48
48
  <img src="asset/framework.jpg">
@@ -76,7 +76,9 @@ https://github.com/user-attachments/assets/8ca00873-5df2-48a7-b853-89e7b18bc6e9
76
76
 
77
77
  - **Comprehensive Benchmark Datasets**: A collection of 36 pre-processed RAG benchmark datasets to test and validate RAG models' performances.
78
78
 
79
- - **Pre-implemented Advanced RAG Algorithms**: Features 17 advancing RAG algorithms with reported results, based on our framework. Easily reproducing results under different settings.
79
+ - **Pre-implemented Advanced RAG Algorithms**: Features **23 advancing RAG algorithms** with reported results, based on our framework. Easily reproducing results under different settings.
80
+
81
+ - **🚀 Reasoning-based Methods**: **NEW!** We now support **7 reasoning-based methods** that combine reasoning ability with retrieval, achieving superior performance on complex multi-hop tasks.
80
82
 
81
83
  - **Efficient Preprocessing Stage**: Simplifies the RAG workflow preparation by providing various scripts like corpus processing for retrieval, retrieval index building, and pre-retrieval of documents.
82
84
 
@@ -92,13 +94,15 @@ FlashRAG is still under development and there are many issues and room for impro
92
94
  - [x] Provdide instructions for each component
93
95
  - [x] Integrate sentence Transformers
94
96
  - [x] Support multimodal RAG
97
+ - [x] Support reasoning-based methods
95
98
  - [ ] Inlcude more RAG approaches
96
- - [ ] Add more evaluation metrics (e.g., Unieval, name-entity F1) and benchmarks (e.g., RGB benchmark)
97
99
  - [ ] Enhance code adaptability and readability
98
100
  - [ ] Add support for api-based retriever (vllm server)
99
101
 
100
102
  ## :page_with_curl: Changelog
101
- [25/03/21] We have added support for **Reasoning Pipeline**, which is a new paradigm that combines reasoning ability and retrieval, representing work that includes [Search-o1](https://github.com/sunnynexus/Search-o1), [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), [ReSearch](https://github.com/Agent-RL/ReSearch). We evaluate the performance of the pipeline on various RAG benchmarks, it can achieve F1 scores close to 60 on multi hop inference datasets such as Hotpotqe. See it in [**result table**](#robot-supporting-methods).
103
+ [25/08/06] 🎯 **NEW!** We have added support for **Reasoning Pipeline**, which is a new paradigm that combines reasoning ability and retrieval, representing work that includes [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), [Search-R1](https://github.com/PeterGriffinJin/Search-R1),.... We evaluate the performance of the pipeline on various RAG benchmarks, it can achieve F1 scores close to 60 on multi hop inference datasets such as HotpotQA. See it in [**result table**](#robot-supporting-methods).
104
+
105
+ [25/03/21] 🚀 **Major Update!** We have expanded our toolkit to support **23 state-of-the-art RAG algorithms**, including **7 reasoning-based methods** that significantly improve performance on complex reasoning tasks. This represents a major milestone in our toolkit's evolution!
102
106
 
103
107
  [25/02/24] 🔥🔥🔥 We have added support for **multimodal RAG**, including [**MLLMs like Llava, Qwen, InternVL**](https://ruc-nlpir.github.io/FlashRAG/#/zh-cn/component/generator?id=%e5%a4%9a%e6%a8%a1%e6%80%81%e7%94%9f%e6%88%90%e5%99%a8), and various [**multimodal retrievers with Clip architecture**](https://ruc-nlpir.github.io/FlashRAG/#/zh-cn/component/retriever?id=%e5%a4%9a%e6%a8%a1%e6%80%81%e6%a3%80%e7%b4%a2%e5%99%a8). More information can be found in our new version of arxiv article and our documentation. Try it!
104
108
 
@@ -587,7 +591,7 @@ python interface.py
587
591
 
588
592
  ## :robot: Supporting Methods
589
593
 
590
- We have implemented 15 works with a consistent setting of:
594
+ We have implemented **23 works** with a consistent setting of:
591
595
 
592
596
  - **Generator:** LLAMA3-8B-instruct with input length of 2048
593
597
  - **Retriever:** e5-base-v2 as embedding model, retrieve 5 docs per query
@@ -597,7 +601,7 @@ For open-source methods, we implemented their processes using our framework. For
597
601
 
598
602
  For necessary settings and hyperparameters specific to some methods, we have documented them in the **specific settings** column. For more details, please consult our [<u>reproduce guidance</u>](./docs/original_docs/reproduce_experiment.md) and [<u>method details</u>](./docs/original_docs/baseline_details.md).
599
603
 
600
- Its important to note that, to ensure consistency, we have utilized a uniform setting. However, this setting may differ from the original setting of the method, leading to variations in results compared to the original outcomes.
604
+ It's important to note that, to ensure consistency, we have utilized a uniform setting. However, this setting may differ from the original setting of the method, leading to variations in results compared to the original outcomes.
601
605
 
602
606
  | Method | Type | NQ (EM) | TriviaQA (EM) | Hotpotqa (F1) | 2Wiki (F1) | PopQA (F1) | WebQA(EM) | Specific setting |
603
607
  | ----------------------------------------------------------------------------------------- | ----------- | ------- | ------------- | ------------- | ---------- | ---------- | --------- | ----------------------------------------------- |
@@ -618,10 +622,21 @@ It’s important to note that, to ensure consistency, we have utilized a uniform
618
622
  | [FLARE](https://arxiv.org/abs/2305.06983) | Loop | 22.5 | 55.8 | 28.0 | 33.9 | 20.7 | 20.2 | |
619
623
  | [Iter-Retgen](https://arxiv.org/abs/2305.15294), [ITRG](https://arxiv.org/abs/2310.05149) | Loop | 36.8 | 60.1 | 38.3 | 21.6 | 37.9 | 18.2 | |
620
624
  | [IRCoT](https://aclanthology.org/2023.acl-long.557.pdf) | Loop | 33.3 | 56.9 | 41.5 | 32.4 | 45.6 | 20.7 | |
621
- | [RQRAG](https://arxiv.org/abs/2404.00610) | Loop | 32.6 | 52.5 | 33.5 | 35.8 | 46.4 | 26.2 | Use trained rqrag-llama2-7B |
622
- | [R1-Searcher](https://arxiv.org/pdf/2503.05592) | Reasoning | 37.3 | 58.7 | 59.5 | 55.5 | 43.9 | 27.5 | Using trained Qwen2.5-7B model |
623
-
625
+ | [RQRAG](https://arxiv.org/abs/2404.00610) | Loop | 32.6 | 52.5 | 33.5 | 35.8 | 46.4 | 26.2 | Use trained rqrag-llama2-7B |
626
+
627
+ #### 🚀 Reasoning-based Methods (NEW!)
628
+
629
+ We now support **7 reasoning-based methods** that combine reasoning ability with retrieval, achieving superior performance on complex multi-hop tasks:
624
630
 
631
+ | Method | Type | NQ (EM) | TriviaQA (EM) | PopQA (EM) | Hotpotqa (F1) | 2Wiki (F1) | Musique (F1) | Bamboogle (F1) | Specific setting |
632
+ | ----------------------------------------------------------------------------------------- | ----------- | ------- | ------- | ------------- | ------------- | ---------- | ---------- | --------- | ----------------------------------------------- |
633
+ | [Search-R1](https://arxiv.org/abs/2503.09516) | Reasoning | 45.2 | 62.2 | 49.2 | 54.5 | 42.6 | 29.2 | 59.9 | SearchR1-nq_hotpotqa_train-qwen2.5-7b-em-ppo |
634
+ | [R1-Searcher](https://arxiv.org/pdf/2503.05592) | Reasoning | 36.9 | 61.6 | 42.0 | 49.0 | 49.1 | 24.7 | 57.7 | Qwen-2.5-7B-base-RAG-RL |
635
+ | [O2-Searcher](https://arxiv.org/pdf/2505.16582) | Reasoning | 41.4 | 51.4 | 46.8 | 43.4 | 48.6 | 19.0 | 47.6 | O2-Searcher-Qwen2.5-3B-GRPO |
636
+ | [AutoRefine](https://www.arxiv.org/pdf/2505.11277) | Reasoning | 43.8 | 59.8 | 32.4 | 54.0 | 50.3 | 23.6 | 46.6 | AutoRefine-Qwen2.5-3B-Base |
637
+ | [ReaRAG](https://arxiv.org/abs/2503.21729) | Reasoning | 26.3 | 51.8 | 24.6 | 42.9 | 41.6 | 21.2 | 41.9 | ReaRAG-9B |
638
+ | [CoRAG](https://arxiv.org/abs/2503.21729) | Reasoning | 40.9 | 63.1 | 36.0 | 56.6 | 60.7 | 31.9 | 54.1 | CoRAG-Llama3.1-8B-MultihopQA |
639
+ | [SimpleDeepSearcher](https://arxiv.org/pdf/2505.16834) | Reasoning | 36.1 | 61.6 | 42.0 | 49.0 | 49.1 | 24.7 | 57.7 | Qwen-7B-SimpleDeepSearcher |
625
640
 
626
641
  ## :notebook: Supporting Datasets & Document Corpus
627
642
 
@@ -25,7 +25,7 @@
25
25
  </h4>
26
26
 
27
27
 
28
- FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 36 pre-processed benchmark RAG datasets and 17 state-of-the-art RAG algorithms.
28
+ FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 36 pre-processed benchmark RAG datasets and **23 state-of-the-art RAG algorithms**, including **7 reasoning-based methods** that combine reasoning ability with retrieval.
29
29
 
30
30
  <p align="center">
31
31
  <img src="asset/framework.jpg">
@@ -59,7 +59,9 @@ https://github.com/user-attachments/assets/8ca00873-5df2-48a7-b853-89e7b18bc6e9
59
59
 
60
60
  - **Comprehensive Benchmark Datasets**: A collection of 36 pre-processed RAG benchmark datasets to test and validate RAG models' performances.
61
61
 
62
- - **Pre-implemented Advanced RAG Algorithms**: Features 17 advancing RAG algorithms with reported results, based on our framework. Easily reproducing results under different settings.
62
+ - **Pre-implemented Advanced RAG Algorithms**: Features **23 advancing RAG algorithms** with reported results, based on our framework. Easily reproducing results under different settings.
63
+
64
+ - **🚀 Reasoning-based Methods**: **NEW!** We now support **7 reasoning-based methods** that combine reasoning ability with retrieval, achieving superior performance on complex multi-hop tasks.
63
65
 
64
66
  - **Efficient Preprocessing Stage**: Simplifies the RAG workflow preparation by providing various scripts like corpus processing for retrieval, retrieval index building, and pre-retrieval of documents.
65
67
 
@@ -75,13 +77,15 @@ FlashRAG is still under development and there are many issues and room for impro
75
77
  - [x] Provdide instructions for each component
76
78
  - [x] Integrate sentence Transformers
77
79
  - [x] Support multimodal RAG
80
+ - [x] Support reasoning-based methods
78
81
  - [ ] Inlcude more RAG approaches
79
- - [ ] Add more evaluation metrics (e.g., Unieval, name-entity F1) and benchmarks (e.g., RGB benchmark)
80
82
  - [ ] Enhance code adaptability and readability
81
83
  - [ ] Add support for api-based retriever (vllm server)
82
84
 
83
85
  ## :page_with_curl: Changelog
84
- [25/03/21] We have added support for **Reasoning Pipeline**, which is a new paradigm that combines reasoning ability and retrieval, representing work that includes [Search-o1](https://github.com/sunnynexus/Search-o1), [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), [ReSearch](https://github.com/Agent-RL/ReSearch). We evaluate the performance of the pipeline on various RAG benchmarks, it can achieve F1 scores close to 60 on multi hop inference datasets such as Hotpotqe. See it in [**result table**](#robot-supporting-methods).
86
+ [25/08/06] 🎯 **NEW!** We have added support for **Reasoning Pipeline**, which is a new paradigm that combines reasoning ability and retrieval, representing work that includes [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), [Search-R1](https://github.com/PeterGriffinJin/Search-R1),.... We evaluate the performance of the pipeline on various RAG benchmarks, it can achieve F1 scores close to 60 on multi hop inference datasets such as HotpotQA. See it in [**result table**](#robot-supporting-methods).
87
+
88
+ [25/03/21] 🚀 **Major Update!** We have expanded our toolkit to support **23 state-of-the-art RAG algorithms**, including **7 reasoning-based methods** that significantly improve performance on complex reasoning tasks. This represents a major milestone in our toolkit's evolution!
85
89
 
86
90
  [25/02/24] 🔥🔥🔥 We have added support for **multimodal RAG**, including [**MLLMs like Llava, Qwen, InternVL**](https://ruc-nlpir.github.io/FlashRAG/#/zh-cn/component/generator?id=%e5%a4%9a%e6%a8%a1%e6%80%81%e7%94%9f%e6%88%90%e5%99%a8), and various [**multimodal retrievers with Clip architecture**](https://ruc-nlpir.github.io/FlashRAG/#/zh-cn/component/retriever?id=%e5%a4%9a%e6%a8%a1%e6%80%81%e6%a3%80%e7%b4%a2%e5%99%a8). More information can be found in our new version of arxiv article and our documentation. Try it!
87
91
 
@@ -570,7 +574,7 @@ python interface.py
570
574
 
571
575
  ## :robot: Supporting Methods
572
576
 
573
- We have implemented 15 works with a consistent setting of:
577
+ We have implemented **23 works** with a consistent setting of:
574
578
 
575
579
  - **Generator:** LLAMA3-8B-instruct with input length of 2048
576
580
  - **Retriever:** e5-base-v2 as embedding model, retrieve 5 docs per query
@@ -580,7 +584,7 @@ For open-source methods, we implemented their processes using our framework. For
580
584
 
581
585
  For necessary settings and hyperparameters specific to some methods, we have documented them in the **specific settings** column. For more details, please consult our [<u>reproduce guidance</u>](./docs/original_docs/reproduce_experiment.md) and [<u>method details</u>](./docs/original_docs/baseline_details.md).
582
586
 
583
- Its important to note that, to ensure consistency, we have utilized a uniform setting. However, this setting may differ from the original setting of the method, leading to variations in results compared to the original outcomes.
587
+ It's important to note that, to ensure consistency, we have utilized a uniform setting. However, this setting may differ from the original setting of the method, leading to variations in results compared to the original outcomes.
584
588
 
585
589
  | Method | Type | NQ (EM) | TriviaQA (EM) | Hotpotqa (F1) | 2Wiki (F1) | PopQA (F1) | WebQA(EM) | Specific setting |
586
590
  | ----------------------------------------------------------------------------------------- | ----------- | ------- | ------------- | ------------- | ---------- | ---------- | --------- | ----------------------------------------------- |
@@ -601,10 +605,21 @@ It’s important to note that, to ensure consistency, we have utilized a uniform
601
605
  | [FLARE](https://arxiv.org/abs/2305.06983) | Loop | 22.5 | 55.8 | 28.0 | 33.9 | 20.7 | 20.2 | |
602
606
  | [Iter-Retgen](https://arxiv.org/abs/2305.15294), [ITRG](https://arxiv.org/abs/2310.05149) | Loop | 36.8 | 60.1 | 38.3 | 21.6 | 37.9 | 18.2 | |
603
607
  | [IRCoT](https://aclanthology.org/2023.acl-long.557.pdf) | Loop | 33.3 | 56.9 | 41.5 | 32.4 | 45.6 | 20.7 | |
604
- | [RQRAG](https://arxiv.org/abs/2404.00610) | Loop | 32.6 | 52.5 | 33.5 | 35.8 | 46.4 | 26.2 | Use trained rqrag-llama2-7B |
605
- | [R1-Searcher](https://arxiv.org/pdf/2503.05592) | Reasoning | 37.3 | 58.7 | 59.5 | 55.5 | 43.9 | 27.5 | Using trained Qwen2.5-7B model |
606
-
608
+ | [RQRAG](https://arxiv.org/abs/2404.00610) | Loop | 32.6 | 52.5 | 33.5 | 35.8 | 46.4 | 26.2 | Use trained rqrag-llama2-7B |
609
+
610
+ #### 🚀 Reasoning-based Methods (NEW!)
611
+
612
+ We now support **7 reasoning-based methods** that combine reasoning ability with retrieval, achieving superior performance on complex multi-hop tasks:
607
613
 
614
+ | Method | Type | NQ (EM) | TriviaQA (EM) | PopQA (EM) | Hotpotqa (F1) | 2Wiki (F1) | Musique (F1) | Bamboogle (F1) | Specific setting |
615
+ | ----------------------------------------------------------------------------------------- | ----------- | ------- | ------- | ------------- | ------------- | ---------- | ---------- | --------- | ----------------------------------------------- |
616
+ | [Search-R1](https://arxiv.org/abs/2503.09516) | Reasoning | 45.2 | 62.2 | 49.2 | 54.5 | 42.6 | 29.2 | 59.9 | SearchR1-nq_hotpotqa_train-qwen2.5-7b-em-ppo |
617
+ | [R1-Searcher](https://arxiv.org/pdf/2503.05592) | Reasoning | 36.9 | 61.6 | 42.0 | 49.0 | 49.1 | 24.7 | 57.7 | Qwen-2.5-7B-base-RAG-RL |
618
+ | [O2-Searcher](https://arxiv.org/pdf/2505.16582) | Reasoning | 41.4 | 51.4 | 46.8 | 43.4 | 48.6 | 19.0 | 47.6 | O2-Searcher-Qwen2.5-3B-GRPO |
619
+ | [AutoRefine](https://www.arxiv.org/pdf/2505.11277) | Reasoning | 43.8 | 59.8 | 32.4 | 54.0 | 50.3 | 23.6 | 46.6 | AutoRefine-Qwen2.5-3B-Base |
620
+ | [ReaRAG](https://arxiv.org/abs/2503.21729) | Reasoning | 26.3 | 51.8 | 24.6 | 42.9 | 41.6 | 21.2 | 41.9 | ReaRAG-9B |
621
+ | [CoRAG](https://arxiv.org/abs/2503.21729) | Reasoning | 40.9 | 63.1 | 36.0 | 56.6 | 60.7 | 31.9 | 54.1 | CoRAG-Llama3.1-8B-MultihopQA |
622
+ | [SimpleDeepSearcher](https://arxiv.org/pdf/2505.16834) | Reasoning | 36.1 | 61.6 | 42.0 | 49.0 | 49.1 | 24.7 | 57.7 | Qwen-7B-SimpleDeepSearcher |
608
623
 
609
624
  ## :notebook: Supporting Datasets & Document Corpus
610
625
 
@@ -12,6 +12,7 @@ from transformers import (
12
12
  AutoConfig,
13
13
  )
14
14
  from flashrag.generator.utils import resolve_max_tokens
15
+ from flashrag.utils import get_device
15
16
 
16
17
 
17
18
  class BaseGenerator:
@@ -553,13 +554,13 @@ class FastChatGenerator(HFCausalLMGenerator):
553
554
  max_gpu_memory = None
554
555
  import torch
555
556
  self.gpu_num = torch.cuda.device_count()
556
- if self.gpu_num != 1:
557
+ if self.gpu_num > 1:
557
558
  available_gpu_memory = get_gpu_memory()
558
559
  max_gpu_memory = str(int(min(available_gpu_memory) * gpu_memory_utilization)) + "GiB"
559
560
 
560
561
  model, tokenizer = load_model(
561
562
  self.model_path,
562
- device="cuda",
563
+ device=get_device(),
563
564
  num_gpus=self.gpu_num,
564
565
  max_gpu_memory=max_gpu_memory,
565
566
  load_8bit=False,
@@ -0,0 +1,150 @@
1
+ import re
2
+ from termcolor import colored
3
+
4
+ class AgentUtilsBase():
5
+ def __init__(self):
6
+ pass
7
+
8
+ def truncate(self, tokenizer, tokenized_prompt, model_max_length):
9
+ half = int(model_max_length/2)
10
+ prompt = tokenizer.decode(tokenized_prompt[:half], skip_special_tokens=False) + \
11
+ tokenizer.decode(tokenized_prompt[-half:], skip_special_tokens=False)
12
+
13
+ return prompt
14
+
15
+ def preprocess_query(self, query):
16
+ if "'" in query and '"' in query:
17
+ query = query.replace("'", "\\'").replace('"', '\\"')
18
+ return query
19
+
20
+ def extract_code(self, text: str) -> str:
21
+ triple_match = re.search(r'```[^\n]*\n(.+?)```', text, re.DOTALL)
22
+ single_match = re.search(r'`([^`]*)`', text, re.DOTALL)
23
+ if triple_match:
24
+ return triple_match.group(1)
25
+ elif single_match:
26
+ return single_match.group(1)
27
+ return text
28
+
29
+ def postprocess_agent_response(self, response):
30
+ """
31
+ Implement the postprocess_agent_response function
32
+ """
33
+ raise NotImplementedError("postprocess_agent_response function must be implemented in a subclass")
34
+
35
+ class AgentUtils(AgentUtilsBase):
36
+ def __init__(self):
37
+ super().__init__()
38
+
39
+ def parse_reasoning_steps(self, text: str):
40
+ """
41
+ Parse a string containing Thought/Action/Observation steps (including multi-line)
42
+ and return a list of dictionaries of the form:
43
+
44
+ [
45
+ {
46
+ "1": {
47
+ "Thought": "...",
48
+ "Action": "...", # Only content inside backticks (if present)
49
+ "Observation": "..."
50
+ }
51
+ },
52
+ {
53
+ "2": {
54
+ "Thought": "...",
55
+ "Action": "...",
56
+ "Observation": "..."
57
+ }
58
+ },
59
+ ...
60
+ ]
61
+ """
62
+ # Regex pattern to match lines that start with "Thought X:", "Action X:", or "Observation X:".
63
+ pattern = re.compile(r'^(Thought|Action|Observation)\s+(\d+):', re.MULTILINE)
64
+
65
+ # This dictionary will accumulate:
66
+ # data_dict[step_number] = {"Thought": ..., "Action": ..., "Observation": ...}
67
+ data_dict = {}
68
+
69
+ # We'll track the current label (Thought/Action/Observation) and step number
70
+ current_label = None
71
+ current_step = None
72
+ last_pos = 0
73
+
74
+ # Find all pattern occurrences in the text
75
+ matches = list(pattern.finditer(text))
76
+
77
+ for match in matches:
78
+ # If we already have a label in progress, we can record its content
79
+ if current_label is not None:
80
+ # Slice the text from the last match's end to the start of this new match
81
+ content = text[last_pos:match.start()].strip()
82
+ # Store that content in data_dict
83
+ data_dict[current_step][current_label] = content
84
+
85
+ # Extract the new label and step
86
+ label = match.group(1) # "Thought", "Action", or "Observation"
87
+ step = match.group(2) # e.g. "1", "2", "3"
88
+
89
+ # Ensure a dict for this step
90
+ if step not in data_dict:
91
+ data_dict[step] = {"Thought": None, "Action": None, "Observation": None}
92
+
93
+ # Update current label/step
94
+ current_label = label
95
+ current_step = step
96
+ # We'll slice from here next time
97
+ last_pos = match.end()
98
+
99
+ # Handle the final block after the last match
100
+ if current_label is not None:
101
+ content = text[last_pos:].strip()
102
+ data_dict[current_step][current_label] = content
103
+
104
+ # Post-process:
105
+ # - For each step, extract only the text inside triple backticks for "Action".
106
+ for step_number in data_dict:
107
+ action_text = data_dict[step_number]["Action"]
108
+ if action_text:
109
+ # Extract content inside triple backticks
110
+ data_dict[step_number]["Action"] = self.extract_code(action_text)
111
+
112
+ # Convert our dictionary to the desired list-of-dicts structure
113
+ structured_data = []
114
+ for step_number in sorted(data_dict.keys(), key=lambda x: int(x)):
115
+ structured_data.append({step_number: data_dict[step_number]})
116
+
117
+ return structured_data
118
+
119
+ def postprocess_agent_response(self, response):
120
+ """
121
+ Extract Thought and Action, then extract the dict from Action.
122
+
123
+ Return:
124
+ - thought: str
125
+ - action: dict
126
+ - is_valid: bool
127
+ """
128
+ parsed_codes = self.parse_reasoning_steps(response)
129
+
130
+ thoughts = []
131
+ actions = []
132
+ for steps in parsed_codes:
133
+ for step_idx, step in steps.items():
134
+ thought = f"Thought {step_idx}: {step['Thought']}"
135
+ action = eval(self.extract_code(step['Action']))
136
+
137
+ assert "function" in action, f"Action does not contain 'function' key: {action}"
138
+ assert "parameters" in action, f"Action does not contain 'parameters' key: {action}"
139
+
140
+ thoughts.append(thought)
141
+ actions.append(action)
142
+
143
+ return thoughts, actions
144
+
145
+ def print_code(codes):
146
+ for idx, step in enumerate(codes):
147
+ print(f"{colored(step['thought'], 'blue')}")
148
+ print(colored(f"Action {idx+1}:\n```\n{step['action']}\n```", 'red'))
149
+ print(colored(f"Observation {idx+1}: {step['observation']}", 'yellow'))
150
+ # print(f"{'-'*60}")
@@ -2,4 +2,5 @@ from flashrag.pipeline.mm_pipeline import *
2
2
  from flashrag.pipeline.pipeline import *
3
3
  from flashrag.pipeline.branching_pipeline import REPLUGPipeline, SuRePipeline
4
4
  from flashrag.pipeline.active_pipeline import IterativePipeline, SelfRAGPipeline, FLAREPipeline, SelfAskPipeline, IRCOTPipeline, RQRAGPipeline
5
- from flashrag.pipeline.reasoning_pipeline import ReasoningPipeline
5
+ from flashrag.pipeline.reasoning_pipeline import *
6
+ from flashrag.pipeline.ReaRAG_utils import *