A hands-on online training course for learning GraphRAG. Hosted for Pearson through O’Reilly media.
Quarkus/Langchain4j version of this app: graphrag-fundamentals-quarkus
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=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=Which companies recently announced major layoffs?"
http ":8080/llm?question=What cybersecurity threats are being discussed in current news?"
#Vector RAG questions
http ":8080/manualRAG?question=Which companies recently announced major layoffs?"
http ":8080/manualRAG?question=What cybersecurity threats are being discussed in the news?"
#GraphRAG questions
http ":8080/manualGraphRAG?question=Which companies recently announced major layoffs?"
http ":8080/manualGraphRAG?question=Which industries are most affected by layoffs?"
#GraphRAG (advisor) questions
http ":8080/graphRAG?question=Which industries are most affected by layoffs?"
http ":8080/graphRAG?question=What industries are seeing the most investment activity?"
##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?"
##Graph agent
http ":8080/agents/agentic?question=Which companies are active in the finance industry?"
##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 JD.com organization located?"
http ":8080/agents/agentic?question=How many employees does Amazon have?"
http ":8080/agents/agentic?question=Which organizations have the most article mentions and what sectors are they in?"
##Combination
http ":8080/agents/agentic?question=What industries are most represented among organizations in the graph?"-
Course page: GraphRAG Fundamentals
-
Neo4j courses: Graphacademy knowledge graph
-
Instructor: Find Jennifer Reif
-
More examples:
