Slide 1

Slide 1 text

GraphRAG: Data with Context Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif Photo by Tomasz Frankowski on Unsplash

Slide 2

Slide 2 text

Who is Jennifer Reif? Developer Advocate, Neo4j • Continuous learner • Technical speaker • Tech blogger, podcaster • Other: geek Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif

Slide 3

Slide 3 text

What is a graph? Answers through relationships • How many coworkers shared classes/degrees? • What are common degree journeys? • How many alumni re- enroll for higher degrees? • Who else went to a school and works for company? Person Degree Degree Company Person Person School ATTENDED ATTENDED W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN ENROLLED_IN Degree C O M PLETED COM PLETED Edward Jones Jacob Jennifer SIUE Music CMIS CS Adrian

Slide 4

Slide 4 text

Graphs add context and meaning Not just point-to-point, but HOW they connect

Slide 5

Slide 5 text

Data model

Slide 6

Slide 6 text

One model to rule them all… Conceptual = Logical = Physical data model

Slide 7

Slide 7 text

One model to rule them all… Conceptual = Logical = Physical data model

Slide 8

Slide 8 text

Knowledge Graphs

Slide 9

Slide 9 text

A knowledge graph is a specific implementation of a graph database, where information is integrated from many different sources, representing the inherent knowledge of a particular domain.

Slide 10

Slide 10 text

Layers of data value

Slide 11

Slide 11 text

Demo!

Slide 12

Slide 12 text

AI

Slide 13

Slide 13 text

Layers of AI • More layers = better result • Complexity vs value

Slide 14

Slide 14 text

Throw an LLM at it Doesn’t often work • LLM strengths: • human-consumable data • probabilistic answers • LLM weaknesses: • complex logic • recognizing nuances • Solo LLM = great -> integrated LLM = more great?

Slide 15

Slide 15 text

RAG architecture • Retrieval • Data retrieved from external source • Augmented • Augments response with facts • Generation • Response in natural language Prompt + Relevant Information LLM API LLM
 Chat API User Database Search Prompt Response Relevant Results / Documents 2 3 1 Database

Slide 16

Slide 16 text

LLMs take text, not databases And context window limit

Slide 17

Slide 17 text

Lexical to Semantic search Semantic layer • Keyword searches aren’t enough • Data dictionaries are complex and limited • How do we search relevant/contextual info?

Slide 18

Slide 18 text

Embeddings / Vectors Convert data to a point in space • Series of numbers • 100s or 1000s of dimensions • Dimension = interesting feature / characteristic

Slide 19

Slide 19 text

Vectors in the physical realm https://www.mathsisfun.com/algebra/vectors.html

Slide 20

Slide 20 text

Vectors in the technical realm Kings and Queens king − man + woman ≈ queen king man wom an 1 king man wom an 2 queen? 3

Slide 21

Slide 21 text

LLMs take certain formats, not databases Vectors

Slide 22

Slide 22 text

How do we search the vectors? Similarity search • Expensive queries (compare to every vector) • Approximate nearest neighbor (k-ANN) • Example: Library • Book classi fi cation - genre vs location of plot • Smaller search set = smaller retrieval time! Photo by Martin Adams on Unsplash

Slide 23

Slide 23 text

Provide prompt + context to LLM Vectors Text

Slide 24

Slide 24 text

Vector-only RAG Similarity is insu ff i cient for rich reasoning/explainability • Missing context, relationships • Vector similarity != relevance • Lack explainability

Slide 25

Slide 25 text

GraphRAG layer Graph DB as a data source • More relevant data to provide as context • Quality connected data, higher accuracy • Explainability, veri fi ability

Slide 26

Slide 26 text

Explainable AI Why graph with GenAI? • How did the LLM get this answer? • Graphs: • Incorporating siloed data into result • Add extra context/related info to graph • Better veri fi cation through understandable format Photo by No Revisions on Unsplash

Slide 27

Slide 27 text

Knowledge graph as knowledge base Document in KG -> Knowledge Graph

Slide 28

Slide 28 text

Explainability layer

Slide 29

Slide 29 text

Nothing is a silver bullet LLM is (of sorts) mind of its own • Can’t guarantee a consistent answer • Prompt engineering • Context window limits

Slide 30

Slide 30 text

Let’s code!

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Resources • Github repository (today’s code): github.com/JMHReif/ai-pet-travel • GraphAcademy LLM courses: graphacademy.neo4j.com/categories/llms/ • Docs for Spring AI: docs.spring.io/spring-ai/reference/api/vectordbs/neo4j.html • Knowledge graph ebook: https://neo4j.com/whitepapers/developers-guide-how- to-build-knowledge-graph/ Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif