SlideShare a Scribd company logo
1 of 42
Download to read offline
Luigi Fugaro
Sr. Solution Architect
Redis
Redis Enterprise as Vector Database
Agenda:
● Native OpenShift Integration
● Introduction to vector embeddings
● Vector Databases
● Redis Enterprise as Vector Database
● The client libraries
● The use cases
Ø Text Semantic Search
Ø LLM & RAG
Native OpenShift Integration
Native OpenShift Integration
Introduction to vector embeddings
● Used to represent unstructured data
● A list of floating-point numbers
● It has fixed size
● Compact and dense data
representation
● Produced by feature engineering or
deep learning techniques
● Translates perceived semantic similarity
to the vector space
Introduction to vector embeddings
Feature Engineering
● Manual creation
● Domain knowledge
● Expensive to scale
Using models
● Models are trained
● Turn objects into vectors
● Dense and high-dimensional
How to create vector embeddings?
How to create vector embeddings?
1. The input is transformed into a
numerical representation
2. Features are captured by the
network
3. A layer is extracted, it provides a
dense representation of the features
4. This layer is the embedding and is
feasible for similarity search
Introduction to vector embeddings
Introduction to vector embeddings
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('sentence-transformers/multi-qa-MiniLM-L6-cos-
v1')
embedding = model.encode("This is a technical document, it describes the SID
sound chip of the Commodore 64")
print(embedding[:10])
[ 0.00631137 -0.005189 -0.03774299 -0.09026785 -0.05783698 0.01209931 -
0.02595172 0.01094836 -0.06051398 0.0521009 ]
Vector Databases
What is a Vector Database?
● A database that can store vectors
● It can index vectors
● It can search the vector space
● Has throughput requirements
● It is scalable and highly available
Redis Enterprise as Vector Database
Redis Enterprise as Vector Database
Raw file Embedding Model Vector Embeddings
Redis Enterprise
Redis Enterprise as Vector Database
Vector Similarity Search:
● Vector Similarity Search (VSS) is a key feature of a vector database.
● It is the process of finding data points that are similar to a given query
vector in a vector database.
● Popular VSS uses include recommendation systems, image and video
search, natural language processing, and anomaly detection.
Redis Enterprise RediSearch
Vector Similarity
Search
Redis Enterprise as Vector Database
Vector Similarity Search focuses on finding out how alike or different
two vectors are. To achieve this in a reliable and measurable way, we
need a specific type of score that can be calculated and compared
objectively. These scores are known as distance metrics.
Redis Enterprise as Vector Database
Raw file Embedding Model Vector Embeddings
Redis Enterprise
That is a very
happy person
That is a Happy
Dog
That is a sunny day
Redis Enterprise as Vector Database
Redis Enterprise
Redis Enterprise as Vector Database
Raw file Embedding Model Vector Embeddings
Redis Enterprise
That is a happy
person
Redis Enterprise as Vector Database
Redis Enterprise
Redis Enterprise as Vector Database
import numpy as np
from numpy.linalg import norm
from sentence_transformers import SentenceTransformer
# Define the model we want to use (it'll download itself)
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
sentences = [
"That is a very happy person",
"That is a happy dog",
"Today is a sunny day"
]
sentence = "That is a happy person"
# vector embeddings created from dataset
embeddings = model.encode(sentences)
# query vector embedding
query_embedding = model.encode(sentence)
# define our distance metric
def cosine_similarity(a, b):
return np.dot(a, b)/(norm(a)*norm(b))
# run semantic similarity search
print("Query: That is a happy person")
for e, s in zip(embeddings, sentences):
print(s, " -> similarity score = ",
cosine_similarity(e, query_embedding))
Redis Enterprise as Vector Database
from redis import Redis
from redis.commands.search.field import VectorField, TagField
def create_flat_index(redis_conn: Redis, number_of_vectors: int, distance_metric: str='COSINE'):
image_field = VectorField("img_vector","FLAT", {
"TYPE": "FLOAT32",
"DIM": 512,
"DISTANCE_METRIC": distance_metric,
"INITIAL_CAP": number_of_vectors,
"BLOCK_SIZE": number_of_vectors})
redis_conn.ft().create_index([image_field])
Redis Enterprise as Vector Database
def search_redis(
redis_conn: redis.Redis,
query_vector: t.List[float],
return_fields: list = [],
k: int = 5,
) -> t.List[dict]:
# Prepare the Query
base_query = f'*=>[KNN {k} @embedding $vector AS vector_score]'
query = (
Query(base_query)
.sort_by("vector_score")
.paging(0, k)
.return_fields(*return_fields)
.dialect(2)
)
params_dict = {"vector": np.array(query_vector, dtype=np.float64).tobytes()}
# Vector Search in Redis
results = redis_conn.ft(INDEX_NAME).search(query, params_dict)
return [process_doc(doc) for doc in results.docs]
Redis client libraries
Redis Enterprise as Vector Database
Vector indexing algorithms
Redis Enterprise manages vectors in an index data structure to enable intelligent similarity search that balances search
speed and search quality. Choose from two popular techniques, FLAT (a brute force approach) and HNSW (Hierarchical
Navigable Small World - a faster, and approximate approach).
Vector search distance metrics
Redis Enterprise uses a distance metric to measure the similarity between two vectors. Choose from three popular
metrics – Euclidean, Inner Product, and Cosine Similarity – used to calculate how “close” or “far apart” two vectors are.
Powerful hybrid filtering
Take advantage of the full suite of search features available in Redis Enterprise query and search. Enhance your
workflows by combining the power of vector similarity with more traditional numeric, text, and tag filters. Incorporate
more business logic into queries and simplify client application code.
Redis Enterprise as Vector Database
Real-time updates
Real-time search and recommendation systems generate large volumes of changing data.
New images, text, products, or metadata? Perform updates, insertions, and deletes to the
search index seamlessly as your dataset changes overtime. Redis Enterprise reduces costly
impacts of stagnant data.
Vector range queries
Traditional vector search is performed by finding the “top K” most similar vectors. Redis
Enterprise also enables the discovery of relevant content within a predefined similarity
range or threshold for an alternative, and offers a more flexible search experience.
Use cases
Text Semantic Search
Vectorize, store and index your documents
Based on a provided document, I want to get a list of recommendations "you may also want to read..."
• Audit the length of your documents: embedding
models consider documents up to a number of words
• Split the documents into chunks if they exceed the
supported length
• Store the original documents and its metadata in a
hash or JSON
JSON documents can store and index multiple
embeddings
Text Semantic Search
Search your documents
Propose a list of similar documents, books, web pages.
• The current document has already a vector
embedding associated
• The embedding is compared to the rest of vector
embeddings with VSS
• It is possible to specify the number of results
• It is also possible to perform hybrid search with
metadata such and search for recent documents,
stock available, categories and more
• You can filter the results by the similarity score
using VSS range search
Visual Search
Vectorize, store and index your documents
Based on a provided image, I want to get a list of similar images ”check products similar to..."
• Convert the images to the vector embedding using a
suitable model (Resnet, Densenet...)
• Store the embedding together with metadata, images
are usually in the file system
• You can choose between storing the embeddings in
hash or JSON documents.
JSON documents can store and index multiple
embeddings
Visual Search
Search your images
Propose a list of similar products, faces, pictures in general.
• Documents store metadata and the embedding for the
image
• The embedding is compared to the rest of vector
embeddings with VSS
• It is possible to specify the number of results
• It is also possible to perform hybrid search with
metadata such and search for recent documents, stock
available, categories and more
• You can filter the results by the similarity score using
VSS range search
Large Language Models - LLM
Motivation
Fine Tuning
● Teach the model from your data
● Higher task-specific performance
● Resolves prompts size limitations
● Higher accuracy than RAG
● Fresh knowledge needs retraining
Retrieval Augmented Generation
● Incorporate external knowledge sources
via retrieval
● Extend the LLM with your knowledge
● Works with your latest data
● Prompt engineering is crucial
● Manages fresh knowledge immediately
Large Language Models - LLM
Context retrieval for Retrieval Augmented Generation (RAG)
Pairing Redis Enterprise with
Large Language Models (LLM)
such as OpenAI's ChatGPT, you
can give the LLM access to
external contextual knowledge.
• Enables more accurate
answers and prevents model
'hallucinations'.
• An LLM combines text
fragments in a (most often)
semantically correct way.
Large Language Models - LLM
LLM Conversion Memory
The idea is to improve the model
quality and personalization
through an adaptive memory.
• Persist all conversation history
(memories) as embeddings in
a vector database.
• A conversational agent checks
for relevant memories to aid
or personalize the LLM
behaviour.
• Allows users to change topics
without misunderstandings
seamlessly.
Large Language Models - LLM
Semantic caching
Because LLM completions are
expensive, it helps to reduce the
overall costs of the ML-powered
application.
• Use vector database to cache
input prompts
• Cache hits evaluated by
semantic similarity
Retrieval Augmented Generation
Choose your domain and prepare your data
Connecting your data is not easy, but Redis comes to the rescue. But before starting, you should answer
a few questions.
• Who is the target of your service, what data can you offer?
• What LLM do you plan to use, local or as-a-service?
OpenAI
Llama
Bard
Vicuna
• What embedding model are you planning to adopt?
HuggingFace
OpenAI
Cohere
• Planning to use a framework (LangChain, LlamaIndex...)?
• Are you storing and sending the context on every interaction?
• Planning to setup a semantic cache or a conversation
memory?
Relative Response Quality Assessed by GPT-4* (Vicuna)
Retrieval Augmented Generation
Choose your domain and prepare your data
Generation. Chat with your data.
When your data is loaded, indexed and you have completed the integration of your
codebase with the chosen LLM, when the user asks a question the following
happen:
• The question in natural language is turned into an embedding
• Using VSS and based on the question, related content is retrieved from Redis
Enterprise 3. The prompt is built based on the results
• The prompt is sent to the LLM and the response is returned to the user
Additionally:
• You may cache the response in Redis Enterprise
• You can store the context in Redis Enterprise and reuse it in a conversation
• You can create complex logic against your entire data set using function calling
So, why Redis Enterprise?
Why Redis Enterprise?
Benefits to Customers:
• Certified to interoperate with
Red Hat OpenShift,
following best practices for
Kubernetes and
containerization, and
portability across clouds.
• Simple to transact, manage
and control enterprise
software with one bill from
IBM through the Red Hat
Marketplace and automated
deployment to any cloud.
Why Redis Enterprise?
Benefits to Customers:
• Certified to interoperate with
Red Hat OpenShift,
following best practices for
Kubernetes and
containerization, and
portability across clouds.
• Simple to transact, manage
and control enterprise
software with one bill from
IBM through the Red Hat
Marketplace and automated
deployment to any cloud.
Why Redis Enterprise?
● Native OpenShift Integration
● You already have it
● Simple and efficient
● Highly performant
● Highly scalable
● One solution for vectorizing, indexing, searching
and caching
● It’s the only database that doesn’t need a cache
● Runs everywhere
Redis Enterprise
Q&A?
Thank you

More Related Content

Similar to Red Hat Summit Connect 2023 - Redis Enterprise, the engine of Generative AI

NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLEDB
 
Document Based Data Modeling Technique
Document Based Data Modeling TechniqueDocument Based Data Modeling Technique
Document Based Data Modeling TechniqueCarmen Sanborn
 
Introducing DocumentDB
Introducing DocumentDB Introducing DocumentDB
Introducing DocumentDB James Serra
 
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)Trivadis
 
Adding Search to Relational Databases
Adding Search to Relational DatabasesAdding Search to Relational Databases
Adding Search to Relational DatabasesAmazon Web Services
 
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
3.Implementation with NOSQL databases Document Databases (Mongodb).pptxRushikeshChikane2
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentationOleksii Usyk
 
MongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDBMongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDBMongoDB
 
Sharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data LessonsSharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data LessonsGeorge Stathis
 
Adding Search to Relational Databases
Adding Search to Relational DatabasesAdding Search to Relational Databases
Adding Search to Relational DatabasesAmazon Web Services
 
Getting started with Elasticsearch in .net
Getting started with Elasticsearch in .netGetting started with Elasticsearch in .net
Getting started with Elasticsearch in .netIsmaeel Enjreny
 
Getting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NETGetting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NETAhmed Abd Ellatif
 
Vector Databases - A Technical Primer.pdf
Vector Databases - A Technical Primer.pdfVector Databases - A Technical Primer.pdf
Vector Databases - A Technical Primer.pdfBabajide Ogunjobi
 
RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...
RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...
RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...Joaquin Delgado PhD.
 
RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning...
 RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning... RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning...
RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning...S. Diana Hu
 

Similar to Red Hat Summit Connect 2023 - Redis Enterprise, the engine of Generative AI (20)

NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Document Based Data Modeling Technique
Document Based Data Modeling TechniqueDocument Based Data Modeling Technique
Document Based Data Modeling Technique
 
Introducing DocumentDB
Introducing DocumentDB Introducing DocumentDB
Introducing DocumentDB
 
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
 
Adding Search to Relational Databases
Adding Search to Relational DatabasesAdding Search to Relational Databases
Adding Search to Relational Databases
 
Introducing Oslo
Introducing OsloIntroducing Oslo
Introducing Oslo
 
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
 
MongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDBMongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDB
 
Pinecone Vector Database.pdf
Pinecone Vector Database.pdfPinecone Vector Database.pdf
Pinecone Vector Database.pdf
 
Sharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data LessonsSharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data Lessons
 
Adding Search to Relational Databases
Adding Search to Relational DatabasesAdding Search to Relational Databases
Adding Search to Relational Databases
 
ER/Studio Data Architect Datasheet
ER/Studio Data Architect DatasheetER/Studio Data Architect Datasheet
ER/Studio Data Architect Datasheet
 
Getting started with Elasticsearch in .net
Getting started with Elasticsearch in .netGetting started with Elasticsearch in .net
Getting started with Elasticsearch in .net
 
Getting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NETGetting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NET
 
NoSQL Databases
NoSQL DatabasesNoSQL Databases
NoSQL Databases
 
Vector Databases - A Technical Primer.pdf
Vector Databases - A Technical Primer.pdfVector Databases - A Technical Primer.pdf
Vector Databases - A Technical Primer.pdf
 
Selecting best NoSQL
Selecting best NoSQL Selecting best NoSQL
Selecting best NoSQL
 
RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...
RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...
RecSys 2015 Tutorial - Scalable Recommender Systems: Where Machine Learning m...
 
RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning...
 RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning... RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning...
RecSys 2015 Tutorial – Scalable Recommender Systems: Where Machine Learning...
 

More from Luigi Fugaro

Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...
Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...
Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...Luigi Fugaro
 
Sharp Coding 2023 - Luigi Fugaro - ACRE.pdf
Sharp Coding 2023 - Luigi Fugaro - ACRE.pdfSharp Coding 2023 - Luigi Fugaro - ACRE.pdf
Sharp Coding 2023 - Luigi Fugaro - ACRE.pdfLuigi Fugaro
 
Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23
Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23
Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23Luigi Fugaro
 
Codemotion Milan '22 - Real Time Data - No CRDTs, no party!
Codemotion Milan '22 - Real Time Data - No CRDTs, no party!Codemotion Milan '22 - Real Time Data - No CRDTs, no party!
Codemotion Milan '22 - Real Time Data - No CRDTs, no party!Luigi Fugaro
 
OpenSlava 2018 - Cloud Native Applications with OpenShift
OpenSlava 2018 - Cloud Native Applications with OpenShiftOpenSlava 2018 - Cloud Native Applications with OpenShift
OpenSlava 2018 - Cloud Native Applications with OpenShiftLuigi Fugaro
 
Redis - Non solo cache
Redis - Non solo cacheRedis - Non solo cache
Redis - Non solo cacheLuigi Fugaro
 
JDV for Codemotion Rome 2017
JDV for Codemotion Rome 2017JDV for Codemotion Rome 2017
JDV for Codemotion Rome 2017Luigi Fugaro
 
2.5tier Javaday (italian)
2.5tier Javaday (italian)2.5tier Javaday (italian)
2.5tier Javaday (italian)Luigi Fugaro
 

More from Luigi Fugaro (8)

Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...
Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...
Ottimizzare le performance dell'API Server K8s come utilizzare cache e eventi...
 
Sharp Coding 2023 - Luigi Fugaro - ACRE.pdf
Sharp Coding 2023 - Luigi Fugaro - ACRE.pdfSharp Coding 2023 - Luigi Fugaro - ACRE.pdf
Sharp Coding 2023 - Luigi Fugaro - ACRE.pdf
 
Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23
Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23
Caching Patterns for lazy devs for lazy loading - Luigi Fugaro VDTJAN23
 
Codemotion Milan '22 - Real Time Data - No CRDTs, no party!
Codemotion Milan '22 - Real Time Data - No CRDTs, no party!Codemotion Milan '22 - Real Time Data - No CRDTs, no party!
Codemotion Milan '22 - Real Time Data - No CRDTs, no party!
 
OpenSlava 2018 - Cloud Native Applications with OpenShift
OpenSlava 2018 - Cloud Native Applications with OpenShiftOpenSlava 2018 - Cloud Native Applications with OpenShift
OpenSlava 2018 - Cloud Native Applications with OpenShift
 
Redis - Non solo cache
Redis - Non solo cacheRedis - Non solo cache
Redis - Non solo cache
 
JDV for Codemotion Rome 2017
JDV for Codemotion Rome 2017JDV for Codemotion Rome 2017
JDV for Codemotion Rome 2017
 
2.5tier Javaday (italian)
2.5tier Javaday (italian)2.5tier Javaday (italian)
2.5tier Javaday (italian)
 

Recently uploaded

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

Red Hat Summit Connect 2023 - Redis Enterprise, the engine of Generative AI

  • 1.
  • 2. Luigi Fugaro Sr. Solution Architect Redis
  • 3. Redis Enterprise as Vector Database Agenda: ● Native OpenShift Integration ● Introduction to vector embeddings ● Vector Databases ● Redis Enterprise as Vector Database ● The client libraries ● The use cases Ø Text Semantic Search Ø LLM & RAG
  • 6. Introduction to vector embeddings ● Used to represent unstructured data ● A list of floating-point numbers ● It has fixed size ● Compact and dense data representation ● Produced by feature engineering or deep learning techniques ● Translates perceived semantic similarity to the vector space
  • 7. Introduction to vector embeddings Feature Engineering ● Manual creation ● Domain knowledge ● Expensive to scale Using models ● Models are trained ● Turn objects into vectors ● Dense and high-dimensional How to create vector embeddings?
  • 8. How to create vector embeddings? 1. The input is transformed into a numerical representation 2. Features are captured by the network 3. A layer is extracted, it provides a dense representation of the features 4. This layer is the embedding and is feasible for similarity search Introduction to vector embeddings
  • 9. Introduction to vector embeddings from sentence_transformers import SentenceTransformer model = SentenceTransformer('sentence-transformers/multi-qa-MiniLM-L6-cos- v1') embedding = model.encode("This is a technical document, it describes the SID sound chip of the Commodore 64") print(embedding[:10]) [ 0.00631137 -0.005189 -0.03774299 -0.09026785 -0.05783698 0.01209931 - 0.02595172 0.01094836 -0.06051398 0.0521009 ]
  • 11. What is a Vector Database? ● A database that can store vectors ● It can index vectors ● It can search the vector space ● Has throughput requirements ● It is scalable and highly available
  • 12. Redis Enterprise as Vector Database
  • 13. Redis Enterprise as Vector Database Raw file Embedding Model Vector Embeddings Redis Enterprise
  • 14. Redis Enterprise as Vector Database Vector Similarity Search: ● Vector Similarity Search (VSS) is a key feature of a vector database. ● It is the process of finding data points that are similar to a given query vector in a vector database. ● Popular VSS uses include recommendation systems, image and video search, natural language processing, and anomaly detection. Redis Enterprise RediSearch Vector Similarity Search
  • 15. Redis Enterprise as Vector Database Vector Similarity Search focuses on finding out how alike or different two vectors are. To achieve this in a reliable and measurable way, we need a specific type of score that can be calculated and compared objectively. These scores are known as distance metrics.
  • 16. Redis Enterprise as Vector Database Raw file Embedding Model Vector Embeddings Redis Enterprise That is a very happy person That is a Happy Dog That is a sunny day
  • 17. Redis Enterprise as Vector Database Redis Enterprise
  • 18. Redis Enterprise as Vector Database Raw file Embedding Model Vector Embeddings Redis Enterprise That is a happy person
  • 19. Redis Enterprise as Vector Database Redis Enterprise
  • 20. Redis Enterprise as Vector Database import numpy as np from numpy.linalg import norm from sentence_transformers import SentenceTransformer # Define the model we want to use (it'll download itself) model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') sentences = [ "That is a very happy person", "That is a happy dog", "Today is a sunny day" ] sentence = "That is a happy person" # vector embeddings created from dataset embeddings = model.encode(sentences) # query vector embedding query_embedding = model.encode(sentence) # define our distance metric def cosine_similarity(a, b): return np.dot(a, b)/(norm(a)*norm(b)) # run semantic similarity search print("Query: That is a happy person") for e, s in zip(embeddings, sentences): print(s, " -> similarity score = ", cosine_similarity(e, query_embedding))
  • 21. Redis Enterprise as Vector Database from redis import Redis from redis.commands.search.field import VectorField, TagField def create_flat_index(redis_conn: Redis, number_of_vectors: int, distance_metric: str='COSINE'): image_field = VectorField("img_vector","FLAT", { "TYPE": "FLOAT32", "DIM": 512, "DISTANCE_METRIC": distance_metric, "INITIAL_CAP": number_of_vectors, "BLOCK_SIZE": number_of_vectors}) redis_conn.ft().create_index([image_field])
  • 22. Redis Enterprise as Vector Database def search_redis( redis_conn: redis.Redis, query_vector: t.List[float], return_fields: list = [], k: int = 5, ) -> t.List[dict]: # Prepare the Query base_query = f'*=>[KNN {k} @embedding $vector AS vector_score]' query = ( Query(base_query) .sort_by("vector_score") .paging(0, k) .return_fields(*return_fields) .dialect(2) ) params_dict = {"vector": np.array(query_vector, dtype=np.float64).tobytes()} # Vector Search in Redis results = redis_conn.ft(INDEX_NAME).search(query, params_dict) return [process_doc(doc) for doc in results.docs]
  • 24. Redis Enterprise as Vector Database Vector indexing algorithms Redis Enterprise manages vectors in an index data structure to enable intelligent similarity search that balances search speed and search quality. Choose from two popular techniques, FLAT (a brute force approach) and HNSW (Hierarchical Navigable Small World - a faster, and approximate approach). Vector search distance metrics Redis Enterprise uses a distance metric to measure the similarity between two vectors. Choose from three popular metrics – Euclidean, Inner Product, and Cosine Similarity – used to calculate how “close” or “far apart” two vectors are. Powerful hybrid filtering Take advantage of the full suite of search features available in Redis Enterprise query and search. Enhance your workflows by combining the power of vector similarity with more traditional numeric, text, and tag filters. Incorporate more business logic into queries and simplify client application code.
  • 25. Redis Enterprise as Vector Database Real-time updates Real-time search and recommendation systems generate large volumes of changing data. New images, text, products, or metadata? Perform updates, insertions, and deletes to the search index seamlessly as your dataset changes overtime. Redis Enterprise reduces costly impacts of stagnant data. Vector range queries Traditional vector search is performed by finding the “top K” most similar vectors. Redis Enterprise also enables the discovery of relevant content within a predefined similarity range or threshold for an alternative, and offers a more flexible search experience.
  • 27. Text Semantic Search Vectorize, store and index your documents Based on a provided document, I want to get a list of recommendations "you may also want to read..." • Audit the length of your documents: embedding models consider documents up to a number of words • Split the documents into chunks if they exceed the supported length • Store the original documents and its metadata in a hash or JSON JSON documents can store and index multiple embeddings
  • 28. Text Semantic Search Search your documents Propose a list of similar documents, books, web pages. • The current document has already a vector embedding associated • The embedding is compared to the rest of vector embeddings with VSS • It is possible to specify the number of results • It is also possible to perform hybrid search with metadata such and search for recent documents, stock available, categories and more • You can filter the results by the similarity score using VSS range search
  • 29. Visual Search Vectorize, store and index your documents Based on a provided image, I want to get a list of similar images ”check products similar to..." • Convert the images to the vector embedding using a suitable model (Resnet, Densenet...) • Store the embedding together with metadata, images are usually in the file system • You can choose between storing the embeddings in hash or JSON documents. JSON documents can store and index multiple embeddings
  • 30. Visual Search Search your images Propose a list of similar products, faces, pictures in general. • Documents store metadata and the embedding for the image • The embedding is compared to the rest of vector embeddings with VSS • It is possible to specify the number of results • It is also possible to perform hybrid search with metadata such and search for recent documents, stock available, categories and more • You can filter the results by the similarity score using VSS range search
  • 31. Large Language Models - LLM Motivation Fine Tuning ● Teach the model from your data ● Higher task-specific performance ● Resolves prompts size limitations ● Higher accuracy than RAG ● Fresh knowledge needs retraining Retrieval Augmented Generation ● Incorporate external knowledge sources via retrieval ● Extend the LLM with your knowledge ● Works with your latest data ● Prompt engineering is crucial ● Manages fresh knowledge immediately
  • 32. Large Language Models - LLM Context retrieval for Retrieval Augmented Generation (RAG) Pairing Redis Enterprise with Large Language Models (LLM) such as OpenAI's ChatGPT, you can give the LLM access to external contextual knowledge. • Enables more accurate answers and prevents model 'hallucinations'. • An LLM combines text fragments in a (most often) semantically correct way.
  • 33. Large Language Models - LLM LLM Conversion Memory The idea is to improve the model quality and personalization through an adaptive memory. • Persist all conversation history (memories) as embeddings in a vector database. • A conversational agent checks for relevant memories to aid or personalize the LLM behaviour. • Allows users to change topics without misunderstandings seamlessly.
  • 34. Large Language Models - LLM Semantic caching Because LLM completions are expensive, it helps to reduce the overall costs of the ML-powered application. • Use vector database to cache input prompts • Cache hits evaluated by semantic similarity
  • 35. Retrieval Augmented Generation Choose your domain and prepare your data Connecting your data is not easy, but Redis comes to the rescue. But before starting, you should answer a few questions. • Who is the target of your service, what data can you offer? • What LLM do you plan to use, local or as-a-service? OpenAI Llama Bard Vicuna • What embedding model are you planning to adopt? HuggingFace OpenAI Cohere • Planning to use a framework (LangChain, LlamaIndex...)? • Are you storing and sending the context on every interaction? • Planning to setup a semantic cache or a conversation memory? Relative Response Quality Assessed by GPT-4* (Vicuna)
  • 36. Retrieval Augmented Generation Choose your domain and prepare your data Generation. Chat with your data. When your data is loaded, indexed and you have completed the integration of your codebase with the chosen LLM, when the user asks a question the following happen: • The question in natural language is turned into an embedding • Using VSS and based on the question, related content is retrieved from Redis Enterprise 3. The prompt is built based on the results • The prompt is sent to the LLM and the response is returned to the user Additionally: • You may cache the response in Redis Enterprise • You can store the context in Redis Enterprise and reuse it in a conversation • You can create complex logic against your entire data set using function calling
  • 37. So, why Redis Enterprise?
  • 38. Why Redis Enterprise? Benefits to Customers: • Certified to interoperate with Red Hat OpenShift, following best practices for Kubernetes and containerization, and portability across clouds. • Simple to transact, manage and control enterprise software with one bill from IBM through the Red Hat Marketplace and automated deployment to any cloud.
  • 39. Why Redis Enterprise? Benefits to Customers: • Certified to interoperate with Red Hat OpenShift, following best practices for Kubernetes and containerization, and portability across clouds. • Simple to transact, manage and control enterprise software with one bill from IBM through the Red Hat Marketplace and automated deployment to any cloud.
  • 40. Why Redis Enterprise? ● Native OpenShift Integration ● You already have it ● Simple and efficient ● Highly performant ● Highly scalable ● One solution for vectorizing, indexing, searching and caching ● It’s the only database that doesn’t need a cache ● Runs everywhere Redis Enterprise
  • 41. Q&A?