Multi-Hop RAG Query Planner

U

@

·

Design a multi-hop RAG query planner with complexity analysis, hop planning, iterative execution, and answer synthesis.

79 copies0 forks
Design a planner for multi-hop RAG queries requiring iterative retrieval.

## Query Types
{{query_types}}

## Knowledge Sources
{{knowledge_sources}}

## Planning Requirements
{{planning_requirements}}

Implement the planner:

```python
class MultiHopQueryPlanner:
    def analyze_query_complexity(self, query: str) -> ComplexityProfile:
        """
        Determine:
        - Number of hops needed
        - Information dependencies
        - Intermediate questions
        """
        pass
    
    def generate_hop_plan(self, query: str) -> List[HopStep]:
        """
        For each hop:
        - Sub-query to execute
        - Expected information
        - Dependency on previous hops
        """
        pass
    
    def execute_plan(self, plan: List[HopStep]) -> MultiHopResult:
        """Execute with intermediate results"""
        pass
    
    def synthesize_answer(self, hop_results: List[HopResult]) -> str:
        """Combine information into final answer"""
        pass
```

Include:
- Early termination
- Dead-end handling
- Confidence propagation
- Cycle detection

Details

Category

Coding

Use Cases

Multi-hop RAGComplex queriesIterative retrieval

Works Best With

claude-sonnet-4-20250514gpt-4o
Created Shared

Create your own prompt vault and start sharing