flashrag-dev 0.1.3.dev20241102__tar.gz → 0.1.3.dev20241104__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {flashrag-dev-0.1.3.dev20241102/flashrag_dev.egg-info → flashrag-dev-0.1.3.dev20241104}/PKG-INFO +5 -4
  2. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/README.md +4 -3
  3. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/generator/openai_generator.py +7 -3
  4. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/prompt/base_prompt.py +8 -9
  5. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/retriever/encoder.py +1 -1
  6. flashrag-dev-0.1.3.dev20241104/flashrag/version.py +1 -0
  7. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104/flashrag_dev.egg-info}/PKG-INFO +5 -4
  8. flashrag-dev-0.1.3.dev20241102/flashrag/version.py +0 -1
  9. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/LICENSE +0 -0
  10. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/__init__.py +0 -0
  11. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/config/__init__.py +0 -0
  12. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/config/basic_config.yaml +0 -0
  13. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/config/config.py +0 -0
  14. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/dataset/__init__.py +0 -0
  15. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/dataset/dataset.py +0 -0
  16. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/dataset/utils.py +0 -0
  17. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/evaluator/__init__.py +0 -0
  18. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/evaluator/_bleu.py +0 -0
  19. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/evaluator/evaluator.py +0 -0
  20. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/evaluator/metrics.py +0 -0
  21. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/evaluator/utils.py +0 -0
  22. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/generator/__init__.py +0 -0
  23. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/generator/fid.py +0 -0
  24. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/generator/generator.py +0 -0
  25. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/generator/stop_word_criteria.py +0 -0
  26. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/judger/__init__.py +0 -0
  27. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/judger/judger.py +0 -0
  28. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/pipeline/__init__.py +0 -0
  29. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/pipeline/active_pipeline.py +0 -0
  30. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/pipeline/branching_pipeline.py +0 -0
  31. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/pipeline/pipeline.py +0 -0
  32. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/pipeline/replug_utils.py +0 -0
  33. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/prompt/__init__.py +0 -0
  34. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/prompt/selfask_examplars.py +0 -0
  35. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/prompt/trace_examplars.py +0 -0
  36. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/refiner/__init__.py +0 -0
  37. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/refiner/kg_refiner.py +0 -0
  38. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/refiner/llmlingua_compressor.py +0 -0
  39. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/refiner/refiner.py +0 -0
  40. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/refiner/selective_context_compressor.py +0 -0
  41. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/retriever/__init__.py +0 -0
  42. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/retriever/__main__.py +0 -0
  43. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/retriever/index_builder.py +0 -0
  44. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/retriever/reranker.py +0 -0
  45. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/retriever/retriever.py +0 -0
  46. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/retriever/utils.py +0 -0
  47. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/utils/__init__.py +0 -0
  48. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/utils/constants.py +0 -0
  49. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/utils/pred_parse.py +0 -0
  50. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag/utils/utils.py +0 -0
  51. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag_dev.egg-info/SOURCES.txt +0 -0
  52. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag_dev.egg-info/dependency_links.txt +0 -0
  53. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag_dev.egg-info/requires.txt +0 -0
  54. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/flashrag_dev.egg-info/top_level.txt +0 -0
  55. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/pyproject.toml +0 -0
  56. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/setup.cfg +0 -0
  57. {flashrag-dev-0.1.3.dev20241102 → flashrag-dev-0.1.3.dev20241104}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag-dev
3
- Version: 0.1.3.dev20241102
3
+ Version: 0.1.3.dev20241104
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
@@ -20,6 +20,7 @@ License-File: LICENSE
20
20
  <div align="center">
21
21
  <a href="https://arxiv.org/abs/2405.13576" target="_blank"><img src=https://img.shields.io/badge/arXiv-b5212f.svg?logo=arxiv></a>
22
22
  <a href="https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/" target="_blank"><img src=https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace%20Datasets-27b3b4.svg></a>
23
+ <a href="https://www.modelscope.cn/datasets/hhjinjiajie/FlashRAG_Dataset" target="_blank"><img src=https://custom-icon-badges.demolab.com/badge/ModelScope%20Datasets-624aff?style=flat&logo=modelscope&logoColor=white></a>
23
24
  <a href="https://github.com/RUC-NLPIR/FlashRAG/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/LICENSE-MIT-green"></a>
24
25
  <a><img alt="Static Badge" src="https://img.shields.io/badge/made_with-Python-blue"></a>
25
26
  </div>
@@ -112,7 +113,7 @@ FlashRAG is still under development and there are many issues and room for impro
112
113
 
113
114
  To get started with FlashRAG, you can simply install it with pip:
114
115
  ```base
115
- pip install flashrag-dev[core]
116
+ pip install flashrag-dev --pre
116
117
  ```
117
118
 
118
119
  Or you can clone it from Github and install (requires Python 3.9+):
@@ -120,7 +121,7 @@ Or you can clone it from Github and install (requires Python 3.9+):
120
121
  ```bash
121
122
  git clone https://github.com/RUC-NLPIR/FlashRAG.git
122
123
  cd FlashRAG
123
- pip install -e .[core]
124
+ pip install -e .
124
125
  ```
125
126
 
126
127
  If you want to use vllm, sentence-transformers or pyserini, you can install the optional dependencies:
@@ -493,7 +494,7 @@ Below is the list of datasets along with the corresponding sample sizes:
493
494
  | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
494
495
  | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
495
496
  | QA | SIQA | - | 33,410 | 1,954 | / |
496
- | QA | CommenseQA | - | 9,741 | 1,221 | / |
497
+ | QA | CommonSenseQA | - | 9,741 | 1,221 | / |
497
498
  | QA | BoolQ | wiki | 9,427 | 3,270 | / |
498
499
  | QA | PIQA | - | 16,113 | 1,838 | / |
499
500
  | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
@@ -4,6 +4,7 @@
4
4
  <div align="center">
5
5
  <a href="https://arxiv.org/abs/2405.13576" target="_blank"><img src=https://img.shields.io/badge/arXiv-b5212f.svg?logo=arxiv></a>
6
6
  <a href="https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/" target="_blank"><img src=https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace%20Datasets-27b3b4.svg></a>
7
+ <a href="https://www.modelscope.cn/datasets/hhjinjiajie/FlashRAG_Dataset" target="_blank"><img src=https://custom-icon-badges.demolab.com/badge/ModelScope%20Datasets-624aff?style=flat&logo=modelscope&logoColor=white></a>
7
8
  <a href="https://github.com/RUC-NLPIR/FlashRAG/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/LICENSE-MIT-green"></a>
8
9
  <a><img alt="Static Badge" src="https://img.shields.io/badge/made_with-Python-blue"></a>
9
10
  </div>
@@ -96,7 +97,7 @@ FlashRAG is still under development and there are many issues and room for impro
96
97
 
97
98
  To get started with FlashRAG, you can simply install it with pip:
98
99
  ```base
99
- pip install flashrag-dev[core]
100
+ pip install flashrag-dev --pre
100
101
  ```
101
102
 
102
103
  Or you can clone it from Github and install (requires Python 3.9+):
@@ -104,7 +105,7 @@ Or you can clone it from Github and install (requires Python 3.9+):
104
105
  ```bash
105
106
  git clone https://github.com/RUC-NLPIR/FlashRAG.git
106
107
  cd FlashRAG
107
- pip install -e .[core]
108
+ pip install -e .
108
109
  ```
109
110
 
110
111
  If you want to use vllm, sentence-transformers or pyserini, you can install the optional dependencies:
@@ -477,7 +478,7 @@ Below is the list of datasets along with the corresponding sample sizes:
477
478
  | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
478
479
  | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
479
480
  | QA | SIQA | - | 33,410 | 1,954 | / |
480
- | QA | CommenseQA | - | 9,741 | 1,221 | / |
481
+ | QA | CommonSenseQA | - | 9,741 | 1,221 | / |
481
482
  | QA | BoolQ | wiki | 9,427 | 3,270 | / |
482
483
  | QA | PIQA | - | 16,113 | 1,838 | / |
483
484
  | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
@@ -27,8 +27,12 @@ class OpenaiGenerator:
27
27
  self.client = AsyncAzureOpenAI(**self.openai_setting)
28
28
  else:
29
29
  self.client = AsyncOpenAI(**self.openai_setting)
30
-
31
- self.tokenizer = tiktoken.encoding_for_model(self.model_name)
30
+ try:
31
+ self.tokenizer = tiktoken.encoding_for_model(self.model_name)
32
+ except Exception as e:
33
+ print("Error: ", e)
34
+ warnings.warn("This model is not supported by tiktoken. Use gpt-3.5-turbo instead.")
35
+ self.tokenizer = tiktoken.encoding_for_model('gpt-3.5-turbo')
32
36
 
33
37
  async def get_response(self, input: List, **params):
34
38
  response = await self.client.chat.completions.create(model=self.model_name, messages=input, **params)
@@ -46,7 +50,7 @@ class OpenaiGenerator:
46
50
 
47
51
  def generate(self, input_list: List[List], batch_size=None, return_scores=False, **params) -> List[str]:
48
52
  # deal with single input
49
- if len(input_list) == 1:
53
+ if len(input_list) == 1 and isinstance(input_list[0], dict):
50
54
  input_list = [input_list]
51
55
  if batch_size is None:
52
56
  batch_size = self.batch_size
@@ -1,5 +1,6 @@
1
1
  from transformers import AutoTokenizer, AutoConfig
2
2
  import tiktoken
3
+ import warnings
3
4
 
4
5
  class PromptTemplate:
5
6
  placeholders = ["reference", "question"]
@@ -26,7 +27,12 @@ class PromptTemplate:
26
27
  else:
27
28
  self.is_chat = True
28
29
  self.enable_chat = True
29
- self.tokenizer = tiktoken.encoding_for_model("gpt-4o")
30
+ try:
31
+ self.tokenizer = tiktoken.encoding_for_model(config['generator_model'])
32
+ except Exception as e:
33
+ print("Error: ", e)
34
+ warnings.warn("This model is not supported by tiktoken. Use gpt-3.5-turbo instead.")
35
+ self.tokenizer = tiktoken.encoding_for_model('gpt-3.5-turbo')
30
36
 
31
37
  if len(system_prompt) == 0 and len(user_prompt) == 0:
32
38
  system_prompt = self.base_system_prompt
@@ -91,9 +97,6 @@ class PromptTemplate:
91
97
  return self.truncate_prompt(messages)
92
98
  if self.is_chat and self.enable_chat:
93
99
  if self.is_openai:
94
- for item in input:
95
- if item["role"] == "system":
96
- item["role"] = "assistant"
97
100
  self.truncate_prompt(messages)
98
101
  else:
99
102
  prompt = self.tokenizer.apply_chat_template(
@@ -124,11 +127,7 @@ class PromptTemplate:
124
127
  input.append({"role": "system", "content": system_prompt})
125
128
  if user_prompt != "":
126
129
  input.append({"role": "user", "content": user_prompt})
127
- if self.is_openai:
128
- for item in input:
129
- if item["role"] == "system":
130
- item["role"] = "assistant"
131
- else:
130
+ if not self.is_openai:
132
131
  input = self.tokenizer.apply_chat_template(input, tokenize=False, add_generation_prompt=True)
133
132
  else:
134
133
  input = "\n\n".join([prompt for prompt in [system_prompt, user_prompt] if prompt != ""])
@@ -37,7 +37,7 @@ class Encoder:
37
37
  query_emb = pooling(
38
38
  output.pooler_output, output.last_hidden_state, inputs["attention_mask"], self.pooling_method
39
39
  )
40
-
40
+ query_emb = torch.nn.functional.normalize(query_emb, dim=-1)
41
41
  query_emb = query_emb.detach().cpu().numpy()
42
42
  query_emb = query_emb.astype(np.float32, order="C")
43
43
  return query_emb
@@ -0,0 +1 @@
1
+ __version__ = "0.1.3dev20241104"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag-dev
3
- Version: 0.1.3.dev20241102
3
+ Version: 0.1.3.dev20241104
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
@@ -20,6 +20,7 @@ License-File: LICENSE
20
20
  <div align="center">
21
21
  <a href="https://arxiv.org/abs/2405.13576" target="_blank"><img src=https://img.shields.io/badge/arXiv-b5212f.svg?logo=arxiv></a>
22
22
  <a href="https://huggingface.co/datasets/RUC-NLPIR/FlashRAG_datasets/" target="_blank"><img src=https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace%20Datasets-27b3b4.svg></a>
23
+ <a href="https://www.modelscope.cn/datasets/hhjinjiajie/FlashRAG_Dataset" target="_blank"><img src=https://custom-icon-badges.demolab.com/badge/ModelScope%20Datasets-624aff?style=flat&logo=modelscope&logoColor=white></a>
23
24
  <a href="https://github.com/RUC-NLPIR/FlashRAG/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/LICENSE-MIT-green"></a>
24
25
  <a><img alt="Static Badge" src="https://img.shields.io/badge/made_with-Python-blue"></a>
25
26
  </div>
@@ -112,7 +113,7 @@ FlashRAG is still under development and there are many issues and room for impro
112
113
 
113
114
  To get started with FlashRAG, you can simply install it with pip:
114
115
  ```base
115
- pip install flashrag-dev[core]
116
+ pip install flashrag-dev --pre
116
117
  ```
117
118
 
118
119
  Or you can clone it from Github and install (requires Python 3.9+):
@@ -120,7 +121,7 @@ Or you can clone it from Github and install (requires Python 3.9+):
120
121
  ```bash
121
122
  git clone https://github.com/RUC-NLPIR/FlashRAG.git
122
123
  cd FlashRAG
123
- pip install -e .[core]
124
+ pip install -e .
124
125
  ```
125
126
 
126
127
  If you want to use vllm, sentence-transformers or pyserini, you can install the optional dependencies:
@@ -493,7 +494,7 @@ Below is the list of datasets along with the corresponding sample sizes:
493
494
  | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
494
495
  | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
495
496
  | QA | SIQA | - | 33,410 | 1,954 | / |
496
- | QA | CommenseQA | - | 9,741 | 1,221 | / |
497
+ | QA | CommonSenseQA | - | 9,741 | 1,221 | / |
497
498
  | QA | BoolQ | wiki | 9,427 | 3,270 | / |
498
499
  | QA | PIQA | - | 16,113 | 1,838 | / |
499
500
  | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
@@ -1 +0,0 @@
1
- __version__ = "0.1.3dev20241102"