Knowledge Graph Entity Linking
Category: Knowledge
Problem
Vector search finds semantically similar memories but cannot reason about relationships. Questions like "Who works at the company that provides our cloud hosting?" require traversing entity relationships — something flat memory stores cannot do.
Architecture
Dakera automatically extracts entities from stored memories using GLiNER (a zero-shot NER model). Entities are linked with 4 edge types and stored in a traversable knowledge graph. BFS traversal answers multi-hop questions by following relationship chains.
Edge Types
- RELATES_TO — general association between entities
- WORKS_AT — person-organization relationship
- LOCATED_IN — geographic containment
- PART_OF — compositional relationship
Implementation
from dakera import Dakera
client = Dakera(base_url="http://localhost:3300", api_key="dk-...")
# Store memories — entities are extracted automatically
client.memory.store(
content="Alice works at Acme Corp as a senior engineer",
namespace="team",
metadata={"type": "fact"}
)
client.memory.store(
content="Acme Corp uses AWS for their cloud infrastructure",
namespace="team",
metadata={"type": "fact"}
)
client.memory.store(
content="Bob is Alice's manager at Acme Corp",
namespace="team",
metadata={"type": "fact"}
)
# Query entities extracted from memories
entities = client.knowledge.entities(
namespace="team"
)
# Returns: [
# {"name": "Alice", "type": "PERSON", "mentions": 2},
# {"name": "Acme Corp", "type": "ORGANIZATION", "mentions": 3},
# {"name": "Bob", "type": "PERSON", "mentions": 1},
# {"name": "AWS", "type": "ORGANIZATION", "mentions": 1}
# ]
# Traverse the knowledge graph
graph = client.knowledge.graph(
entity="Alice",
namespace="team",
depth=2 # BFS depth
)
# Returns relationships:
# Alice --WORKS_AT--> Acme Corp
# Acme Corp --RELATES_TO--> AWS
# Bob --WORKS_AT--> Acme Corp
# Bob --RELATES_TO--> Alice (manager)
# Multi-hop query: "What cloud provider does Alice's company use?"
# Traversal: Alice -> WORKS_AT -> Acme Corp -> RELATES_TO -> AWS
# Answer: AWS
REST API Example
# Get entities for a namespace
curl -X POST http://localhost:3300/v1/knowledge/entities \
-H "Authorization: Bearer dk-..." \
-H "Content-Type: application/json" \
-d '{"namespace": "team"}'
# Traverse the graph from an entity
curl -X POST http://localhost:3300/v1/knowledge/graph \
-H "Authorization: Bearer dk-..." \
-H "Content-Type: application/json" \
-d '{
"entity": "Alice",
"namespace": "team",
"depth": 2,
"edge_types": ["WORKS_AT", "RELATES_TO"]
}'
When to Use This Pattern
- CRM systems tracking people, companies, and relationships
- Research assistants connecting papers, authors, and institutions
- Any application requiring multi-hop reasoning over stored knowledge
- Building organizational knowledge maps from conversations
Key Considerations
- Entity extraction happens automatically on store — no extra API calls needed
- GLiNER runs on-device via ONNX, so entity extraction is private and fast
- Use depth limits on traversal to avoid returning the entire graph
- Combine graph results with vector recall for comprehensive answers
- Knowledge graphs complement (not replace) semantic search — use both