flashrag-dev 0.1.4.dev20250309__tar.gz → 0.1.4.dev20250319__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 (61) hide show
  1. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/PKG-INFO +24 -18
  2. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/README.md +23 -17
  3. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/generator/openai_generator.py +1 -1
  4. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/prompt/mm_prompt.py +72 -1
  5. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/retriever/retriever.py +2 -1
  6. flashrag_dev-0.1.4.dev20250319/flashrag/version.py +1 -0
  7. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag_dev.egg-info/PKG-INFO +24 -18
  8. flashrag_dev-0.1.4.dev20250309/flashrag/version.py +0 -1
  9. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/LICENSE +0 -0
  10. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/__init__.py +0 -0
  11. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/config/__init__.py +0 -0
  12. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/config/basic_config.yaml +0 -0
  13. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/config/config.py +0 -0
  14. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/dataset/__init__.py +0 -0
  15. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/dataset/dataset.py +0 -0
  16. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/dataset/utils.py +0 -0
  17. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/evaluator/__init__.py +0 -0
  18. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/evaluator/_bleu.py +0 -0
  19. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/evaluator/evaluator.py +0 -0
  20. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/evaluator/metrics.py +0 -0
  21. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/evaluator/utils.py +0 -0
  22. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/generator/__init__.py +0 -0
  23. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/generator/fid.py +0 -0
  24. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/generator/generator.py +0 -0
  25. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/generator/multimodal_generator.py +0 -0
  26. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/generator/stop_word_criteria.py +0 -0
  27. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/generator/utils.py +0 -0
  28. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/judger/__init__.py +0 -0
  29. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/judger/judger.py +0 -0
  30. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/pipeline/__init__.py +0 -0
  31. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/pipeline/active_pipeline.py +0 -0
  32. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/pipeline/branching_pipeline.py +0 -0
  33. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/pipeline/mm_pipeline.py +0 -0
  34. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/pipeline/pipeline.py +0 -0
  35. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/pipeline/replug_utils.py +0 -0
  36. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/prompt/__init__.py +0 -0
  37. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/prompt/base_prompt.py +0 -0
  38. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/prompt/selfask_examplars.py +0 -0
  39. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/prompt/trace_examplars.py +0 -0
  40. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/refiner/__init__.py +0 -0
  41. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/refiner/kg_refiner.py +0 -0
  42. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/refiner/llmlingua_compressor.py +0 -0
  43. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/refiner/refiner.py +0 -0
  44. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/refiner/selective_context_compressor.py +0 -0
  45. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/retriever/__init__.py +0 -0
  46. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/retriever/__main__.py +0 -0
  47. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/retriever/encoder.py +0 -0
  48. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/retriever/index_builder.py +0 -0
  49. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/retriever/reranker.py +0 -0
  50. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/retriever/utils.py +0 -0
  51. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/utils/__init__.py +0 -0
  52. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/utils/constants.py +0 -0
  53. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/utils/pred_parse.py +0 -0
  54. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag/utils/utils.py +0 -0
  55. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag_dev.egg-info/SOURCES.txt +0 -0
  56. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag_dev.egg-info/dependency_links.txt +0 -0
  57. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag_dev.egg-info/requires.txt +0 -0
  58. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/flashrag_dev.egg-info/top_level.txt +0 -0
  59. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/pyproject.toml +0 -0
  60. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/setup.cfg +0 -0
  61. {flashrag_dev-0.1.4.dev20250309 → flashrag_dev-0.1.4.dev20250319}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag_dev
3
- Version: 0.1.4.dev20250309
3
+ Version: 0.1.4.dev20250319
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
@@ -102,11 +102,11 @@ FlashRAG is still under development and there are many issues and room for impro
102
102
 
103
103
  [25/01/12] Introduce <strong>FlashRAG-UI</strong>, an easy to use interface. You can easily and quickly configure and experience the supported RAG methods and evaluate them on the benchmarks.
104
104
 
105
- [25/01/11] We have added support for a new method [<u>RQRAG</u>](https://arxiv.org/abs/2404.00610) method, see it in [**reproduce_experiment**](docs/reproduce_experiment.md).
105
+ [25/01/11] We have added support for a new method [<u>RQRAG</u>](https://arxiv.org/abs/2404.00610) method, see it in [**reproduce_experiment**](docs/original_docs/reproduce_experiment.md).
106
106
 
107
- [25/01/07] We have currently support the aggregation of multiple retrievers, see it in [**multi retriever usage**](https://github.com/RUC-NLPIR/FlashRAG/blob/main/docs/multi_retriever_usage.md).
107
+ [25/01/07] We have currently support the aggregation of multiple retrievers, see it in [**multi retriever usage**](https://github.com/RUC-NLPIR/FlashRAG/blob/main/docs/original_docs/multi_retriever_usage.md).
108
108
 
109
- [25/01/07] We have integrated a very flexible and lightweight corpus chunking library [**Chunkie**](https://github.com/chonkie-ai/chonkie?tab=readme-ov-file#usage), which supports various custom chunking methods (tokens, sentences, semantic, etc.). Use it in [<u>chunking doc corpus</u>](docs/chunk-doc-corpus.md).
109
+ [25/01/07] We have integrated a very flexible and lightweight corpus chunking library [**Chunkie**](https://github.com/chonkie-ai/chonkie?tab=readme-ov-file#usage), which supports various custom chunking methods (tokens, sentences, semantic, etc.). Use it in [<u>chunking doc corpus</u>](docs/original_docs/chunk-doc-corpus.md).
110
110
 
111
111
  [24/10/21] We have released a version based on the Paddle framework that supports Chinese hardware platforms. Please refer to [FlashRAG Paddle](https://github.com/RUC-NLPIR/FlashRAG-Paddle) for details.
112
112
 
@@ -125,7 +125,7 @@ FlashRAG is still under development and there are many issues and room for impro
125
125
 
126
126
  [24/07/17] Due to some unknown issues with HuggingFace, our original dataset link has been invalid. We have updated it. Please check the [new link](https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/) if you encounter any problems.
127
127
 
128
- [24/07/06] We add support for a new method: [<u>Trace</u>](https://arxiv.org/abs/2406.11460), which refine text by constructing a knowledge graph. See it [<u>results</u>](#robot-supporting-methods) and [<u>details</u>](./docs/baseline_details.md).
128
+ [24/07/06] We add support for a new method: [<u>Trace</u>](https://arxiv.org/abs/2406.11460), which refine text by constructing a knowledge graph. See it [<u>results</u>](#robot-supporting-methods) and [<u>details</u>](./docs/original_docs/baseline_details.md).
129
129
 
130
130
  [24/06/19] We add support for a new method: [<u>IRCoT</u>](https://arxiv.org/abs/2212.10509), and update the [<u>result table</u>](#robot-supporting-methods).
131
131
 
@@ -133,9 +133,9 @@ FlashRAG is still under development and there are many issues and room for impro
133
133
 
134
134
  [24/06/11] We have integrated `sentence transformers` in the retriever module. Now it's easier to use the retriever without setting pooling methods.
135
135
 
136
- [24/06/05] We have provided detailed document for reproducing existing methods (see [how to reproduce](./docs/reproduce_experiment.md), [baseline details](./docs/baseline_details.md)), and [<u>configurations settings</u>](./docs/configuration.md).
136
+ [24/06/05] We have provided detailed document for reproducing existing methods (see [how to reproduce](./docs/original_docs/reproduce_experiment.md), [baseline details](./docs/original_docs/baseline_details.md)), and [<u>configurations settings</u>](./docs/original_docs/configuration.md).
137
137
 
138
- [24/06/02] We have provided an introduction of FlashRAG for beginners, see [<u>an introduction to flashrag</u>](./docs/introduction_for_beginners_en.md) ([<u>中文版</u>](./docs/introduction_for_beginners_zh.md) [<u>한국어</u>](./docs/introduction_for_beginners_kr.md)).
138
+ [24/06/02] We have provided an introduction of FlashRAG for beginners, see [<u>an introduction to flashrag</u>](./docs/original_docs/introduction_for_beginners_en.md) ([<u>中文版</u>](./docs/original_docs/introduction_for_beginners_zh.md) [<u>한국어</u>](./docs/original_docs/introduction_for_beginners_kr.md)).
139
139
 
140
140
  [24/05/31] We supported Openai-series models as generator.
141
141
 
@@ -200,7 +200,7 @@ To build an index, you first need to save your corpus as a `jsonl` file with eac
200
200
  {"id": "1", "contents": "..."}
201
201
  ```
202
202
 
203
- If you want to use Wikipedia as your corpus, you can refer to our documentation [Processing Wikipedia](./docs/process-wiki.md) to convert it into an indexable format.
203
+ If you want to use Wikipedia as your corpus, you can refer to our documentation [Processing Wikipedia](./docs/original_docs/process-wiki.md) to convert it into an indexable format.
204
204
 
205
205
  ### Index Construction
206
206
 
@@ -289,7 +289,7 @@ my_config = Config(
289
289
  config_dict = config_dict
290
290
  ```
291
291
 
292
- We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/configuration.md).
292
+ We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/original_docs/configuration.md).
293
293
  You can also refer to the [<u>basic yaml file</u>](./flashrag/config/basic_config.yaml) we provide to set your own parameters.
294
294
 
295
295
  Next, load the corresponding dataset and initialize the pipeline. The components in the pipeline will be automatically loaded.
@@ -360,11 +360,11 @@ class ToyPipeline(BasicPipeline):
360
360
  return dataset
361
361
  ```
362
362
 
363
- Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/basic_usage.md).
363
+ Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/original_docs/basic_usage.md).
364
364
 
365
365
  ### Just use components
366
366
 
367
- If you already have your own code and only want to use our components to embed the original code, you can refer to the [<u>basic introduction of the components</u>](./docs/basic_usage.md) to obtain the input and output formats of each component.
367
+ If you already have your own code and only want to use our components to embed the original code, you can refer to the [<u>basic introduction of the components</u>](./docs/original_docs/basic_usage.md) to obtain the input and output formats of each component.
368
368
 
369
369
  ## :gear: Components
370
370
 
@@ -554,11 +554,11 @@ We have implemented 15 works with a consistent setting of:
554
554
 
555
555
  - **Generator:** LLAMA3-8B-instruct with input length of 2048
556
556
  - **Retriever:** e5-base-v2 as embedding model, retrieve 5 docs per query
557
- - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/baseline_details.md).
557
+ - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/original_docs/baseline_details.md).
558
558
 
559
559
  For open-source methods, we implemented their processes using our framework. For methods where the author did not provide source code, we will try our best to follow the methods in the original paper for implementation.
560
560
 
561
- 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/reproduce_experiment.md) and [<u>method details</u>](./docs/baseline_details.md).
561
+ 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).
562
562
 
563
563
  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.
564
564
 
@@ -653,7 +653,7 @@ Our toolkit supports jsonl format for retrieval document collections, with the f
653
653
 
654
654
  The `contents` key is essential for building the index. For documents that include both text and title, we recommend setting the value of `contents` to `{title}\n{text}`. The corpus file can also contain other keys to record additional characteristics of the documents.
655
655
 
656
- In the academic research, Wikipedia and MS MARCO are the most commonly used retrieval document collections. For Wikipedia, we provide a [<u>comprehensive script</u>](./docs/process-wiki.md) to process any Wikipedia dump into a clean corpus. Additionally, various processed versions of the Wikipedia corpus are available in many works, and we have listed some reference links.
656
+ In the academic research, Wikipedia and MS MARCO are the most commonly used retrieval document collections. For Wikipedia, we provide a [<u>comprehensive script</u>](./docs/original_docs/process-wiki.md) to process any Wikipedia dump into a clean corpus. Additionally, various processed versions of the Wikipedia corpus are available in many works, and we have listed some reference links.
657
657
 
658
658
  For MS MARCO, it is already processed upon release and can be directly downloaded from its [<u>hosting link</u>](https://huggingface.co/datasets/Tevatron/msmarco-passage-corpus) on Hugging Face.
659
659
 
@@ -663,12 +663,18 @@ To facilitate easier replication of the experiments, we now provide a preprocess
663
663
 
664
664
  The index was created using the e5-base-v2 retriever on our uploaded wiki18_100w dataset, which is consistent with the index used in our experiments.
665
665
 
666
+ ## :lollipop: Awesome Work using FlashRAG
667
+
668
+ - [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), a method that incentivizes the search capability in LLMs via reinforcement learning
669
+ - [ReSearch](https://github.com/Agent-RL/ReSearch), a method that learns to reason with search for LLMs via reinforcement learning
670
+ - [AutoCoA](https://github.com/ADaM-BJTU/AutoCoA), a method that internalizes chain-of-action generation into reasoning models
671
+
666
672
  ## :raised_hands: Additional FAQs
667
673
 
668
- - [How should I set different experimental parameters?](./docs/configuration.md)
669
- - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/process-wiki.md)
670
- - [How to index my own corpus?](./docs/building-index.md)
671
- - [How to reproduce supporting methods?](./docs/reproduce_experiment.md)
674
+ - [How should I set different experimental parameters?](./docs/original_docs/configuration.md)
675
+ - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/original_docs/process-wiki.md)
676
+ - [How to index my own corpus?](./docs/original_docs/building-index.md)
677
+ - [How to reproduce supporting methods?](./docs/original_docs/reproduce_experiment.md)
672
678
 
673
679
  ## :bookmark: License
674
680
 
@@ -85,11 +85,11 @@ FlashRAG is still under development and there are many issues and room for impro
85
85
 
86
86
  [25/01/12] Introduce <strong>FlashRAG-UI</strong>, an easy to use interface. You can easily and quickly configure and experience the supported RAG methods and evaluate them on the benchmarks.
87
87
 
88
- [25/01/11] We have added support for a new method [<u>RQRAG</u>](https://arxiv.org/abs/2404.00610) method, see it in [**reproduce_experiment**](docs/reproduce_experiment.md).
88
+ [25/01/11] We have added support for a new method [<u>RQRAG</u>](https://arxiv.org/abs/2404.00610) method, see it in [**reproduce_experiment**](docs/original_docs/reproduce_experiment.md).
89
89
 
90
- [25/01/07] We have currently support the aggregation of multiple retrievers, see it in [**multi retriever usage**](https://github.com/RUC-NLPIR/FlashRAG/blob/main/docs/multi_retriever_usage.md).
90
+ [25/01/07] We have currently support the aggregation of multiple retrievers, see it in [**multi retriever usage**](https://github.com/RUC-NLPIR/FlashRAG/blob/main/docs/original_docs/multi_retriever_usage.md).
91
91
 
92
- [25/01/07] We have integrated a very flexible and lightweight corpus chunking library [**Chunkie**](https://github.com/chonkie-ai/chonkie?tab=readme-ov-file#usage), which supports various custom chunking methods (tokens, sentences, semantic, etc.). Use it in [<u>chunking doc corpus</u>](docs/chunk-doc-corpus.md).
92
+ [25/01/07] We have integrated a very flexible and lightweight corpus chunking library [**Chunkie**](https://github.com/chonkie-ai/chonkie?tab=readme-ov-file#usage), which supports various custom chunking methods (tokens, sentences, semantic, etc.). Use it in [<u>chunking doc corpus</u>](docs/original_docs/chunk-doc-corpus.md).
93
93
 
94
94
  [24/10/21] We have released a version based on the Paddle framework that supports Chinese hardware platforms. Please refer to [FlashRAG Paddle](https://github.com/RUC-NLPIR/FlashRAG-Paddle) for details.
95
95
 
@@ -108,7 +108,7 @@ FlashRAG is still under development and there are many issues and room for impro
108
108
 
109
109
  [24/07/17] Due to some unknown issues with HuggingFace, our original dataset link has been invalid. We have updated it. Please check the [new link](https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/) if you encounter any problems.
110
110
 
111
- [24/07/06] We add support for a new method: [<u>Trace</u>](https://arxiv.org/abs/2406.11460), which refine text by constructing a knowledge graph. See it [<u>results</u>](#robot-supporting-methods) and [<u>details</u>](./docs/baseline_details.md).
111
+ [24/07/06] We add support for a new method: [<u>Trace</u>](https://arxiv.org/abs/2406.11460), which refine text by constructing a knowledge graph. See it [<u>results</u>](#robot-supporting-methods) and [<u>details</u>](./docs/original_docs/baseline_details.md).
112
112
 
113
113
  [24/06/19] We add support for a new method: [<u>IRCoT</u>](https://arxiv.org/abs/2212.10509), and update the [<u>result table</u>](#robot-supporting-methods).
114
114
 
@@ -116,9 +116,9 @@ FlashRAG is still under development and there are many issues and room for impro
116
116
 
117
117
  [24/06/11] We have integrated `sentence transformers` in the retriever module. Now it's easier to use the retriever without setting pooling methods.
118
118
 
119
- [24/06/05] We have provided detailed document for reproducing existing methods (see [how to reproduce](./docs/reproduce_experiment.md), [baseline details](./docs/baseline_details.md)), and [<u>configurations settings</u>](./docs/configuration.md).
119
+ [24/06/05] We have provided detailed document for reproducing existing methods (see [how to reproduce](./docs/original_docs/reproduce_experiment.md), [baseline details](./docs/original_docs/baseline_details.md)), and [<u>configurations settings</u>](./docs/original_docs/configuration.md).
120
120
 
121
- [24/06/02] We have provided an introduction of FlashRAG for beginners, see [<u>an introduction to flashrag</u>](./docs/introduction_for_beginners_en.md) ([<u>中文版</u>](./docs/introduction_for_beginners_zh.md) [<u>한국어</u>](./docs/introduction_for_beginners_kr.md)).
121
+ [24/06/02] We have provided an introduction of FlashRAG for beginners, see [<u>an introduction to flashrag</u>](./docs/original_docs/introduction_for_beginners_en.md) ([<u>中文版</u>](./docs/original_docs/introduction_for_beginners_zh.md) [<u>한국어</u>](./docs/original_docs/introduction_for_beginners_kr.md)).
122
122
 
123
123
  [24/05/31] We supported Openai-series models as generator.
124
124
 
@@ -183,7 +183,7 @@ To build an index, you first need to save your corpus as a `jsonl` file with eac
183
183
  {"id": "1", "contents": "..."}
184
184
  ```
185
185
 
186
- If you want to use Wikipedia as your corpus, you can refer to our documentation [Processing Wikipedia](./docs/process-wiki.md) to convert it into an indexable format.
186
+ If you want to use Wikipedia as your corpus, you can refer to our documentation [Processing Wikipedia](./docs/original_docs/process-wiki.md) to convert it into an indexable format.
187
187
 
188
188
  ### Index Construction
189
189
 
@@ -272,7 +272,7 @@ my_config = Config(
272
272
  config_dict = config_dict
273
273
  ```
274
274
 
275
- We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/configuration.md).
275
+ We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/original_docs/configuration.md).
276
276
  You can also refer to the [<u>basic yaml file</u>](./flashrag/config/basic_config.yaml) we provide to set your own parameters.
277
277
 
278
278
  Next, load the corresponding dataset and initialize the pipeline. The components in the pipeline will be automatically loaded.
@@ -343,11 +343,11 @@ class ToyPipeline(BasicPipeline):
343
343
  return dataset
344
344
  ```
345
345
 
346
- Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/basic_usage.md).
346
+ Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/original_docs/basic_usage.md).
347
347
 
348
348
  ### Just use components
349
349
 
350
- If you already have your own code and only want to use our components to embed the original code, you can refer to the [<u>basic introduction of the components</u>](./docs/basic_usage.md) to obtain the input and output formats of each component.
350
+ If you already have your own code and only want to use our components to embed the original code, you can refer to the [<u>basic introduction of the components</u>](./docs/original_docs/basic_usage.md) to obtain the input and output formats of each component.
351
351
 
352
352
  ## :gear: Components
353
353
 
@@ -537,11 +537,11 @@ We have implemented 15 works with a consistent setting of:
537
537
 
538
538
  - **Generator:** LLAMA3-8B-instruct with input length of 2048
539
539
  - **Retriever:** e5-base-v2 as embedding model, retrieve 5 docs per query
540
- - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/baseline_details.md).
540
+ - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/original_docs/baseline_details.md).
541
541
 
542
542
  For open-source methods, we implemented their processes using our framework. For methods where the author did not provide source code, we will try our best to follow the methods in the original paper for implementation.
543
543
 
544
- 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/reproduce_experiment.md) and [<u>method details</u>](./docs/baseline_details.md).
544
+ 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).
545
545
 
546
546
  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.
547
547
 
@@ -636,7 +636,7 @@ Our toolkit supports jsonl format for retrieval document collections, with the f
636
636
 
637
637
  The `contents` key is essential for building the index. For documents that include both text and title, we recommend setting the value of `contents` to `{title}\n{text}`. The corpus file can also contain other keys to record additional characteristics of the documents.
638
638
 
639
- In the academic research, Wikipedia and MS MARCO are the most commonly used retrieval document collections. For Wikipedia, we provide a [<u>comprehensive script</u>](./docs/process-wiki.md) to process any Wikipedia dump into a clean corpus. Additionally, various processed versions of the Wikipedia corpus are available in many works, and we have listed some reference links.
639
+ In the academic research, Wikipedia and MS MARCO are the most commonly used retrieval document collections. For Wikipedia, we provide a [<u>comprehensive script</u>](./docs/original_docs/process-wiki.md) to process any Wikipedia dump into a clean corpus. Additionally, various processed versions of the Wikipedia corpus are available in many works, and we have listed some reference links.
640
640
 
641
641
  For MS MARCO, it is already processed upon release and can be directly downloaded from its [<u>hosting link</u>](https://huggingface.co/datasets/Tevatron/msmarco-passage-corpus) on Hugging Face.
642
642
 
@@ -646,12 +646,18 @@ To facilitate easier replication of the experiments, we now provide a preprocess
646
646
 
647
647
  The index was created using the e5-base-v2 retriever on our uploaded wiki18_100w dataset, which is consistent with the index used in our experiments.
648
648
 
649
+ ## :lollipop: Awesome Work using FlashRAG
650
+
651
+ - [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), a method that incentivizes the search capability in LLMs via reinforcement learning
652
+ - [ReSearch](https://github.com/Agent-RL/ReSearch), a method that learns to reason with search for LLMs via reinforcement learning
653
+ - [AutoCoA](https://github.com/ADaM-BJTU/AutoCoA), a method that internalizes chain-of-action generation into reasoning models
654
+
649
655
  ## :raised_hands: Additional FAQs
650
656
 
651
- - [How should I set different experimental parameters?](./docs/configuration.md)
652
- - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/process-wiki.md)
653
- - [How to index my own corpus?](./docs/building-index.md)
654
- - [How to reproduce supporting methods?](./docs/reproduce_experiment.md)
657
+ - [How should I set different experimental parameters?](./docs/original_docs/configuration.md)
658
+ - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/original_docs/process-wiki.md)
659
+ - [How to index my own corpus?](./docs/original_docs/building-index.md)
660
+ - [How to reproduce supporting methods?](./docs/original_docs/reproduce_experiment.md)
655
661
 
656
662
  ## :bookmark: License
657
663
 
@@ -35,7 +35,7 @@ class OpenaiGenerator:
35
35
  try:
36
36
  self.tokenizer = tiktoken.encoding_for_model(self.model_name)
37
37
  except Exception as e:
38
- print("Error: ", e)
38
+ print("Warning: ", e)
39
39
  warnings.warn("This model is not supported by tiktoken. Use gpt-3.5-turbo instead.")
40
40
  self.tokenizer = tiktoken.encoding_for_model('gpt-3.5-turbo')
41
41
  @property
@@ -84,4 +84,75 @@ class GAOKAOMMPromptTemplate(MMPromptTemplate):
84
84
  content_list.append({'type': 'text', 'text': user_prompt})
85
85
  messages.append({"role": "user", "content": content_list})
86
86
  return messages
87
-
87
+
88
+
89
+ class MathVistaPromptTemplate:
90
+ BASE_USER_PROMPT_FREE_FORM = (
91
+ "You are an AI assistant designed to solve mathematical and visual reasoning problems. "
92
+ "Below is a question that requires you to analyze the given information and provide a detailed answer.\n\n"
93
+ "### Reference Information:\n{reference}\n\n"
94
+ "### Question:\n{question}\n\n"
95
+ "### Instructions:\n"
96
+ "Only give me the final answer.\n\n"
97
+ "### Answer:\n"
98
+ )
99
+
100
+ BASE_USER_PROMPT_MULTI_CHOICE = (
101
+ "You are an AI assistant designed to solve mathematical and visual reasoning problems. "
102
+ "Below is a multiple-choice question that requires you to analyze the given information and select the correct choice.\n\n"
103
+ "### Reference Information:\n{reference}\n\n"
104
+ "### Question:\n{question}\n\n"
105
+ "### Instructions:\n"
106
+ "Only give me the correct option letter, e.g., A, B, C, D.\n\n"
107
+ "### Answer:\n"
108
+ )
109
+
110
+ def __init__(self, config, system_prompt=None, user_prompt_free_form=None, user_prompt_multi_choice=None):
111
+ self.config = config
112
+ self.system_prompt = system_prompt
113
+ self.user_prompt_free_form = user_prompt_free_form if user_prompt_free_form is not None else self.BASE_USER_PROMPT_FREE_FORM
114
+ self.user_prompt_multi_choice = user_prompt_multi_choice if user_prompt_multi_choice is not None else self.BASE_USER_PROMPT_MULTI_CHOICE
115
+
116
+ def get_string(self, item, use_retrieval_image=False, use_retrieval_text=False, use_question_image=False):
117
+ question = item.question if item.question is not None else item.text
118
+ question_image = item.image
119
+ question_type = item.question_type # 'free_form' or 'multi_choice'
120
+
121
+ messages = []
122
+ if self.system_prompt is not None:
123
+ messages.append({"role": "system", "content": self.system_prompt})
124
+
125
+ content_list = []
126
+ reference_str = ""
127
+
128
+ # Add retrieval results as reference (if available)
129
+ try:
130
+ retrieval_result = item.retrieval_result
131
+ except:
132
+ retrieval_result = []
133
+
134
+ for idx, item in enumerate(retrieval_result):
135
+ if 'image' not in item:
136
+ reference_str += f'Example {idx + 1}: {item["contents"]}\n'
137
+ else:
138
+ content_list.append({'type': 'image', 'image': item['image']})
139
+ reference_str += f'Example {idx + 1}: {item["text"]}\n'
140
+
141
+ # Add question image (if available)
142
+ if question_image:
143
+ content_list.append({'type': 'image', 'image': question_image})
144
+
145
+ # Format the user prompt based on question type
146
+ if question_type == 'free_form':
147
+ user_prompt = self.user_prompt_free_form.format(question=question, reference=reference_str)
148
+ elif question_type == 'multi_choice':
149
+ user_prompt = self.user_prompt_multi_choice.format(question=question, reference=reference_str)
150
+ else:
151
+ raise ValueError(f"Unsupported question type: {question_type}")
152
+
153
+ # Add the formatted user prompt
154
+ content_list.append({'type': 'text', 'text': user_prompt})
155
+ messages.append({"role": "user", "content": content_list})
156
+
157
+ return messages
158
+
@@ -324,7 +324,8 @@ class BM25Retriever(BaseTextRetriever):
324
324
  results, scores = self.searcher.retrieve(query_tokens, k=num)
325
325
  else:
326
326
  assert False, "Invalid bm25 backend!"
327
-
327
+ results = results.tolist() if isinstance(results,np.ndarray) else results
328
+ scores = scores.tolist() if isinstance(scores,np.ndarray) else scores
328
329
  if return_score:
329
330
  return results, scores
330
331
  else:
@@ -0,0 +1 @@
1
+ __version__ = "0.1.4dev20250319"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag-dev
3
- Version: 0.1.4.dev20250309
3
+ Version: 0.1.4.dev20250319
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
@@ -102,11 +102,11 @@ FlashRAG is still under development and there are many issues and room for impro
102
102
 
103
103
  [25/01/12] Introduce <strong>FlashRAG-UI</strong>, an easy to use interface. You can easily and quickly configure and experience the supported RAG methods and evaluate them on the benchmarks.
104
104
 
105
- [25/01/11] We have added support for a new method [<u>RQRAG</u>](https://arxiv.org/abs/2404.00610) method, see it in [**reproduce_experiment**](docs/reproduce_experiment.md).
105
+ [25/01/11] We have added support for a new method [<u>RQRAG</u>](https://arxiv.org/abs/2404.00610) method, see it in [**reproduce_experiment**](docs/original_docs/reproduce_experiment.md).
106
106
 
107
- [25/01/07] We have currently support the aggregation of multiple retrievers, see it in [**multi retriever usage**](https://github.com/RUC-NLPIR/FlashRAG/blob/main/docs/multi_retriever_usage.md).
107
+ [25/01/07] We have currently support the aggregation of multiple retrievers, see it in [**multi retriever usage**](https://github.com/RUC-NLPIR/FlashRAG/blob/main/docs/original_docs/multi_retriever_usage.md).
108
108
 
109
- [25/01/07] We have integrated a very flexible and lightweight corpus chunking library [**Chunkie**](https://github.com/chonkie-ai/chonkie?tab=readme-ov-file#usage), which supports various custom chunking methods (tokens, sentences, semantic, etc.). Use it in [<u>chunking doc corpus</u>](docs/chunk-doc-corpus.md).
109
+ [25/01/07] We have integrated a very flexible and lightweight corpus chunking library [**Chunkie**](https://github.com/chonkie-ai/chonkie?tab=readme-ov-file#usage), which supports various custom chunking methods (tokens, sentences, semantic, etc.). Use it in [<u>chunking doc corpus</u>](docs/original_docs/chunk-doc-corpus.md).
110
110
 
111
111
  [24/10/21] We have released a version based on the Paddle framework that supports Chinese hardware platforms. Please refer to [FlashRAG Paddle](https://github.com/RUC-NLPIR/FlashRAG-Paddle) for details.
112
112
 
@@ -125,7 +125,7 @@ FlashRAG is still under development and there are many issues and room for impro
125
125
 
126
126
  [24/07/17] Due to some unknown issues with HuggingFace, our original dataset link has been invalid. We have updated it. Please check the [new link](https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/) if you encounter any problems.
127
127
 
128
- [24/07/06] We add support for a new method: [<u>Trace</u>](https://arxiv.org/abs/2406.11460), which refine text by constructing a knowledge graph. See it [<u>results</u>](#robot-supporting-methods) and [<u>details</u>](./docs/baseline_details.md).
128
+ [24/07/06] We add support for a new method: [<u>Trace</u>](https://arxiv.org/abs/2406.11460), which refine text by constructing a knowledge graph. See it [<u>results</u>](#robot-supporting-methods) and [<u>details</u>](./docs/original_docs/baseline_details.md).
129
129
 
130
130
  [24/06/19] We add support for a new method: [<u>IRCoT</u>](https://arxiv.org/abs/2212.10509), and update the [<u>result table</u>](#robot-supporting-methods).
131
131
 
@@ -133,9 +133,9 @@ FlashRAG is still under development and there are many issues and room for impro
133
133
 
134
134
  [24/06/11] We have integrated `sentence transformers` in the retriever module. Now it's easier to use the retriever without setting pooling methods.
135
135
 
136
- [24/06/05] We have provided detailed document for reproducing existing methods (see [how to reproduce](./docs/reproduce_experiment.md), [baseline details](./docs/baseline_details.md)), and [<u>configurations settings</u>](./docs/configuration.md).
136
+ [24/06/05] We have provided detailed document for reproducing existing methods (see [how to reproduce](./docs/original_docs/reproduce_experiment.md), [baseline details](./docs/original_docs/baseline_details.md)), and [<u>configurations settings</u>](./docs/original_docs/configuration.md).
137
137
 
138
- [24/06/02] We have provided an introduction of FlashRAG for beginners, see [<u>an introduction to flashrag</u>](./docs/introduction_for_beginners_en.md) ([<u>中文版</u>](./docs/introduction_for_beginners_zh.md) [<u>한국어</u>](./docs/introduction_for_beginners_kr.md)).
138
+ [24/06/02] We have provided an introduction of FlashRAG for beginners, see [<u>an introduction to flashrag</u>](./docs/original_docs/introduction_for_beginners_en.md) ([<u>中文版</u>](./docs/original_docs/introduction_for_beginners_zh.md) [<u>한국어</u>](./docs/original_docs/introduction_for_beginners_kr.md)).
139
139
 
140
140
  [24/05/31] We supported Openai-series models as generator.
141
141
 
@@ -200,7 +200,7 @@ To build an index, you first need to save your corpus as a `jsonl` file with eac
200
200
  {"id": "1", "contents": "..."}
201
201
  ```
202
202
 
203
- If you want to use Wikipedia as your corpus, you can refer to our documentation [Processing Wikipedia](./docs/process-wiki.md) to convert it into an indexable format.
203
+ If you want to use Wikipedia as your corpus, you can refer to our documentation [Processing Wikipedia](./docs/original_docs/process-wiki.md) to convert it into an indexable format.
204
204
 
205
205
  ### Index Construction
206
206
 
@@ -289,7 +289,7 @@ my_config = Config(
289
289
  config_dict = config_dict
290
290
  ```
291
291
 
292
- We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/configuration.md).
292
+ We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/original_docs/configuration.md).
293
293
  You can also refer to the [<u>basic yaml file</u>](./flashrag/config/basic_config.yaml) we provide to set your own parameters.
294
294
 
295
295
  Next, load the corresponding dataset and initialize the pipeline. The components in the pipeline will be automatically loaded.
@@ -360,11 +360,11 @@ class ToyPipeline(BasicPipeline):
360
360
  return dataset
361
361
  ```
362
362
 
363
- Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/basic_usage.md).
363
+ Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/original_docs/basic_usage.md).
364
364
 
365
365
  ### Just use components
366
366
 
367
- If you already have your own code and only want to use our components to embed the original code, you can refer to the [<u>basic introduction of the components</u>](./docs/basic_usage.md) to obtain the input and output formats of each component.
367
+ If you already have your own code and only want to use our components to embed the original code, you can refer to the [<u>basic introduction of the components</u>](./docs/original_docs/basic_usage.md) to obtain the input and output formats of each component.
368
368
 
369
369
  ## :gear: Components
370
370
 
@@ -554,11 +554,11 @@ We have implemented 15 works with a consistent setting of:
554
554
 
555
555
  - **Generator:** LLAMA3-8B-instruct with input length of 2048
556
556
  - **Retriever:** e5-base-v2 as embedding model, retrieve 5 docs per query
557
- - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/baseline_details.md).
557
+ - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/original_docs/baseline_details.md).
558
558
 
559
559
  For open-source methods, we implemented their processes using our framework. For methods where the author did not provide source code, we will try our best to follow the methods in the original paper for implementation.
560
560
 
561
- 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/reproduce_experiment.md) and [<u>method details</u>](./docs/baseline_details.md).
561
+ 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).
562
562
 
563
563
  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.
564
564
 
@@ -653,7 +653,7 @@ Our toolkit supports jsonl format for retrieval document collections, with the f
653
653
 
654
654
  The `contents` key is essential for building the index. For documents that include both text and title, we recommend setting the value of `contents` to `{title}\n{text}`. The corpus file can also contain other keys to record additional characteristics of the documents.
655
655
 
656
- In the academic research, Wikipedia and MS MARCO are the most commonly used retrieval document collections. For Wikipedia, we provide a [<u>comprehensive script</u>](./docs/process-wiki.md) to process any Wikipedia dump into a clean corpus. Additionally, various processed versions of the Wikipedia corpus are available in many works, and we have listed some reference links.
656
+ In the academic research, Wikipedia and MS MARCO are the most commonly used retrieval document collections. For Wikipedia, we provide a [<u>comprehensive script</u>](./docs/original_docs/process-wiki.md) to process any Wikipedia dump into a clean corpus. Additionally, various processed versions of the Wikipedia corpus are available in many works, and we have listed some reference links.
657
657
 
658
658
  For MS MARCO, it is already processed upon release and can be directly downloaded from its [<u>hosting link</u>](https://huggingface.co/datasets/Tevatron/msmarco-passage-corpus) on Hugging Face.
659
659
 
@@ -663,12 +663,18 @@ To facilitate easier replication of the experiments, we now provide a preprocess
663
663
 
664
664
  The index was created using the e5-base-v2 retriever on our uploaded wiki18_100w dataset, which is consistent with the index used in our experiments.
665
665
 
666
+ ## :lollipop: Awesome Work using FlashRAG
667
+
668
+ - [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), a method that incentivizes the search capability in LLMs via reinforcement learning
669
+ - [ReSearch](https://github.com/Agent-RL/ReSearch), a method that learns to reason with search for LLMs via reinforcement learning
670
+ - [AutoCoA](https://github.com/ADaM-BJTU/AutoCoA), a method that internalizes chain-of-action generation into reasoning models
671
+
666
672
  ## :raised_hands: Additional FAQs
667
673
 
668
- - [How should I set different experimental parameters?](./docs/configuration.md)
669
- - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/process-wiki.md)
670
- - [How to index my own corpus?](./docs/building-index.md)
671
- - [How to reproduce supporting methods?](./docs/reproduce_experiment.md)
674
+ - [How should I set different experimental parameters?](./docs/original_docs/configuration.md)
675
+ - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/original_docs/process-wiki.md)
676
+ - [How to index my own corpus?](./docs/original_docs/building-index.md)
677
+ - [How to reproduce supporting methods?](./docs/original_docs/reproduce_experiment.md)
672
678
 
673
679
  ## :bookmark: License
674
680
 
@@ -1 +0,0 @@
1
- __version__ = "0.1.4dev20250309"