Skip to main content

Knowledge Graph

SharedMemory's knowledge graph is the structured backbone of its memory system. Built on Neo4j, it represents knowledge as entities, facts, and relationships.

Node Types​

Entity​

The core unit — a person, project, technology, organization, or concept.

{
"name": "John Smith",
"type": "person",
"summary": "Senior engineer at Google specializing in React and cloud computing",
"volume_id": "abc-123"
}

Fact​

A specific piece of knowledge linked to an entity.

{
"content": "Works as a senior engineer at Google since 2021",
"category": "experience",
"importance": 0.85
}

Summary​

Auto-generated narrative summaries updated as new facts arrive.

Document​

Represents an ingested document linked to its extracted entities.

Relationship Types​

RelationshipDescriptionExample
HAS_FACTEntity → FactJohn → HAS_FACT → "Senior engineer"
HAS_SUMMARYEntity → SummaryJohn → HAS_SUMMARY → Summary v3
RELATES_TOEntity → EntityJohn → WORKS_AT → Google
SOURCE_OFDocument → Entityresume.pdf → SOURCE_OF → John

RELATES_TO edges carry a type property (e.g., WORKS_AT, HAS_SKILL, CONTRIBUTED_TO).

Extraction Process​

When text enters SharedMemory, the knowledge extractor:

  1. Identifies entities — People, organizations, technologies, projects
  2. Extracts facts — 3-6 facts per work experience, 2-4 per education/project
  3. Builds relationships — How entities connect to each other
  4. Deduplicates — Merges with existing entities by name + volume
  5. Updates summaries — Regenerates entity summaries incorporating new facts

Example​

Input: "John worked as a senior engineer at Google from 2021-2024, building distributed systems with Go and Kubernetes."

Extracted:

  • Entities: John (Person), Google (Organization), Go (Technology), Kubernetes (Technology)
  • Facts: "Senior engineer at Google 2021-2024", "Built distributed systems"
  • Relationships: John WORKS_AT Google, John HAS_SKILL Go, John HAS_SKILL Kubernetes

Querying the Graph​

Via SDK​

const john = await memory.getEntity("John Smith")
const results = await memory.searchEntities("Google")
const graph = await memory.getGraph()

Via API​

POST /agent/entity
{ "volume_id": "...", "entity_name": "John Smith" }