Knowledge Graphs with Neo4j: overview
- Source
- From the RAG & Agents Engineering course
- By
- Sourav Banerjee
- Last updated
- 8 Nov 2026
A knowledge graph represents named entities and their relationships explicitly. Cypher matches those relationships; vector retrieval helps find a starting entity when a question uses different words. The T13.2 notebooks build on four ideas: the property graph, pattern queries, translating questions into Cypher, and combining graph facts with text retrieval.
The running example extends the fictional Larkspur Cloud handbook into plans, features, regions and supporting passages. The golden questions ask which plans support exports in the EU, which source establishes that capability, and what happens after a policy version changes. The notebooks use healthcare, historical and extraction examples; the Larkspur catalogue is a separate teaching fixture.
In short
- Model identity, edge direction and source provenance before querying the graph.
- Bind the same plan variable across feature and region patterns when both constraints must hold.
- The 43.3 notebook executes hand-written Cypher; automatic text-to-Cypher is an explained extension.
- Vector candidates can fail exact relationship checks. In the lab,
k=2yields no eligible plans,k=3yields one andk=5yields both. - A stored source link helps only when retrieval carries its passage into the answer evidence.
Mental model
- Read a versioned Larkspur handbook passage.
- Extract candidate facts and resolve their entity identities.
- Store relationships and retain supporting text.
- Match graph facts and retrieve related passages.
- Generate an answer from the retrieved evidence.
Extraction turns prose into candidate facts. Stable identities let those facts connect across documents, while retained passages let a reader inspect what supports them. Retrieval must carry both the matched relationship and its supporting text into the answer.
Interactive lab
Candidates and graph constraints: open the file in a browser. Increase k until the first EU export plan survives. Continue until both eligible plans appear, then inspect the extra candidate checks after recall stops changing. Read the ledger's rejection reason for the highest-ranked record.
How it connects
Key Takeaways
- Choose stable entity identities and explicit relationship meanings before import.
- Compare generated Cypher with a hand-written query and inspect rows before grading prose.
- Separate semantic candidate selection from exact graph validation and measure both stages.
- Retrieve source passages with graph assertions so each answer claim can be checked.