Neo4j LLM Graph Builder

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.

A screenshot of the LLM Graph Builder

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.

The Neo4j LLM Graph Builder is a Neo4j Labs project is under active development, and features may change.

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:

  1. Connect the LLM Graph Builder to a Neo4j database

  2. Upload the course content

  3. 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.

A screenshot of the LLM Graph Builder connection screen
Open Knowledge Graph Builder →

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 LLM Graph Builder upload screen

The file will uploaded and added to the list of documents.

The uploaded document in the documents list

You can upload multiple documents to the LLM Graph Builder to be processed together. When creating a knowledge graph, uploading a single document to test the process is often helpful.

Once you have uploaded the document, you can create the knowledge graph using the Generate Graph button.

The generate graph button highlighted

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.

The file status shows 'processing'

Once the document has completed processing, the knowledge graph will be available for exploration.

The files status shows 'completed'

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?.

Asking the chatbot about Knowledge Graphs and getting a response

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.

cypher
CALL db.schema.visualization()
The schema for the knowledge graph

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.

The schema configuration screen

Try modifying the schema to include the following node labels:

  • Technology

  • Concept

  • Skill

  • Event

  • Person

  • Object

You must delete the existing document, re-upload the PDF, and regenerate the graph to apply the new schema.

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.