flashrag-dev 0.3.0.dev20250924__tar.gz → 0.3.0.dev20251106__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.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/PKG-INFO +97 -3
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/README.md +3 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/retriever.py +147 -0
- flashrag_dev-0.3.0.dev20251106/flashrag/version.py +1 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/PKG-INFO +98 -4
- flashrag_dev-0.3.0.dev20250924/flashrag/version.py +0 -1
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/LICENSE +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/config/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/config/basic_config.yaml +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/config/config.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/dataset/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/dataset/dataset.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/dataset/utils.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/_bleu.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/evaluator.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/metrics.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/utils.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/fid.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/generator.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/multimodal_generator.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/openai_generator.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/stop_word_criteria.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/utils.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/judger/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/judger/judger.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/ReaRAG_utils.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/active_pipeline.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/branching_pipeline.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/mm_pipeline.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/pipeline.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/reasoning_pipeline.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/replug_utils.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/base_prompt.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/coRAG_prompt.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/mm_prompt.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/selfask_examplars.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/trace_examplars.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/kg_refiner.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/llmlingua_compressor.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/refiner.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/selective_context_compressor.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/__main__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/encoder.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/index_builder.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/reranker.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/utils.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/utils/__init__.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/utils/constants.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/utils/pred_parse.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/utils/utils.py +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/SOURCES.txt +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/dependency_links.txt +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/requires.txt +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/top_level.txt +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/pyproject.toml +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/setup.cfg +0 -0
- {flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: flashrag_dev
|
|
3
|
-
Version: 0.3.0.
|
|
3
|
+
Version: 0.3.0.dev20251106
|
|
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
|
|
@@ -8,12 +8,103 @@ Author-email: jinjiajie@ruc.edu.cn
|
|
|
8
8
|
License: MIT License
|
|
9
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: langid
|
|
17
|
+
Requires-Dist: openai
|
|
18
|
+
Requires-Dist: peft
|
|
19
|
+
Requires-Dist: PyYAML
|
|
20
|
+
Requires-Dist: rank_bm25
|
|
21
|
+
Requires-Dist: rouge
|
|
22
|
+
Requires-Dist: spacy
|
|
23
|
+
Requires-Dist: tiktoken
|
|
24
|
+
Requires-Dist: torch
|
|
25
|
+
Requires-Dist: tqdm
|
|
26
|
+
Requires-Dist: transformers>=4.40.0
|
|
27
|
+
Requires-Dist: bm25s[core]==0.2.1
|
|
28
|
+
Requires-Dist: fschat
|
|
29
|
+
Requires-Dist: streamlit
|
|
30
|
+
Requires-Dist: chonkie<1.1.0,>=1.0.2
|
|
31
|
+
Requires-Dist: gradio>=5.0.0
|
|
32
|
+
Requires-Dist: rouge-chinese
|
|
33
|
+
Requires-Dist: jieba
|
|
11
34
|
Provides-Extra: core
|
|
35
|
+
Requires-Dist: datasets; extra == "core"
|
|
36
|
+
Requires-Dist: base58; extra == "core"
|
|
37
|
+
Requires-Dist: nltk; extra == "core"
|
|
38
|
+
Requires-Dist: numpy; extra == "core"
|
|
39
|
+
Requires-Dist: langid; extra == "core"
|
|
40
|
+
Requires-Dist: openai; extra == "core"
|
|
41
|
+
Requires-Dist: peft; extra == "core"
|
|
42
|
+
Requires-Dist: PyYAML; extra == "core"
|
|
43
|
+
Requires-Dist: rank_bm25; extra == "core"
|
|
44
|
+
Requires-Dist: rouge; extra == "core"
|
|
45
|
+
Requires-Dist: spacy; extra == "core"
|
|
46
|
+
Requires-Dist: tiktoken; extra == "core"
|
|
47
|
+
Requires-Dist: torch; extra == "core"
|
|
48
|
+
Requires-Dist: tqdm; extra == "core"
|
|
49
|
+
Requires-Dist: transformers>=4.40.0; extra == "core"
|
|
50
|
+
Requires-Dist: bm25s[core]==0.2.1; extra == "core"
|
|
51
|
+
Requires-Dist: fschat; extra == "core"
|
|
52
|
+
Requires-Dist: streamlit; extra == "core"
|
|
53
|
+
Requires-Dist: chonkie<1.1.0,>=1.0.2; extra == "core"
|
|
54
|
+
Requires-Dist: gradio>=5.0.0; extra == "core"
|
|
55
|
+
Requires-Dist: rouge-chinese; extra == "core"
|
|
56
|
+
Requires-Dist: jieba; extra == "core"
|
|
12
57
|
Provides-Extra: retriever
|
|
58
|
+
Requires-Dist: pyserini; extra == "retriever"
|
|
59
|
+
Requires-Dist: sentence-transformers>=3.0.1; extra == "retriever"
|
|
13
60
|
Provides-Extra: generator
|
|
61
|
+
Requires-Dist: vllm; extra == "generator"
|
|
14
62
|
Provides-Extra: multimodal
|
|
63
|
+
Requires-Dist: timm; extra == "multimodal"
|
|
64
|
+
Requires-Dist: torchvision; extra == "multimodal"
|
|
65
|
+
Requires-Dist: pillow; extra == "multimodal"
|
|
66
|
+
Requires-Dist: qwen_vl_utils; extra == "multimodal"
|
|
15
67
|
Provides-Extra: full
|
|
16
|
-
|
|
68
|
+
Requires-Dist: datasets; extra == "full"
|
|
69
|
+
Requires-Dist: base58; extra == "full"
|
|
70
|
+
Requires-Dist: nltk; extra == "full"
|
|
71
|
+
Requires-Dist: numpy; extra == "full"
|
|
72
|
+
Requires-Dist: langid; extra == "full"
|
|
73
|
+
Requires-Dist: openai; extra == "full"
|
|
74
|
+
Requires-Dist: peft; extra == "full"
|
|
75
|
+
Requires-Dist: PyYAML; extra == "full"
|
|
76
|
+
Requires-Dist: rank_bm25; extra == "full"
|
|
77
|
+
Requires-Dist: rouge; extra == "full"
|
|
78
|
+
Requires-Dist: spacy; extra == "full"
|
|
79
|
+
Requires-Dist: tiktoken; extra == "full"
|
|
80
|
+
Requires-Dist: torch; extra == "full"
|
|
81
|
+
Requires-Dist: tqdm; extra == "full"
|
|
82
|
+
Requires-Dist: transformers>=4.40.0; extra == "full"
|
|
83
|
+
Requires-Dist: bm25s[core]==0.2.1; extra == "full"
|
|
84
|
+
Requires-Dist: fschat; extra == "full"
|
|
85
|
+
Requires-Dist: streamlit; extra == "full"
|
|
86
|
+
Requires-Dist: chonkie<1.1.0,>=1.0.2; extra == "full"
|
|
87
|
+
Requires-Dist: gradio>=5.0.0; extra == "full"
|
|
88
|
+
Requires-Dist: rouge-chinese; extra == "full"
|
|
89
|
+
Requires-Dist: jieba; extra == "full"
|
|
90
|
+
Requires-Dist: pyserini; extra == "full"
|
|
91
|
+
Requires-Dist: sentence-transformers>=3.0.1; extra == "full"
|
|
92
|
+
Requires-Dist: vllm; extra == "full"
|
|
93
|
+
Requires-Dist: timm; extra == "full"
|
|
94
|
+
Requires-Dist: torchvision; extra == "full"
|
|
95
|
+
Requires-Dist: pillow; extra == "full"
|
|
96
|
+
Requires-Dist: qwen_vl_utils; extra == "full"
|
|
97
|
+
Dynamic: author
|
|
98
|
+
Dynamic: author-email
|
|
99
|
+
Dynamic: description
|
|
100
|
+
Dynamic: description-content-type
|
|
101
|
+
Dynamic: home-page
|
|
102
|
+
Dynamic: license
|
|
103
|
+
Dynamic: license-file
|
|
104
|
+
Dynamic: provides-extra
|
|
105
|
+
Dynamic: requires-dist
|
|
106
|
+
Dynamic: requires-python
|
|
107
|
+
Dynamic: summary
|
|
17
108
|
|
|
18
109
|
# <div align="center">⚡FlashRAG: A Python Toolkit for Efficient RAG Research<div>
|
|
19
110
|
\[ English | [中文](README_zh.md) \]
|
|
@@ -100,6 +191,8 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
100
191
|
- [ ] Add support for api-based retriever (vllm server)
|
|
101
192
|
|
|
102
193
|
## :page_with_curl: Changelog
|
|
194
|
+
[25/11/06] 🎯 NEW Retriever! We have integrated a Web Search Engine-based Retriever, which seamlessly integrates with existing methods and can be enabled quickly with just a Serper API key! This enhancement significantly expands retrieval coverage and real-time capability, supporting dynamic information access and external knowledge augmentation. Experience a more flexible and powerful retrieval workflow now!
|
|
195
|
+
|
|
103
196
|
[25/08/06] 🎯 **NEW!** We have added support for **Reasoning Pipeline**, which is a new paradigm that combines reasoning ability and retrieval, representing work that includes [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), [Search-R1](https://github.com/PeterGriffinJin/Search-R1),.... We evaluate the performance of the pipeline on various RAG benchmarks, it can achieve F1 scores close to 60 on multi hop inference datasets such as HotpotQA. See it in [**result table**](#robot-supporting-methods).
|
|
104
197
|
|
|
105
198
|
[25/03/21] 🚀 **Major Update!** We have expanded our toolkit to support **23 state-of-the-art RAG algorithms**, including **7 reasoning-based methods** that significantly improve performance on complex reasoning tasks. This represents a major milestone in our toolkit's evolution!
|
|
@@ -767,6 +860,7 @@ Please kindly cite our paper if helps your research:
|
|
|
767
860
|
}
|
|
768
861
|
```
|
|
769
862
|
|
|
863
|
+
|
|
770
864
|
## Star History
|
|
771
865
|
|
|
772
866
|
[](https://star-history.com/#RUC-NLPIR/FlashRAG&Date)
|
|
@@ -83,6 +83,8 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
83
83
|
- [ ] Add support for api-based retriever (vllm server)
|
|
84
84
|
|
|
85
85
|
## :page_with_curl: Changelog
|
|
86
|
+
[25/11/06] 🎯 NEW Retriever! We have integrated a Web Search Engine-based Retriever, which seamlessly integrates with existing methods and can be enabled quickly with just a Serper API key! This enhancement significantly expands retrieval coverage and real-time capability, supporting dynamic information access and external knowledge augmentation. Experience a more flexible and powerful retrieval workflow now!
|
|
87
|
+
|
|
86
88
|
[25/08/06] 🎯 **NEW!** We have added support for **Reasoning Pipeline**, which is a new paradigm that combines reasoning ability and retrieval, representing work that includes [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), [Search-R1](https://github.com/PeterGriffinJin/Search-R1),.... We evaluate the performance of the pipeline on various RAG benchmarks, it can achieve F1 scores close to 60 on multi hop inference datasets such as HotpotQA. See it in [**result table**](#robot-supporting-methods).
|
|
87
89
|
|
|
88
90
|
[25/03/21] 🚀 **Major Update!** We have expanded our toolkit to support **23 state-of-the-art RAG algorithms**, including **7 reasoning-based methods** that significantly improve performance on complex reasoning tasks. This represents a major milestone in our toolkit's evolution!
|
|
@@ -750,6 +752,7 @@ Please kindly cite our paper if helps your research:
|
|
|
750
752
|
}
|
|
751
753
|
```
|
|
752
754
|
|
|
755
|
+
|
|
753
756
|
## Star History
|
|
754
757
|
|
|
755
758
|
[](https://star-history.com/#RUC-NLPIR/FlashRAG&Date)
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/retriever.py
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
import time
|
|
4
|
+
import requests
|
|
4
5
|
|
|
5
6
|
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
6
7
|
import warnings
|
|
@@ -1141,3 +1142,149 @@ class SparseRetriever(BaseTextRetriever):
|
|
|
1141
1142
|
num_threads=int(self.cores)
|
|
1142
1143
|
)
|
|
1143
1144
|
return search_results
|
|
1145
|
+
|
|
1146
|
+
class SerperRetriever(BaseRetriever):
|
|
1147
|
+
"""Retriever based on Google Serper API for web search."""
|
|
1148
|
+
|
|
1149
|
+
def __init__(self, config):
|
|
1150
|
+
super().__init__(config)
|
|
1151
|
+
|
|
1152
|
+
# Serper API specific configuration
|
|
1153
|
+
self.api_key = config["serper_api_key"]
|
|
1154
|
+
if not self.api_key:
|
|
1155
|
+
raise ValueError("serper_api_key is required in config")
|
|
1156
|
+
|
|
1157
|
+
self.api_url = "https://google.serper.dev/search"
|
|
1158
|
+
self.search_type = config["serper_search_type"] if config["serper_search_type"] else "search" # search, news, images, etc.
|
|
1159
|
+
self.location = config["serper_location"] if config["serper_location"] else None # e.g., "United States"
|
|
1160
|
+
self.gl = config["serper_gl"] if config["serper_gl"] else None # Country code, e.g., "us"
|
|
1161
|
+
self.hl = config["serper_hl"] if config["serper_hl"] else "en" # Language, e.g., "en"
|
|
1162
|
+
|
|
1163
|
+
def _search(self, query: str, num: int) -> List[Dict[str, str]]:
|
|
1164
|
+
"""
|
|
1165
|
+
Retrieve top-k relevant documents using Google Serper API.
|
|
1166
|
+
|
|
1167
|
+
Args:
|
|
1168
|
+
query: Search query string
|
|
1169
|
+
num: Number of results to return
|
|
1170
|
+
return_score: Whether to return relevance scores
|
|
1171
|
+
|
|
1172
|
+
Returns:
|
|
1173
|
+
List of dictionaries containing search results with keys:
|
|
1174
|
+
- contents: The snippet/description
|
|
1175
|
+
- title: Page title
|
|
1176
|
+
- text: Full text (same as contents for web search)
|
|
1177
|
+
- url: Page URL
|
|
1178
|
+
- score: Relevance score (if return_score=True)
|
|
1179
|
+
"""
|
|
1180
|
+
headers = {
|
|
1181
|
+
'X-API-KEY': self.api_key,
|
|
1182
|
+
'Content-Type': 'application/json'
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
payload = {
|
|
1186
|
+
'q': query,
|
|
1187
|
+
'num': num,
|
|
1188
|
+
'hl': self.hl
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
if self.location:
|
|
1192
|
+
payload['location'] = self.location
|
|
1193
|
+
if self.gl:
|
|
1194
|
+
payload['gl'] = self.gl
|
|
1195
|
+
|
|
1196
|
+
try:
|
|
1197
|
+
response = requests.post(
|
|
1198
|
+
self.api_url,
|
|
1199
|
+
headers=headers,
|
|
1200
|
+
json=payload,
|
|
1201
|
+
timeout=30
|
|
1202
|
+
)
|
|
1203
|
+
response.raise_for_status()
|
|
1204
|
+
data = response.json()
|
|
1205
|
+
|
|
1206
|
+
results = []
|
|
1207
|
+
|
|
1208
|
+
# Parse organic results
|
|
1209
|
+
organic_results = data.get('organic', [])
|
|
1210
|
+
for idx, item in enumerate(organic_results[:num]):
|
|
1211
|
+
result = {
|
|
1212
|
+
'title': item.get('title', ''),
|
|
1213
|
+
'text': item.get('snippet', ''),
|
|
1214
|
+
'url': item.get('link', ''),
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
results.append(result)
|
|
1218
|
+
|
|
1219
|
+
return results
|
|
1220
|
+
|
|
1221
|
+
except requests.exceptions.RequestException as e:
|
|
1222
|
+
print(f"Error calling Serper API: {e}")
|
|
1223
|
+
return []
|
|
1224
|
+
except Exception as e:
|
|
1225
|
+
print(f"Unexpected error in _search: {e}")
|
|
1226
|
+
return []
|
|
1227
|
+
|
|
1228
|
+
def search(self, query: str, num: int = None) -> List[Dict[str, str]]:
|
|
1229
|
+
"""
|
|
1230
|
+
Single search wrapper for SerperRetriever.
|
|
1231
|
+
"""
|
|
1232
|
+
if num is None:
|
|
1233
|
+
num = self.topk
|
|
1234
|
+
return self._search(query, num)
|
|
1235
|
+
|
|
1236
|
+
def _batch_search(self, query_list: List[str], num: int) -> List[List[Dict[str, str]]]:
|
|
1237
|
+
"""
|
|
1238
|
+
Batch search for multiple queries.
|
|
1239
|
+
|
|
1240
|
+
Args:
|
|
1241
|
+
query_list: List of query strings
|
|
1242
|
+
num: Number of results per query
|
|
1243
|
+
return_score: Whether to return relevance scores
|
|
1244
|
+
|
|
1245
|
+
Returns:
|
|
1246
|
+
List of result lists, one for each query
|
|
1247
|
+
"""
|
|
1248
|
+
results = []
|
|
1249
|
+
if num is None:
|
|
1250
|
+
num = self.topk
|
|
1251
|
+
|
|
1252
|
+
for query in query_list:
|
|
1253
|
+
result = self._search(query, num)
|
|
1254
|
+
results.append(result)
|
|
1255
|
+
# Add a small delay to avoid rate limiting
|
|
1256
|
+
time.sleep(0.1)
|
|
1257
|
+
|
|
1258
|
+
return results
|
|
1259
|
+
|
|
1260
|
+
def batch_search(self, query_list: List[str], num: int = None):
|
|
1261
|
+
return self._batch_search(query_list, num)
|
|
1262
|
+
|
|
1263
|
+
def main():
|
|
1264
|
+
# Example configuration
|
|
1265
|
+
config = {
|
|
1266
|
+
# Base retriever config
|
|
1267
|
+
"retrieval_method": "serper",
|
|
1268
|
+
"retrieval_topk": 10,
|
|
1269
|
+
"index_path": None, # Not used for Serper
|
|
1270
|
+
"corpus_path": None, # Not used for Serper
|
|
1271
|
+
"save_dir": "./output",
|
|
1272
|
+
|
|
1273
|
+
# Serper specific config
|
|
1274
|
+
"serper_api_key": "your-api-key",
|
|
1275
|
+
"serper_search_type": "search",
|
|
1276
|
+
"serper_location": "United States",
|
|
1277
|
+
"serper_gl": "us",
|
|
1278
|
+
"serper_hl": "en"
|
|
1279
|
+
}
|
|
1280
|
+
from flashrag.config import Config
|
|
1281
|
+
config = Config("basic_config.yaml",config)
|
|
1282
|
+
retriever = SerperRetriever(config)
|
|
1283
|
+
|
|
1284
|
+
# Batch search
|
|
1285
|
+
queries = ["Python programming", "Machine learning"]
|
|
1286
|
+
batch_results = retriever.batch_search(queries)
|
|
1287
|
+
print(batch_results)
|
|
1288
|
+
|
|
1289
|
+
if __name__ == "__main__":
|
|
1290
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.0dev20251106"
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.3.0.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flashrag_dev
|
|
3
|
+
Version: 0.3.0.dev20251106
|
|
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
|
|
@@ -8,12 +8,103 @@ Author-email: jinjiajie@ruc.edu.cn
|
|
|
8
8
|
License: MIT License
|
|
9
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: langid
|
|
17
|
+
Requires-Dist: openai
|
|
18
|
+
Requires-Dist: peft
|
|
19
|
+
Requires-Dist: PyYAML
|
|
20
|
+
Requires-Dist: rank_bm25
|
|
21
|
+
Requires-Dist: rouge
|
|
22
|
+
Requires-Dist: spacy
|
|
23
|
+
Requires-Dist: tiktoken
|
|
24
|
+
Requires-Dist: torch
|
|
25
|
+
Requires-Dist: tqdm
|
|
26
|
+
Requires-Dist: transformers>=4.40.0
|
|
27
|
+
Requires-Dist: bm25s[core]==0.2.1
|
|
28
|
+
Requires-Dist: fschat
|
|
29
|
+
Requires-Dist: streamlit
|
|
30
|
+
Requires-Dist: chonkie<1.1.0,>=1.0.2
|
|
31
|
+
Requires-Dist: gradio>=5.0.0
|
|
32
|
+
Requires-Dist: rouge-chinese
|
|
33
|
+
Requires-Dist: jieba
|
|
11
34
|
Provides-Extra: core
|
|
35
|
+
Requires-Dist: datasets; extra == "core"
|
|
36
|
+
Requires-Dist: base58; extra == "core"
|
|
37
|
+
Requires-Dist: nltk; extra == "core"
|
|
38
|
+
Requires-Dist: numpy; extra == "core"
|
|
39
|
+
Requires-Dist: langid; extra == "core"
|
|
40
|
+
Requires-Dist: openai; extra == "core"
|
|
41
|
+
Requires-Dist: peft; extra == "core"
|
|
42
|
+
Requires-Dist: PyYAML; extra == "core"
|
|
43
|
+
Requires-Dist: rank_bm25; extra == "core"
|
|
44
|
+
Requires-Dist: rouge; extra == "core"
|
|
45
|
+
Requires-Dist: spacy; extra == "core"
|
|
46
|
+
Requires-Dist: tiktoken; extra == "core"
|
|
47
|
+
Requires-Dist: torch; extra == "core"
|
|
48
|
+
Requires-Dist: tqdm; extra == "core"
|
|
49
|
+
Requires-Dist: transformers>=4.40.0; extra == "core"
|
|
50
|
+
Requires-Dist: bm25s[core]==0.2.1; extra == "core"
|
|
51
|
+
Requires-Dist: fschat; extra == "core"
|
|
52
|
+
Requires-Dist: streamlit; extra == "core"
|
|
53
|
+
Requires-Dist: chonkie<1.1.0,>=1.0.2; extra == "core"
|
|
54
|
+
Requires-Dist: gradio>=5.0.0; extra == "core"
|
|
55
|
+
Requires-Dist: rouge-chinese; extra == "core"
|
|
56
|
+
Requires-Dist: jieba; extra == "core"
|
|
12
57
|
Provides-Extra: retriever
|
|
58
|
+
Requires-Dist: pyserini; extra == "retriever"
|
|
59
|
+
Requires-Dist: sentence-transformers>=3.0.1; extra == "retriever"
|
|
13
60
|
Provides-Extra: generator
|
|
61
|
+
Requires-Dist: vllm; extra == "generator"
|
|
14
62
|
Provides-Extra: multimodal
|
|
63
|
+
Requires-Dist: timm; extra == "multimodal"
|
|
64
|
+
Requires-Dist: torchvision; extra == "multimodal"
|
|
65
|
+
Requires-Dist: pillow; extra == "multimodal"
|
|
66
|
+
Requires-Dist: qwen_vl_utils; extra == "multimodal"
|
|
15
67
|
Provides-Extra: full
|
|
16
|
-
|
|
68
|
+
Requires-Dist: datasets; extra == "full"
|
|
69
|
+
Requires-Dist: base58; extra == "full"
|
|
70
|
+
Requires-Dist: nltk; extra == "full"
|
|
71
|
+
Requires-Dist: numpy; extra == "full"
|
|
72
|
+
Requires-Dist: langid; extra == "full"
|
|
73
|
+
Requires-Dist: openai; extra == "full"
|
|
74
|
+
Requires-Dist: peft; extra == "full"
|
|
75
|
+
Requires-Dist: PyYAML; extra == "full"
|
|
76
|
+
Requires-Dist: rank_bm25; extra == "full"
|
|
77
|
+
Requires-Dist: rouge; extra == "full"
|
|
78
|
+
Requires-Dist: spacy; extra == "full"
|
|
79
|
+
Requires-Dist: tiktoken; extra == "full"
|
|
80
|
+
Requires-Dist: torch; extra == "full"
|
|
81
|
+
Requires-Dist: tqdm; extra == "full"
|
|
82
|
+
Requires-Dist: transformers>=4.40.0; extra == "full"
|
|
83
|
+
Requires-Dist: bm25s[core]==0.2.1; extra == "full"
|
|
84
|
+
Requires-Dist: fschat; extra == "full"
|
|
85
|
+
Requires-Dist: streamlit; extra == "full"
|
|
86
|
+
Requires-Dist: chonkie<1.1.0,>=1.0.2; extra == "full"
|
|
87
|
+
Requires-Dist: gradio>=5.0.0; extra == "full"
|
|
88
|
+
Requires-Dist: rouge-chinese; extra == "full"
|
|
89
|
+
Requires-Dist: jieba; extra == "full"
|
|
90
|
+
Requires-Dist: pyserini; extra == "full"
|
|
91
|
+
Requires-Dist: sentence-transformers>=3.0.1; extra == "full"
|
|
92
|
+
Requires-Dist: vllm; extra == "full"
|
|
93
|
+
Requires-Dist: timm; extra == "full"
|
|
94
|
+
Requires-Dist: torchvision; extra == "full"
|
|
95
|
+
Requires-Dist: pillow; extra == "full"
|
|
96
|
+
Requires-Dist: qwen_vl_utils; extra == "full"
|
|
97
|
+
Dynamic: author
|
|
98
|
+
Dynamic: author-email
|
|
99
|
+
Dynamic: description
|
|
100
|
+
Dynamic: description-content-type
|
|
101
|
+
Dynamic: home-page
|
|
102
|
+
Dynamic: license
|
|
103
|
+
Dynamic: license-file
|
|
104
|
+
Dynamic: provides-extra
|
|
105
|
+
Dynamic: requires-dist
|
|
106
|
+
Dynamic: requires-python
|
|
107
|
+
Dynamic: summary
|
|
17
108
|
|
|
18
109
|
# <div align="center">⚡FlashRAG: A Python Toolkit for Efficient RAG Research<div>
|
|
19
110
|
\[ English | [中文](README_zh.md) \]
|
|
@@ -100,6 +191,8 @@ FlashRAG is still under development and there are many issues and room for impro
|
|
|
100
191
|
- [ ] Add support for api-based retriever (vllm server)
|
|
101
192
|
|
|
102
193
|
## :page_with_curl: Changelog
|
|
194
|
+
[25/11/06] 🎯 NEW Retriever! We have integrated a Web Search Engine-based Retriever, which seamlessly integrates with existing methods and can be enabled quickly with just a Serper API key! This enhancement significantly expands retrieval coverage and real-time capability, supporting dynamic information access and external knowledge augmentation. Experience a more flexible and powerful retrieval workflow now!
|
|
195
|
+
|
|
103
196
|
[25/08/06] 🎯 **NEW!** We have added support for **Reasoning Pipeline**, which is a new paradigm that combines reasoning ability and retrieval, representing work that includes [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), [Search-R1](https://github.com/PeterGriffinJin/Search-R1),.... We evaluate the performance of the pipeline on various RAG benchmarks, it can achieve F1 scores close to 60 on multi hop inference datasets such as HotpotQA. See it in [**result table**](#robot-supporting-methods).
|
|
104
197
|
|
|
105
198
|
[25/03/21] 🚀 **Major Update!** We have expanded our toolkit to support **23 state-of-the-art RAG algorithms**, including **7 reasoning-based methods** that significantly improve performance on complex reasoning tasks. This represents a major milestone in our toolkit's evolution!
|
|
@@ -767,6 +860,7 @@ Please kindly cite our paper if helps your research:
|
|
|
767
860
|
}
|
|
768
861
|
```
|
|
769
862
|
|
|
863
|
+
|
|
770
864
|
## Star History
|
|
771
865
|
|
|
772
866
|
[](https://star-history.com/#RUC-NLPIR/FlashRAG&Date)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.0dev20250924"
|
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/config/__init__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/config/basic_config.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/dataset/__init__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/dataset/dataset.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/__init__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/_bleu.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/evaluator.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/metrics.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/evaluator/utils.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/generator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/generator/utils.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/judger/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/ReaRAG_utils.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/mm_pipeline.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/pipeline.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/pipeline/replug_utils.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/__init__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/base_prompt.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/coRAG_prompt.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/mm_prompt.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/prompt/trace_examplars.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/__init__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/kg_refiner.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/refiner/refiner.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/__init__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/__main__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/encoder.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/reranker.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/retriever/utils.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/utils/__init__.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/utils/constants.py
RENAMED
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag/utils/pred_parse.py
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{flashrag_dev-0.3.0.dev20250924 → flashrag_dev-0.3.0.dev20251106}/flashrag_dev.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|