Hybrid Retrieval
Hybrid Retrieval is the orchestration of both Semantic Search and Graph Retrieval to provide the most complete and relevant context for an AI.
By combining these two methods, the platform overcomes the individual limitations of each, ensuring that the AI understands both the meaning of the query and the structure of the world it's operating in.
How it Works
The Memory Engine performs hybrid retrieval in three stages:
Stage 1: Explicit Graph Filtering
The engine first identifies the subject scope (User, Project, Org) and uses the Knowledge Graph to find all structural connections. This establishes the "hard boundaries" for retrieval.
Stage 2: Semantic Ranking
Within those boundaries, the engine performs a vector search in Qdrant to find the memories that are semantically most relevant to the query.
Stage 3: Salience & Confidence Re-ranking
The results from the semantic search are re-ranked using a composite score that takes into account:
- Semantic Similarity: How well the meanings match.
- Salience: How "important" the memory is currently.
- Confidence: How reliable the source is.
The Composite Scoring Formula
Final Score = (Similarity * 0.5) + (Salience * 0.3) + (Confidence * 0.2)
Weights can be adjusted based on the specific retrieval strategy.
Benefits of Hybrid Retrieval
- Eliminates Hallucinations: By using structural graph boundaries, the system prevents the AI from "drifting" into semantically similar but structurally unrelated context.
- Handles Evolution: The Knowledge Graph handles the "latest" version via
SUPERSEDESedges, while the Vector store handles the "concept." - Context Clarity: The AI doesn't just get a list of facts; it gets facts that are structurally relevant to the entities it's currently discussing.
Integration in the API
Hybrid retrieval is triggered via the memory.query tool or the GET /api/v1/memories/search endpoint. Developers don't need to specify which search method to use; the engine automatically applies the best hybrid strategy based on the query parameters.