dynavec / Docs / Knowledge graph

Knowledge graph

Attach meaning to embeddings and traverse it to guide search.

Alongside the vector index, dynavec keeps a lightweight entity-relationship graph in DynamoDB. Entities link to documents; you can traverse the graph first (cheap key lookups) to gather a candidate set, then rank only those against the query embedding. That is the DynamoDB → S3 Vectors reference join.

# build the graph
db.graph_add_edge("acme", "competes_with", "globex", namespace="kb")
db.graph_link("acme", ["doc-1", "doc-2"], namespace="kb")

# GraphRAG: traverse from seeds, then rank related docs by the query
hits = db.graph_search(
    "recent product launches",
    seed_entities=["acme"],
    hops=2,
    top_k=10,
    namespace="kb",
)

Traversal helpers: graph_add_node, graph_add_edge, graph_link, graph_neighbors.

Removing nodes and edges

Both deletes are idempotent — removing something that is already gone returns 0 — and both return the number of edges removed.

# drop one relation (pass bidirectional=True to remove the reverse edge too)
db.graph_delete_edge("acme", "competes_with", "globex", namespace="kb")

# drop an entity, its outbound edges, and every edge pointing at it
db.graph_delete_node("globex", namespace="kb")

graph_delete_node leaves linked documents and their embeddings in place; delete those with db.delete(...) if you want them gone. Nothing indexes inbound edges, so finding them scans the namespace (dynamodb:Scan) — fine for occasional cleanup, not for a hot path. Edge removal is a conditional write that retries if another writer changes the adjacency list concurrently.

The graph uses embedded adjacency lists (one item per node). Very high fan-out entities want a sort-key adjacency design — on the roadmap.