Stop 14 · Retrieval-Augmented Generation & Vector DatabasesTopics · 9/9

Knowledge Graphs (Overview)

Part of the AI Engineer Roadmap

In short

Some questions are about connections: 'Which suppliers of our top product are in Gujarat?' Plain chunk search struggles with that. Knowledge graphs store facts as linked entities, so you can follow the links.

Structured representations of entities and their relationships — an alternative or complement to vector search for queries that need explicit relational reasoning.

The blob points at a big family tree of round portrait frames joined by coloured strings on a wall.

Think of it like this

The wedding family tree

At a big Indian wedding, someone always draws the family tree: who is whose cousin, whose mama, whose daughter-in-law. With the tree, 'how is Rohan related to Priya?' is a quick walk along the lines. A knowledge graph is that tree, for any kind of fact.

Watch it happen

Facts around one company (fictional)

Zentro Ltd
HQ: Pune
CEO: Asha
Makes: KoolFan
Supplier: MotoCo
State: Gujarat

1/5Each node is an entity. Each line is a relationship, stored as a triple: (Zentro, HQ_IN, Pune).

The big ideas

What you need to know

Triples are the unit

Facts are stored as (subject, relation, object), like (Asha, CEO_OF, Zentro).

Great for multi-hop

Questions that chain relationships are easy on a graph and hard with chunk similarity alone.

LLMs can build them

An LLM can extract entities and relations from text into triples. Check quality, since it makes mistakes.

Graph databases

Neo4j is a popular graph database, queried with a language called Cypher.

See it in code

Walk through the code

text
1// Cypher (Neo4j): create a few facts2CREATE (z:Company {name: "Zentro"})-[:MAKES]->(p:Product {name: "KoolFan"}),3       (p)-[:SUPPLIED_BY]->(s:Company {name: "MotoCo", state: "Gujarat"})4 5// Multi-hop question: suppliers of Zentro's products in Gujarat6MATCH (:Company {name: "Zentro"})-[:MAKES]->(:Product)-[:SUPPLIED_BY]->(s:Company)7WHERE s.state = "Gujarat"8RETURN s.name

1/3Create nodes with labels and properties, linked by named relationships.

Cypher describes paths with arrows. The query walks Company to Product to Supplier in one pattern.

Save yourself the pain

Common mistakes

Oops

Building a knowledge graph for simple document Q&A.

Do this instead

Plain RAG is enough for most 'what does the document say' questions. Use graphs when relationships are the point.

Oops

Trusting LLM-extracted triples without checks.

Do this instead

Sample and review extracted facts. Merge duplicate entities like 'Zentro' and 'Zentro Ltd'.

Your mission

Map your college

~30 min

Quick check

Which question benefits most from a knowledge graph over plain chunk retrieval?

Go deeper

  1. 1Read how GraphRAG combines knowledge graphs with vector retrieval.
  2. 2Understand when relational queries (multi-hop reasoning) beat plain vector similarity.
  3. 3Explore a simple knowledge graph tool at an overview level, without building a production one.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge