Skip to content

JMHReif/graphrag-fundamentals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphRAG Fundamentals training course

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

Overview

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)

Requirements

In order to run the application, you will need the following things:

  1. OpenAI key (temporary key is granted by presenter during live course)

  2. Java 17 or higher

  3. Maven

Data and data model

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.

companies graph data model

Feel free to add entities or change things for further development later on!

Environment setup

  1. Rename the src/main/resources/exampleEnv.sh script to env.sh:

cp src/main/resources/exampleEnv.sh src/main/resources/env.sh
  1. OpenAI API Key: Set your OpenAI API key in the copied env.sh script:

export OPENAI_API_KEY=your_openai_api_key_here
  1. Run the env.sh to set your environment:

source ./env.sh

Running the application

Set environment variable (if applicable) for Large Language Model - e.g. Open AI.

source ./env.sh

Run the application.

./mvnw spring-boot:run

Test 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?"

Labs

Instructions for hands-on exercises are available in the labs.adoc file.

Presentation slides

About

This repository contains material to accompany a live online training - GraphRAG Fundamentals

Resources

Stars

14 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors