Skip to main content

GraphRAG Hybrid Search

GraphRAG blends two retrieval strategies: vector similarity (what's semantically similar?) and graph proximity (what's contextually connected?). The result is retrieval that understands not just meaning, but relationships.

Why GraphRAG?​

ApproachFindsMisses
Vector onlySemantically similar contentConnected but differently-worded content
Graph onlyStructurally related entitiesContent not yet linked to entities
GraphRAGBoth — blended by configurable weightNothing (best of both worlds)

Example: You ask "What is Company X's pricing strategy?"

  • Vector search finds memories mentioning "pricing" or "strategy"
  • Graph traversal finds: Company X → negotiation with Person Y → budget constraint Z → competitor comparison W
  • GraphRAG returns all of these, ranked by blended score

How It Works​

1. Vector search → top 20 candidate memories
2. Extract entity names from candidates
3. For each entity, traverse 2 hops in the knowledge graph
4. Score: final = (vector_score × 0.7) + (graph_proximity × 0.3)
5. Re-rank and return top N

Graph proximity scoring:

  • Directly linked to a traversed entity: 1.0
  • 1 hop away: 0.5
  • 2 hops away: 0.25

Usage​

curl -X POST https://api.ainative.studio/api/v1/public/memory/v2/graph/graphrag \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "What pricing strategies does Company X use?",
"limit": 10,
"graph_weight": 0.3,
"max_hops": 2
}'

Tuning graph_weight​

ValueBehaviorBest For
0.0Pure vector searchGeneral similarity queries
0.1-0.3Mostly vector, light graph boostDefault — good for most use cases
0.4-0.6BalancedMulti-entity questions
0.7-0.9Mostly graphRelationship-focused queries
1.0Pure graph proximity"How is X connected to Y?"

Response Shape​

{
"results": [
{
"id": "memory-uuid",
"content": "Company X proposed a 15% discount...",
"score": 0.82,
"vector_score": 0.75,
"graph_boost": 0.98,
"memory_type": "episodic",
"entity_id": "company_x",
"tags": ["negotiation", "pricing"]
}
],
"query": "pricing strategies",
"graph_weight": 0.3,
"max_hops": 2,
"entities_traversed": ["company_x", "person_y", "competitor_z"],
"total": 10
}

Prerequisites​

GraphRAG works best when:

  1. Memories are stored via /remember (builds the vector index)
  2. Entities are created via /entity (builds the graph)
  3. Edges connect entities via /edge (enables traversal)

Without a graph, GraphRAG falls back to pure vector search (graph_boost = 0 for all results).