flashrag-dev 0.1.3.dev20241103__tar.gz → 0.1.3.dev20241106__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.dev20241103/flashrag_dev.egg-info → flashrag-dev-0.1.3.dev20241106}/PKG-INFO +2 -2
  2. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/README.md +1 -1
  3. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/generator/generator.py +1 -0
  4. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/generator/openai_generator.py +7 -3
  5. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/pipeline/active_pipeline.py +1 -1
  6. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/prompt/base_prompt.py +7 -4
  7. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/retriever/encoder.py +1 -1
  8. flashrag-dev-0.1.3.dev20241106/flashrag/version.py +1 -0
  9. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106/flashrag_dev.egg-info}/PKG-INFO +2 -2
  10. flashrag-dev-0.1.3.dev20241103/flashrag/version.py +0 -1
  11. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/LICENSE +0 -0
  12. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/__init__.py +0 -0
  13. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/config/__init__.py +0 -0
  14. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/config/basic_config.yaml +0 -0
  15. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/config/config.py +0 -0
  16. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/dataset/__init__.py +0 -0
  17. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/dataset/dataset.py +0 -0
  18. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/dataset/utils.py +0 -0
  19. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/evaluator/__init__.py +0 -0
  20. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/evaluator/_bleu.py +0 -0
  21. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/evaluator/evaluator.py +0 -0
  22. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/evaluator/metrics.py +0 -0
  23. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/evaluator/utils.py +0 -0
  24. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/generator/__init__.py +0 -0
  25. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/generator/fid.py +0 -0
  26. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/generator/stop_word_criteria.py +0 -0
  27. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/judger/__init__.py +0 -0
  28. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/judger/judger.py +0 -0
  29. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/pipeline/__init__.py +0 -0
  30. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/pipeline/branching_pipeline.py +0 -0
  31. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/pipeline/pipeline.py +0 -0
  32. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/pipeline/replug_utils.py +0 -0
  33. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/prompt/__init__.py +0 -0
  34. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/prompt/selfask_examplars.py +0 -0
  35. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/prompt/trace_examplars.py +0 -0
  36. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/refiner/__init__.py +0 -0
  37. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/refiner/kg_refiner.py +0 -0
  38. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/refiner/llmlingua_compressor.py +0 -0
  39. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/refiner/refiner.py +0 -0
  40. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/refiner/selective_context_compressor.py +0 -0
  41. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/retriever/__init__.py +0 -0
  42. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/retriever/__main__.py +0 -0
  43. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/retriever/index_builder.py +0 -0
  44. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/retriever/reranker.py +0 -0
  45. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/retriever/retriever.py +0 -0
  46. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/retriever/utils.py +0 -0
  47. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/utils/__init__.py +0 -0
  48. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/utils/constants.py +0 -0
  49. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/utils/pred_parse.py +0 -0
  50. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag/utils/utils.py +0 -0
  51. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag_dev.egg-info/SOURCES.txt +0 -0
  52. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag_dev.egg-info/dependency_links.txt +0 -0
  53. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag_dev.egg-info/requires.txt +0 -0
  54. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/flashrag_dev.egg-info/top_level.txt +0 -0
  55. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/pyproject.toml +0 -0
  56. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/setup.cfg +0 -0
  57. {flashrag-dev-0.1.3.dev20241103 → flashrag-dev-0.1.3.dev20241106}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag-dev
3
- Version: 0.1.3.dev20241103
3
+ Version: 0.1.3.dev20241106
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
@@ -494,7 +494,7 @@ Below is the list of datasets along with the corresponding sample sizes:
494
494
  | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
495
495
  | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
496
496
  | QA | SIQA | - | 33,410 | 1,954 | / |
497
- | QA | CommenseQA | - | 9,741 | 1,221 | / |
497
+ | QA | CommonSenseQA | - | 9,741 | 1,221 | / |
498
498
  | QA | BoolQ | wiki | 9,427 | 3,270 | / |
499
499
  | QA | PIQA | - | 16,113 | 1,838 | / |
500
500
  | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
@@ -478,7 +478,7 @@ Below is the list of datasets along with the corresponding sample sizes:
478
478
  | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
479
479
  | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
480
480
  | QA | SIQA | - | 33,410 | 1,954 | / |
481
- | QA | CommenseQA | - | 9,741 | 1,221 | / |
481
+ | QA | CommonSenseQA | - | 9,741 | 1,221 | / |
482
482
  | QA | BoolQ | wiki | 9,427 | 3,270 | / |
483
483
  | QA | PIQA | - | 16,113 | 1,838 | / |
484
484
  | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
@@ -235,6 +235,7 @@ class VLLMGenerator(BaseGenerator):
235
235
  # fix for llama3
236
236
  if "stop" in generation_params:
237
237
  generation_params["stop"].append("<|eot_id|>")
238
+ generation_params['include_stop_str_in_output'] = True
238
239
  else:
239
240
  generation_params["stop"] = ["<|eot_id|>"]
240
241
 
@@ -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
@@ -932,7 +932,7 @@ class IRCOTPipeline(BasicPipeline):
932
932
  input_prompt = self.prompt_template.get_string(
933
933
  question=question, retrieval_result=retrieval_result, previous_gen=" ".join(thoughts)
934
934
  )
935
- new_thought = self.generator.generate(input_prompt)[0]
935
+ new_thought = self.generator.generate(input_prompt,stop=['.', '\n'])[0]
936
936
  thoughts.append(new_thought)
937
937
  iter_num += 1
938
938
  if "So the answer is:" in new_thought:
@@ -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(
@@ -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.3dev20241106"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag-dev
3
- Version: 0.1.3.dev20241103
3
+ Version: 0.1.3.dev20241106
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
@@ -494,7 +494,7 @@ Below is the list of datasets along with the corresponding sample sizes:
494
494
  | QA | WebQuestions | Google Freebase | 3,778 | / | 2,032 |
495
495
  | QA | AmbigQA | wiki | 10,036 | 2,002 | / |
496
496
  | QA | SIQA | - | 33,410 | 1,954 | / |
497
- | QA | CommenseQA | - | 9,741 | 1,221 | / |
497
+ | QA | CommonSenseQA | - | 9,741 | 1,221 | / |
498
498
  | QA | BoolQ | wiki | 9,427 | 3,270 | / |
499
499
  | QA | PIQA | - | 16,113 | 1,838 | / |
500
500
  | QA | Fermi | wiki | 8,000 | 1,000 | 1,000 |
@@ -1 +0,0 @@
1
- __version__ = "0.1.3dev20241103"