|
def _retrieve_with_planning(self, query: str, enable_reflection: Optional[bool] = None) -> List[MemoryEntry]: |
|
""" |
|
Execute retrieval with intelligent planning process |
|
|
|
Args: |
|
- query: Search query |
|
- enable_reflection: Override reflection setting for this query |
|
""" |
|
print(f"\n[Planning] Analyzing information requirements for: {query}") |
|
|
|
# Step 1: Intelligent analysis of what information is needed |
|
information_plan = self._analyze_information_requirements(query) |
|
print(f"[Planning] Identified {len(information_plan['required_info'])} information requirements") |
|
|
|
# Step 2: Generate minimal necessary queries based on the plan |
|
search_queries = self._generate_targeted_queries(query, information_plan) |
|
print(f"[Planning] Generated {len(search_queries)} targeted queries") |
|
|
|
# Step 3: Execute searches for all queries (parallel or sequential) |
|
if self.enable_parallel_retrieval and len(search_queries) > 1: |
|
all_results = self._execute_parallel_searches(search_queries) |
|
else: |
|
all_results = [] |
|
for i, search_query in enumerate(search_queries, 1): |
|
print(f"[Search {i}] {search_query}") |
|
results = self._semantic_search(search_query) |
|
all_results.extend(results) |
|
|
|
# Step 3.5: Execute keyword and structured searches (hybrid retrieval) |
|
query_analysis = self._analyze_query(query) |
|
|
|
# Keyword search (Lexical Layer) |
|
keyword_results = self._keyword_search(query, query_analysis) |
|
print(f"[Keyword Search] Found {len(keyword_results)} results") |
|
all_results.extend(keyword_results) |
|
|
|
# Structured search (Symbolic Layer) |
|
structured_results = self._structured_search(query_analysis) |
|
print(f"[Structured Search] Found {len(structured_results)} results") |
|
all_results.extend(structured_results) |
|
|
|
# Step 4: Merge and deduplicate results |
|
merged_results = self._merge_and_deduplicate_entries(all_results) |
|
print(f"[Planning] Found {len(merged_results)} unique results (semantic + keyword + structured)") |
|
|
|
# Step 5: Optional reflection-based additional retrieval |
|
# Use override parameter if provided, otherwise use global setting |
|
should_use_reflection = enable_reflection if enable_reflection is not None else self.enable_reflection |
|
|
|
if should_use_reflection: |
|
merged_results = self._retrieve_with_intelligent_reflection(query, merged_results, information_plan) |
|
|
|
return merged_results |
SimpleMem/core/hybrid_retriever.py
Lines 75 to 127 in 94ef7d7
Hi, I saw this code in your project.
I wonder if it means that the framework of ReAct is in the Intent-Aware Retrieval Planning module?
I thought SimpleMem was a one-step memory before I found this code. So it seems that the paragraph mentioned in your paper, which makes an opposition about the " iterative reasoning procedures" approach, may need some modification.
And I wonder what number you set for "self.max_reflection_rounds" for the final experiment.
Thank for your reply.