flashrag-dev 0.1.4.dev20250306__tar.gz → 0.1.4.dev20250310__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 (61) hide show
  1. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/PKG-INFO +7 -1
  2. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/README.md +6 -0
  3. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/prompt/mm_prompt.py +72 -1
  4. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/retriever/retriever.py +2 -1
  5. flashrag_dev-0.1.4.dev20250310/flashrag/version.py +1 -0
  6. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag_dev.egg-info/PKG-INFO +7 -1
  7. flashrag_dev-0.1.4.dev20250306/flashrag/version.py +0 -1
  8. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/LICENSE +0 -0
  9. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/__init__.py +0 -0
  10. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/config/__init__.py +0 -0
  11. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/config/basic_config.yaml +0 -0
  12. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/config/config.py +0 -0
  13. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/dataset/__init__.py +0 -0
  14. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/dataset/dataset.py +0 -0
  15. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/dataset/utils.py +0 -0
  16. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/evaluator/__init__.py +0 -0
  17. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/evaluator/_bleu.py +0 -0
  18. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/evaluator/evaluator.py +0 -0
  19. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/evaluator/metrics.py +0 -0
  20. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/evaluator/utils.py +0 -0
  21. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/generator/__init__.py +0 -0
  22. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/generator/fid.py +0 -0
  23. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/generator/generator.py +0 -0
  24. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/generator/multimodal_generator.py +0 -0
  25. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/generator/openai_generator.py +0 -0
  26. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/generator/stop_word_criteria.py +0 -0
  27. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/generator/utils.py +0 -0
  28. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/judger/__init__.py +0 -0
  29. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/judger/judger.py +0 -0
  30. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/pipeline/__init__.py +0 -0
  31. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/pipeline/active_pipeline.py +0 -0
  32. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/pipeline/branching_pipeline.py +0 -0
  33. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/pipeline/mm_pipeline.py +0 -0
  34. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/pipeline/pipeline.py +0 -0
  35. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/pipeline/replug_utils.py +0 -0
  36. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/prompt/__init__.py +0 -0
  37. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/prompt/base_prompt.py +0 -0
  38. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/prompt/selfask_examplars.py +0 -0
  39. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/prompt/trace_examplars.py +0 -0
  40. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/refiner/__init__.py +0 -0
  41. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/refiner/kg_refiner.py +0 -0
  42. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/refiner/llmlingua_compressor.py +0 -0
  43. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/refiner/refiner.py +0 -0
  44. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/refiner/selective_context_compressor.py +0 -0
  45. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/retriever/__init__.py +0 -0
  46. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/retriever/__main__.py +0 -0
  47. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/retriever/encoder.py +0 -0
  48. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/retriever/index_builder.py +0 -0
  49. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/retriever/reranker.py +0 -0
  50. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/retriever/utils.py +0 -0
  51. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/utils/__init__.py +0 -0
  52. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/utils/constants.py +0 -0
  53. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/utils/pred_parse.py +0 -0
  54. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag/utils/utils.py +0 -0
  55. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag_dev.egg-info/SOURCES.txt +0 -0
  56. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag_dev.egg-info/dependency_links.txt +0 -0
  57. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag_dev.egg-info/requires.txt +0 -0
  58. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/flashrag_dev.egg-info/top_level.txt +0 -0
  59. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/pyproject.toml +0 -0
  60. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/setup.cfg +0 -0
  61. {flashrag_dev-0.1.4.dev20250306 → flashrag_dev-0.1.4.dev20250310}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag_dev
3
- Version: 0.1.4.dev20250306
3
+ Version: 0.1.4.dev20250310
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
@@ -663,6 +663,12 @@ To facilitate easier replication of the experiments, we now provide a preprocess
663
663
 
664
664
  The index was created using the e5-base-v2 retriever on our uploaded wiki18_100w dataset, which is consistent with the index used in our experiments.
665
665
 
666
+ ## :lollipop: Awesome Work using FlashRAG
667
+
668
+ - [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), a method that incentivizes the search capability in LLMs via reinforcement learning
669
+ - [ReSearch](https://github.com/Agent-RL/ReSearch), a method that learns to reason with search for LLMs via reinforcement learning
670
+ - [AutoCoA](https://github.com/ADaM-BJTU/AutoCoA), a method that internalizes chain-of-action generation into reasoning models
671
+
666
672
  ## :raised_hands: Additional FAQs
667
673
 
668
674
  - [How should I set different experimental parameters?](./docs/configuration.md)
@@ -646,6 +646,12 @@ To facilitate easier replication of the experiments, we now provide a preprocess
646
646
 
647
647
  The index was created using the e5-base-v2 retriever on our uploaded wiki18_100w dataset, which is consistent with the index used in our experiments.
648
648
 
649
+ ## :lollipop: Awesome Work using FlashRAG
650
+
651
+ - [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), a method that incentivizes the search capability in LLMs via reinforcement learning
652
+ - [ReSearch](https://github.com/Agent-RL/ReSearch), a method that learns to reason with search for LLMs via reinforcement learning
653
+ - [AutoCoA](https://github.com/ADaM-BJTU/AutoCoA), a method that internalizes chain-of-action generation into reasoning models
654
+
649
655
  ## :raised_hands: Additional FAQs
650
656
 
651
657
  - [How should I set different experimental parameters?](./docs/configuration.md)
@@ -84,4 +84,75 @@ class GAOKAOMMPromptTemplate(MMPromptTemplate):
84
84
  content_list.append({'type': 'text', 'text': user_prompt})
85
85
  messages.append({"role": "user", "content": content_list})
86
86
  return messages
87
-
87
+
88
+
89
+ class MathVistaPromptTemplate:
90
+ BASE_USER_PROMPT_FREE_FORM = (
91
+ "You are an AI assistant designed to solve mathematical and visual reasoning problems. "
92
+ "Below is a question that requires you to analyze the given information and provide a detailed answer.\n\n"
93
+ "### Reference Information:\n{reference}\n\n"
94
+ "### Question:\n{question}\n\n"
95
+ "### Instructions:\n"
96
+ "Only give me the final answer.\n\n"
97
+ "### Answer:\n"
98
+ )
99
+
100
+ BASE_USER_PROMPT_MULTI_CHOICE = (
101
+ "You are an AI assistant designed to solve mathematical and visual reasoning problems. "
102
+ "Below is a multiple-choice question that requires you to analyze the given information and select the correct choice.\n\n"
103
+ "### Reference Information:\n{reference}\n\n"
104
+ "### Question:\n{question}\n\n"
105
+ "### Instructions:\n"
106
+ "Only give me the correct option letter, e.g., A, B, C, D.\n\n"
107
+ "### Answer:\n"
108
+ )
109
+
110
+ def __init__(self, config, system_prompt=None, user_prompt_free_form=None, user_prompt_multi_choice=None):
111
+ self.config = config
112
+ self.system_prompt = system_prompt
113
+ self.user_prompt_free_form = user_prompt_free_form if user_prompt_free_form is not None else self.BASE_USER_PROMPT_FREE_FORM
114
+ self.user_prompt_multi_choice = user_prompt_multi_choice if user_prompt_multi_choice is not None else self.BASE_USER_PROMPT_MULTI_CHOICE
115
+
116
+ def get_string(self, item, use_retrieval_image=False, use_retrieval_text=False, use_question_image=False):
117
+ question = item.question if item.question is not None else item.text
118
+ question_image = item.image
119
+ question_type = item.question_type # 'free_form' or 'multi_choice'
120
+
121
+ messages = []
122
+ if self.system_prompt is not None:
123
+ messages.append({"role": "system", "content": self.system_prompt})
124
+
125
+ content_list = []
126
+ reference_str = ""
127
+
128
+ # Add retrieval results as reference (if available)
129
+ try:
130
+ retrieval_result = item.retrieval_result
131
+ except:
132
+ retrieval_result = []
133
+
134
+ for idx, item in enumerate(retrieval_result):
135
+ if 'image' not in item:
136
+ reference_str += f'Example {idx + 1}: {item["contents"]}\n'
137
+ else:
138
+ content_list.append({'type': 'image', 'image': item['image']})
139
+ reference_str += f'Example {idx + 1}: {item["text"]}\n'
140
+
141
+ # Add question image (if available)
142
+ if question_image:
143
+ content_list.append({'type': 'image', 'image': question_image})
144
+
145
+ # Format the user prompt based on question type
146
+ if question_type == 'free_form':
147
+ user_prompt = self.user_prompt_free_form.format(question=question, reference=reference_str)
148
+ elif question_type == 'multi_choice':
149
+ user_prompt = self.user_prompt_multi_choice.format(question=question, reference=reference_str)
150
+ else:
151
+ raise ValueError(f"Unsupported question type: {question_type}")
152
+
153
+ # Add the formatted user prompt
154
+ content_list.append({'type': 'text', 'text': user_prompt})
155
+ messages.append({"role": "user", "content": content_list})
156
+
157
+ return messages
158
+
@@ -324,7 +324,8 @@ class BM25Retriever(BaseTextRetriever):
324
324
  results, scores = self.searcher.retrieve(query_tokens, k=num)
325
325
  else:
326
326
  assert False, "Invalid bm25 backend!"
327
-
327
+ results = results.tolist() if isinstance(results,np.ndarray) else results
328
+ scores = scores.tolist() if isinstance(scores,np.ndarray) else scores
328
329
  if return_score:
329
330
  return results, scores
330
331
  else:
@@ -0,0 +1 @@
1
+ __version__ = "0.1.4dev20250310"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flashrag-dev
3
- Version: 0.1.4.dev20250306
3
+ Version: 0.1.4.dev20250310
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
@@ -663,6 +663,12 @@ To facilitate easier replication of the experiments, we now provide a preprocess
663
663
 
664
664
  The index was created using the e5-base-v2 retriever on our uploaded wiki18_100w dataset, which is consistent with the index used in our experiments.
665
665
 
666
+ ## :lollipop: Awesome Work using FlashRAG
667
+
668
+ - [R1-Searcher](https://github.com/SsmallSong/R1-Searcher), a method that incentivizes the search capability in LLMs via reinforcement learning
669
+ - [ReSearch](https://github.com/Agent-RL/ReSearch), a method that learns to reason with search for LLMs via reinforcement learning
670
+ - [AutoCoA](https://github.com/ADaM-BJTU/AutoCoA), a method that internalizes chain-of-action generation into reasoning models
671
+
666
672
  ## :raised_hands: Additional FAQs
667
673
 
668
674
  - [How should I set different experimental parameters?](./docs/configuration.md)
@@ -1 +0,0 @@
1
- __version__ = "0.1.4dev20250306"