Storing LLM Extracted Entities and Relationships in Neo4j

Learn how to write modular code to store a large number of LLM-extracted entities and relationships for our dataset in Neo4j.

In the previous lesson, we covered how to store two hard-coded entities and the relationship between them in Neo4j. Now, we’ll move forward by storing an entire list of entities and relationships extracted from our question-answer dataset.

A modular implementation: Storing data to Neo4j

If we look at the code below, the only new file we see is neo4j_db.py. We'll understand how this file manages the storage of entities and relationships in Neo4j. In this file, we define a class, Neo4jHandler, which is used to manage interactions with a Neo4j database. The class allows us to store entities and relationships extracted from our dataset into Neo4j in a structured and efficient way.

Get hands-on with 1400+ tech skills courses.