flashrag-dev 0.1.1__tar.gz → 0.1.2__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 (54) hide show
  1. {flashrag_dev-0.1.1/flashrag_dev.egg-info → flashrag_dev-0.1.2}/PKG-INFO +621 -616
  2. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/README.md +548 -543
  3. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/config/config.py +221 -219
  4. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/generator/generator.py +625 -623
  5. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/pipeline/active_pipeline.py +979 -980
  6. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/pipeline/branching_pipeline.py +249 -250
  7. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/pipeline/pipeline.py +247 -248
  8. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/prompt/base_prompt.py +202 -165
  9. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/refiner/refiner.py +2 -2
  10. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/retriever/encoder.py +80 -120
  11. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/retriever/index_builder.py +355 -334
  12. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/retriever/retriever.py +352 -346
  13. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/retriever/utils.py +98 -49
  14. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/utils/utils.py +3 -1
  15. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2/flashrag_dev.egg-info}/PKG-INFO +621 -616
  16. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/setup.cfg +4 -4
  17. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/setup.py +2 -2
  18. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/LICENSE +0 -0
  19. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/__init__.py +0 -0
  20. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/config/__init__.py +0 -0
  21. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/dataset/__init__.py +0 -0
  22. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/dataset/dataset.py +0 -0
  23. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/dataset/utils.py +0 -0
  24. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/evaluator/__init__.py +0 -0
  25. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/evaluator/_bleu.py +0 -0
  26. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/evaluator/evaluator.py +0 -0
  27. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/evaluator/metrics.py +0 -0
  28. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/evaluator/utils.py +0 -0
  29. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/generator/__init__.py +0 -0
  30. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/generator/fid.py +0 -0
  31. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/generator/openai_generator.py +0 -0
  32. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/generator/stop_word_criteria.py +0 -0
  33. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/judger/__init__.py +0 -0
  34. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/judger/judger.py +0 -0
  35. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/pipeline/__init__.py +0 -0
  36. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/pipeline/replug_utils.py +0 -0
  37. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/prompt/__init__.py +0 -0
  38. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/prompt/selfask_examplars.py +0 -0
  39. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/prompt/trace_examplars.py +0 -0
  40. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/refiner/__init__.py +0 -0
  41. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/refiner/kg_refiner.py +0 -0
  42. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/refiner/llmlingua_compressor.py +0 -0
  43. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/refiner/selective_context_compressor.py +0 -0
  44. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/retriever/__init__.py +0 -0
  45. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/retriever/__main__.py +0 -0
  46. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/retriever/reranker.py +0 -0
  47. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/utils/__init__.py +0 -0
  48. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/utils/constants.py +0 -0
  49. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag/utils/pred_parse.py +0 -0
  50. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag_dev.egg-info/SOURCES.txt +0 -0
  51. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag_dev.egg-info/dependency_links.txt +0 -0
  52. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag_dev.egg-info/requires.txt +0 -0
  53. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/flashrag_dev.egg-info/top_level.txt +0 -0
  54. {flashrag_dev-0.1.1 → flashrag_dev-0.1.2}/pyproject.toml +0 -0
@@ -1,616 +1,621 @@
1
- Metadata-Version: 2.1
2
- Name: flashrag-dev
3
- Version: 0.1.1
4
- Summary: A library for efficient Retrieval-Augmented Generation research
5
- Home-page: https://github.com/RUC-NLPIR/FlashRAG
6
- Author: Jiajie Jin, Yutao Zhu, Chenghao Zhang, Xinyu Yang, Zhicheng Dou
7
- Author-email: jinjiajie@ruc.edu.cn
8
- License: MIT License
9
- Requires-Python: >=3.8
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: datasets
13
- Requires-Dist: base58
14
- Requires-Dist: nltk
15
- Requires-Dist: numpy
16
- Requires-Dist: openai
17
- Requires-Dist: peft
18
- Requires-Dist: PyYAML
19
- Requires-Dist: rank_bm25
20
- Requires-Dist: rouge
21
- Requires-Dist: spacy>=3.6.1
22
- Requires-Dist: tiktoken
23
- Requires-Dist: torch
24
- Requires-Dist: tqdm
25
- Requires-Dist: transformers>=4.40.0
26
- Requires-Dist: bm25s[full]
27
- Requires-Dist: fschat
28
- Requires-Dist: streamlit
29
- Provides-Extra: core
30
- Requires-Dist: datasets; extra == "core"
31
- Requires-Dist: base58; extra == "core"
32
- Requires-Dist: nltk; extra == "core"
33
- Requires-Dist: numpy; extra == "core"
34
- Requires-Dist: openai; extra == "core"
35
- Requires-Dist: peft; extra == "core"
36
- Requires-Dist: PyYAML; extra == "core"
37
- Requires-Dist: rank_bm25; extra == "core"
38
- Requires-Dist: rouge; extra == "core"
39
- Requires-Dist: spacy>=3.6.1; extra == "core"
40
- Requires-Dist: tiktoken; extra == "core"
41
- Requires-Dist: torch; extra == "core"
42
- Requires-Dist: tqdm; extra == "core"
43
- Requires-Dist: transformers>=4.40.0; extra == "core"
44
- Requires-Dist: bm25s[full]; extra == "core"
45
- Requires-Dist: fschat; extra == "core"
46
- Requires-Dist: streamlit; extra == "core"
47
- Provides-Extra: retriever
48
- Requires-Dist: pyserini; extra == "retriever"
49
- Requires-Dist: sentence-transformers>=3.0.1; extra == "retriever"
50
- Provides-Extra: generator
51
- Requires-Dist: vllm>=0.4.1; extra == "generator"
52
- Provides-Extra: full
53
- Requires-Dist: datasets; extra == "full"
54
- Requires-Dist: base58; extra == "full"
55
- Requires-Dist: nltk; extra == "full"
56
- Requires-Dist: numpy; extra == "full"
57
- Requires-Dist: openai; extra == "full"
58
- Requires-Dist: peft; extra == "full"
59
- Requires-Dist: PyYAML; extra == "full"
60
- Requires-Dist: rank_bm25; extra == "full"
61
- Requires-Dist: rouge; extra == "full"
62
- Requires-Dist: spacy>=3.6.1; extra == "full"
63
- Requires-Dist: tiktoken; extra == "full"
64
- Requires-Dist: torch; extra == "full"
65
- Requires-Dist: tqdm; extra == "full"
66
- Requires-Dist: transformers>=4.40.0; extra == "full"
67
- Requires-Dist: bm25s[full]; extra == "full"
68
- Requires-Dist: fschat; extra == "full"
69
- Requires-Dist: streamlit; extra == "full"
70
- Requires-Dist: pyserini; extra == "full"
71
- Requires-Dist: sentence-transformers>=3.0.1; extra == "full"
72
- Requires-Dist: vllm>=0.4.1; extra == "full"
73
-
74
- # <div align="center">⚡FlashRAG: A Python Toolkit for Efficient RAG Research<div>
75
-
76
-
77
- <div align="center">
78
- <a href="https://arxiv.org/abs/2405.13576" target="_blank"><img src=https://img.shields.io/badge/arXiv-b5212f.svg?logo=arxiv></a>
79
- <a href="https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/" target="_blank"><img src=https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace%20Datasets-27b3b4.svg></a>
80
- <a href="https://github.com/RUC-NLPIR/FlashRAG/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/LICENSE-MIT-green"></a>
81
- <a><img alt="Static Badge" src="https://img.shields.io/badge/made_with-Python-blue"></a>
82
- </div>
83
-
84
- <h4 align="center">
85
-
86
- <p>
87
- <a href="#wrench-installation">Installation</a> |
88
- <a href="#sparkles-features">Features</a> |
89
- <a href="#running-quick-start">Quick-Start</a> |
90
- <a href="#gear-components"> Components</a> |
91
- <a href="#robot-supporting-methods"> Supporting Methods</a> |
92
- <a href="#notebook-supporting-datasets"> Supporting Datasets</a> |
93
- <a href="#raised_hands-additional-faqs"> FAQs</a>
94
- </p>
95
-
96
- </h4>
97
- FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 32 pre-processed benchmark RAG datasets and 15 state-of-the-art RAG algorithms.
98
-
99
- <p align="center">
100
- <img src="asset/framework.jpg">
101
- </p>
102
-
103
- With FlashRAG and provided resources, you can effortlessly reproduce existing SOTA works in the RAG domain or implement your custom RAG processes and components.
104
- <p>
105
- <a href="https://trendshift.io/repositories/10454" target="_blank"><img src="https://trendshift.io/api/badge/repositories/10454" alt="RUC-NLPIR%2FFlashRAG | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
106
- </p>
107
-
108
-
109
- ## :sparkles: Features
110
-
111
- - **Extensive and Customizable Framework**: Includes essential components for RAG scenarios such as retrievers, rerankers, generators, and compressors, allowing for flexible assembly of complex pipelines.
112
-
113
- - **Comprehensive Benchmark Datasets**: A collection of 32 pre-processed RAG benchmark datasets to test and validate RAG models' performances.
114
-
115
- - **Pre-implemented Advanced RAG Algorithms**: Features 15 advancing RAG algorithms with reported results, based on our framework. Easily reproducing results under different settings.
116
-
117
- - **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.
118
-
119
- - **Optimized Execution**: The library's efficiency is enhanced with tools like vLLM, FastChat for LLM inference acceleration, and Faiss for vector index management.
120
-
121
- ## :mag_right: Roadmap
122
-
123
- FlashRAG is still under development and there are many issues and room for improvement. We will continue to update. And we also sincerely welcome contributions on this open-source toolkit.
124
-
125
- - [x] Support OpenAI models
126
- - [ ] Support Claude and Gemini models
127
- - [x] Provdide instructions for each component
128
- - [x] Integrate sentence Transformers
129
- - [ ] Inlcude more RAG approaches
130
- - [ ] Add more evaluation metrics (e.g., Unieval, name-entity F1) and benchmarks (e.g., RGB benchmark)
131
- - [ ] Enhance code adaptability and readability
132
-
133
-
134
- ## :page_with_curl: Changelog
135
-
136
- [24/09/18] Due to the complexity and limitations of installing Pyserini in certain environments, we have introduced a lightweight `BM25s` package as an alternative (faster and easier to use). The retriever based on Pyserini will be deprecated in future versions. To use retriever with `bm25s`, just set `bm25_backend` to `bm25s` in config.
137
-
138
- [24/09/09] We add support for a new method [<u>Adaptive-RAG</u>](https://aclanthology.org/2024.naacl-long.389.pdf), which can automatically select the RAG process to execute based on the type of query. See it result in [<u>result table</u>](#robot-supporting-methods).
139
-
140
- [24/08/02] We add support for a new method [<u>Spring</u>](https://arxiv.org/abs/2405.19670), significantly improve the performance of LLM by adding only a few token embeddings. See it result in [<u>result table</u>](#robot-supporting-methods).
141
-
142
- [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.
143
-
144
- [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).
145
-
146
- <details>
147
- <summary>Show more</summary>
148
-
149
- [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).
150
-
151
- [24/06/15] We provide a [<u>demo</u>](./examples/quick_start/demo_en.py) to perform the RAG process using our toolkit.
152
-
153
- [24/06/11] We have integrated `sentence transformers` in the retriever module. Now it's easier to use the retriever without setting pooling methods.
154
-
155
- [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).
156
-
157
- [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)).
158
-
159
- [24/05/31] We supported Openai-series models as generator.
160
-
161
- </details>
162
-
163
-
164
- ## :wrench: Installation
165
-
166
- To get started with FlashRAG, you can simply install it with pip:
167
- ```base
168
- pip install flashrag[core]
169
- ```
170
-
171
- Or you can clone it from Github and install (requires Python 3.9+):
172
-
173
- ```bash
174
- git clone https://github.com/RUC-NLPIR/FlashRAG.git
175
- cd FlashRAG
176
- pip install -e .[core]
177
- ```
178
-
179
- If you want to use vllm, sentence-transformers or pyserini, you can install the optional dependencies:
180
- ```bash
181
- # Install all extra dependencies
182
- pip install flashrag[full]
183
-
184
- # Install vllm for faster speed
185
- pip install vllm>=0.4.1
186
-
187
- # Install sentence-transformers
188
- pip install sentence-transformers
189
-
190
- # Install pyserini for bm25
191
- pip install pyserini
192
- ```
193
-
194
- Due to the incompatibility when installing `faiss` using `pip`, it is necessary to use the following conda command for installation.
195
- ```bash
196
- # CPU-only version
197
- conda install -c pytorch faiss-cpu=1.8.0
198
-
199
- # GPU(+CPU) version
200
- conda install -c pytorch -c nvidia faiss-gpu=1.8.0
201
- ```
202
-
203
- Note: It is impossible to install the latest version of `faiss` on certain systems.
204
-
205
- From the official Faiss repository ([source](https://github.com/facebookresearch/faiss/blob/main/INSTALL.md)):
206
-
207
- > - The CPU-only faiss-cpu conda package is currently available on Linux (x86_64 and arm64), OSX (arm64 only), and Windows (x86_64)
208
- > - faiss-gpu, containing both CPU and GPU indices, is available on Linux (x86_64 only) for CUDA 11.4 and 12.1
209
-
210
- ## :rocket: Quick Start
211
-
212
-
213
- ### Toy Example
214
-
215
- For beginners, we provide a [<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)) to help you familiarize yourself with our toolkit. Alternatively, you can directly refer to the code below.
216
-
217
- #### Demo
218
-
219
- We provide a toy demo to implement a simple RAG process. You can freely change the corpus and model you want to use. The English demo uses [general knowledge](https://huggingface.co/datasets/MuskumPillerum/General-Knowledge) as the corpus, `e5-base-v2` as the retriever, and `Llama3-8B-instruct` as generator. The Chinese demo uses data crawled from the official website of Remin University of China as the corpus, `bge-large-zh-v1.5` as the retriever, and qwen1.5-14B as the generator. Please fill in the corresponding path in the file.
220
-
221
- <div style="display: flex; justify-content: space-around;">
222
- <div style="text-align: center;">
223
- <img src="./asset/demo_en.gif" style="width: 100%;">
224
- </div>
225
- </div>
226
-
227
- To run the demo:
228
-
229
- ```bash
230
- cd examples/quick_start
231
-
232
- # copy the config file here, otherwise, streamlit will complain that file s
233
- cp ../methods/my_config.yaml .
234
-
235
- # run english demo
236
- streamlit run demo_en.py
237
-
238
- # run chinese demo
239
- streamlit run demo_zh.py
240
- ```
241
-
242
-
243
- #### Pipeline
244
-
245
- We also provide an example to use our framework for pipeline execution.
246
- Run the following code to implement a naive RAG pipeline using provided toy datasets.
247
- The default retriever is `e5-base-v2` and default generator is `Llama3-8B-instruct`. You need to fill in the corresponding model path in the following command. If you wish to use other models, please refer to the detailed instructions below.
248
-
249
- ```bash
250
- cd examples/quick_start
251
- python simple_pipeline.py \
252
- --model_path <Llama-3-8B-instruct-PATH> \
253
- --retriever_path <E5-PATH>
254
- ```
255
-
256
- After the code is completed, you can view the intermediate results of the run and the final evaluation score in the output folder under the corresponding path.
257
-
258
- ### Using the ready-made pipeline
259
-
260
- You can use the pipeline class we have already built (as shown in [<u>pipelines</u>](#pipelines)) to implement the RAG process inside. In this case, you just need to configure the config and load the corresponding pipeline.
261
-
262
- Firstly, load the entire process's config, which records various hyperparameters required in the RAG process. You can input yaml files as parameters or directly as variables. The priority of variables as input is higher than that of files.
263
-
264
- ```python
265
- from flashrag.config import Config
266
-
267
- config_dict = {'data_dir': 'dataset/'}
268
- my_config = Config(config_file_path = 'my_config.yaml',
269
- config_dict = config_dict)
270
- ```
271
-
272
- We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/configuration.md).
273
- You can also refer to the [<u>basic yaml file</u>](./flashrag/config/basic_config.yaml) we provide to set your own parameters.
274
-
275
- Next, load the corresponding dataset and initialize the pipeline. The components in the pipeline will be automatically loaded.
276
-
277
- ```python
278
- from flashrag.utils import get_dataset
279
- from flashrag.pipeline import SequentialPipeline
280
- from flashrag.prompt import PromptTemplate
281
- from flashrag.config import Config
282
-
283
- config_dict = {'data_dir': 'dataset/'}
284
- my_config = Config(config_file_path = 'my_config.yaml',
285
- config_dict = config_dict)
286
- all_split = get_dataset(my_config)
287
- test_data = all_split['test']
288
-
289
- pipeline = SequentialPipeline(my_config)
290
- ```
291
-
292
- You can specify your own input prompt using `PromptTemplete`:
293
- ```python
294
- prompt_templete = PromptTemplate(
295
- config,
296
- system_prompt = "Answer the question based on the given document. Only give me the answer and do not output any other words.\nThe following are given documents.\n\n{reference}",
297
- user_prompt = "Question: {question}\nAnswer:"
298
- )
299
- pipeline = SequentialPipeline(my_config, prompt_template=prompt_templete)
300
- ```
301
-
302
- Finally, execute `pipeline.run` to obtain the final result.
303
-
304
- ```python
305
- output_dataset = pipeline.run(test_data, do_eval=True)
306
- ```
307
- The `output_dataset` contains the intermediate results and metric scores for each item in the input dataset.
308
- Meanwhile, the dataset with intermediate results and the overall evaluation score will also be saved as a file (if `save_intermediate_data` and `save_metric_score` are specified).
309
-
310
- ### Build your own pipeline
311
-
312
- Sometimes you may need to implement more complex RAG process, and you can build your own pipeline to implement it.
313
- You just need to inherit `BasicPipeline`, initialize the components you need, and complete the `run` function.
314
-
315
- ```python
316
- from flashrag.pipeline import BasicPipeline
317
- from flashrag.utils import get_retriever, get_generator
318
-
319
- class ToyPipeline(BasicPipeline):
320
- def __init__(self, config, prompt_templete=None):
321
- # Load your own components
322
- pass
323
-
324
- def run(self, dataset, do_eval=True):
325
- # Complete your own process logic
326
-
327
- # get attribute in dataset using `.`
328
- input_query = dataset.question
329
- ...
330
- # use `update_output` to save intermeidate data
331
- dataset.update_output("pred",pred_answer_list)
332
- dataset = self.evaluate(dataset, do_eval=do_eval)
333
- return dataset
334
- ```
335
-
336
- Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/basic_usage.md).
337
-
338
-
339
- ### Just use components
340
-
341
- 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.
342
-
343
- ## :gear: Components
344
-
345
- In FlashRAG, we have built a series of common RAG components, including retrievers, generators, refiners, and more. Based on these components, we have assembled several pipelines to implement the RAG workflow, while also providing the flexibility to combine these components in custom arrangements to create your own pipeline.
346
-
347
- #### RAG-Components
348
-
349
- <table>
350
- <thead>
351
- <tr>
352
- <th>Type</th>
353
- <th>Module</th>
354
- <th>Description</th>
355
- </tr>
356
- </thead>
357
- <tbody>
358
- <tr>
359
- <td rowspan="1">Judger</td>
360
- <td>SKR Judger</td>
361
- <td>Judging whether to retrieve using <a href="https://aclanthology.org/2023.findings-emnlp.691.pdf">SKR</a> method</td>
362
- </tr>
363
- <tr>
364
- <td rowspan="4">Retriever</td>
365
- <td>Dense Retriever</td>
366
- <td>Bi-encoder models such as dpr, bge, e5, using faiss for search</td>
367
- </tr>
368
- <tr>
369
- <td>BM25 Retriever</td>
370
- <td>Sparse retrieval method based on Lucene</td>
371
- </tr>
372
- <tr>
373
- <td>Bi-Encoder Reranker</td>
374
- <td>Calculate matching score using bi-Encoder</td>
375
- </tr>
376
- <tr>
377
- <td>Cross-Encoder Reranker</td>
378
- <td>Calculate matching score using cross-encoder</td>
379
- </tr>
380
- <tr>
381
- <td rowspan="5">Refiner</td>
382
- <td>Extractive Refiner</td>
383
- <td>Refine input by extracting important context</td>
384
- </tr>
385
- <tr>
386
- <td>Abstractive Refiner</td>
387
- <td>Refine input through seq2seq model</td>
388
- </tr>
389
- <tr>
390
- <td>LLMLingua Refiner</td>
391
- <td><a href="https://aclanthology.org/2023.emnlp-main.825/">LLMLingua-series</a> prompt compressor</td>
392
- </tr>
393
- <tr>
394
- <td>SelectiveContext Refiner</td>
395
- <td><a href="https://arxiv.org/abs/2310.06201">Selective-Context</a> prompt compressor</td>
396
- </tr>
397
- <tr>
398
- <td> KG Refiner </td>
399
- <td>Use <a hred='https://arxiv.org/abs/2406.11460'>Trace method to construct a knowledge graph</td>
400
- <tr>
401
- <td rowspan="4">Generator</td>
402
- <td>Encoder-Decoder Generator</td>
403
- <td>Encoder-Decoder model, supporting <a href="https://arxiv.org/abs/2007.01282">Fusion-in-Decoder (FiD)</a></td>
404
- </tr>
405
- <tr>
406
- <td>Decoder-only Generator</td>
407
- <td>Native transformers implementation</td>
408
- </tr>
409
- <tr>
410
- <td>FastChat Generator</td>
411
- <td>Accelerate with <a href="https://github.com/lm-sys/FastChat">FastChat</a></td>
412
- </tr>
413
- <tr>
414
- <td>vllm Generator</td>
415
- <td>Accelerate with <a href="https://github.com/vllm-project/vllm">vllm</a></td>
416
- </tr>
417
- </tbody>
418
- </table>
419
-
420
- #### Pipelines
421
-
422
- Referring to a [<u>survey on retrieval-augmented generation</u>](https://arxiv.org/abs/2312.10997), we categorized RAG methods into four types based on their inference paths.
423
-
424
- - **Sequential**: Sequential execuation of RAG process, like Query-(pre-retrieval)-retriever-(post-retrieval)-generator
425
- - **Conditional**: Implements different paths for different types of input queries
426
- - **Branching** : Executes multiple paths in parallel, merging the responses from each path
427
- - **Loop**: Iteratively performs retrieval and generation
428
-
429
- In each category, we have implemented corresponding common pipelines. Some pipelines have corresponding work papers.
430
-
431
- <table>
432
- <thead>
433
- <tr>
434
- <th>Type</th>
435
- <th>Module</th>
436
- <th>Description</th>
437
- </tr>
438
- </thead>
439
- <tbody>
440
- <tr>
441
- <td rowspan="1">Sequential</td>
442
- <td>Sequential Pipeline</td>
443
- <td>Linear execution of query, supporting refiner, reranker</td>
444
- </tr>
445
- <tr>
446
- <td rowspan="1">Conditional</td>
447
- <td>Conditional Pipeline</td>
448
- <td>With a judger module, distinct execution paths for various query types</td>
449
- </tr>
450
- <tr>
451
- <td rowspan="2">Branching</td>
452
- <td>REPLUG Pipeline</td>
453
- <td>Generate answer by integrating probabilities in multiple generation paths</td>
454
- </tr>
455
- <td>SuRe Pipeline</td>
456
- <td>Ranking and merging generated results based on each document</td>
457
- </tr>
458
- <tr>
459
- <td rowspan="5">Loop</td>
460
- <td>Iterative Pipeline</td>
461
- <td>Alternating retrieval and generation</td>
462
- </tr>
463
- <tr>
464
- <td>Self-Ask Pipeline</td>
465
- <td>Decompose complex problems into subproblems using <a href="https://arxiv.org/abs/2210.03350">self-ask</a> </td>
466
- </tr>
467
- <tr>
468
- <td>Self-RAG Pipeline</td>
469
- <td>Adaptive retrieval, critique, and generation</td>
470
- </tr>
471
- <tr>
472
- <td>FLARE Pipeline</td>
473
- <td>Dynamic retrieval during the generation process</td>
474
- </tr>
475
- <tr>
476
- <td>IRCoT Pipeline</td>
477
- <td>Integrate retrieval process with CoT</td>
478
- </tr>
479
- </tbody>
480
- </table>
481
-
482
-
483
- ## :robot: Supporting Methods
484
-
485
- We have implemented 15 works with a consistent setting of:
486
- - **Generator:** LLAMA3-8B-instruct with input length of 2048
487
- - **Retriever:** e5-base-v2 as embedding model, retrieve 5 docs per query
488
- - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/baseline_details.md).
489
-
490
- 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.
491
-
492
- 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).
493
-
494
- 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.
495
-
496
-
497
- | Method | Type | NQ (EM) | TriviaQA (EM) | Hotpotqa (F1) | 2Wiki (F1)| PopQA (F1)| WebQA(EM) | Specific setting |
498
- |----------------------|----------------|---------|---------------|---------------|---------------|---------------|---------------|------------------------------------------------------------------------------------|
499
- | Naive Generation | Sequential | 22.6 | 55.7 | 28.4 | 33.9| 21.7| 18.8| |
500
- | Standard RAG | Sequential | 35.1 | 58.9 | 35.3 | 21.0 | 36.7|15.7| |
501
- | [AAR-contriever-kilt](https://aclanthology.org/2023.acl-long.136.pdf) | Sequential | 30.1 | 56.8 | 33.4 | 19.8 | 36.1 | 16.1| |
502
- | [LongLLMLingua](https://arxiv.org/abs/2310.06839) | Sequential | 32.2 | 59.2 | 37.5 |25.0| 38.7| 17.5| Compress Ratio=0.5 |
503
- | [RECOMP-abstractive](https://arxiv.org/pdf/2310.04408) | Sequential | 33.1 | 56.4 | 37.5 | 32.4 | 39.9| 20.2| |
504
- | [Selective-Context](https://arxiv.org/abs/2310.06201) | Sequential | 30.5 | 55.6 | 34.4 |18.5| 33.5| 17.3| Compress Ratio=0.5|
505
- | [Trace](https://arxiv.org/abs/2406.11460) | Sequential | 30.7 | 50.2 | 34.0 | 15.5 | 37.4 | 19.9 | |
506
- | [Spring](https://arxiv.org/abs/2405.19670) | Sequential | 37.9 | 64.6 |42.6 | 37.3 |54.8 |27.7 | Use Llama2-7B-chat with trained embedding table |
507
- | [SuRe](https://arxiv.org/abs/2404.13081) | Branching | 37.1 | 53.2 | 33.4 |20.6|48.1|24.2| Use provided prompt|
508
- | [REPLUG](https://arxiv.org/abs/2301.12652) | Branching | 28.9 | 57.7 | 31.2 |21.1|27.8|20.2| |
509
- | [SKR](https://aclanthology.org/2023.findings-emnlp.691.pdf) | Conditional | 33.2 | 56.0 | 32.4 | 23.4 |31.7|17.0|Use infernece-time training data|
510
- |[Adaptive-RAG](https://aclanthology.org/2024.naacl-long.389.pdf) | Conditional | 35.1 | 56.6 | 39.1 | 28.4 | 40.4 | 16.0| |
511
- | [Ret-Robust](https://arxiv.org/abs/2310.01558) | Loop | 42.9 | 68.2 | 35.8 |43.4|57.2|33.7| Use LLAMA2-13B with trained lora|
512
- | [Self-RAG](https://arxiv.org/abs/2310.11511) | Loop | 36.4 | 38.2 | 29.6 | 25.1|32.7|21.9| Use trained selfrag-llama2-7B|
513
- | [FLARE](https://arxiv.org/abs/2305.06983) | Loop | 22.5 | 55.8 | 28.0 |33.9| 20.7| 20.2| |
514
- | [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| |
515
- | [IRCoT](https://aclanthology.org/2023.acl-long.557.pdf) | Loop | 33.3| 56.9|41.5|32.4 |45.6 |20.7 | |
516
-
517
-
518
- ## :notebook: Supporting Datasets & Document Corpus
519
-
520
- ### Datasets
521
-
522
- We have collected and processed 35 datasets widely used in RAG research, pre-processing them to ensure a consistent format for ease of use. For certain datasets (such as Wiki-asp), we have adapted them to fit the requirements of RAG tasks according to the methods commonly used within the community. All datasets are available at [<u>Huggingface datasets</u>](https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets).
523
-
524
- For each dataset, we save each split as a `jsonl` file, and each line is a dict as follows:
525
- ```python
526
- {
527
- 'id': str,
528
- 'question': str,
529
- 'golden_answers': List[str],
530
- 'metadata': dict
531
- }
532
- ```
533
-
534
-
535
- Below is the list of datasets along with the corresponding sample sizes:
536
-
537
- | Task | Dataset Name | Knowledge Source | # Train | # Dev | # Test |
538
- |---------------------------|-----------------|------------------|-----------|---------|--------|
539
- | QA | NQ | wiki | 79,168 | 8,757 | 3,610 |
540
- | QA | TriviaQA | wiki & web | 78,785 | 8,837 | 11,313 |
541
- | QA | PopQA | wiki | / | / | 14,267 |
542
- | QA | SQuAD | wiki | 87,599 | 10,570 | / |
543
- | QA | MSMARCO-QA | web | 808,731 | 101,093 | / |
544
- | QA | NarrativeQA | books and story | 32,747 | 3,461 | 10,557 |
545
- | QA | WikiQA | wiki | 20,360 | 2,733 | 6,165 |
546
- | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
547
- | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
548
- | QA | SIQA | - | 33,410 | 1,954 | / |
549
- | QA | CommenseQA | - | 9,741 | 1,221 | / |
550
- | QA | BoolQ | wiki | 9,427 | 3,270 | / |
551
- | QA | PIQA | - | 16,113 | 1,838 | / |
552
- | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
553
- | multi-hop QA | HotpotQA | wiki | 90,447 | 7,405 | / |
554
- | multi-hop QA | 2WikiMultiHopQA | wiki | 15,000 | 12,576 | / |
555
- | multi-hop QA | Musique | wiki | 19,938 | 2,417 | / |
556
- | multi-hop QA | Bamboogle | wiki | / | / | 125 |
557
- | Long-form QA | ASQA | wiki | 4,353 | 948 | / |
558
- | Long-form QA | ELI5 | Reddit | 272,634 | 1,507 | / |
559
- | Open-Domain Summarization | WikiASP | wiki | 300,636 | 37,046 | 37,368 |
560
- | multiple-choice | MMLU | - | 99,842 | 1,531 | 14,042 |
561
- | multiple-choice | TruthfulQA | wiki | / | 817 | / |
562
- | multiple-choice | HellaSWAG | ActivityNet | 39,905 | 10,042 | / |
563
- | multiple-choice | ARC | - | 3,370 | 869 | 3,548 |
564
- | multiple-choice | OpenBookQA | - | 4,957 | 500 | 500 |
565
- | Fact Verification | FEVER | wiki | 104,966 | 10,444 | / |
566
- | Dialog Generation | WOW | wiki | 63,734 | 3,054 | / |
567
- | Entity Linking | AIDA CoNll-yago | Freebase & wiki | 18,395 | 4,784 | / |
568
- | Entity Linking | WNED | Wiki | / | 8,995 | / |
569
- | Slot Filling | T-REx | DBPedia | 2,284,168 | 5,000 | / |
570
- | Slot Filling | Zero-shot RE | wiki | 147,909 | 3,724 | / |
571
-
572
- ### Document Corpus
573
-
574
- Our toolkit supports jsonl format for retrieval document collections, with the following structure:
575
-
576
- ```jsonl
577
- {"id":"0", "contents": "...."}
578
- {"id":"1", "contents": "..."}
579
- ```
580
- 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.
581
-
582
- 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.
583
-
584
-
585
- 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.
586
-
587
-
588
- ## :raised_hands: Additional FAQs
589
-
590
- - [How should I set different experimental parameters?](./docs/configuration.md)
591
- - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/process-wiki.md)
592
- - [How to index my own corpus?](./docs/building-index.md)
593
- - [How to reproduce supporting methods?](./docs/reproduce_experiment.md)
594
-
595
- ## :bookmark: License
596
-
597
- FlashRAG is licensed under the [<u>MIT License</u>](./LICENSE).
598
-
599
- ## :star2: Citation
600
- Please kindly cite our paper if helps your research:
601
- ```BibTex
602
- @article{FlashRAG,
603
- author={Jiajie Jin and
604
- Yutao Zhu and
605
- Xinyu Yang and
606
- Chenghao Zhang and
607
- Zhicheng Dou},
608
- title={FlashRAG: A Modular Toolkit for Efficient Retrieval-Augmented Generation Research},
609
- journal={CoRR},
610
- volume={abs/2405.13576},
611
- year={2024},
612
- url={https://arxiv.org/abs/2405.13576},
613
- eprinttype={arXiv},
614
- eprint={2405.13576}
615
- }
616
- ```
1
+ Metadata-Version: 2.1
2
+ Name: flashrag-dev
3
+ Version: 0.1.2
4
+ Summary: A library for efficient Retrieval-Augmented Generation research
5
+ Home-page: https://github.com/RUC-NLPIR/FlashRAG
6
+ Author: Jiajie Jin, Yutao Zhu, Chenghao Zhang, Xinyu Yang, Zhicheng Dou
7
+ Author-email: jinjiajie@ruc.edu.cn
8
+ License: MIT License
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: datasets
13
+ Requires-Dist: base58
14
+ Requires-Dist: nltk
15
+ Requires-Dist: numpy
16
+ Requires-Dist: openai
17
+ Requires-Dist: peft
18
+ Requires-Dist: PyYAML
19
+ Requires-Dist: rank_bm25
20
+ Requires-Dist: rouge
21
+ Requires-Dist: spacy>=3.6.1
22
+ Requires-Dist: tiktoken
23
+ Requires-Dist: torch
24
+ Requires-Dist: tqdm
25
+ Requires-Dist: transformers>=4.40.0
26
+ Requires-Dist: bm25s[full]
27
+ Requires-Dist: fschat
28
+ Requires-Dist: streamlit
29
+ Provides-Extra: core
30
+ Requires-Dist: datasets; extra == "core"
31
+ Requires-Dist: base58; extra == "core"
32
+ Requires-Dist: nltk; extra == "core"
33
+ Requires-Dist: numpy; extra == "core"
34
+ Requires-Dist: openai; extra == "core"
35
+ Requires-Dist: peft; extra == "core"
36
+ Requires-Dist: PyYAML; extra == "core"
37
+ Requires-Dist: rank_bm25; extra == "core"
38
+ Requires-Dist: rouge; extra == "core"
39
+ Requires-Dist: spacy>=3.6.1; extra == "core"
40
+ Requires-Dist: tiktoken; extra == "core"
41
+ Requires-Dist: torch; extra == "core"
42
+ Requires-Dist: tqdm; extra == "core"
43
+ Requires-Dist: transformers>=4.40.0; extra == "core"
44
+ Requires-Dist: bm25s[full]; extra == "core"
45
+ Requires-Dist: fschat; extra == "core"
46
+ Requires-Dist: streamlit; extra == "core"
47
+ Provides-Extra: retriever
48
+ Requires-Dist: pyserini; extra == "retriever"
49
+ Requires-Dist: sentence-transformers>=3.0.1; extra == "retriever"
50
+ Provides-Extra: generator
51
+ Requires-Dist: vllm>=0.4.1; extra == "generator"
52
+ Provides-Extra: full
53
+ Requires-Dist: datasets; extra == "full"
54
+ Requires-Dist: base58; extra == "full"
55
+ Requires-Dist: nltk; extra == "full"
56
+ Requires-Dist: numpy; extra == "full"
57
+ Requires-Dist: openai; extra == "full"
58
+ Requires-Dist: peft; extra == "full"
59
+ Requires-Dist: PyYAML; extra == "full"
60
+ Requires-Dist: rank_bm25; extra == "full"
61
+ Requires-Dist: rouge; extra == "full"
62
+ Requires-Dist: spacy>=3.6.1; extra == "full"
63
+ Requires-Dist: tiktoken; extra == "full"
64
+ Requires-Dist: torch; extra == "full"
65
+ Requires-Dist: tqdm; extra == "full"
66
+ Requires-Dist: transformers>=4.40.0; extra == "full"
67
+ Requires-Dist: bm25s[full]; extra == "full"
68
+ Requires-Dist: fschat; extra == "full"
69
+ Requires-Dist: streamlit; extra == "full"
70
+ Requires-Dist: pyserini; extra == "full"
71
+ Requires-Dist: sentence-transformers>=3.0.1; extra == "full"
72
+ Requires-Dist: vllm>=0.4.1; extra == "full"
73
+
74
+ # <div align="center">⚡FlashRAG: A Python Toolkit for Efficient RAG Research<div>
75
+
76
+
77
+ <div align="center">
78
+ <a href="https://arxiv.org/abs/2405.13576" target="_blank"><img src=https://img.shields.io/badge/arXiv-b5212f.svg?logo=arxiv></a>
79
+ <a href="https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/" target="_blank"><img src=https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace%20Datasets-27b3b4.svg></a>
80
+ <a href="https://github.com/RUC-NLPIR/FlashRAG/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/LICENSE-MIT-green"></a>
81
+ <a><img alt="Static Badge" src="https://img.shields.io/badge/made_with-Python-blue"></a>
82
+ </div>
83
+
84
+ <h4 align="center">
85
+
86
+ <p>
87
+ <a href="#wrench-installation">Installation</a> |
88
+ <a href="#sparkles-features">Features</a> |
89
+ <a href="#running-quick-start">Quick-Start</a> |
90
+ <a href="#gear-components"> Components</a> |
91
+ <a href="#robot-supporting-methods"> Supporting Methods</a> |
92
+ <a href="#notebook-supporting-datasets"> Supporting Datasets</a> |
93
+ <a href="#raised_hands-additional-faqs"> FAQs</a>
94
+ </p>
95
+
96
+ </h4>
97
+ FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 32 pre-processed benchmark RAG datasets and 15 state-of-the-art RAG algorithms.
98
+
99
+ <p align="center">
100
+ <img src="asset/framework.jpg">
101
+ </p>
102
+
103
+ With FlashRAG and provided resources, you can effortlessly reproduce existing SOTA works in the RAG domain or implement your custom RAG processes and components.
104
+ <p>
105
+ <a href="https://trendshift.io/repositories/10454" target="_blank"><img src="https://trendshift.io/api/badge/repositories/10454" alt="RUC-NLPIR%2FFlashRAG | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
106
+ </p>
107
+
108
+
109
+ ## :sparkles: Features
110
+
111
+ - **Extensive and Customizable Framework**: Includes essential components for RAG scenarios such as retrievers, rerankers, generators, and compressors, allowing for flexible assembly of complex pipelines.
112
+
113
+ - **Comprehensive Benchmark Datasets**: A collection of 32 pre-processed RAG benchmark datasets to test and validate RAG models' performances.
114
+
115
+ - **Pre-implemented Advanced RAG Algorithms**: Features 15 advancing RAG algorithms with reported results, based on our framework. Easily reproducing results under different settings.
116
+
117
+ - **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.
118
+
119
+ - **Optimized Execution**: The library's efficiency is enhanced with tools like vLLM, FastChat for LLM inference acceleration, and Faiss for vector index management.
120
+
121
+ ## :mag_right: Roadmap
122
+
123
+ FlashRAG is still under development and there are many issues and room for improvement. We will continue to update. And we also sincerely welcome contributions on this open-source toolkit.
124
+
125
+ - [x] Support OpenAI models
126
+ - [x] Provdide instructions for each component
127
+ - [x] Integrate sentence Transformers
128
+ - [ ] Inlcude more RAG approaches
129
+ - [ ] Add more evaluation metrics (e.g., Unieval, name-entity F1) and benchmarks (e.g., RGB benchmark)
130
+ - [ ] Enhance code adaptability and readability
131
+
132
+
133
+ ## :page_with_curl: Changelog
134
+ [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.
135
+
136
+ [24/10/13] A new in-domain dataset and corpus - [DomainRAG](https://arxiv.org/pdf/2406.05654) have been added to the dataset. The dataset is based on the internal enrollment data of Renmin University of China, covering seven types of tasks, which can be used for conducting domain-specific RAG testing.
137
+
138
+ [24/09/24] We have released a version based on the MindSpore framework that supports Chinese hardware platforms. Please refer to [FlashRAG MindSpore](https://github.com/RUC-NLPIR/FlashRAG-MindSpore) for details.
139
+
140
+ [24/09/18] Due to the complexity and limitations of installing Pyserini in certain environments, we have introduced a lightweight `BM25s` package as an alternative (faster and easier to use). The retriever based on Pyserini will be deprecated in future versions. To use retriever with `bm25s`, just set `bm25_backend` to `bm25s` in config.
141
+
142
+ [24/09/09] We add support for a new method [<u>Adaptive-RAG</u>](https://aclanthology.org/2024.naacl-long.389.pdf), which can automatically select the RAG process to execute based on the type of query. See it result in [<u>result table</u>](#robot-supporting-methods).
143
+
144
+ [24/08/02] We add support for a new method [<u>Spring</u>](https://arxiv.org/abs/2405.19670), significantly improve the performance of LLM by adding only a few token embeddings. See it result in [<u>result table</u>](#robot-supporting-methods).
145
+
146
+ [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.
147
+
148
+ [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).
149
+
150
+ <details>
151
+ <summary>Show more</summary>
152
+
153
+ [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).
154
+
155
+ [24/06/15] We provide a [<u>demo</u>](./examples/quick_start/demo_en.py) to perform the RAG process using our toolkit.
156
+
157
+ [24/06/11] We have integrated `sentence transformers` in the retriever module. Now it's easier to use the retriever without setting pooling methods.
158
+
159
+ [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).
160
+
161
+ [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)).
162
+
163
+ [24/05/31] We supported Openai-series models as generator.
164
+
165
+ </details>
166
+
167
+
168
+ ## :wrench: Installation
169
+
170
+ To get started with FlashRAG, you can simply install it with pip:
171
+ ```base
172
+ pip install flashrag-dev[core]
173
+ ```
174
+
175
+ Or you can clone it from Github and install (requires Python 3.9+):
176
+
177
+ ```bash
178
+ git clone https://github.com/RUC-NLPIR/FlashRAG.git
179
+ cd FlashRAG
180
+ pip install -e .[core]
181
+ ```
182
+
183
+ If you want to use vllm, sentence-transformers or pyserini, you can install the optional dependencies:
184
+ ```bash
185
+ # Install all extra dependencies
186
+ pip install flashrag[full]
187
+
188
+ # Install vllm for faster speed
189
+ pip install vllm>=0.4.1
190
+
191
+ # Install sentence-transformers
192
+ pip install sentence-transformers
193
+
194
+ # Install pyserini for bm25
195
+ pip install pyserini
196
+ ```
197
+
198
+ Due to the incompatibility when installing `faiss` using `pip`, it is necessary to use the following conda command for installation.
199
+ ```bash
200
+ # CPU-only version
201
+ conda install -c pytorch faiss-cpu=1.8.0
202
+
203
+ # GPU(+CPU) version
204
+ conda install -c pytorch -c nvidia faiss-gpu=1.8.0
205
+ ```
206
+
207
+ Note: It is impossible to install the latest version of `faiss` on certain systems.
208
+
209
+ From the official Faiss repository ([source](https://github.com/facebookresearch/faiss/blob/main/INSTALL.md)):
210
+
211
+ > - The CPU-only faiss-cpu conda package is currently available on Linux (x86_64 and arm64), OSX (arm64 only), and Windows (x86_64)
212
+ > - faiss-gpu, containing both CPU and GPU indices, is available on Linux (x86_64 only) for CUDA 11.4 and 12.1
213
+
214
+ ## :rocket: Quick Start
215
+
216
+
217
+ ### Toy Example
218
+
219
+ For beginners, we provide a [<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)) to help you familiarize yourself with our toolkit. Alternatively, you can directly refer to the code below.
220
+
221
+ #### Demo
222
+
223
+ We provide a toy demo to implement a simple RAG process. You can freely change the corpus and model you want to use. The English demo uses [general knowledge](https://huggingface.co/datasets/MuskumPillerum/General-Knowledge) as the corpus, `e5-base-v2` as the retriever, and `Llama3-8B-instruct` as generator. The Chinese demo uses data crawled from the official website of Remin University of China as the corpus, `bge-large-zh-v1.5` as the retriever, and qwen1.5-14B as the generator. Please fill in the corresponding path in the file.
224
+
225
+ <div style="display: flex; justify-content: space-around;">
226
+ <div style="text-align: center;">
227
+ <img src="./asset/demo_en.gif" style="width: 100%;">
228
+ </div>
229
+ </div>
230
+
231
+ To run the demo:
232
+
233
+ ```bash
234
+ cd examples/quick_start
235
+
236
+ # copy the config file here, otherwise, streamlit will complain that file s
237
+ cp ../methods/my_config.yaml .
238
+
239
+ # run english demo
240
+ streamlit run demo_en.py
241
+
242
+ # run chinese demo
243
+ streamlit run demo_zh.py
244
+ ```
245
+
246
+
247
+ #### Pipeline
248
+
249
+ We also provide an example to use our framework for pipeline execution.
250
+ Run the following code to implement a naive RAG pipeline using provided toy datasets.
251
+ The default retriever is `e5-base-v2` and default generator is `Llama3-8B-instruct`. You need to fill in the corresponding model path in the following command. If you wish to use other models, please refer to the detailed instructions below.
252
+
253
+ ```bash
254
+ cd examples/quick_start
255
+ python simple_pipeline.py \
256
+ --model_path <Llama-3-8B-instruct-PATH> \
257
+ --retriever_path <E5-PATH>
258
+ ```
259
+
260
+ After the code is completed, you can view the intermediate results of the run and the final evaluation score in the output folder under the corresponding path.
261
+
262
+ ### Using the ready-made pipeline
263
+
264
+ You can use the pipeline class we have already built (as shown in [<u>pipelines</u>](#pipelines)) to implement the RAG process inside. In this case, you just need to configure the config and load the corresponding pipeline.
265
+
266
+ Firstly, load the entire process's config, which records various hyperparameters required in the RAG process. You can input yaml files as parameters or directly as variables. The priority of variables as input is higher than that of files.
267
+
268
+ ```python
269
+ from flashrag.config import Config
270
+
271
+ config_dict = {'data_dir': 'dataset/'}
272
+ my_config = Config(config_file_path = 'my_config.yaml',
273
+ config_dict = config_dict)
274
+ ```
275
+
276
+ We provide comprehensive guidance on how to set configurations, you can see our [<u>configuration guidance</u>](./docs/configuration.md).
277
+ You can also refer to the [<u>basic yaml file</u>](./flashrag/config/basic_config.yaml) we provide to set your own parameters.
278
+
279
+ Next, load the corresponding dataset and initialize the pipeline. The components in the pipeline will be automatically loaded.
280
+
281
+ ```python
282
+ from flashrag.utils import get_dataset
283
+ from flashrag.pipeline import SequentialPipeline
284
+ from flashrag.prompt import PromptTemplate
285
+ from flashrag.config import Config
286
+
287
+ config_dict = {'data_dir': 'dataset/'}
288
+ my_config = Config(config_file_path = 'my_config.yaml',
289
+ config_dict = config_dict)
290
+ all_split = get_dataset(my_config)
291
+ test_data = all_split['test']
292
+
293
+ pipeline = SequentialPipeline(my_config)
294
+ ```
295
+
296
+ You can specify your own input prompt using `PromptTemplete`:
297
+ ```python
298
+ prompt_templete = PromptTemplate(
299
+ config,
300
+ system_prompt = "Answer the question based on the given document. Only give me the answer and do not output any other words.\nThe following are given documents.\n\n{reference}",
301
+ user_prompt = "Question: {question}\nAnswer:"
302
+ )
303
+ pipeline = SequentialPipeline(my_config, prompt_template=prompt_templete)
304
+ ```
305
+
306
+ Finally, execute `pipeline.run` to obtain the final result.
307
+
308
+ ```python
309
+ output_dataset = pipeline.run(test_data, do_eval=True)
310
+ ```
311
+ The `output_dataset` contains the intermediate results and metric scores for each item in the input dataset.
312
+ Meanwhile, the dataset with intermediate results and the overall evaluation score will also be saved as a file (if `save_intermediate_data` and `save_metric_score` are specified).
313
+
314
+ ### Build your own pipeline
315
+
316
+ Sometimes you may need to implement more complex RAG process, and you can build your own pipeline to implement it.
317
+ You just need to inherit `BasicPipeline`, initialize the components you need, and complete the `run` function.
318
+
319
+ ```python
320
+ from flashrag.pipeline import BasicPipeline
321
+ from flashrag.utils import get_retriever, get_generator
322
+
323
+ class ToyPipeline(BasicPipeline):
324
+ def __init__(self, config, prompt_templete=None):
325
+ # Load your own components
326
+ pass
327
+
328
+ def run(self, dataset, do_eval=True):
329
+ # Complete your own process logic
330
+
331
+ # get attribute in dataset using `.`
332
+ input_query = dataset.question
333
+ ...
334
+ # use `update_output` to save intermeidate data
335
+ dataset.update_output("pred",pred_answer_list)
336
+ dataset = self.evaluate(dataset, do_eval=do_eval)
337
+ return dataset
338
+ ```
339
+
340
+ Please first understand the input and output forms of the components you need to use from our [<u>documentation</u>](./docs/basic_usage.md).
341
+
342
+
343
+ ### Just use components
344
+
345
+ 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.
346
+
347
+ ## :gear: Components
348
+
349
+ In FlashRAG, we have built a series of common RAG components, including retrievers, generators, refiners, and more. Based on these components, we have assembled several pipelines to implement the RAG workflow, while also providing the flexibility to combine these components in custom arrangements to create your own pipeline.
350
+
351
+ #### RAG-Components
352
+
353
+ <table>
354
+ <thead>
355
+ <tr>
356
+ <th>Type</th>
357
+ <th>Module</th>
358
+ <th>Description</th>
359
+ </tr>
360
+ </thead>
361
+ <tbody>
362
+ <tr>
363
+ <td rowspan="1">Judger</td>
364
+ <td>SKR Judger</td>
365
+ <td>Judging whether to retrieve using <a href="https://aclanthology.org/2023.findings-emnlp.691.pdf">SKR</a> method</td>
366
+ </tr>
367
+ <tr>
368
+ <td rowspan="4">Retriever</td>
369
+ <td>Dense Retriever</td>
370
+ <td>Bi-encoder models such as dpr, bge, e5, using faiss for search</td>
371
+ </tr>
372
+ <tr>
373
+ <td>BM25 Retriever</td>
374
+ <td>Sparse retrieval method based on Lucene</td>
375
+ </tr>
376
+ <tr>
377
+ <td>Bi-Encoder Reranker</td>
378
+ <td>Calculate matching score using bi-Encoder</td>
379
+ </tr>
380
+ <tr>
381
+ <td>Cross-Encoder Reranker</td>
382
+ <td>Calculate matching score using cross-encoder</td>
383
+ </tr>
384
+ <tr>
385
+ <td rowspan="5">Refiner</td>
386
+ <td>Extractive Refiner</td>
387
+ <td>Refine input by extracting important context</td>
388
+ </tr>
389
+ <tr>
390
+ <td>Abstractive Refiner</td>
391
+ <td>Refine input through seq2seq model</td>
392
+ </tr>
393
+ <tr>
394
+ <td>LLMLingua Refiner</td>
395
+ <td><a href="https://aclanthology.org/2023.emnlp-main.825/">LLMLingua-series</a> prompt compressor</td>
396
+ </tr>
397
+ <tr>
398
+ <td>SelectiveContext Refiner</td>
399
+ <td><a href="https://arxiv.org/abs/2310.06201">Selective-Context</a> prompt compressor</td>
400
+ </tr>
401
+ <tr>
402
+ <td> KG Refiner </td>
403
+ <td>Use <a hred='https://arxiv.org/abs/2406.11460'>Trace method to construct a knowledge graph</td>
404
+ <tr>
405
+ <td rowspan="4">Generator</td>
406
+ <td>Encoder-Decoder Generator</td>
407
+ <td>Encoder-Decoder model, supporting <a href="https://arxiv.org/abs/2007.01282">Fusion-in-Decoder (FiD)</a></td>
408
+ </tr>
409
+ <tr>
410
+ <td>Decoder-only Generator</td>
411
+ <td>Native transformers implementation</td>
412
+ </tr>
413
+ <tr>
414
+ <td>FastChat Generator</td>
415
+ <td>Accelerate with <a href="https://github.com/lm-sys/FastChat">FastChat</a></td>
416
+ </tr>
417
+ <tr>
418
+ <td>vllm Generator</td>
419
+ <td>Accelerate with <a href="https://github.com/vllm-project/vllm">vllm</a></td>
420
+ </tr>
421
+ </tbody>
422
+ </table>
423
+
424
+ #### Pipelines
425
+
426
+ Referring to a [<u>survey on retrieval-augmented generation</u>](https://arxiv.org/abs/2312.10997), we categorized RAG methods into four types based on their inference paths.
427
+
428
+ - **Sequential**: Sequential execuation of RAG process, like Query-(pre-retrieval)-retriever-(post-retrieval)-generator
429
+ - **Conditional**: Implements different paths for different types of input queries
430
+ - **Branching** : Executes multiple paths in parallel, merging the responses from each path
431
+ - **Loop**: Iteratively performs retrieval and generation
432
+
433
+ In each category, we have implemented corresponding common pipelines. Some pipelines have corresponding work papers.
434
+
435
+ <table>
436
+ <thead>
437
+ <tr>
438
+ <th>Type</th>
439
+ <th>Module</th>
440
+ <th>Description</th>
441
+ </tr>
442
+ </thead>
443
+ <tbody>
444
+ <tr>
445
+ <td rowspan="1">Sequential</td>
446
+ <td>Sequential Pipeline</td>
447
+ <td>Linear execution of query, supporting refiner, reranker</td>
448
+ </tr>
449
+ <tr>
450
+ <td rowspan="1">Conditional</td>
451
+ <td>Conditional Pipeline</td>
452
+ <td>With a judger module, distinct execution paths for various query types</td>
453
+ </tr>
454
+ <tr>
455
+ <td rowspan="2">Branching</td>
456
+ <td>REPLUG Pipeline</td>
457
+ <td>Generate answer by integrating probabilities in multiple generation paths</td>
458
+ </tr>
459
+ <td>SuRe Pipeline</td>
460
+ <td>Ranking and merging generated results based on each document</td>
461
+ </tr>
462
+ <tr>
463
+ <td rowspan="5">Loop</td>
464
+ <td>Iterative Pipeline</td>
465
+ <td>Alternating retrieval and generation</td>
466
+ </tr>
467
+ <tr>
468
+ <td>Self-Ask Pipeline</td>
469
+ <td>Decompose complex problems into subproblems using <a href="https://arxiv.org/abs/2210.03350">self-ask</a> </td>
470
+ </tr>
471
+ <tr>
472
+ <td>Self-RAG Pipeline</td>
473
+ <td>Adaptive retrieval, critique, and generation</td>
474
+ </tr>
475
+ <tr>
476
+ <td>FLARE Pipeline</td>
477
+ <td>Dynamic retrieval during the generation process</td>
478
+ </tr>
479
+ <tr>
480
+ <td>IRCoT Pipeline</td>
481
+ <td>Integrate retrieval process with CoT</td>
482
+ </tr>
483
+ </tbody>
484
+ </table>
485
+
486
+
487
+ ## :robot: Supporting Methods
488
+
489
+ We have implemented 15 works with a consistent setting of:
490
+ - **Generator:** LLAMA3-8B-instruct with input length of 2048
491
+ - **Retriever:** e5-base-v2 as embedding model, retrieve 5 docs per query
492
+ - **Prompt:** A consistent default prompt, template can be found in the [<u>method details</u>](./docs/baseline_details.md).
493
+
494
+ 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.
495
+
496
+ 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).
497
+
498
+ 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.
499
+
500
+
501
+ | Method | Type | NQ (EM) | TriviaQA (EM) | Hotpotqa (F1) | 2Wiki (F1)| PopQA (F1)| WebQA(EM) | Specific setting |
502
+ |----------------------|----------------|---------|---------------|---------------|---------------|---------------|---------------|------------------------------------------------------------------------------------|
503
+ | Naive Generation | Sequential | 22.6 | 55.7 | 28.4 | 33.9| 21.7| 18.8| |
504
+ | Standard RAG | Sequential | 35.1 | 58.9 | 35.3 | 21.0 | 36.7|15.7| |
505
+ | [AAR-contriever-kilt](https://aclanthology.org/2023.acl-long.136.pdf) | Sequential | 30.1 | 56.8 | 33.4 | 19.8 | 36.1 | 16.1| |
506
+ | [LongLLMLingua](https://arxiv.org/abs/2310.06839) | Sequential | 32.2 | 59.2 | 37.5 |25.0| 38.7| 17.5| Compress Ratio=0.5 |
507
+ | [RECOMP-abstractive](https://arxiv.org/pdf/2310.04408) | Sequential | 33.1 | 56.4 | 37.5 | 32.4 | 39.9| 20.2| |
508
+ | [Selective-Context](https://arxiv.org/abs/2310.06201) | Sequential | 30.5 | 55.6 | 34.4 |18.5| 33.5| 17.3| Compress Ratio=0.5|
509
+ | [Trace](https://arxiv.org/abs/2406.11460) | Sequential | 30.7 | 50.2 | 34.0 | 15.5 | 37.4 | 19.9 | |
510
+ | [Spring](https://arxiv.org/abs/2405.19670) | Sequential | 37.9 | 64.6 |42.6 | 37.3 |54.8 |27.7 | Use Llama2-7B-chat with trained embedding table |
511
+ | [SuRe](https://arxiv.org/abs/2404.13081) | Branching | 37.1 | 53.2 | 33.4 |20.6|48.1|24.2| Use provided prompt|
512
+ | [REPLUG](https://arxiv.org/abs/2301.12652) | Branching | 28.9 | 57.7 | 31.2 |21.1|27.8|20.2| |
513
+ | [SKR](https://aclanthology.org/2023.findings-emnlp.691.pdf) | Conditional | 33.2 | 56.0 | 32.4 | 23.4 |31.7|17.0|Use infernece-time training data|
514
+ |[Adaptive-RAG](https://aclanthology.org/2024.naacl-long.389.pdf) | Conditional | 35.1 | 56.6 | 39.1 | 28.4 | 40.4 | 16.0| |
515
+ | [Ret-Robust](https://arxiv.org/abs/2310.01558) | Loop | 42.9 | 68.2 | 35.8 |43.4|57.2|33.7| Use LLAMA2-13B with trained lora|
516
+ | [Self-RAG](https://arxiv.org/abs/2310.11511) | Loop | 36.4 | 38.2 | 29.6 | 25.1|32.7|21.9| Use trained selfrag-llama2-7B|
517
+ | [FLARE](https://arxiv.org/abs/2305.06983) | Loop | 22.5 | 55.8 | 28.0 |33.9| 20.7| 20.2| |
518
+ | [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| |
519
+ | [IRCoT](https://aclanthology.org/2023.acl-long.557.pdf) | Loop | 33.3| 56.9|41.5|32.4 |45.6 |20.7 | |
520
+
521
+
522
+ ## :notebook: Supporting Datasets & Document Corpus
523
+
524
+ ### Datasets
525
+
526
+ We have collected and processed 35 datasets widely used in RAG research, pre-processing them to ensure a consistent format for ease of use. For certain datasets (such as Wiki-asp), we have adapted them to fit the requirements of RAG tasks according to the methods commonly used within the community. All datasets are available at [<u>Huggingface datasets</u>](https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets).
527
+
528
+ For each dataset, we save each split as a `jsonl` file, and each line is a dict as follows:
529
+ ```python
530
+ {
531
+ 'id': str,
532
+ 'question': str,
533
+ 'golden_answers': List[str],
534
+ 'metadata': dict
535
+ }
536
+ ```
537
+
538
+
539
+ Below is the list of datasets along with the corresponding sample sizes:
540
+
541
+ | Task | Dataset Name | Knowledge Source | # Train | # Dev | # Test |
542
+ |---------------------------|-----------------|------------------|-----------|---------|--------|
543
+ | QA | NQ | wiki | 79,168 | 8,757 | 3,610 |
544
+ | QA | TriviaQA | wiki & web | 78,785 | 8,837 | 11,313 |
545
+ | QA | PopQA | wiki | / | / | 14,267 |
546
+ | QA | SQuAD | wiki | 87,599 | 10,570 | / |
547
+ | QA | MSMARCO-QA | web | 808,731 | 101,093 | / |
548
+ | QA | NarrativeQA | books and story | 32,747 | 3,461 | 10,557 |
549
+ | QA | WikiQA | wiki | 20,360 | 2,733 | 6,165 |
550
+ | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
551
+ | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
552
+ | QA | SIQA | - | 33,410 | 1,954 | / |
553
+ | QA | CommenseQA | - | 9,741 | 1,221 | / |
554
+ | QA | BoolQ | wiki | 9,427 | 3,270 | / |
555
+ | QA | PIQA | - | 16,113 | 1,838 | / |
556
+ | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
557
+ | multi-hop QA | HotpotQA | wiki | 90,447 | 7,405 | / |
558
+ | multi-hop QA | 2WikiMultiHopQA | wiki | 15,000 | 12,576 | / |
559
+ | multi-hop QA | Musique | wiki | 19,938 | 2,417 | / |
560
+ | multi-hop QA | Bamboogle | wiki | / | / | 125 |
561
+ | Long-form QA | ASQA | wiki | 4,353 | 948 | / |
562
+ | Long-form QA | ELI5 | Reddit | 272,634 | 1,507 | / |
563
+ | Open-Domain Summarization | WikiASP | wiki | 300,636 | 37,046 | 37,368 |
564
+ | multiple-choice | MMLU | - | 99,842 | 1,531 | 14,042 |
565
+ | multiple-choice | TruthfulQA | wiki | / | 817 | / |
566
+ | multiple-choice | HellaSWAG | ActivityNet | 39,905 | 10,042 | / |
567
+ | multiple-choice | ARC | - | 3,370 | 869 | 3,548 |
568
+ | multiple-choice | OpenBookQA | - | 4,957 | 500 | 500 |
569
+ | Fact Verification | FEVER | wiki | 104,966 | 10,444 | / |
570
+ | Dialog Generation | WOW | wiki | 63,734 | 3,054 | / |
571
+ | Entity Linking | AIDA CoNll-yago | Freebase & wiki | 18,395 | 4,784 | / |
572
+ | Entity Linking | WNED | Wiki | / | 8,995 | / |
573
+ | Slot Filling | T-REx | DBPedia | 2,284,168 | 5,000 | / |
574
+ | Slot Filling | Zero-shot RE | wiki | 147,909 | 3,724 | / |
575
+ | In-domain QA| DomainRAG | Web pages of RUC| / | / | 485|
576
+
577
+ ### Document Corpus
578
+
579
+ Our toolkit supports jsonl format for retrieval document collections, with the following structure:
580
+
581
+ ```jsonl
582
+ {"id":"0", "contents": "...."}
583
+ {"id":"1", "contents": "..."}
584
+ ```
585
+ 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.
586
+
587
+ 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.
588
+
589
+
590
+ 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.
591
+
592
+
593
+ ## :raised_hands: Additional FAQs
594
+
595
+ - [How should I set different experimental parameters?](./docs/configuration.md)
596
+ - [How to build my own corpus, such as a specific segmented Wikipedia?](./docs/process-wiki.md)
597
+ - [How to index my own corpus?](./docs/building-index.md)
598
+ - [How to reproduce supporting methods?](./docs/reproduce_experiment.md)
599
+
600
+ ## :bookmark: License
601
+
602
+ FlashRAG is licensed under the [<u>MIT License</u>](./LICENSE).
603
+
604
+ ## :star2: Citation
605
+ Please kindly cite our paper if helps your research:
606
+ ```BibTex
607
+ @article{FlashRAG,
608
+ author={Jiajie Jin and
609
+ Yutao Zhu and
610
+ Xinyu Yang and
611
+ Chenghao Zhang and
612
+ Zhicheng Dou},
613
+ title={FlashRAG: A Modular Toolkit for Efficient Retrieval-Augmented Generation Research},
614
+ journal={CoRR},
615
+ volume={abs/2405.13576},
616
+ year={2024},
617
+ url={https://arxiv.org/abs/2405.13576},
618
+ eprinttype={arXiv},
619
+ eprint={2405.13576}
620
+ }
621
+ ```