Describe the problem
For complex, multi-part questions (e.g., "Compare the efficacy in chapter 2 with the safety profile in chapter 5"), the retriever searches ChromaDB and BM25 using a single global query. This often fails to retrieve relevant chunks for all distinct parts of the question, as they exist in separate parts of the document.
Describe the solution
Implement a sub-query decomposition layer in the retriever:
- In the query transformer (
backend/app/rag/retriever.py), prompt the LLM to inspect the user's question and decompose it into a JSON array of independent sub-queries.
- Execute retrieval for each sub-query in parallel against the vector database and BM25.
- Merge and deduplicate all candidates using Reciprocal Rank Fusion (RRF) before forwarding them to the cross-encoder reranker.
Level: Advanced
Affected Files: backend/app/rag/retriever.py, backend/app/rag/agent.py
Describe the problem
For complex, multi-part questions (e.g., "Compare the efficacy in chapter 2 with the safety profile in chapter 5"), the retriever searches ChromaDB and BM25 using a single global query. This often fails to retrieve relevant chunks for all distinct parts of the question, as they exist in separate parts of the document.
Describe the solution
Implement a sub-query decomposition layer in the retriever:
backend/app/rag/retriever.py), prompt the LLM to inspect the user's question and decompose it into a JSON array of independent sub-queries.Level: Advanced
Affected Files:
backend/app/rag/retriever.py,backend/app/rag/agent.py