Slide 1

Slide 1 text

What you need to know: Data, apps, and AI for graph databases Jennifer Reif jennifer.reif@neo4j.com @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

What is a graph? Jennifer Jacob ??

Slide 4

Slide 4 text

What is a graph? Company Jennifer Jacob WORKED_FOR WORKED_FOR

Slide 5

Slide 5 text

What is a graph? Company Jennifer Jacob School W ORKED_FOR WORKED_FOR ATTENDED ATTENDED

Slide 6

Slide 6 text

What is a graph? Degree Degree Company Jennifer Jacob School W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN ATTENDED ATTENDED

Slide 7

Slide 7 text

What is a graph? Adrian Degree Degree Company Jennifer Jacob School W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN ENROLLED_IN Degree C O M PLETED COM PLETED ATTENDED ATTENDED

Slide 8

Slide 8 text

What is a graph? Person Degree Degree Company Person Person School 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 ATTENDED ATTENDED

Slide 9

Slide 9 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 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 ATTENDED ATTENDED

Slide 10

Slide 10 text

Nodes (vertices) Objects or entities • Can have labels • May have properties Person Degree Degree Company Person Person School Degree Edward Jones Jacob Jennifer SIUE Music CMIS CS Adrian

Slide 11

Slide 11 text

Relationships (edges) Connect entities • Must have type (label) • Must have direction • May have properties Person Degree Degree Company Person Person School 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 ATTENDED ATTENDED

Slide 12

Slide 12 text

Example: Logistics Home

Slide 13

Slide 13 text

Logistics • Where fi rst? • Depends on when ready to leave house Home School Opens: 08:00 Donation Opens: 09:00 Shipping Opens: 10:00 Grocery Opens: 07:00

Slide 14

Slide 14 text

Logistics Criteria • Where is time critical? • Personal preferences for refrigerated food? • How long at each store? Music Home School Opens: 08:00 Donation Opens: 09:00 Shipping Opens: 10:00 Grocery Opens: 07:00 WENT_1 W ENT_2 WENT_3 WENT_4 W ENT_5 WENT_6

Slide 15

Slide 15 text

Answer questions Habits/preferences • E ffi ciency improvements? • Adding stop? Where/time? • Share load across more people? • Distance and location calculations? Music Home School Opens: 08:00 Donation Opens: 09:00 Shipping Opens: 10:00 Grocery Opens: 07:00 WENT_1 W ENT_2 WENT_3 WENT_4 W ENT_5 WENT_6

Slide 16

Slide 16 text

Other use cases • Fraud detection • Identity and access management • Recommendations • Supply chain

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Applications

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Translates to app model, too! • Java, OOM language • Entity-based mapping • Very little change • Neo4j/Java types nearly same @Node public class Order { @Id String orderId; LocalDate orderDate; LocalTime orderTime; String inStore; @Relationship(value = "BOUGHT", direction = Relationship.Direction.INCOMING) Customer customer; [ { "customer": { "customerId": "1", "customerName": "Kelly Key", "loyaltyId": "908-424-2890" }, "inStore": "N", "orderDate": "2019-04-01", "orderId": "76", "orderTime": "07:52:17" }, { "customer": { "customerId": "1", "customerName": "Kelly Key", "loyaltyId": "908-424-2890" }, "inStore": "N", "orderDate": "2019-04-01", "orderId": "662", "orderTime": "14:53:06" },

Slide 22

Slide 22 text

Let’s code!

Slide 23

Slide 23 text

AI

Slide 24

Slide 24 text

Throw an LLM at it Doesn’t often work • LLM strengths: • human-consumable data • general/public info • LLM weaknesses: • context/big picture • private knowledge • Solo LLM = great -> integrated LLM = more great?

Slide 25

Slide 25 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 26

Slide 26 text

GraphRAG Graph DB as a data source • Graph fi lls in LLM weaknesses! • Store relevant knowledge

Slide 27

Slide 27 text

GraphRAG benefits Graph DB as a data source • Higher accuracy (more relevance in result) • Using existing, quality data • Explainability, veri fi ability

Slide 28

Slide 28 text

Let’s code!

Slide 29

Slide 29 text

Resources • Github repository (today’s code): github.com/JMHReif/springai-goodreads • 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 jennifer.reif@neo4j.com @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif