NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.
com
Who Am I?
Paulo Dichone
Software, Cloud, AI Engineer
and Instructor
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
What Is This Course About?
● Knowledge Graphs & RAG -
○ Fundamentals of Knowledge Graphs
○ Implement Knowledge Graphs to Improve RAG Systems
○ Optimization and Best Practices
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Who Is This Course For
Open
minded
Entrepreneurs
learners :)
Project
Developers Managers
Data
Scientists
Data
Professionals
Business
Analysts
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Course Prerequisites
1. Know Programming (highly preferred… at least the basics)
a. There will be Python code
b. Basics of LangChain, LLM, AI
2. This is not a programming course
3. Willingness to learn :)
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Course Structure
Theory (Fundamental Concepts)
Mixture of both
Hands-on
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Development Environment setup
● Python
● VS Code (or any other code editor)
● OpenAI API Account and API Key
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Set up OpenAI API Account
** Please note that you will need an API key to use OpenAI
services, and there may be some costs associated with using
the API. However, these costs should be minimal.
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
OpenAI API - Dev Environment Setup
Python (Win, Mac, Linux)
https://kinsta.com/knowledgebase/install-python/
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
● What are they?
● Why (motivation)?
● Advantages
Knowledge ● Key concepts
Graphs ●
●
Structure
Components
Deep Dive ● Use cases
● Advantages & Challenges
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Knowledge Graphs
A KG is a structured representation of facts and relationships within a specific
domain…
Math
Interested studied
Albert
E.
Physics
played
violin
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Key concepts
Albert studied
Physics
E.
Entity Edge/Relationship Entity
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Key concepts
Albert studied
Physics
E.
Attributes:
● Birth data
● Nationality Entity
● profession
Edge/Relationship
Entity
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Key concepts
Albert studied
Physics
E.
Triples
Attributes:
● Subject (Albert)
● Birth data
● Predicate
● Nationality
(studied)
● profession
● Object (Physics)
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Structure
● Graph-based Structure: nodes, edges, to model
real-world knowledge
● Ontology: schema that defines the types of entities,
relationships and attributes
● Taxonomy: Hierarchical classification of entities in the
graph
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Structure
● Nodes: represent entities or instances
● Edges: relationships between entities
● Labels: tags assigned to nodes and edges to define
their types
● Properties: additional information or attribute about
nodes and edges
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
KG construction
● Manual curation: manual input of data into graph
● Automated Extraction: using algos and NLP to extract
information from unstructured data sources (txt, docs,
DBs…)
● Crowdsourcing: input from a large number of sources
to populate and refine the graph.
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
KG applications
● Search engines: enhance search capabilities
● Recommendation systems: provide personalized
recommendations
● Data Integration: combine data from various sources
into one framework
● AI and Machine Learning: enhance machine
understanding
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
KG Advantages
● Enhanced data interoperability: good for integrating
heterogeneous data sources
● Improved data quality and Consistency: ensures
accuracy (well-defined ontologies and taxonomies)
● Facilitate Advanced Querying: allows complex
queries
● Supports Inference and Reasoning: machines can
infer new knowledge from existing data easily
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
KG challenges
● Data quality: accuracy and reliability of the data is
challenging
● Scalability: managing and processing large-scale KGs
efficiently
● Complexity: developing and maintaining complex
ontologies and taxonomies
● Data Privacy: securing sensitive data while utilizing
KGs
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Conclusion
● KGs: a powerful tool for structuring and reasoning
about complex data
● Scalability: enhance capabilities of AI systems
(improve search and recommendation engines…)
● Data integration: facilitate data integration and
analysis across various domains
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Knowledge ● Building a Knowledge
Graphs
Graph
○ Introduction to neo4j
Deep Dive ■
■
Relationships
Entities
neo4j ● hands -on
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Building a Knowledge Graph
Albert (studied)
(born in) E.
Physics
Germany won
(died in) Nobel Prize in
Physics
USA
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Technologies and Languages
RDF ( Resource Description
Framework)
SPARQL (SPARQL Protocol and RDF
Query Language)
OWL (Web Ontology Language)
Neo4j
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Albert (studied)
(born in) E.
Physics
Germany won
(died in) Nobel Prize in
Physics
USA
(a:Person)-[:STUDIED]->(p:Physics)
(a:Person)-[:WON]->(n:NobelPrize)
(a:Person)-[:DIED_IN]->(u:USA)
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Neo4j graph database
Neo4j
A leading graph database management system that provides
an ACID-compliant transactional backend for applications
Key concepts:
● Nodes
● Relationships
● Properties
● Labels
● Cypher - the query language for interacting with the graph data
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Summary
● Neo4j set up
○ Account
○ Create a graph database
○ Neo4j browser
○ Visual KGs
● Create a KG programmatically
● Querying the KG
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Knowledge Graphs & RAG
Graph retrieval-augmented generation (GraphRAG)
A powerful addition to traditional vector search retrieval methods
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
RAG Overview
query Documents…
Chunk 1 Chunk 2 Chunk 3
Embedding LLM
Emb 1 Emb 2 Emb 3
Embedding
Most similar Gen. LLM response
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Knowledge Graph & RAG - Steps
Unstructured Data Generate K
Extraction
data Integration Graph
Knowledge Graph & RAG - Overview
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Knowledge graph
Graph search prompt
Combined
question LLM
User sources Relevant context
Keyword search
query
Vector
store
Vector search
response
RAG Documents of
retriever unstructured text
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
GraphRAG Build a Knowledge Graph and a
Hybrid Retrieval for RAG
Hand-on
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Graph Retriever - Flow
User
identify flatten
LLM extracting
query results
entities
Relevant nodes with … that can be passed to an LLM
their
neighborhoods
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Hands-on - The Roman Empire RAG System
Enhance the accuracy of RAG application with
Knowledge Graphs
Unstructured Data Generate K
Extraction
data Integration Graph
● Unstructured data retrieval (vector store,
keyword search, vector search)
● Graph Retrieval ( more involved, but offers
more freedom)
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Hands-on - The Roman Empire RAG System
Enhance the accuracy of RAG application with
Knowledge Graphs
Pull text/docs
from wikipedia
about the Data Generate K
Extraction
Roman Empire Integration Graph
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
You made it to the end!
● Next steps…
Congratulations!
Course Summary
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
● Knowledge Graphs for RAG (GraphRAG)
○ Fundamentals of Knowledge Graphs
○ Key characteristics
○ How they work
○ Deep dive into Building Knowledge Graphs
■ Built first simple KG
■ Basics Cypher Query Language
■ The Neo4J Graph database
■ GraphRAG Hands on
● Using framework to extract, embed unstructured text
● Full on real-world use case scenarios
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Wrap up - Where to Go From Here?
● Keep learning
○ Extend the projects we worked on in this course
○ Implement your own knowledge Graphs and RAG
● Challenge yourself to keep learning new skills!
NOT FOR DISTRIBUTION ©Paulo Dichone www.vincibits.com
Thank you!