A hands-on online training course for learning GraphRAG. Hosted for Pearson through O’Reilly media.
This repository contains a completed solution for implementing GraphRAG with a variety of different approaches:
-
manual GraphRAG: assembling vector search + graph retrieval
-
Spring advisors: out-of-the-box, yet customizable, approaches to RAG
-
agents: allowing LLM to decide best function(s) for each question
Technologies used include:
-
Spring AI Java framework (Langchain4j also an alternative)
-
Neo4j graph database
-
OpenAI model (text-embedding-ada-002)
In order to run the application, you will need the following things:
-
OpenAI key (temporary key is granted by presenter during live course)
-
Java 17 or higher
-
Maven
A Neo4j database is set up with data pre-loaded for you to use. You are welcome to connect to this public, read-only instance or configure your own. The data schema for this instance is shown below. Though not every entity is defined in our application, the domain classes are enough to explore for this course.
Feel free to add entities or change things for further development later on!
-
Rename the
src/main/resources/exampleEnv.shscript toenv.sh:
cp src/main/resources/exampleEnv.sh src/main/resources/env.sh-
OpenAI API Key: Set your OpenAI API key in the copied
env.shscript:
export OPENAI_API_KEY=your_openai_api_key_here-
Run the
env.shto set your environment:
source ./env.shSet environment variable (if applicable) for Large Language Model - e.g. Open AI.
source ./env.shRun the application.
./mvnw spring-boot:runTest the endpoints.
#Graph query
http ":8080/articleMentions"
#LLM questions
http ":8080/llm?question=Who is Jennifer Reif?"
http ":8080/llm?question=Could you create a short poem about technology in the style of Emily Dickinson?"
http ":8080//llm?question=Who is Jennifer Reif using this as context? Jennifer Reif is a developer advocate at Neo4j, focusing on the Java ecosystem. She is a technical speaker, blogger, podcaster, and author, with an MS in CMIS."
http ":8080/llm?question=What is the latest news about toys?"
#Vector RAG questions
http ":8080/manualRAG?question=What is the latest news about toys?"
##bare minimum results
http ":8080/manualRAG?question=What organizations are mentioned related to layoffs?"
#GraphRAG questions
http ":8080/manualGraphRAG?question=What organizations are mentioned related to layoffs?"
http ":8080/manualGraphRAG?question=Which industries are most affected by the layoffs?"
#GraphRAG (advisor) questions
http ":8080/graphRAG?question=Are there new launch announcements in the news?"
http ":8080/graphRAG?question=Which industries are seeing the most change?"
http ":8080/graphRAG?question=What are the major funding announcements related to technology?"
##DEMO portion:
#Bad RAG question
http ":8080/manualGraphRAG?question=What is the latest news with Volkswagen?"
http ":8080/compare?question=What is the latest news with Volkswagen?"
#Good RAG questions
http ":8080/manualRAG?question=Were there major investments made recently?"
http ":8080/manualGraphRAG?question=Are there organizations with major investments recently?"
#Agentic
http ":8080/agents/debug/tools"
#Vector agent
http ":8080/agents/agentic?question=What news is related to cybersecurity threats?"
http ":8080/agents/agentic?question=Are there any major funding announcements related to technology?"
#Graph agent
http ":8080/agents/agentic?question=Which industries are seeing the most change?"
http ":8080/agents/agentic?question=Which organizations are dealing with layoffs?"
#Text2Cypher agent
http ":8080/agents/agentic?question=Which organizations are not public and have revenue over 50 billion?"
http ":8080/agents/agentic?question=Where is iDefense organization located?"
http ":8080/agents/agentic?question=How many employees does CRMWaypoint have?"
http ":8080/agents/agentic?question=Which organizations are mentioned most in articles?"-
Course page: GraphRAG Fundamentals
-
Neo4j courses: Graphacademy knowledge graph
-
Instructor: Find Jennifer Reif
-
More examples:
