flashrag-dev 0.1.1__tar.gz → 0.1.2.dev20241101__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.
- {flashrag_dev-0.1.1/flashrag_dev.egg-info → flashrag-dev-0.1.2.dev20241101}/PKG-INFO +13 -64
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/README.md +10 -4
- flashrag-dev-0.1.2.dev20241101/flashrag/config/basic_config.yaml +104 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/config/config.py +2 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/generator/generator.py +5 -3
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/pipeline/active_pipeline.py +0 -1
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/pipeline/branching_pipeline.py +0 -1
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/pipeline/pipeline.py +0 -1
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/prompt/base_prompt.py +44 -7
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/refiner/refiner.py +2 -2
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/retriever/encoder.py +10 -50
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/retriever/index_builder.py +46 -25
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/retriever/retriever.py +15 -7
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/retriever/utils.py +49 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/utils/utils.py +3 -1
- flashrag-dev-0.1.2.dev20241101/flashrag/version.py +1 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101/flashrag_dev.egg-info}/PKG-INFO +13 -64
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag_dev.egg-info/SOURCES.txt +2 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag_dev.egg-info/requires.txt +2 -2
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/setup.py +7 -4
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/LICENSE +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/config/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/dataset/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/dataset/dataset.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/dataset/utils.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/evaluator/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/evaluator/_bleu.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/evaluator/evaluator.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/evaluator/metrics.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/evaluator/utils.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/generator/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/generator/fid.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/generator/openai_generator.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/generator/stop_word_criteria.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/judger/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/judger/judger.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/pipeline/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/pipeline/replug_utils.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/prompt/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/prompt/selfask_examplars.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/prompt/trace_examplars.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/refiner/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/refiner/kg_refiner.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/refiner/llmlingua_compressor.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/refiner/selective_context_compressor.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/retriever/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/retriever/__main__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/retriever/reranker.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/utils/__init__.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/utils/constants.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/utils/pred_parse.py +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag_dev.egg-info/dependency_links.txt +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag_dev.egg-info/top_level.txt +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/pyproject.toml +0 -0
- {flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/setup.cfg +0 -0
|
@@ -1,75 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flashrag-dev
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2.dev20241101
|
|
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
|
|
7
7
|
Author-email: jinjiajie@ruc.edu.cn
|
|
8
8
|
License: MIT License
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
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
11
|
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
12
|
Provides-Extra: retriever
|
|
48
|
-
Requires-Dist: pyserini; extra == "retriever"
|
|
49
|
-
Requires-Dist: sentence-transformers>=3.0.1; extra == "retriever"
|
|
50
13
|
Provides-Extra: generator
|
|
51
|
-
Requires-Dist: vllm>=0.4.1; extra == "generator"
|
|
52
14
|
Provides-Extra: full
|
|
53
|
-
|
|
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"
|
|
15
|
+
License-File: LICENSE
|
|
73
16
|
|
|
74
17
|
# <div align="center">⚡FlashRAG: A Python Toolkit for Efficient RAG Research<div>
|
|
75
18
|
|
|
@@ -94,7 +37,7 @@ Requires-Dist: vllm>=0.4.1; extra == "full"
|
|
|
94
37
|
</p>
|
|
95
38
|
|
|
96
39
|
</h4>
|
|
97
|
-
FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes
|
|
40
|
+
FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 33 pre-processed benchmark RAG datasets and 15 state-of-the-art RAG algorithms.
|
|
98
41
|
|
|
99
42
|
<p align="center">
|
|
100
43
|
<img src="asset/framework.jpg">
|
|
@@ -110,7 +53,7 @@ With FlashRAG and provided resources, you can effortlessly reproduce existing SO
|
|
|
110
53
|
|
|
111
54
|
- **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
55
|
|
|
113
|
-
- **Comprehensive Benchmark Datasets**: A collection of
|
|
56
|
+
- **Comprehensive Benchmark Datasets**: A collection of 33 pre-processed RAG benchmark datasets to test and validate RAG models' performances.
|
|
114
57
|
|
|
115
58
|
- **Pre-implemented Advanced RAG Algorithms**: Features 15 advancing RAG algorithms with reported results, based on our framework. Easily reproducing results under different settings.
|
|
116
59
|
|
|
@@ -123,7 +66,6 @@ With FlashRAG and provided resources, you can effortlessly reproduce existing SO
|
|
|
123
66
|
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
67
|
|
|
125
68
|
- [x] Support OpenAI models
|
|
126
|
-
- [ ] Support Claude and Gemini models
|
|
127
69
|
- [x] Provdide instructions for each component
|
|
128
70
|
- [x] Integrate sentence Transformers
|
|
129
71
|
- [ ] Inlcude more RAG approaches
|
|
@@ -132,6 +74,11 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
132
74
|
|
|
133
75
|
|
|
134
76
|
## :page_with_curl: Changelog
|
|
77
|
+
[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.
|
|
78
|
+
|
|
79
|
+
[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.
|
|
80
|
+
|
|
81
|
+
[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.
|
|
135
82
|
|
|
136
83
|
[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
84
|
|
|
@@ -165,7 +112,7 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
165
112
|
|
|
166
113
|
To get started with FlashRAG, you can simply install it with pip:
|
|
167
114
|
```base
|
|
168
|
-
pip install flashrag[core]
|
|
115
|
+
pip install flashrag-dev[core]
|
|
169
116
|
```
|
|
170
117
|
|
|
171
118
|
Or you can clone it from Github and install (requires Python 3.9+):
|
|
@@ -554,6 +501,7 @@ Below is the list of datasets along with the corresponding sample sizes:
|
|
|
554
501
|
| multi-hop QA | 2WikiMultiHopQA | wiki | 15,000 | 12,576 | / |
|
|
555
502
|
| multi-hop QA | Musique | wiki | 19,938 | 2,417 | / |
|
|
556
503
|
| multi-hop QA | Bamboogle | wiki | / | / | 125 |
|
|
504
|
+
| multi-hop QA | StrategyQA | wiki | 2290 | / | /
|
|
557
505
|
| Long-form QA | ASQA | wiki | 4,353 | 948 | / |
|
|
558
506
|
| Long-form QA | ELI5 | Reddit | 272,634 | 1,507 | / |
|
|
559
507
|
| Open-Domain Summarization | WikiASP | wiki | 300,636 | 37,046 | 37,368 |
|
|
@@ -568,6 +516,7 @@ Below is the list of datasets along with the corresponding sample sizes:
|
|
|
568
516
|
| Entity Linking | WNED | Wiki | / | 8,995 | / |
|
|
569
517
|
| Slot Filling | T-REx | DBPedia | 2,284,168 | 5,000 | / |
|
|
570
518
|
| Slot Filling | Zero-shot RE | wiki | 147,909 | 3,724 | / |
|
|
519
|
+
| In-domain QA| DomainRAG | Web pages of RUC| / | / | 485|
|
|
571
520
|
|
|
572
521
|
### Document Corpus
|
|
573
522
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
</h4>
|
|
24
|
-
FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes
|
|
24
|
+
FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 33 pre-processed benchmark RAG datasets and 15 state-of-the-art RAG algorithms.
|
|
25
25
|
|
|
26
26
|
<p align="center">
|
|
27
27
|
<img src="asset/framework.jpg">
|
|
@@ -37,7 +37,7 @@ With FlashRAG and provided resources, you can effortlessly reproduce existing SO
|
|
|
37
37
|
|
|
38
38
|
- **Extensive and Customizable Framework**: Includes essential components for RAG scenarios such as retrievers, rerankers, generators, and compressors, allowing for flexible assembly of complex pipelines.
|
|
39
39
|
|
|
40
|
-
- **Comprehensive Benchmark Datasets**: A collection of
|
|
40
|
+
- **Comprehensive Benchmark Datasets**: A collection of 33 pre-processed RAG benchmark datasets to test and validate RAG models' performances.
|
|
41
41
|
|
|
42
42
|
- **Pre-implemented Advanced RAG Algorithms**: Features 15 advancing RAG algorithms with reported results, based on our framework. Easily reproducing results under different settings.
|
|
43
43
|
|
|
@@ -50,7 +50,6 @@ With FlashRAG and provided resources, you can effortlessly reproduce existing SO
|
|
|
50
50
|
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.
|
|
51
51
|
|
|
52
52
|
- [x] Support OpenAI models
|
|
53
|
-
- [ ] Support Claude and Gemini models
|
|
54
53
|
- [x] Provdide instructions for each component
|
|
55
54
|
- [x] Integrate sentence Transformers
|
|
56
55
|
- [ ] Inlcude more RAG approaches
|
|
@@ -59,6 +58,11 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
59
58
|
|
|
60
59
|
|
|
61
60
|
## :page_with_curl: Changelog
|
|
61
|
+
[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.
|
|
62
|
+
|
|
63
|
+
[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.
|
|
64
|
+
|
|
65
|
+
[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.
|
|
62
66
|
|
|
63
67
|
[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.
|
|
64
68
|
|
|
@@ -92,7 +96,7 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
92
96
|
|
|
93
97
|
To get started with FlashRAG, you can simply install it with pip:
|
|
94
98
|
```base
|
|
95
|
-
pip install flashrag[core]
|
|
99
|
+
pip install flashrag-dev[core]
|
|
96
100
|
```
|
|
97
101
|
|
|
98
102
|
Or you can clone it from Github and install (requires Python 3.9+):
|
|
@@ -481,6 +485,7 @@ Below is the list of datasets along with the corresponding sample sizes:
|
|
|
481
485
|
| multi-hop QA | 2WikiMultiHopQA | wiki | 15,000 | 12,576 | / |
|
|
482
486
|
| multi-hop QA | Musique | wiki | 19,938 | 2,417 | / |
|
|
483
487
|
| multi-hop QA | Bamboogle | wiki | / | / | 125 |
|
|
488
|
+
| multi-hop QA | StrategyQA | wiki | 2290 | / | /
|
|
484
489
|
| Long-form QA | ASQA | wiki | 4,353 | 948 | / |
|
|
485
490
|
| Long-form QA | ELI5 | Reddit | 272,634 | 1,507 | / |
|
|
486
491
|
| Open-Domain Summarization | WikiASP | wiki | 300,636 | 37,046 | 37,368 |
|
|
@@ -495,6 +500,7 @@ Below is the list of datasets along with the corresponding sample sizes:
|
|
|
495
500
|
| Entity Linking | WNED | Wiki | / | 8,995 | / |
|
|
496
501
|
| Slot Filling | T-REx | DBPedia | 2,284,168 | 5,000 | / |
|
|
497
502
|
| Slot Filling | Zero-shot RE | wiki | 147,909 | 3,724 | / |
|
|
503
|
+
| In-domain QA| DomainRAG | Web pages of RUC| / | / | 485|
|
|
498
504
|
|
|
499
505
|
### Document Corpus
|
|
500
506
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# ------------------------------------------------Global Paths------------------------------------------------#
|
|
2
|
+
# Paths to various models
|
|
3
|
+
model2path:
|
|
4
|
+
e5: "intfloat/e5-base-v2"
|
|
5
|
+
bge: "intfloat/e5-base-v2"
|
|
6
|
+
contriever: "facebook/contriever"
|
|
7
|
+
llama2-7B-chat: "meta-llama/Llama-2-7b-chat-hf"
|
|
8
|
+
llama2-7B: "meta-llama/Llama-2-7b-hf"
|
|
9
|
+
llama2-13B: "meta-llama/Llama-2-13b-hf"
|
|
10
|
+
llama2-13B-chat: "meta-llama/Llama-2-13b-chat-hf"
|
|
11
|
+
|
|
12
|
+
# Pooling methods for each embedding model
|
|
13
|
+
model2pooling:
|
|
14
|
+
e5: "mean"
|
|
15
|
+
bge: "cls"
|
|
16
|
+
contriever: "mean"
|
|
17
|
+
jina: 'mean'
|
|
18
|
+
dpr: cls
|
|
19
|
+
|
|
20
|
+
# Indexes path for retrieval models
|
|
21
|
+
method2index:
|
|
22
|
+
e5: ~
|
|
23
|
+
bm25: ~
|
|
24
|
+
contriever: ~
|
|
25
|
+
|
|
26
|
+
# ------------------------------------------------Environment Settings------------------------------------------------#
|
|
27
|
+
# Directory paths for data and outputs
|
|
28
|
+
data_dir: "dataset/"
|
|
29
|
+
save_dir: "output/"
|
|
30
|
+
|
|
31
|
+
gpu_id: "0,1,2,3"
|
|
32
|
+
dataset_name: "nq" # name of the dataset in data_dir
|
|
33
|
+
split: ["test"] # dataset split to load (e.g. train,dev,test)
|
|
34
|
+
|
|
35
|
+
# Sampling configurations for testing
|
|
36
|
+
test_sample_num: ~ # number of samples to test (only work in dev/test split), if None, test all samples
|
|
37
|
+
random_sample: False # whether to randomly sample the test samples
|
|
38
|
+
|
|
39
|
+
# Seed for reproducibility
|
|
40
|
+
seed: 2024
|
|
41
|
+
|
|
42
|
+
# Whether save intermediate data
|
|
43
|
+
save_intermediate_data: True
|
|
44
|
+
save_note: 'experiment'
|
|
45
|
+
|
|
46
|
+
# -------------------------------------------------Retrieval Settings------------------------------------------------#
|
|
47
|
+
# If set the name, the model path will be find in global paths
|
|
48
|
+
retrieval_method: "e5" # name or path of the retrieval model.
|
|
49
|
+
retrieval_model_path: ~ # path to the retrieval model
|
|
50
|
+
index_path: ~ # set automatically if not provided.
|
|
51
|
+
faiss_gpu: False # whether use gpu to hold index
|
|
52
|
+
corpus_path: ~ # path to corpus in '.jsonl' format that store the documents
|
|
53
|
+
|
|
54
|
+
instruction: ~ # instruction for the retrieval model
|
|
55
|
+
retrieval_topk: 5 # number of retrieved documents
|
|
56
|
+
retrieval_batch_size: 256 # batch size for retrieval
|
|
57
|
+
retrieval_use_fp16: True # whether to use fp16 for retrieval model
|
|
58
|
+
retrieval_query_max_length: 128 # max length of the query
|
|
59
|
+
save_retrieval_cache: False # whether to save the retrieval cache
|
|
60
|
+
use_retrieval_cache: False # whether to use the retrieval cache
|
|
61
|
+
retrieval_cache_path: ~ # path to the retrieval cache
|
|
62
|
+
retrieval_pooling_method: ~ # set automatically if not provided
|
|
63
|
+
bm25_backend: bm25s # pyserini, bm25s
|
|
64
|
+
use_sentence_transformer: False
|
|
65
|
+
|
|
66
|
+
use_reranker: False # whether to use reranker
|
|
67
|
+
rerank_model_name: ~ # same as retrieval_method
|
|
68
|
+
rerank_model_path: ~ # path to reranker model, path will be automatically find in `model2path`
|
|
69
|
+
rerank_pooling_method: ~
|
|
70
|
+
rerank_topk: 5 # number of remain documents after reranking
|
|
71
|
+
rerank_max_length: 512
|
|
72
|
+
rerank_batch_size: 256 # batch size for reranker
|
|
73
|
+
rerank_use_fp16: True
|
|
74
|
+
|
|
75
|
+
# -------------------------------------------------Generator Settings------------------------------------------------#
|
|
76
|
+
framework: fschat # inference frame work of LLM, supporting: 'hf','vllm','fschat', 'openai'
|
|
77
|
+
generator_model: "llama3-8B-instruct" # name or path of the generator model
|
|
78
|
+
# setting for openai model, only valid in openai framework
|
|
79
|
+
openai_setting:
|
|
80
|
+
api_key: ~
|
|
81
|
+
base_url: ~
|
|
82
|
+
|
|
83
|
+
generator_model_path: ~
|
|
84
|
+
generator_max_input_len: 1024 # max length of the input
|
|
85
|
+
generator_batch_size: 4 # batch size for generation, invalid for vllm
|
|
86
|
+
generation_params:
|
|
87
|
+
#do_sample: false
|
|
88
|
+
max_tokens: 32
|
|
89
|
+
#temperature: 1.0
|
|
90
|
+
#top_p: 1.0
|
|
91
|
+
use_fid: False # whether to use FID, only valid in encoder-decoder model
|
|
92
|
+
gpu_memory_utilization: 0.85 # ratio of gpu's memory usage for generator
|
|
93
|
+
|
|
94
|
+
# -------------------------------------------------Evaluation Settings------------------------------------------------#
|
|
95
|
+
# Metrics to evaluate the result
|
|
96
|
+
metrics: ['em','f1','acc','precision','recall','input_tokens']
|
|
97
|
+
# Specify setting for metric, will be called within certain metrics
|
|
98
|
+
metric_setting:
|
|
99
|
+
retrieval_recall_topk: 5
|
|
100
|
+
tokenizer_name: 'gpt-4'
|
|
101
|
+
save_metric_score: True # whether to save the metric score into txt file
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
@@ -158,6 +158,8 @@ class Config:
|
|
|
158
158
|
refiner_model = self.final_config["refiner_name"]
|
|
159
159
|
if "refiner_model_path" not in self.final_config or self.final_config["refiner_model_path"] is None:
|
|
160
160
|
self.final_config["refiner_model_path"] = model2path.get(refiner_model, None)
|
|
161
|
+
if 'instruction' not in self.final_config or self.final_config['instruction'] is None:
|
|
162
|
+
self.final_config['instruction'] = ""
|
|
161
163
|
|
|
162
164
|
# set model path in metric setting
|
|
163
165
|
metric_setting = self.final_config["metric_setting"]
|
|
@@ -24,7 +24,7 @@ class BaseGenerator:
|
|
|
24
24
|
self.batch_size = config["generator_batch_size"]
|
|
25
25
|
self.device = config["device"]
|
|
26
26
|
self.gpu_num = torch.cuda.device_count()
|
|
27
|
-
|
|
27
|
+
self.config = config
|
|
28
28
|
self.generation_params = config["generation_params"]
|
|
29
29
|
|
|
30
30
|
def generate(self, input_list: list) -> List[str]:
|
|
@@ -217,8 +217,10 @@ class VLLMGenerator(BaseGenerator):
|
|
|
217
217
|
generation_params = deepcopy(self.generation_params)
|
|
218
218
|
generation_params.update(params)
|
|
219
219
|
if "do_sample" in generation_params:
|
|
220
|
-
generation_params.pop("do_sample")
|
|
221
|
-
|
|
220
|
+
do_sample_flag = generation_params.pop("do_sample")
|
|
221
|
+
if not do_sample_flag:
|
|
222
|
+
generation_params['temperature'] = 0
|
|
223
|
+
generation_params['seed'] = self.config['seed']
|
|
222
224
|
max_tokens = params.pop("max_tokens", None) or params.pop(
|
|
223
225
|
"max_new_tokens", None
|
|
224
226
|
)
|
{flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/pipeline/branching_pipeline.py
RENAMED
|
@@ -34,7 +34,6 @@ class REPLUGPipeline(BasicPipeline):
|
|
|
34
34
|
from flashrag.pipeline.replug_utils import REPLUGLogitsProcessor
|
|
35
35
|
|
|
36
36
|
input_query = dataset.question
|
|
37
|
-
|
|
38
37
|
retrieval_results, doc_scores = self.retriever.batch_search(input_query, return_score=True)
|
|
39
38
|
dataset.update_output("retrieval_result", retrieval_results)
|
|
40
39
|
dataset.update_output("doc_scores", doc_scores)
|
|
@@ -84,7 +84,6 @@ class SequentialPipeline(BasicPipeline):
|
|
|
84
84
|
|
|
85
85
|
def run(self, dataset, do_eval=True, pred_process_fun=None):
|
|
86
86
|
input_query = dataset.question
|
|
87
|
-
|
|
88
87
|
retrieval_results = self.retriever.batch_search(input_query)
|
|
89
88
|
dataset.update_output("retrieval_result", retrieval_results)
|
|
90
89
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from transformers import AutoTokenizer, AutoConfig
|
|
2
|
-
|
|
2
|
+
import tiktoken
|
|
3
3
|
|
|
4
4
|
class PromptTemplate:
|
|
5
5
|
placeholders = ["reference", "question"]
|
|
@@ -14,6 +14,7 @@ class PromptTemplate:
|
|
|
14
14
|
|
|
15
15
|
self.config = config
|
|
16
16
|
self.is_openai = config["framework"] == "openai"
|
|
17
|
+
self.max_input_len = config['generator_max_input_len']
|
|
17
18
|
if not self.is_openai:
|
|
18
19
|
self.generator_path = config["generator_model_path"]
|
|
19
20
|
model_config = AutoConfig.from_pretrained(self.generator_path, trust_remote_code=True)
|
|
@@ -21,10 +22,11 @@ class PromptTemplate:
|
|
|
21
22
|
self.is_chat = False
|
|
22
23
|
if "chat" in model_name or "instruct" in model_name:
|
|
23
24
|
self.is_chat = True
|
|
24
|
-
|
|
25
|
+
self.tokenizer = AutoTokenizer.from_pretrained(self.generator_path, trust_remote_code=True)
|
|
25
26
|
else:
|
|
26
27
|
self.is_chat = True
|
|
27
28
|
self.enable_chat = True
|
|
29
|
+
self.tokenizer = tiktoken.encoding_for_model("gpt-4o")
|
|
28
30
|
|
|
29
31
|
if len(system_prompt) == 0 and len(user_prompt) == 0:
|
|
30
32
|
system_prompt = self.base_system_prompt
|
|
@@ -48,26 +50,61 @@ class PromptTemplate:
|
|
|
48
50
|
if not flag and holder != "reference":
|
|
49
51
|
assert False
|
|
50
52
|
|
|
53
|
+
def truncate_prompt(self, prompt):
|
|
54
|
+
if self.is_openai:
|
|
55
|
+
truncated_messages = []
|
|
56
|
+
total_tokens = 0
|
|
57
|
+
assert isinstance(prompt, list)
|
|
58
|
+
for message in prompt:
|
|
59
|
+
role_content = message['content']
|
|
60
|
+
encoded_message = self.tokenizer.encode(role_content)
|
|
61
|
+
|
|
62
|
+
if total_tokens + len(encoded_message) <= self.max_input_len:
|
|
63
|
+
truncated_messages.append(message)
|
|
64
|
+
total_tokens += len(encoded_message)
|
|
65
|
+
else:
|
|
66
|
+
print(f"The input text length is greater than the maximum length ({total_tokens + len(encoded_message)} > {self.max_input_len}) and has been truncated!")
|
|
67
|
+
remaining_tokens = self.max_input_len - total_tokens
|
|
68
|
+
truncated_message = self.encoding.decode(encoded_message[:remaining_tokens])
|
|
69
|
+
message['content'] = truncated_message
|
|
70
|
+
truncated_messages.append(message)
|
|
71
|
+
break
|
|
72
|
+
|
|
73
|
+
return truncated_messages
|
|
74
|
+
|
|
75
|
+
else:
|
|
76
|
+
assert isinstance(prompt, str)
|
|
77
|
+
tokenized_prompt = self.tokenizer(prompt, truncation=False, return_tensors="pt").input_ids[0]
|
|
78
|
+
|
|
79
|
+
if len(tokenized_prompt) > self.max_input_len:
|
|
80
|
+
print(f"The input text length is greater than the maximum length ({len(tokenized_prompt)} > {self.max_input_len}) and has been truncated!")
|
|
81
|
+
half = int(self.max_input_len / 2)
|
|
82
|
+
prompt = self.tokenizer.decode(tokenized_prompt[:half], skip_special_tokens=True) + \
|
|
83
|
+
self.tokenizer.decode(tokenized_prompt[-half:], skip_special_tokens=True)
|
|
84
|
+
return prompt
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
51
88
|
def get_string(self, question=None, retrieval_result=None, formatted_reference=None, previous_gen=None, messages=None, **params):
|
|
52
89
|
if messages is not None:
|
|
53
90
|
if isinstance(messages, str):
|
|
54
|
-
return messages
|
|
91
|
+
return self.truncate_prompt(messages)
|
|
55
92
|
if self.is_chat and self.enable_chat:
|
|
56
93
|
if self.is_openai:
|
|
57
94
|
for item in input:
|
|
58
95
|
if item["role"] == "system":
|
|
59
96
|
item["role"] = "assistant"
|
|
60
|
-
|
|
97
|
+
self.truncate_prompt(messages)
|
|
61
98
|
else:
|
|
62
99
|
prompt = self.tokenizer.apply_chat_template(
|
|
63
100
|
messages, tokenize=False, add_generation_prompt=True
|
|
64
101
|
)
|
|
65
|
-
return prompt
|
|
102
|
+
return self.truncate_prompt(prompt)
|
|
66
103
|
else:
|
|
67
104
|
prompt = "\n\n".join(
|
|
68
105
|
[message['content'] for message in messages if message['content']]
|
|
69
106
|
)
|
|
70
|
-
return prompt
|
|
107
|
+
return self.truncate_prompt(prompt)
|
|
71
108
|
|
|
72
109
|
if formatted_reference is None:
|
|
73
110
|
if retrieval_result is not None:
|
|
@@ -99,7 +136,7 @@ class PromptTemplate:
|
|
|
99
136
|
if previous_gen is not None and previous_gen not in ["", " "] and self.is_openai is False:
|
|
100
137
|
input += previous_gen
|
|
101
138
|
|
|
102
|
-
return input
|
|
139
|
+
return self.truncate_prompt(input)
|
|
103
140
|
|
|
104
141
|
def get_string_with_varying_examplars(
|
|
105
142
|
self,
|
|
@@ -174,8 +174,8 @@ class ExtractiveRefiner(BaseRefiner):
|
|
|
174
174
|
|
|
175
175
|
flatten_batch_sents = sum(batch_sents, [])
|
|
176
176
|
sent_embs = []
|
|
177
|
-
for s_index in tqdm(range(0, len(flatten_batch_sents), self.
|
|
178
|
-
mini_batch_sents = flatten_batch_sents[s_index:s_index+self.
|
|
177
|
+
for s_index in tqdm(range(0, len(flatten_batch_sents), self.mini_batch_size), desc='Sentence encoding..,'):
|
|
178
|
+
mini_batch_sents = flatten_batch_sents[s_index:s_index+self.mini_batch_size]
|
|
179
179
|
mini_sent_embs = self.encoder.encode(mini_batch_sents, is_query=False)
|
|
180
180
|
sent_embs.append(mini_sent_embs)
|
|
181
181
|
sent_embs = np.concatenate(sent_embs, axis=0)
|
|
@@ -1,63 +1,23 @@
|
|
|
1
1
|
from typing import List
|
|
2
2
|
import torch
|
|
3
3
|
import numpy as np
|
|
4
|
-
from flashrag.retriever.utils import load_model, pooling
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def parse_query(model_name, query_list, is_query=True):
|
|
8
|
-
"""
|
|
9
|
-
processing query for different encoders
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
def is_zh(str):
|
|
13
|
-
import unicodedata
|
|
14
|
-
|
|
15
|
-
zh_char = 0
|
|
16
|
-
for c in str:
|
|
17
|
-
try:
|
|
18
|
-
if "CJK" in unicodedata.name(c):
|
|
19
|
-
zh_char += 1
|
|
20
|
-
except:
|
|
21
|
-
continue
|
|
22
|
-
if zh_char / len(str) > 0.2:
|
|
23
|
-
return True
|
|
24
|
-
else:
|
|
25
|
-
return False
|
|
26
|
-
|
|
27
|
-
if isinstance(query_list, str):
|
|
28
|
-
query_list = [query_list]
|
|
29
|
-
|
|
30
|
-
if "e5" in model_name.lower():
|
|
31
|
-
if is_query:
|
|
32
|
-
query_list = [f"query: {query}" for query in query_list]
|
|
33
|
-
else:
|
|
34
|
-
query_list = [f"passage: {query}" for query in query_list]
|
|
35
|
-
|
|
36
|
-
if "bge" in model_name.lower():
|
|
37
|
-
if is_query:
|
|
38
|
-
if is_zh(query_list[0]):
|
|
39
|
-
query_list = [f"为这个句子生成表示以用于检索相关文章:{query}" for query in query_list]
|
|
40
|
-
else:
|
|
41
|
-
query_list = [
|
|
42
|
-
f"Represent this sentence for searching relevant passages: {query}" for query in query_list
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
return query_list
|
|
4
|
+
from flashrag.retriever.utils import load_model, pooling, parse_query
|
|
46
5
|
|
|
47
6
|
|
|
48
7
|
class Encoder:
|
|
49
|
-
def __init__(self, model_name, model_path, pooling_method, max_length, use_fp16):
|
|
8
|
+
def __init__(self, model_name, model_path, pooling_method, max_length, use_fp16, instruction):
|
|
50
9
|
self.model_name = model_name
|
|
51
10
|
self.model_path = model_path
|
|
52
11
|
self.pooling_method = pooling_method
|
|
53
12
|
self.max_length = max_length
|
|
54
13
|
self.use_fp16 = use_fp16
|
|
14
|
+
self.instruction = instruction
|
|
55
15
|
|
|
56
16
|
self.model, self.tokenizer = load_model(model_path=model_path, use_fp16=use_fp16)
|
|
57
17
|
|
|
58
18
|
@torch.inference_mode(mode=True)
|
|
59
19
|
def encode(self, query_list: List[str], is_query=True) -> np.ndarray:
|
|
60
|
-
query_list = parse_query(self.model_name, query_list,
|
|
20
|
+
query_list = parse_query(self.model_name, query_list, self.instruction)
|
|
61
21
|
|
|
62
22
|
inputs = self.tokenizer(
|
|
63
23
|
query_list, max_length=self.max_length, padding=True, truncation=True, return_tensors="pt"
|
|
@@ -84,7 +44,7 @@ class Encoder:
|
|
|
84
44
|
|
|
85
45
|
|
|
86
46
|
class STEncoder:
|
|
87
|
-
def __init__(self, model_name, model_path, max_length, use_fp16):
|
|
47
|
+
def __init__(self, model_name, model_path, max_length, use_fp16, instruction):
|
|
88
48
|
import torch
|
|
89
49
|
from sentence_transformers import SentenceTransformer
|
|
90
50
|
|
|
@@ -92,16 +52,16 @@ class STEncoder:
|
|
|
92
52
|
self.model_path = model_path
|
|
93
53
|
self.max_length = max_length
|
|
94
54
|
self.use_fp16 = use_fp16
|
|
95
|
-
|
|
55
|
+
self.instruction = instruction
|
|
96
56
|
self.model = SentenceTransformer(
|
|
97
57
|
model_path, model_kwargs={"torch_dtype": torch.float16 if use_fp16 else torch.float}
|
|
98
58
|
)
|
|
99
59
|
|
|
100
60
|
@torch.inference_mode(mode=True)
|
|
101
61
|
def encode(self, query_list: List[str], batch_size=64, is_query=True) -> np.ndarray:
|
|
102
|
-
query_list = parse_query(self.model_name, query_list,
|
|
62
|
+
query_list = parse_query(self.model_name, query_list, self.instruction)
|
|
103
63
|
query_emb = self.model.encode(
|
|
104
|
-
query_list, batch_size=batch_size, convert_to_numpy=True, normalize_embeddings=True
|
|
64
|
+
query_list, batch_size=batch_size, convert_to_numpy=True, normalize_embeddings=True, show_progress_bar=True
|
|
105
65
|
)
|
|
106
66
|
query_emb = query_emb.astype(np.float32, order="C")
|
|
107
67
|
|
|
@@ -109,10 +69,10 @@ class STEncoder:
|
|
|
109
69
|
|
|
110
70
|
@torch.inference_mode(mode=True)
|
|
111
71
|
def multi_gpu_encode(self, query_list: List[str], is_query=True, batch_size=None) -> np.ndarray:
|
|
112
|
-
query_list = parse_query(self.model_name, query_list,
|
|
72
|
+
query_list = parse_query(self.model_name, query_list, self.instruction)
|
|
113
73
|
pool = self.model.start_multi_process_pool()
|
|
114
74
|
query_emb = self.model.encode_multi_process(
|
|
115
|
-
query_list, pool, convert_to_numpy=True, normalize_embeddings=True, batch_size=batch_size
|
|
75
|
+
query_list, pool, convert_to_numpy=True, normalize_embeddings=True, batch_size=batch_size,show_progress_bar=True
|
|
116
76
|
)
|
|
117
77
|
self.model.stop_multi_process_pool(pool)
|
|
118
78
|
query_emb.astype(np.float32, order="C")
|
|
@@ -10,7 +10,7 @@ import argparse
|
|
|
10
10
|
import datasets
|
|
11
11
|
import torch
|
|
12
12
|
from tqdm import tqdm
|
|
13
|
-
from flashrag.retriever.utils import load_model, load_corpus, pooling
|
|
13
|
+
from flashrag.retriever.utils import load_model, load_corpus, pooling, set_default_instruction
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class Index_Builder:
|
|
@@ -25,7 +25,8 @@ class Index_Builder:
|
|
|
25
25
|
max_length,
|
|
26
26
|
batch_size,
|
|
27
27
|
use_fp16,
|
|
28
|
-
pooling_method,
|
|
28
|
+
pooling_method=None,
|
|
29
|
+
instruction=None,
|
|
29
30
|
faiss_type=None,
|
|
30
31
|
embedding_path=None,
|
|
31
32
|
save_embedding=False,
|
|
@@ -41,7 +42,7 @@ class Index_Builder:
|
|
|
41
42
|
self.max_length = max_length
|
|
42
43
|
self.batch_size = batch_size
|
|
43
44
|
self.use_fp16 = use_fp16
|
|
44
|
-
self.
|
|
45
|
+
self.instruction = instruction
|
|
45
46
|
self.faiss_type = faiss_type if faiss_type is not None else "Flat"
|
|
46
47
|
self.embedding_path = embedding_path
|
|
47
48
|
self.save_embedding = save_embedding
|
|
@@ -49,6 +50,43 @@ class Index_Builder:
|
|
|
49
50
|
self.use_sentence_transformer = use_sentence_transformer
|
|
50
51
|
self.bm25_backend = bm25_backend
|
|
51
52
|
|
|
53
|
+
# set instruction for encode
|
|
54
|
+
if self.instruction is not None:
|
|
55
|
+
self.instruction = self.instruction.strip() + " "
|
|
56
|
+
print("Set instruction for encoding:", self.instruction)
|
|
57
|
+
else:
|
|
58
|
+
self.instruction = set_default_instruction(self.retrieval_method, is_query=False)
|
|
59
|
+
if self.instruction == "":
|
|
60
|
+
warnings.warn("Instruction is not set!")
|
|
61
|
+
else:
|
|
62
|
+
warnings.warn(f"Instruction is set to default: {self.instruction}")
|
|
63
|
+
|
|
64
|
+
#. config pooling method
|
|
65
|
+
if pooling_method is None:
|
|
66
|
+
try:
|
|
67
|
+
# read pooling method from 1_Pooling/config.json
|
|
68
|
+
pooling_config = json.load(open(os.path.join(self.model_path, "1_Pooling/config.json")))
|
|
69
|
+
for k, v in pooling_config.items():
|
|
70
|
+
if k.startswith("pooling_mode") and v == True:
|
|
71
|
+
pooling_method = k.split("pooling_mode_")[-1]
|
|
72
|
+
if pooling_method == 'mean_tokens':
|
|
73
|
+
pooling_method = 'mean'
|
|
74
|
+
elif pooling_method == 'cls_token':
|
|
75
|
+
pooling_method = 'cls'
|
|
76
|
+
else:
|
|
77
|
+
# raise warning: not implemented pooling method
|
|
78
|
+
warnings.warn(f"Pooling method {pooling_method} is not implemented.", UserWarning)
|
|
79
|
+
pooling_method = 'mean'
|
|
80
|
+
break
|
|
81
|
+
except:
|
|
82
|
+
print(f"Pooling method not found in {self.model_path}, use default pooling method (mean).")
|
|
83
|
+
# use default pooling method
|
|
84
|
+
pooling_method = 'mean'
|
|
85
|
+
else:
|
|
86
|
+
if pooling_method not in ['mean', 'cls', 'pooler']:
|
|
87
|
+
raise ValueError(f"Invalid pooling method {pooling_method}.")
|
|
88
|
+
self.pooling_method = pooling_method
|
|
89
|
+
|
|
52
90
|
self.gpu_num = torch.cuda.device_count()
|
|
53
91
|
# prepare save dir
|
|
54
92
|
print(self.save_dir)
|
|
@@ -162,8 +200,7 @@ class Index_Builder:
|
|
|
162
200
|
self.batch_size = self.batch_size * self.gpu_num
|
|
163
201
|
|
|
164
202
|
sentence_list = [item["contents"] for item in self.corpus]
|
|
165
|
-
|
|
166
|
-
sentence_list = [f"passage: {doc}" for doc in sentence_list]
|
|
203
|
+
sentence_list = [f"{self.instruction}{doc}" for doc in sentence_list]
|
|
167
204
|
all_embeddings = self.encoder.encode(sentence_list, batch_size=self.batch_size)
|
|
168
205
|
|
|
169
206
|
return all_embeddings
|
|
@@ -175,12 +212,9 @@ class Index_Builder:
|
|
|
175
212
|
self.batch_size = self.batch_size * self.gpu_num
|
|
176
213
|
|
|
177
214
|
all_embeddings = []
|
|
178
|
-
|
|
179
215
|
for start_idx in tqdm(range(0, len(self.corpus), self.batch_size), desc="Inference Embeddings:"):
|
|
180
216
|
batch_data = self.corpus[start_idx : start_idx + self.batch_size]["contents"]
|
|
181
|
-
|
|
182
|
-
if self.retrieval_method == "e5":
|
|
183
|
-
batch_data = [f"passage: {doc}" for doc in batch_data]
|
|
217
|
+
batch_data = [f"{self.instruction}{doc}" for doc in batch_data]
|
|
184
218
|
|
|
185
219
|
inputs = self.tokenizer(
|
|
186
220
|
batch_data,
|
|
@@ -273,9 +307,6 @@ class Index_Builder:
|
|
|
273
307
|
print("Finish!")
|
|
274
308
|
|
|
275
309
|
|
|
276
|
-
MODEL2POOLING = {"e5": "mean", "bge": "cls", "contriever": "mean", "jina": "mean"}
|
|
277
|
-
|
|
278
|
-
|
|
279
310
|
def main():
|
|
280
311
|
parser = argparse.ArgumentParser(description="Creating index.")
|
|
281
312
|
|
|
@@ -290,6 +321,7 @@ def main():
|
|
|
290
321
|
parser.add_argument("--batch_size", type=int, default=512)
|
|
291
322
|
parser.add_argument("--use_fp16", default=False, action="store_true")
|
|
292
323
|
parser.add_argument("--pooling_method", type=str, default=None)
|
|
324
|
+
parser.add_argument("--instruction", type=str, default=None)
|
|
293
325
|
parser.add_argument("--faiss_type", default=None, type=str)
|
|
294
326
|
parser.add_argument("--embedding_path", default=None, type=str)
|
|
295
327
|
parser.add_argument("--save_embedding", action="store_true", default=False)
|
|
@@ -299,18 +331,6 @@ def main():
|
|
|
299
331
|
|
|
300
332
|
args = parser.parse_args()
|
|
301
333
|
|
|
302
|
-
if args.pooling_method is None:
|
|
303
|
-
pooling_method = "mean"
|
|
304
|
-
for k, v in MODEL2POOLING.items():
|
|
305
|
-
if k in args.retrieval_method.lower():
|
|
306
|
-
pooling_method = v
|
|
307
|
-
break
|
|
308
|
-
else:
|
|
309
|
-
if args.pooling_method not in ["mean", "cls", "pooler"]:
|
|
310
|
-
raise NotImplementedError
|
|
311
|
-
else:
|
|
312
|
-
pooling_method = args.pooling_method
|
|
313
|
-
|
|
314
334
|
index_builder = Index_Builder(
|
|
315
335
|
retrieval_method=args.retrieval_method,
|
|
316
336
|
model_path=args.model_path,
|
|
@@ -319,7 +339,8 @@ def main():
|
|
|
319
339
|
max_length=args.max_length,
|
|
320
340
|
batch_size=args.batch_size,
|
|
321
341
|
use_fp16=args.use_fp16,
|
|
322
|
-
pooling_method=pooling_method,
|
|
342
|
+
pooling_method=args.pooling_method,
|
|
343
|
+
instruction=args.instruction,
|
|
323
344
|
faiss_type=args.faiss_type,
|
|
324
345
|
embedding_path=args.embedding_path,
|
|
325
346
|
save_embedding=args.save_embedding,
|
|
@@ -38,7 +38,7 @@ def cache_manager(func):
|
|
|
38
38
|
warnings.warn(f"The number of cached retrieval results is less than topk ({num})")
|
|
39
39
|
cache_res = cache_res[:num]
|
|
40
40
|
# separate the doc score
|
|
41
|
-
doc_scores = [item
|
|
41
|
+
doc_scores = [item["score"] for item in cache_res]
|
|
42
42
|
cache_results.append((cache_res, doc_scores))
|
|
43
43
|
else:
|
|
44
44
|
cache_results.append(None)
|
|
@@ -194,10 +194,10 @@ class BM25Retriever(BaseRetriever):
|
|
|
194
194
|
import Stemmer
|
|
195
195
|
import bm25s
|
|
196
196
|
|
|
197
|
-
stemmer = Stemmer.Stemmer('english')
|
|
197
|
+
self.stemmer = Stemmer.Stemmer('english')
|
|
198
198
|
self.searcher = bm25s.BM25.load(self.index_path, mmap=True, load_corpus=True)
|
|
199
199
|
self.searcher.backend = 'numba'
|
|
200
|
-
|
|
200
|
+
|
|
201
201
|
else:
|
|
202
202
|
assert False, 'Invalid bm25 backend!'
|
|
203
203
|
|
|
@@ -235,7 +235,8 @@ class BM25Retriever(BaseRetriever):
|
|
|
235
235
|
else:
|
|
236
236
|
results = load_docs(self.corpus, [hit.docid for hit in hits])
|
|
237
237
|
elif self.backend == 'bm25s':
|
|
238
|
-
|
|
238
|
+
import bm25s
|
|
239
|
+
query_tokens = bm25s.tokenize([query], stemmer=self.stemmer)
|
|
239
240
|
results, scores = self.searcher.retrieve(query_tokens, k=num)
|
|
240
241
|
results = results[0]
|
|
241
242
|
scores = scores[0]
|
|
@@ -257,7 +258,8 @@ class BM25Retriever(BaseRetriever):
|
|
|
257
258
|
results.append(item_result)
|
|
258
259
|
scores.append(item_score)
|
|
259
260
|
elif self.backend == 'bm25s':
|
|
260
|
-
|
|
261
|
+
import bm25s
|
|
262
|
+
query_tokens = bm25s.tokenize(query_list, stemmer=self.stemmer)
|
|
261
263
|
results, scores = self.searcher.retrieve(query_tokens, k=num)
|
|
262
264
|
else:
|
|
263
265
|
assert False, 'Invalid bm25 backend!'
|
|
@@ -273,6 +275,8 @@ class DenseRetriever(BaseRetriever):
|
|
|
273
275
|
|
|
274
276
|
def __init__(self, config: dict):
|
|
275
277
|
super().__init__(config)
|
|
278
|
+
if not os.path.exists(self.index_path):
|
|
279
|
+
raise Warning(f"Index file {self.index_path} does not exist!")
|
|
276
280
|
self.index = faiss.read_index(self.index_path)
|
|
277
281
|
if config["faiss_gpu"]:
|
|
278
282
|
co = faiss.GpuMultipleClonerOptions()
|
|
@@ -281,6 +285,9 @@ class DenseRetriever(BaseRetriever):
|
|
|
281
285
|
self.index = faiss.index_cpu_to_all_gpus(self.index, co=co)
|
|
282
286
|
|
|
283
287
|
self.corpus = load_corpus(self.corpus_path)
|
|
288
|
+
self.topk = config["retrieval_topk"]
|
|
289
|
+
self.batch_size = config["retrieval_batch_size"]
|
|
290
|
+
self.instruction = config["instruction"]
|
|
284
291
|
|
|
285
292
|
if config["use_sentence_transformer"]:
|
|
286
293
|
self.encoder = STEncoder(
|
|
@@ -288,6 +295,7 @@ class DenseRetriever(BaseRetriever):
|
|
|
288
295
|
model_path=config["retrieval_model_path"],
|
|
289
296
|
max_length=config["retrieval_query_max_length"],
|
|
290
297
|
use_fp16=config["retrieval_use_fp16"],
|
|
298
|
+
instruction=self.instruction,
|
|
291
299
|
)
|
|
292
300
|
else:
|
|
293
301
|
self.encoder = Encoder(
|
|
@@ -296,9 +304,9 @@ class DenseRetriever(BaseRetriever):
|
|
|
296
304
|
pooling_method=config["retrieval_pooling_method"],
|
|
297
305
|
max_length=config["retrieval_query_max_length"],
|
|
298
306
|
use_fp16=config["retrieval_use_fp16"],
|
|
307
|
+
instruction=self.instruction,
|
|
299
308
|
)
|
|
300
|
-
|
|
301
|
-
self.batch_size = self.config["retrieval_batch_size"]
|
|
309
|
+
|
|
302
310
|
|
|
303
311
|
def _search(self, query: str, num: int = None, return_score=False):
|
|
304
312
|
if num is None:
|
|
@@ -26,6 +26,55 @@ def pooling(pooler_output, last_hidden_state, attention_mask=None, pooling_metho
|
|
|
26
26
|
else:
|
|
27
27
|
raise NotImplementedError("Pooling method not implemented!")
|
|
28
28
|
|
|
29
|
+
def set_default_instruction(model_name, is_query=True, is_zh=False):
|
|
30
|
+
instruction = ""
|
|
31
|
+
if "e5" in model_name.lower():
|
|
32
|
+
if is_query:
|
|
33
|
+
instruction = "query: "
|
|
34
|
+
else:
|
|
35
|
+
instruction = "passage: "
|
|
36
|
+
|
|
37
|
+
if "bge" in model_name.lower():
|
|
38
|
+
if is_query:
|
|
39
|
+
if 'zh' in model_name.lower() or is_zh:
|
|
40
|
+
instruction = "为这个句子生成表示以用于检索相关文章:"
|
|
41
|
+
else:
|
|
42
|
+
instruction = "Represent this sentence for searching relevant passages: "
|
|
43
|
+
|
|
44
|
+
return instruction
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def parse_query(model_name, query_list, instruction=None):
|
|
48
|
+
"""
|
|
49
|
+
processing query for different encoders
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def is_zh(str):
|
|
53
|
+
import unicodedata
|
|
54
|
+
|
|
55
|
+
zh_char = 0
|
|
56
|
+
for c in str:
|
|
57
|
+
try:
|
|
58
|
+
if "CJK" in unicodedata.name(c):
|
|
59
|
+
zh_char += 1
|
|
60
|
+
except:
|
|
61
|
+
continue
|
|
62
|
+
if zh_char / len(str) > 0.2:
|
|
63
|
+
return True
|
|
64
|
+
else:
|
|
65
|
+
return False
|
|
66
|
+
|
|
67
|
+
if isinstance(query_list, str):
|
|
68
|
+
query_list = [query_list]
|
|
69
|
+
|
|
70
|
+
if instruction is not None:
|
|
71
|
+
instruction = instruction.strip() + " "
|
|
72
|
+
else:
|
|
73
|
+
instruction = set_default_instruction(model_name, is_query=True, is_zh=is_zh(query_list[0]))
|
|
74
|
+
|
|
75
|
+
query_list = [instruction + query for query in query_list]
|
|
76
|
+
|
|
77
|
+
return query_list
|
|
29
78
|
|
|
30
79
|
def load_corpus(corpus_path: str):
|
|
31
80
|
corpus = datasets.load_dataset("json", data_files=corpus_path, split="train")
|
|
@@ -101,7 +101,9 @@ def get_refiner(config, retriever=None, generator=None):
|
|
|
101
101
|
try:
|
|
102
102
|
model_config = AutoConfig.from_pretrained(refiner_path)
|
|
103
103
|
arch = model_config.architectures[0].lower()
|
|
104
|
-
|
|
104
|
+
print(arch)
|
|
105
|
+
except Exception as e:
|
|
106
|
+
print("Warning", e)
|
|
105
107
|
model_config, arch = "", ""
|
|
106
108
|
|
|
107
109
|
if "recomp" in refiner_name or "bert" in arch:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.2dev20241101"
|
|
@@ -1,75 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flashrag-dev
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2.dev20241101
|
|
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
|
|
7
7
|
Author-email: jinjiajie@ruc.edu.cn
|
|
8
8
|
License: MIT License
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
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
11
|
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
12
|
Provides-Extra: retriever
|
|
48
|
-
Requires-Dist: pyserini; extra == "retriever"
|
|
49
|
-
Requires-Dist: sentence-transformers>=3.0.1; extra == "retriever"
|
|
50
13
|
Provides-Extra: generator
|
|
51
|
-
Requires-Dist: vllm>=0.4.1; extra == "generator"
|
|
52
14
|
Provides-Extra: full
|
|
53
|
-
|
|
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"
|
|
15
|
+
License-File: LICENSE
|
|
73
16
|
|
|
74
17
|
# <div align="center">⚡FlashRAG: A Python Toolkit for Efficient RAG Research<div>
|
|
75
18
|
|
|
@@ -94,7 +37,7 @@ Requires-Dist: vllm>=0.4.1; extra == "full"
|
|
|
94
37
|
</p>
|
|
95
38
|
|
|
96
39
|
</h4>
|
|
97
|
-
FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes
|
|
40
|
+
FlashRAG is a Python toolkit for the reproduction and development of Retrieval Augmented Generation (RAG) research. Our toolkit includes 33 pre-processed benchmark RAG datasets and 15 state-of-the-art RAG algorithms.
|
|
98
41
|
|
|
99
42
|
<p align="center">
|
|
100
43
|
<img src="asset/framework.jpg">
|
|
@@ -110,7 +53,7 @@ With FlashRAG and provided resources, you can effortlessly reproduce existing SO
|
|
|
110
53
|
|
|
111
54
|
- **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
55
|
|
|
113
|
-
- **Comprehensive Benchmark Datasets**: A collection of
|
|
56
|
+
- **Comprehensive Benchmark Datasets**: A collection of 33 pre-processed RAG benchmark datasets to test and validate RAG models' performances.
|
|
114
57
|
|
|
115
58
|
- **Pre-implemented Advanced RAG Algorithms**: Features 15 advancing RAG algorithms with reported results, based on our framework. Easily reproducing results under different settings.
|
|
116
59
|
|
|
@@ -123,7 +66,6 @@ With FlashRAG and provided resources, you can effortlessly reproduce existing SO
|
|
|
123
66
|
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
67
|
|
|
125
68
|
- [x] Support OpenAI models
|
|
126
|
-
- [ ] Support Claude and Gemini models
|
|
127
69
|
- [x] Provdide instructions for each component
|
|
128
70
|
- [x] Integrate sentence Transformers
|
|
129
71
|
- [ ] Inlcude more RAG approaches
|
|
@@ -132,6 +74,11 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
132
74
|
|
|
133
75
|
|
|
134
76
|
## :page_with_curl: Changelog
|
|
77
|
+
[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.
|
|
78
|
+
|
|
79
|
+
[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.
|
|
80
|
+
|
|
81
|
+
[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.
|
|
135
82
|
|
|
136
83
|
[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
84
|
|
|
@@ -165,7 +112,7 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
165
112
|
|
|
166
113
|
To get started with FlashRAG, you can simply install it with pip:
|
|
167
114
|
```base
|
|
168
|
-
pip install flashrag[core]
|
|
115
|
+
pip install flashrag-dev[core]
|
|
169
116
|
```
|
|
170
117
|
|
|
171
118
|
Or you can clone it from Github and install (requires Python 3.9+):
|
|
@@ -554,6 +501,7 @@ Below is the list of datasets along with the corresponding sample sizes:
|
|
|
554
501
|
| multi-hop QA | 2WikiMultiHopQA | wiki | 15,000 | 12,576 | / |
|
|
555
502
|
| multi-hop QA | Musique | wiki | 19,938 | 2,417 | / |
|
|
556
503
|
| multi-hop QA | Bamboogle | wiki | / | / | 125 |
|
|
504
|
+
| multi-hop QA | StrategyQA | wiki | 2290 | / | /
|
|
557
505
|
| Long-form QA | ASQA | wiki | 4,353 | 948 | / |
|
|
558
506
|
| Long-form QA | ELI5 | Reddit | 272,634 | 1,507 | / |
|
|
559
507
|
| Open-Domain Summarization | WikiASP | wiki | 300,636 | 37,046 | 37,368 |
|
|
@@ -568,6 +516,7 @@ Below is the list of datasets along with the corresponding sample sizes:
|
|
|
568
516
|
| Entity Linking | WNED | Wiki | / | 8,995 | / |
|
|
569
517
|
| Slot Filling | T-REx | DBPedia | 2,284,168 | 5,000 | / |
|
|
570
518
|
| Slot Filling | Zero-shot RE | wiki | 147,909 | 3,724 | / |
|
|
519
|
+
| In-domain QA| DomainRAG | Web pages of RUC| / | / | 485|
|
|
571
520
|
|
|
572
521
|
### Document Corpus
|
|
573
522
|
|
|
@@ -4,17 +4,20 @@ with open("requirements.txt",encoding='utf-8') as fp:
|
|
|
4
4
|
requirements = fp.read().splitlines()
|
|
5
5
|
with open("README.md", "r",encoding='utf-8') as fh:
|
|
6
6
|
long_description = fh.read()
|
|
7
|
+
version = {}
|
|
8
|
+
with open("flashrag/version.py", encoding="utf8") as fp:
|
|
9
|
+
exec(fp.read(), version)
|
|
7
10
|
|
|
8
11
|
extras_require = {
|
|
9
12
|
'core': requirements,
|
|
10
13
|
'retriever': ['pyserini', 'sentence-transformers>=3.0.1'],
|
|
11
|
-
'generator': ['vllm
|
|
14
|
+
'generator': ['vllm==0.5.5']
|
|
12
15
|
}
|
|
13
16
|
extras_require['full'] = sum(extras_require.values(), [])
|
|
14
17
|
|
|
15
18
|
setup(
|
|
16
19
|
name="flashrag-dev",
|
|
17
|
-
version=
|
|
20
|
+
version=version['__version__'],
|
|
18
21
|
packages=find_packages(),
|
|
19
22
|
url="https://github.com/RUC-NLPIR/FlashRAG",
|
|
20
23
|
license="MIT License",
|
|
@@ -23,9 +26,9 @@ setup(
|
|
|
23
26
|
description="A library for efficient Retrieval-Augmented Generation research",
|
|
24
27
|
long_description=long_description,
|
|
25
28
|
long_description_content_type="text/markdown",
|
|
29
|
+
package_data={"": ["*.yaml"]},
|
|
26
30
|
include_package_data=True,
|
|
27
|
-
package_data={"flashrag-dev": ["/config/basic_config.yaml"]},
|
|
28
31
|
install_requires=extras_require['core'],
|
|
29
32
|
extras_require=extras_require,
|
|
30
|
-
python_requires=">=3.
|
|
33
|
+
python_requires=">=3.9",
|
|
31
34
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/generator/openai_generator.py
RENAMED
|
File without changes
|
{flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/generator/stop_word_criteria.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag/refiner/llmlingua_compressor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.1.1 → flashrag-dev-0.1.2.dev20241101}/flashrag_dev.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|