Day 49 of #100daysofnetworks
Knowledge Graph Anatomy 101: An Exploration
Hello everyone. A lot has happened since my last article, and I learned a lot, so I feel like I have a million things to write about. Here’s some of the excitement!
I was hired as a Principal ML and AI Engineer. I’m really enjoying the job. I’m also very happy that the job search is over. That is always stressful, for anyone.
While I was looking for a job, I stayed very busy in research and development, for things that I am interested in. As a result, I have created several of my own AI tools and interfaces for various things, and I am really impressed with improvements to accuracy and reliability compared to what I have experienced with other approaches.
I have extended my implementation of GraphRAG to Temporal Graph RAG and am now working on extending beyond even that. My previous work in #100daysofnlp helped me come up with interesting and powerful techniques, and now I am using them to hopefully open up my AI interfaces to being able to do even more. This is very experimental. I have no findings to communicate, yet.
So, with all that, it has been a bit difficult to write, as I feel like I have a million things to say. But inspiration eventually kicks in and that always jumpstarts the writing.
So, let’s start with quiet, and let all of that fade into the background…
…
<quiet>
Anatomy of Knowledge Graphs
Today, I am going to write about the anatomy of Knowledge Graphs. Knowledge Graphs are different from other network graphs we have explored, as Knowledge Graphs are constructed, not natural. They are created by intelligence (human or AI). They hold relationships between things and other things, and between other categories of things. Whereas, the networks we often explore on this blog are often more like social networks, how things work together, such as Arxiv collaboration networks.
Lately, I have met people who just want to see a Knowledge Graph. They hear people talking about them all the time, but they want to SEE them. You can learn a lot about a graph just by looking at them.
So, to save everyone a mountain of time and work, here are two Knowledge Graphs I made for today:
Jane Austen, Pride and Prejudice - https://github.com/itsgorain/100daysofnetworks/blob/main/data/kg/kg_jane_austen.htm
Red Letter Scripture from the New Testament of the Bible - https://github.com/itsgorain/100daysofnetworks/blob/main/data/kg/kg_jesus_red_letter.htm
Just click the download button and then you can open them in a browser.
I chose them because they both mention people and events. They both describe things happening at different times. In fact, the Jane Austen KG captures temporal attributes, dates.
Look closely and you can see January 1820, May 1820, “date of <various things>”, and other things. If you create a temporal KG with more content with more dates, you would see more dates. This book is fiction, so I can imagine there would be fewer specific dates. Still, it’s very interesting.
Well, we’ve already jumped in, so let’s jump in.
Anatomy of a Knowledge Graph: Exploration
First, something to know: there’s not one single way to create a KG. There are many, and as many as you can imagine and build, even. But for prototyping things quickly, I don’t want to reinvent the wheel. Today, I’m just going to show Cognee, because it makes it extremely easy to create a usable KG very quickly, and chat with it. These ones took minutes to create. In the future, we may explore more KG tools and approaches. Let me know in the comments if there is something you would like to learn more about.
We will explore both of the KGs. I’m not going to introduce the books. Please Google what they are about, if you are curious and don’t know.
What is Cognee?
I’ll save a ton of time by saying that Cognee is a tool that helps you very quickly create usable Knowledge Graphs. It is more than just a tool for creating Knowledge Graphs, so please explore them at https://www.cognee.ai.
From their website:
You should really learn about Cognee.
Creating a Knowledge Graph
Cognee is very, very easy to use. Please just follow the steps here. https://docs.cognee.ai/getting-started/quickstart
Setup is a breeze. Their documentation is clearer than if I explained it again. Once you have text in a ‘text’ variable, the rest is easy and repeatable. Put whatever text you want in that ‘text’ variable and experiment.
Here is their minimal example. Start there until you get it to work.
IMPORTANT: I also recommend saving the KG to an HTML file. Here is how I do it.
filename = “/work/html/kg_jane_austen.htm”
html = await cognee.visualize_graph()
with open(filename, “w”, encoding=”utf-8”) as f:
f.write(html)Then, you can explore them, like we are going to do now.
Jane Austen, Pride and Prejudice
Open the Jane Austen Knowledge graph linked to previously. Then you can interact with it, too. Once it opens, it will render the entire Knowledge Graph. From our previous articles, you can consider this Whole Network Analysis (WNA). We are exploring the whole graph.
Notice the purple dots. Those are categories. You’ll see that they have vague names, like “date”, “person”, “organization”, “event”, etc. These are your higher level categories. When considering a KG for use, you should inspect the KG’s categories, and how the KG has been built.
If you click onto one of the purple nodes and drag it in any direction, its connected nodes will move with it, making things easier to see.
In this screenshot, I grabbed the “location” node, and I can see that it is linked to several specific locations.
If I do the same with the “person” node, I can see all of this:
I can see lots and lots of characters from Pride and Prejudice, and how they are connected. Explore this KG and see what other interesting nodes you can find.
Bible, New Testament, Red Letter Scripture
Looking at the KG created from Red Letter Scripture is pretty revealing. It is like a trip through time.
First, the graph looks different, but also similar to Pride and Prejudice. Notice the white nodes on the left. Notice that the purple nodes are categories and that the orange nodes are specific. You learn a lot about a graph by first just looking at it and exploring it.
If I grab the “group” node and draw it far to a less dense side, I can start to see some of the individual groups. I’m sorry this is a little blurry. This was a harder set to capture. I see: the peacemakers, the fallen prophets, the merciful, the poor in spirit, the meek, the pure in heart. Very cool.
I can also see a “concept” node I had never noticed before.
This contains concepts such as sacrifice, resurrection, and betrayal. Very interesting! I will have to chat with this KG about these, using AI.
And if I drag the person node, I can explore what people are mentioned in the text.
Cognee: You Can Chat with It
If you use Cognee with your LLM of choice, you can chat with your knowledge graph. Here are some examples from some quick prompts:
I had ChatGPT help come up with difficult questions. You can prompt Cognee’s search with whatever you like. I wanted to “stress test” it by seeing what it could do.
This is what it looks like when I ask a question:
Prompt: Map every significant relationship—romantic, familial, or social—among the main characters in *Pride and Prejudice*, and describe the nature and evolution of each connection throughout the story.
(Note: seriously, I would like to see anyone attempt that off the top of their head…)
And here is a screenshot of the response. I have not validated it yet, just showing part of the answer.
Prompt: What happened at Netherfield Park?
Answer: “At Netherfield Park, Mr. Bingley, a wealthy and affable gentleman, has taken residence, creating excitement among local families, particularly the Bennet sisters. His arrival prompts Mrs. Bennet to hope for potential marriages for her daughters, sparking social engagements, notably a dinner invitation and various gatherings. However, the interactions are also characterized by the introduction of Mr. Darcy, which stirs emotions, especially for Elizabeth Bennet, who has had previous encounters with him, leading to tension and expectations.”
You will need to evaluate the answers. I specifically used GPT4 for this, not GPT5. Apparently, some nuance has been lost, but I am pretty happy with this as first results. This isn’t tuned, this is rough.
Prompt: What happened when Bingley returned to Netherfield?
Answer: “When Bingley returned to Netherfield, he arrived to mixed emotions from the Bennet family, particularly Jane, who felt distressed yet curious about his presence. Elizabeth observed that Bingley seemed pleased but also embarrassed, particularly in the presence of her mother, who engaged awkwardly with him. Bingley expressed a continued interest in Jane, and despite Elizabeth’s confusion and discomfort, she noticed that his admiration for Jane rekindled during the visit.”
Now, You Try!
That’s enough for today. I wanted to give you enough to enable you to get to experimentation as quickly as possible. Now you have two example Knowledge Graphs to play with, a description of Cognee, some example code, some example prompts, and some example answers that I am getting.
After this is validation. That takes a lot more work. I will write about validation another time. For now, consider independent LLMs, routers, and let your mind wander.
Please Support this Blog
This blog has over 700 subscribers. I have written nearly 50 articles. Each article typically involves about four hours of research and development, so that’s about 200 hours of valuable work and writing that I’ve provided for free, because most important is that I want people to learn this. I am not doing this to make money.
However, these days, there are things that I would like to do. We now have a Graph Database to use. If we have more support, we can do bigger and more powerful experiments, and learn from them together. This helps all of us.
So, I have opened up a few ways for you to support this blog:
If you are a subscriber, please consider converting to a paid subscriber. I provide code, data files, and coding explanations that are absolutely worth more than $8 per month. But I understand that not everyone can afford to pay, and that’s fine. Free is absolutely fine, for those who need free.
If you are a paid or unpaid subscriber and you want more flexibility in your contributions, I set up a ko-fi account. CLICK HERE. You can use this to buy me a coffee ($5 donation) or even to pitch in to support the Neo4j Aura instance, which we now have.
And no matter what, if you are here, please buy and read my book. I am working on more book projects, as mentioned on Day 43.
Oh, and please participate in comments. I am a friendly guy. What is on your mind? What graph challenges are you facing? Have any cool ideas you want to brainstorm? Don’t be intimidated, for sure. Be creative instead.














David - what advice or resources can you provide on effective graphic organizing principles? The problem I am working is organizing health studies into a knowledge graph. Information includes program, study type, findings, etc. Using neo4j. Trying to determine the optimal way to structure the connections for question and answering