Skip to content

[FEATURE] Implement Semantic Sub-query Decomposition for Multi-part User Questions #566

Description

@knoxiboy

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:

  1. 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.
  2. Execute retrieval for each sub-query in parallel against the vector database and BM25.
  3. 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

Metadata

Metadata

Labels

gssocGirlScript Summer of Code 2026 issue/PR

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions