Skip to content
Optimal Lab

AI Engineering · interactive

GraphRAG and knowledge graphs

Vector search finds notes that sound like the question. Some answers are spread across notes linked only by names: checkout calls payments, Ledger owns payments, Priya is on call for Ledger. Extract those links into a graph and you can walk them. Ask three kinds of question and compare.

User

asks

Your app

2-hop walk

Vector index

8 notes

Graph

14 nodes · 13 facts

Summaries

2 communities

LLM

answers

callsownsownsuseson call forbrokecaused byhithitcheckoutpaymentssearchStorefrontLedgerDiscoveryPriyaMarcoStripeOpenSearchinc 112inc 121inc 125inc 118
serviceteampersonincidentvendor· lit: reached by this retrieval

Checkout calls payments, Ledger owns payments, Priya is on call for Ledger: three notes, linked only by names. ✗ Graph walk: “Checkout is owned by Team Storefront, and Marco is on call for them: page Marco.”

Question

Retrieval

✗ Wrong or incomplete

Step 1 of 5

  1. 1

    Ask the question

    Some questions live in one note, some need several notes chained by names, and some are about the whole collection.

    Checkout is failing on card charges. Who should I page?

    Checkout calls payments, Ledger owns payments, Priya is on call for Ledger: three notes, linked only by names.

  2. 2

    Find where to start

    Vector search embeds the question. A graph walk needs entities: a small model call finds the services, teams and people the question names.

    Start at checkout.

  3. 3

    Retrieve

    Vector: the closest notes. Graph: every fact within N hops of the start. Global: summaries an LLM wrote for each cluster of the graph at index time.

    Hops

    • checkout calls payments
    • Storefront owns checkout
    • inc 112 broke checkout
    • Ledger owns payments
    • payments uses Stripe
    • Marco on call for Storefront
    • inc 112 caused by payments
    • inc 121 hit payments
    • inc 125 hit payments
  4. 4

    Paste it into the prompt

    Only what was retrieved reaches the model. More hops find more, and also pull in facts that don't matter.

    9 lines · 34 words

    Each fact links back to the note it came from, so the answer can cite it.

  5. 5

    Answer from that context

    The model can only join facts it was given. A missing link becomes a guess or a confident wrong answer.

    ✗ Checkout is owned by Team Storefront, and Marco is on call for them: page Marco.

    • Vector search✗
    • Graph walk, 1 hop✗
    • Graph walk, 2 hops✗
    • Graph walk, 3 hopsright ✓
    • Community summaries✗

    The price is paid at index time: an LLM reads every chunk to extract entities and relations, and writes a summary per community. That is many times the cost of embedding the same text.