Skip to Content
ConceptsKnowledge Graph

Knowledge Graph

The knowledge graph connects entities through typed relationships, enabling multi-hop reasoning and contextual queries.

Structure

The graph consists of:

  • Nodes — Entities (people, places, things)
  • Edges — Relationships between entities (works_at, lives_in, prefers, etc.)
  • Communities — Clusters of closely related entities

Graph reasoning

When use_graph_reasoning=True is set on a recall query, Memorer traverses the knowledge graph to answer questions that require connecting multiple pieces of information:

# Multi-hop query: "What tools does the engineer at Acme use?" # Graph path: Acme Corp -> works_at -> Alice -> prefers -> Python, VS Code results = user.recall( "What tools does the engineer at Acme use?", use_graph_reasoning=True, )

Graph visualization

You can get the full graph data for visualization:

viz = user.knowledge.graph(limit=200) print(f"Nodes: {len(viz.nodes)}") print(f"Edges: {len(viz.edges)}") print(f"Communities: {len(viz.communities)}") if viz.stats: print(f"Total entities: {viz.stats.total_entities}") print(f"Total relationships: {viz.stats.total_relationships}")

Memory stats

stats = user.memories.stats() print(f"Total memories: {stats.total_memories}") print(f"Direct: {stats.direct_memories}") print(f"Derived: {stats.derived_memories}") print(f"Relationships: {stats.relationships}")

Ingesting structured data

Beyond remember(), you can ingest larger bodies of text:

user.knowledge.ingest("Long document or conversation transcript...")

This processes the text, extracts all entities and relationships, and adds them to the graph.

Last updated on