Building Knowledge Graphs
From a pile of documents to entities and relationships you can query, computed on your own machine
- Length
- 2 hours
- For
- Anyone who has wanted to use the relationships in their data to answer questions that span documents. No graph database experience needed
Arrow keys advance. P shows the notes. Esc comes back here.
- 01

antfly.io/events/building-knowledge-graphs
- 02
What we cover
- Extracting entities and relationships from documents with a local model
- Storing relationships alongside the source documents themselves
- Querying across the graph and the text in one request
- 03
Contents
- Why Graphs
- From Documents to a Graph
- Why Not Just Ask an Agent?
- 04
Why Graphs
- 05
AI search engines for science

- Often irrelevant results
- Pretty slow
- Bad precision
- 06
We take our agents having access to web-scale data as a given

- 07
The OG web-scale graph: PageRank
"Everyone links to Website B, so it must be important."
"Website B links to Website C, so it probably is as well."

- 08
From Documents to a Graph
- 09
But what if you just have a pile of documents?

- 10

- 11
Try it yourself
Ask your agent:
Or do it yourself:
git clone https://github.com/antflydb/knowledge-graphs-workshop cd knowledge-graphs-workshop make up # → http://127.0.0.1:8000 (Ctrl-C stops everything)Prerequisites:
uvand Antfly v0.3.0-rc.1 on your PATH (setANTFLY_BINif an olderantflyis installed).The first run pulls GLiNER2.5 and EmbeddingGemma (~2 GB) and the prebuilt database (~350 MB); after that it starts in seconds.
- 12

- 13
Entity extraction from text
Entity types Relationship vocabulary character parent_of house member_of kingdom rules city located_in - 14

- 15
Entity resolving

- 16
Pass through a decision model
Try to weed out weak or untrue relations.
Ordered pair Saved decision Eddard "Ned" Stark → Winterfell rules 0.575 "is the Lord of Winterfell" no_relation 0.241 unclear 0.184 - 17
Change the config and rerun


- 18
Things to try
Search the ASoIaF graph:
- Why does Tyrion kill Tywin?
- Jon Snow mother
- Dorne
Then pick one relationship:
- Open its supporting passage.
- Does the passage support the relationship's type and direction?
- Change one choice in config.yaml, rebuild, and compare.
- 19
Why Not Just Ask an Agent?
- 20

- 21

- 22

- 23

- 24
What Claude did
- Used a bunch of knowledge outside the text corpus
- Used 18 subagents and $62 of API credits
- Merged entities "by hand"
- Its agents used varying conventions
Agents can totally build knowledge graphs, but you should give them the right tools to do it.
- 25
Why not just ask an agent?
- Keep data on-prem
- More reproducible, scalable, and deterministic
- Control terminology
- Run it yourself, own it yourself
- An agent won't know your data. Hallucinations are definitely still a thing
- 26
Why else? Enterprise
Each of our systems is internally coherent and externally isolated. Atlas, our telemetry platform, knows applications and their time series. Radar, our alerting system, knows thresholds and firing history. incident.io knows severities and responders. PagerDuty knows rotations. Spinnaker knows what shipped and when. And our Slack history knows, in a form no query engine can reach, which engineer solved something very similar last quarter and what they found.
The difficulty is that they do not agree on what they are talking about.
Ontology-Driven Observability: Building an End-to-End Knowledge Graph at Netflix Scale netflixtechblog.com
- 27
Other tools
Tool What it's for Graphiti Real-time knowledge graphs for agent memory GraphRAG Graph-based retrieval-augmented generation, from Microsoft LightRAG Simple, fast graph-based RAG LLM Graph Builder Neo4j graphs from unstructured documents Cognee Open-source memory platform for agents Mem0 A memory layer for agents and apps - 28
Apollo 13

- 29
Events
- Building Knowledge Graphs
· Kiln, Portland