In this lesson, you will use the LLM Graph Builder to construct a simple knowledge graph.
LLM Graph Builder
The Neo4j LLM Graph Builder is a tool for turning unstructured data into a knowledge graph. It automates the same process described in the previous lesson and builds graphs from text.
The LLM Graph Builder includes a chat interface to interact with the graph and explore the data. The chatbot can use different Retrieval Augmented Generation (RAG) approaches to answer questions, including GraphRAG, Vector Search, and Text2Cypher.
You can upload text-based documents and import text directly from Wikipedia and YouTube.
The LLM Graph Builder allows you to configure the LLM model, the types of entities and relationships, and a pre-defined schema.
You can learn more in the Neo4j LLM Graph Builder documentation.
Create a Knowledge Graph
You will use the LLM Graph Builder to create a knowledge graph of the GraphAcademy course content. You can then ask questions about the course content and explore the relationships between the different topics.
To complete this task, you will need to:
-
Connect the LLM Graph Builder to a Neo4j database
-
Upload the course content
-
Generate the knowledge graph
Connect to Neo4j
When you open the Neo4j LLM Graph Builder, you will be prompted to Connect to Neo4j. The LLM Graph Builder will create your knowledge graph in this database.
You can use the Neo4j Sandbox that was created for you when you enrolled in the course:
- Protocol
-
bolt
- URI
-
{sandbox-ip}:{sandbox-boltPort}
- Database
-
neo4j
- Username
-
{sandbox-username}
- Password
-
{sandbox-password}
Ensure you have the correct connection details and connect.
Upload the course content
You will use the lessons from the Neo4j & LLM Fundamentals course. We have converted the lessons into PDF documents so you can upload them.
Download the PDF file for lesson 1 - Introduction to Neo4j & GenAI.
Upload the PDF file to the LLM Graph Builder.
The file will uploaded and added to the list of documents.
Once you have uploaded the document, you can create the knowledge graph using the Generate Graph button.
When generating the graph, the LLM Graph Builder runs the steps described in the previous lesson. The application chunks the data, creates vectors, extracts the nodes and relationships, and creates the graph.
Once the document has completed processing, the knowledge graph will be available for exploration.
Preview
You can preview the graph for a single document by selecting the document and clicking the Preview Graph button. image::images/preview-annotated.png[The file is selected and Preview Graph button highlighted]Query the Knowledge Graph
You can use the built-in chatbot to ask questions about the document’s content.
The PDF file for lesson 1 contains information about Knowledge Graphs, try asking What is a Knowledge Graph?.
The chatbot will use the knowledge graph to find the answer.
Review the lesson content, try asking other questions, and review the response.
Schema
Currently, the LLM will extract any nodes and relationships in the text. The graph can become complex even with a single, relatively simple document.
You can view the current schema using the db.schema.visualization()
function.
CALL db.schema.visualization()
This unrestricted schema can help understand granular details in the text. However, you can focus on specific entities and relationships by defining a schema.
The schema is a set of node labels and relationship types you want to identify within the text.
To define a schema, click the Graph Enhancement button.
You can load a pre-defined schema or supply a list of node labels and relationship types.
Try modifying the schema to include the following node labels:
-
Technology
-
Concept
-
Skill
-
Event
-
Person
-
Object
Experiment with different schema configurations to see how the graph changes.
When you are ready, move on to the next lesson.
Summary
In this lesson, you learned how to create a knowledge graph using the Neo4j LLM Graph Builder.
In the next lesson, you will explore the knowledge graph using Cypher.