Knowledge Graphs
and Generative AI
Data Science Solutions
Architect
Neo4j
1
Dr. Katie Roberts
© 2023 Neo4j, Inc. All ri hts reserved.
Agenda
Groundin LLMs with Knowled e
Graphs
● Knowled e Graphs
● Graph Data Science
● Semantic Search
Neo4j Grounded Chatbot Demo
2
Katie Roberts
Data Science Solution Architect
© 2023 Neo4j, Inc. All ri hts reserved. 3
LLMs Give Us an Amazing
Opportunity to:
Automate data
retrieval tasks
Improve customer
service experiences
Expedite readin ,
understandin , & summarizin
2
Generate
content & code
4
1
3
© 2023 Neo4j, Inc. All ri hts reserved.
Example…
Q: What was the impact o Hurricane Lee?
● A: Hurricane Lee was a lon -lastin tropical cyclone that
ormed in the Atlantic durin the 2017 hurricane season…..
4
© 2023 Neo4j, Inc. All ri hts reserved. 5
But There Are Challenges…
Knowledge
cut-off
1
Reasonable answers,
not always accurate
Can inherit bias throu h
trainin data
2 3
Lack of enterprise
domain knowledge
4
Inability to veri y or
attribute sources
5
© 2023 Neo4j, Inc. All ri hts reserved. 6
How can you take advantage of this
massive opportunity while
overcoming these challenges?
© 2023 Neo4j, Inc. All ri hts reserved. 7
Use a Knowledge Graph to
Ground LLMs
What was the
impact o
Hurricane
Lee?
Hurricane Lee
may impact
distribution
networks in
the ollowin
areas: MA, NY,
NH, ME…
© 2023 Neo4j, Inc. All ri hts reserved. 8
Grounding with Neo4j
Knowledge Graphs
Connect Enrich Consume
Context rich,
connected view o
your data that
enables easier
decision makin
Enhance your data
with raph data
science, text
embeddin s, and
additional derived
context
Ground responses
with in ormation and
context in the raph
Improve search
relevance combinin
vector search and
raph traversals
© 2023 Neo4j, Inc. All ri hts reserved.
Connected Data
9
With Knowled e Graphs
© 2023 Neo4j, Inc. All ri hts reserved.
Knowledge Graphs
10
Structured
Unstructured
Ontolo ies
Graph Al orithms and
Graph Queries
Semantics,
Derived Relationships and
Additional Context
Natural
Relationships
© 2023 Neo4j, Inc. All ri hts reserved. 11
What can you do with a knowledge graph?
Finance
How many fla ed accounts are
in the applicant’s network 4+
hops out?
How many lo in / account
variables in common?
Add these metrics to your
approval process
What completes the
connections rom enes to
diseases to tar ets?
What enes can be reached 4+
hops out rom a known dru
tar et?
What mechanisms in common
are there between two dru s?
Collaborative filterin : users
who bou ht X, also bou ht Y
What items make you more
likely to buy additional items in
subsequent transactions?
Traverse hierarchies-what items
are similar 4+ hops out?
Li e Sciences
Marketin &
Recommendations
© 2023 Neo4j, Inc. All ri hts reserved.
Enrich
12
With Cypher Patterns, Graph Data Science &
Text Embeddin s
© 2023 Neo4j, Inc. All ri hts reserved.
Graph Enrichment
13
Human-cra ted query, human-readable result
MATCH (p1:Person)-[:ENEMY]->(:Person)<-[:ENEMY]-(p2:PERSON)
MERGE (p1)-[:FRIEND]->(p2)
AI-learned ormula, machine-readable result
Predefined ormula, human-readable result
PageRank(Emil) = 13.25
PageRank(Amy) = 4.83
PageRank(Alicia) = 4.75
Node2Vec(Emil) =[5.4 5.1 2.4 4.5 3.1]
Node2Vec(Amy) =[2.8 1.8 7.2 0.9 3.0]
Node2Vec(Katie) =[1.4 5.2 4.4 3.9 3.2]
Queries
Al orithms
Embeddin s
Machine
Learnin
Workflows
Train ML models
based on results
© 2023 Neo4j, Inc. All ri hts reserved.
What Are Graph Algorithms?
14
© 2023 Neo4j, Inc. All ri hts reserved. 15
Insights From Graph Algorithms
Outliers, Influencers, Vulnerabilities,..
Recommendations, Homophily, Outliers,..
Recommendations, What-i Analysis, Disambi uation,..
Shortest Path, Optimal path, Route Optimization,...
Link prediction, Recommendations, Next-Best Action,..
Centrality
Pathfinding
Community
Detection
Similarity
Embeddings
Link Prediction
Dimensionality Reduction, Representation Learnin , ..
© 2023 Neo4j, Inc. All ri hts reserved.
Text Embedding Vectors for
Semantic Search
16
Given a question, find the most relevant documents based on a similarity metric
(such as Cosine Similarity) between vector o the question and vectors o
contents.
Movin rom keyword search to similarity (semantic) search.
Q: what is a text
embeddin ?
abstractId similarity
456 0.923445
22 0.892114
… ...
Top K by similarity
© 2023 Neo4j, Inc. All ri hts reserved. 17
Graph Data Science Journey
Find the patterns you’re
looking for in connected data
Identify associations,
anomalies, and trends using
unsupervised machine learning
Learn features in your graph
that you don’t even know
are important yet
Knowled e Graphs
Graph Al orithms
Graph Native ML
→
→
© 2023 Neo4j, Inc. All ri hts reserved.
Consume
18
With LLMs and Semantic Search
© 2023 Neo4j, Inc. All ri hts reserved. 19
Semantic Search Journey
Vector Similarity
Search
Graph Traversals &
Pattern Matchin
Knowled e Graph
In erence & ML
Find relevant documents and
content or user queries
Find people, places, and thin s
associated to content. Identi y
patterns in connected data.
Further improve search
relevance and insi hts by
enhancin your Knowled e
Graph.
Use raph al orithms and ML
to discover new relationships,
entities, and roups.
Vector Database Graph Database
Neo4j
Graph Data Science
© 2023 Neo4j, Inc. All ri hts reserved. 20
Knowledge Retrieval with Neo4j
© 2023 Neo4j, Inc. All ri hts reserved.
RAG (Retrieval Augmented Generation)
Pattern with Neo4j
21
Neo4j
LLM API
User
Cypher Prompt + Relevant
In ormation
Prompt Response
Relevant Results
Retrieve relevant results rom Neo4j
usin LLM to enerate embeddin s
and/or Cypher
2
3
1
1
2
3
Combine relevant results with
prompt
Instruct LLM to only use the relevant
results to enerate response
LLM API
Embeddin s and/or
Cypher Generation
Improved ACCURACY and RELEVANCE o
responses
E. . What is the impact o Hurricane
Calvin?
Hurricane Calvin caused minor floodin in
Hawaii….
vs…
50 policyholders may be at risk o property
dama e due to Hurricane Calvin.
© 2023 Neo4j, Inc. All ri hts reserved. 22
Q: Does claim X
have any
association with
previous
fraudulent
parties?
Q: Provide a list
of claims with
damage
amounts
>$100,000
Q: What
policyholders
may be impacted
by Hurricane
Calvin?
Knowledge Retrieval with Neo4j
© 2023 Neo4j, Inc. All ri hts reserved.
Demo Intro
23
LLM Chatbot
© 2023 Neo4j, Inc. All ri hts reserved.
Typical Business Resilience Data
Analyze business impact o
● so tware & OS vulnerabilities,
● hardware & so tware up rades,
● buildin / eo raphic disasters
● chan es to business data ormats
…across mission critical applications and
business locations
24
hierarchies, flows,
relationships…
© 2023 Neo4j, Inc. All ri hts reserved.
Actual Data Model
25
CVE Data
Business Data
Elements
Vendors,So tware
Business Tasks
Application Instances
Data Trans ers
People/Roles
Locations
IT Assets
© 2023 Neo4j, Inc. All ri hts reserved.
LangChain
Demo
Application
● Translates En lish to
Cypher
● Consumption usin LLM
model with ew shot
promptin
● Data au mentation rom
Neo4j response
26
© 2023 Neo4j, Inc. All ri hts reserved. 27
Demo
© 2023 Neo4j, Inc. All ri hts reserved.
Neo4j Database
30
API
Knowled e Graph
Graph Data Science
Graph DB
Knowled e Apps
In ormation Extraction
& In estion
Structured
Unstructured
Ontolo ies
GCP Vertex AI
Data
Sources API Layer
Customer Service
Ticket Tria in
Recommendations
News Content &
Discovery
Enterprise Knowled e
Search
Patient Prioritization
Clinical Decision
Support Systems
Pharmacovi ilance
Health Assistants
FAQ Bots
LLMs
Amazon
Sa eMaker
AzureML
Bloom
Aura Enterprise Edition LLMs
API
Step 1: Capture Knowled e Step2: Enrich Step 3: Semantic & Contextual Search
© 2023 Neo4j, Inc. All ri hts reserved. 31
Neo4j Enriches All Phases of an
AI Ecosystem
Knowled e Graphs Graph Feature
En ineerin and Graph
ML
Graph Analytics,
Investi ations and
Counter actuals
Inte rations and
Knowled e Graphs or
Heuristic AI
Connect Analyze Capitalize
Interpret
Neo4j Neo4j GDS Neo4j Bloom Neo4j Connectors
© 2023 Neo4j, Inc. All ri hts reserved.
Thank
You!
katie.roberts@neo4j
32

Knowledge Graphs and Generative AI

  • 1.
    Knowledge Graphs and GenerativeAI Data Science Solutions Architect Neo4j 1 Dr. Katie Roberts
  • 2.
    © 2023 Neo4j,Inc. All ri hts reserved. Agenda Groundin LLMs with Knowled e Graphs ● Knowled e Graphs ● Graph Data Science ● Semantic Search Neo4j Grounded Chatbot Demo 2 Katie Roberts Data Science Solution Architect
  • 3.
    © 2023 Neo4j,Inc. All ri hts reserved. 3 LLMs Give Us an Amazing Opportunity to: Automate data retrieval tasks Improve customer service experiences Expedite readin , understandin , & summarizin 2 Generate content & code 4 1 3
  • 4.
    © 2023 Neo4j,Inc. All ri hts reserved. Example… Q: What was the impact o Hurricane Lee? ● A: Hurricane Lee was a lon -lastin tropical cyclone that ormed in the Atlantic durin the 2017 hurricane season….. 4
  • 5.
    © 2023 Neo4j,Inc. All ri hts reserved. 5 But There Are Challenges… Knowledge cut-off 1 Reasonable answers, not always accurate Can inherit bias throu h trainin data 2 3 Lack of enterprise domain knowledge 4 Inability to veri y or attribute sources 5
  • 6.
    © 2023 Neo4j,Inc. All ri hts reserved. 6 How can you take advantage of this massive opportunity while overcoming these challenges?
  • 7.
    © 2023 Neo4j,Inc. All ri hts reserved. 7 Use a Knowledge Graph to Ground LLMs What was the impact o Hurricane Lee? Hurricane Lee may impact distribution networks in the ollowin areas: MA, NY, NH, ME…
  • 8.
    © 2023 Neo4j,Inc. All ri hts reserved. 8 Grounding with Neo4j Knowledge Graphs Connect Enrich Consume Context rich, connected view o your data that enables easier decision makin Enhance your data with raph data science, text embeddin s, and additional derived context Ground responses with in ormation and context in the raph Improve search relevance combinin vector search and raph traversals
  • 9.
    © 2023 Neo4j,Inc. All ri hts reserved. Connected Data 9 With Knowled e Graphs
  • 10.
    © 2023 Neo4j,Inc. All ri hts reserved. Knowledge Graphs 10 Structured Unstructured Ontolo ies Graph Al orithms and Graph Queries Semantics, Derived Relationships and Additional Context Natural Relationships
  • 11.
    © 2023 Neo4j,Inc. All ri hts reserved. 11 What can you do with a knowledge graph? Finance How many fla ed accounts are in the applicant’s network 4+ hops out? How many lo in / account variables in common? Add these metrics to your approval process What completes the connections rom enes to diseases to tar ets? What enes can be reached 4+ hops out rom a known dru tar et? What mechanisms in common are there between two dru s? Collaborative filterin : users who bou ht X, also bou ht Y What items make you more likely to buy additional items in subsequent transactions? Traverse hierarchies-what items are similar 4+ hops out? Li e Sciences Marketin & Recommendations
  • 12.
    © 2023 Neo4j,Inc. All ri hts reserved. Enrich 12 With Cypher Patterns, Graph Data Science & Text Embeddin s
  • 13.
    © 2023 Neo4j,Inc. All ri hts reserved. Graph Enrichment 13 Human-cra ted query, human-readable result MATCH (p1:Person)-[:ENEMY]->(:Person)<-[:ENEMY]-(p2:PERSON) MERGE (p1)-[:FRIEND]->(p2) AI-learned ormula, machine-readable result Predefined ormula, human-readable result PageRank(Emil) = 13.25 PageRank(Amy) = 4.83 PageRank(Alicia) = 4.75 Node2Vec(Emil) =[5.4 5.1 2.4 4.5 3.1] Node2Vec(Amy) =[2.8 1.8 7.2 0.9 3.0] Node2Vec(Katie) =[1.4 5.2 4.4 3.9 3.2] Queries Al orithms Embeddin s Machine Learnin Workflows Train ML models based on results
  • 14.
    © 2023 Neo4j,Inc. All ri hts reserved. What Are Graph Algorithms? 14
  • 15.
    © 2023 Neo4j,Inc. All ri hts reserved. 15 Insights From Graph Algorithms Outliers, Influencers, Vulnerabilities,.. Recommendations, Homophily, Outliers,.. Recommendations, What-i Analysis, Disambi uation,.. Shortest Path, Optimal path, Route Optimization,... Link prediction, Recommendations, Next-Best Action,.. Centrality Pathfinding Community Detection Similarity Embeddings Link Prediction Dimensionality Reduction, Representation Learnin , ..
  • 16.
    © 2023 Neo4j,Inc. All ri hts reserved. Text Embedding Vectors for Semantic Search 16 Given a question, find the most relevant documents based on a similarity metric (such as Cosine Similarity) between vector o the question and vectors o contents. Movin rom keyword search to similarity (semantic) search. Q: what is a text embeddin ? abstractId similarity 456 0.923445 22 0.892114 … ... Top K by similarity
  • 17.
    © 2023 Neo4j,Inc. All ri hts reserved. 17 Graph Data Science Journey Find the patterns you’re looking for in connected data Identify associations, anomalies, and trends using unsupervised machine learning Learn features in your graph that you don’t even know are important yet Knowled e Graphs Graph Al orithms Graph Native ML → →
  • 18.
    © 2023 Neo4j,Inc. All ri hts reserved. Consume 18 With LLMs and Semantic Search
  • 19.
    © 2023 Neo4j,Inc. All ri hts reserved. 19 Semantic Search Journey Vector Similarity Search Graph Traversals & Pattern Matchin Knowled e Graph In erence & ML Find relevant documents and content or user queries Find people, places, and thin s associated to content. Identi y patterns in connected data. Further improve search relevance and insi hts by enhancin your Knowled e Graph. Use raph al orithms and ML to discover new relationships, entities, and roups. Vector Database Graph Database Neo4j Graph Data Science
  • 20.
    © 2023 Neo4j,Inc. All ri hts reserved. 20 Knowledge Retrieval with Neo4j
  • 21.
    © 2023 Neo4j,Inc. All ri hts reserved. RAG (Retrieval Augmented Generation) Pattern with Neo4j 21 Neo4j LLM API User Cypher Prompt + Relevant In ormation Prompt Response Relevant Results Retrieve relevant results rom Neo4j usin LLM to enerate embeddin s and/or Cypher 2 3 1 1 2 3 Combine relevant results with prompt Instruct LLM to only use the relevant results to enerate response LLM API Embeddin s and/or Cypher Generation Improved ACCURACY and RELEVANCE o responses E. . What is the impact o Hurricane Calvin? Hurricane Calvin caused minor floodin in Hawaii…. vs… 50 policyholders may be at risk o property dama e due to Hurricane Calvin.
  • 22.
    © 2023 Neo4j,Inc. All ri hts reserved. 22 Q: Does claim X have any association with previous fraudulent parties? Q: Provide a list of claims with damage amounts >$100,000 Q: What policyholders may be impacted by Hurricane Calvin? Knowledge Retrieval with Neo4j
  • 23.
    © 2023 Neo4j,Inc. All ri hts reserved. Demo Intro 23 LLM Chatbot
  • 24.
    © 2023 Neo4j,Inc. All ri hts reserved. Typical Business Resilience Data Analyze business impact o ● so tware & OS vulnerabilities, ● hardware & so tware up rades, ● buildin / eo raphic disasters ● chan es to business data ormats …across mission critical applications and business locations 24 hierarchies, flows, relationships…
  • 25.
    © 2023 Neo4j,Inc. All ri hts reserved. Actual Data Model 25 CVE Data Business Data Elements Vendors,So tware Business Tasks Application Instances Data Trans ers People/Roles Locations IT Assets
  • 26.
    © 2023 Neo4j,Inc. All ri hts reserved. LangChain Demo Application ● Translates En lish to Cypher ● Consumption usin LLM model with ew shot promptin ● Data au mentation rom Neo4j response 26
  • 27.
    © 2023 Neo4j,Inc. All ri hts reserved. 27 Demo
  • 28.
    © 2023 Neo4j,Inc. All ri hts reserved. Neo4j Database 30 API Knowled e Graph Graph Data Science Graph DB Knowled e Apps In ormation Extraction & In estion Structured Unstructured Ontolo ies GCP Vertex AI Data Sources API Layer Customer Service Ticket Tria in Recommendations News Content & Discovery Enterprise Knowled e Search Patient Prioritization Clinical Decision Support Systems Pharmacovi ilance Health Assistants FAQ Bots LLMs Amazon Sa eMaker AzureML Bloom Aura Enterprise Edition LLMs API Step 1: Capture Knowled e Step2: Enrich Step 3: Semantic & Contextual Search
  • 29.
    © 2023 Neo4j,Inc. All ri hts reserved. 31 Neo4j Enriches All Phases of an AI Ecosystem Knowled e Graphs Graph Feature En ineerin and Graph ML Graph Analytics, Investi ations and Counter actuals Inte rations and Knowled e Graphs or Heuristic AI Connect Analyze Capitalize Interpret Neo4j Neo4j GDS Neo4j Bloom Neo4j Connectors
  • 30.
    © 2023 Neo4j,Inc. All ri hts reserved. Thank You! katie.roberts@neo4j 32