SlideShare a Scribd company logo
1 of 59
Download to read offline
Our Sponsors
2024
Unleashing the Power of
Vector Search and
Semantic Caching in .NET
Luigi Fugaro
Agenda
WeBuild 2023 2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
The Data Balance
Turning Data Into Vectors
Enter ML Embeddings
Redis as Vector Database
Redis OM .NET for Vector and more
Demo – Live Coding... dotnet run
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
The Data Balance
Structured vs. Unstructured
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Growth
IDC Report 2023 - https://www.box.com/resources/unstructured-data-paper
Around 80%
of the data generated by organizations is
Unstructured
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Growth
Unstructured
Quasi-Structured
Semi-Structured
Structured
No inherent structure/many degrees of
freedom ~ Docs, PDFs, images, audio, video
Erratic patterns/formats ~ Clickstreams
There's a discernible pattern ~ Spreadsheets /
XML / JSON
Schema/defined data model ~ Database
Data type
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
How to deal with unstructured data?
Common approaches were labeling and tagging
There are labor intensive, subjective, and error-prone
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Turning Data into Vectors
The Old Fashion Way
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vectors…
What is a Vector?
Numeric representation of something in N-dimensional space
Can represent anything... entire documents, images, video, audio
Quantifies features or characteristics of the item
More importantly... they are comparable
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector generating Techniques
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Image Vector Generation example with HOG
Pre-Processing Gradient Calculation
Our Vector!
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Enter ML Embeddings
Using Machine Learning for Feature Extraction
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Machine Learning/Deep Learning has leaped forward in the last decade
ML model outperform humans in many tasks nowadays
CV (Computer Vision) models excel at detection/classification
LLMs (LArge Language Models) have advanced exponentially
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Feature Engineering
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
T-Shirt Jacket
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Automated Feature Engineering
ML model extract latent features
ML embeddings catch the gray areas between features
The process of generating the embeddings is vectorizing
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vectors
Storing and creating Vectors
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Visually
Semantic Relationship Syntactic Relationship
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Visually
https://jalammar.github.io/illustrated-word2vec
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
https://jalammar.github.io/illustrated-word2vec
Vectors can be operated upon
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vectorizing
Generating Vector Embeddings for your Data
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vectorizing
1. Choose an Embedding Method
2. Clean and preprocess the data as needed
3. Train/Refine the embedding model
4. Generate Embeddings
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vectorizing
Better Models, better Vectors
Embeddings can capture the semantics of complex data
Option #1: Use a pre-trained model
Option #2: train your models with custom data
Vector similarity is a downline tool to analyze embeddings
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Similarity
Finding similar vectors
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Similarity Metrics
➢ Measure “closeness” between vectors in multi-dimensional space
➢ Enable efficient similarity search in vector databases
➢ Improve relevance and precision of search results
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Similarity/Distance Metrics
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Cosine Similarity
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector Similarity in Redis
Redis as Vector Database
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector Similarity in Redis
Index and query vector data stored as BLOBs in Redis Hashes/JSON
3 distance metrics: Euclidean, Internal Product and Cosine
2 indexing methods: HNSW and Flat
Pre-filtering queries with GEO, TAG, TEXT or NUMERIC fields
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Demo with a Fashion Product Finder
Image & Text - Hybrid Similarity Search
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
eCommerce Searches
There's a growing expectation for effective search functionality
Unstructured Data is "high-dimensional"
Needs to capture "meaning and context" in unstructured data
Encompasses Recommendation Engines and Similarity Search
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Natural Language Search
Visual Search
Recommenders
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
How to implement the solution?
Framework and libraries
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
A Redis Framework
It’s more than Object Mapping
Redis OM stands for Redis Object Mapping, a suite of libraries designed to
facilitate object-oriented interaction with Redis. It simplifies working with
Redis by abstracting direct commands into higher-level operations.
https://github.com/redis/redis-om-dotnet
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
More to come...
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Redis OM
Why?
● Redis OM simplifies application
development by abstracting Redis'
complexity, increasing productivity, and
enhancing code readability.
What?
◆ Redis OM enables building real-time
applications, supporting:
● Model Data
● Perform CRUD Operations
● Index and Search Data
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Fashion Product Finder
Breakdown
■ A Product domain mapped to Redis JSON
■ [Indexed] decorated field for text and numeric indexing
■ [ImageVectorizer] decorated field to generate embeddings
■ [SentenceVectorizer] decorated field to generate embeddings
■ Pre-filter the search if needed
■ Entity Streams to query for K nearest neighbors
■ Display results
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
namespace ProductCatalog.Model;
[Document(StorageType = StorageType.Json)]
public class Product
{
// Other fields...
}
Model → Redis JSON
[Document]
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Make Product Searchable
[Indexed] decoration
namespace ProductCatalog.Model;
[Document(StorageType = StorageType.Json)]
public class Product
{
[RedisIdField] [Indexed] public int Id { get; set; }
// Other fields...
[Indexed] public string Gender { get; set; }
[Indexed] public int? Year { get; set; }
// Other fields...
}
Decorate what
you want to
make searchable
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Automatic Embedding Generation
[IVectorizer] decoration
namespace ProductCatalog.Model;
[Document(StorageType = StorageType.Json)]
public class Product
{
// Other fields...
[Indexed(Algorithm = VectorAlgorithm.HNSW, DistanceMetric = DistanceMetric.COSINE)]
[ImageVectorizer]public Vector<string> ImageUrl { get; set; }
[Indexed(Algorithm = VectorAlgorithm.FLAT, DistanceMetric = DistanceMetric.COSINE)]
[SentenceVectorizer] public Vector<string> ProductDisplayName { get; set; }
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Searching with Fluent API
[IVectorizer] decoration
[HttpGet("byImage")]
public IEnumerable<CatalogResponse > ByImage([FromQuery]string url)
{
var collection = _provider.RedisCollection <Product>();
var response = collection.NearestNeighbors(x => x.ImageUrl, 15, url);
return response.Select(CatalogResponse .Of);
}
[HttpGet("byDescription" )]
public IEnumerable<CatalogResponse > ByDescription([FromQuery] string description)
{
var collection = _provider.RedisCollection <Product>();
var response = collection.NearestNeighbors(x => x.ProductDisplayName, 15, description);
return response.Select(CatalogResponse .Of);
}
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
dotnet run --project ProductCatalog
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
The tools and techniques to unlock
the value in Unstructured Data have
evolved greatly...
Unleashing the Power of Vector Search and Semantic Caching in .NET
Databases like Redis and frameworks
like Redis OM can help!
2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
INTEGRATIONS
FEATURES
Storage: HASH | JSON
Indexing: HNSW (ANN) | Flat (KNN)
Distance: L2 | Cosine | IP
Search Types: KNN/ANN | Hybrid |
Range | Full Text
Management: Realtime CRUD
operations, aliasing, temp indices, and
more
Ecosystem integrations
NEW REDIS ENTERPRISE 7.2
FEATURE
Scalable search and query for
improved performance, up to 16X
compared to previous versions
Redis as Vector Database
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector Similarity Search Use Cases
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector Similarity Search Use Cases
Question & Answering
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector Similarity Search Use Cases
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.
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector Similarity Search Use Cases
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.
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Vector Similarity Search Use Cases
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.
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Additional resources for learning about Redis
Central place to find
example apps that are
built on Redis
launchpad.redis.com
Redis Launchpad
Free online courses
taught by Redis experts
university.redis.com
Redis University
Create a database
Code your application
Explore your data
developer.redis.com
Developers Portal
Professional certification
program for developers
university.redis.com/
certification
Redis Certification
Unleashing the Power of Vector Search and Semantic Caching in .NET
2024
Redis Stack for Application Modernization
Questions
&
Answers

More Related Content

Similar to Unleashing the Power of Vector Search in .NET - SharpCoding2024.pdf

GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxNeo4j
 
Building Enterprise-Ready Knowledge Graph Applications in the Cloud
Building Enterprise-Ready Knowledge Graph Applications in the CloudBuilding Enterprise-Ready Knowledge Graph Applications in the Cloud
Building Enterprise-Ready Knowledge Graph Applications in the CloudPeter Haase
 
SAP BO ONLINE TRAINING
SAP BO ONLINE TRAININGSAP BO ONLINE TRAINING
SAP BO ONLINE TRAININGMadhukar Reddy
 
Linked data for Enterprise Data Integration
Linked data for Enterprise Data IntegrationLinked data for Enterprise Data Integration
Linked data for Enterprise Data IntegrationSören Auer
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010David McCarter
 
Document Based Data Modeling Technique
Document Based Data Modeling TechniqueDocument Based Data Modeling Technique
Document Based Data Modeling TechniqueCarmen Sanborn
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity FrameworkMahmoud Tolba
 
La strada verso il successo con i database a grafo, la Graph Data Science e l...
La strada verso il successo con i database a grafo, la Graph Data Science e l...La strada verso il successo con i database a grafo, la Graph Data Science e l...
La strada verso il successo con i database a grafo, la Graph Data Science e l...Neo4j
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Karen Thompson
 
Dataminds - ML in Production
Dataminds - ML in ProductionDataminds - ML in Production
Dataminds - ML in ProductionNathan Bijnens
 
Searching Repositories of Web Application Models
Searching Repositories of Web Application ModelsSearching Repositories of Web Application Models
Searching Repositories of Web Application ModelsMarco Brambilla
 
Workflow - IED Barcelona - Digital Media 2012
Workflow - IED Barcelona - Digital Media 2012Workflow - IED Barcelona - Digital Media 2012
Workflow - IED Barcelona - Digital Media 2012Mario Esposito
 
Verndale - Sitecore User Group Los Angeles Presentation
Verndale - Sitecore User Group Los Angeles PresentationVerndale - Sitecore User Group Los Angeles Presentation
Verndale - Sitecore User Group Los Angeles PresentationDavid Brown
 
Vertical Image Search Engine
 Vertical Image Search Engine Vertical Image Search Engine
Vertical Image Search Engineshivam_kedia
 
Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...
Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...
Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...IOSR Journals
 
Beyond Retrieval Augmented Generation (RAG): Vector Databases
Beyond Retrieval Augmented Generation (RAG): Vector DatabasesBeyond Retrieval Augmented Generation (RAG): Vector Databases
Beyond Retrieval Augmented Generation (RAG): Vector DatabasesZilliz
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 

Similar to Unleashing the Power of Vector Search in .NET - SharpCoding2024.pdf (20)

GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
 
Velociraptor - SANS Summit 2019
Velociraptor - SANS Summit 2019Velociraptor - SANS Summit 2019
Velociraptor - SANS Summit 2019
 
Building Enterprise-Ready Knowledge Graph Applications in the Cloud
Building Enterprise-Ready Knowledge Graph Applications in the CloudBuilding Enterprise-Ready Knowledge Graph Applications in the Cloud
Building Enterprise-Ready Knowledge Graph Applications in the Cloud
 
SAP BO ONLINE TRAINING
SAP BO ONLINE TRAININGSAP BO ONLINE TRAINING
SAP BO ONLINE TRAINING
 
Linked data for Enterprise Data Integration
Linked data for Enterprise Data IntegrationLinked data for Enterprise Data Integration
Linked data for Enterprise Data Integration
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
 
Document Based Data Modeling Technique
Document Based Data Modeling TechniqueDocument Based Data Modeling Technique
Document Based Data Modeling Technique
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
 
La strada verso il successo con i database a grafo, la Graph Data Science e l...
La strada verso il successo con i database a grafo, la Graph Data Science e l...La strada verso il successo con i database a grafo, la Graph Data Science e l...
La strada verso il successo con i database a grafo, la Graph Data Science e l...
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
 
Dataminds - ML in Production
Dataminds - ML in ProductionDataminds - ML in Production
Dataminds - ML in Production
 
Searching Repositories of Web Application Models
Searching Repositories of Web Application ModelsSearching Repositories of Web Application Models
Searching Repositories of Web Application Models
 
Workflow - IED Barcelona - Digital Media 2012
Workflow - IED Barcelona - Digital Media 2012Workflow - IED Barcelona - Digital Media 2012
Workflow - IED Barcelona - Digital Media 2012
 
Verndale - Sitecore User Group Los Angeles Presentation
Verndale - Sitecore User Group Los Angeles PresentationVerndale - Sitecore User Group Los Angeles Presentation
Verndale - Sitecore User Group Los Angeles Presentation
 
Vertical Image Search Engine
 Vertical Image Search Engine Vertical Image Search Engine
Vertical Image Search Engine
 
Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...
Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...
Advance Frameworks for Hidden Web Retrieval Using Innovative Vision-Based Pag...
 
Beyond Retrieval Augmented Generation (RAG): Vector Databases
Beyond Retrieval Augmented Generation (RAG): Vector DatabasesBeyond Retrieval Augmented Generation (RAG): Vector Databases
Beyond Retrieval Augmented Generation (RAG): Vector Databases
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 

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

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
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

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...
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Unleashing the Power of Vector Search in .NET - SharpCoding2024.pdf

  • 2. Unleashing the Power of Vector Search and Semantic Caching in .NET Luigi Fugaro
  • 3. Agenda WeBuild 2023 2024 Unleashing the Power of Vector Search and Semantic Caching in .NET The Data Balance Turning Data Into Vectors Enter ML Embeddings Redis as Vector Database Redis OM .NET for Vector and more Demo – Live Coding... dotnet run
  • 4. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 The Data Balance Structured vs. Unstructured
  • 5. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Growth IDC Report 2023 - https://www.box.com/resources/unstructured-data-paper Around 80% of the data generated by organizations is Unstructured
  • 6. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Growth Unstructured Quasi-Structured Semi-Structured Structured No inherent structure/many degrees of freedom ~ Docs, PDFs, images, audio, video Erratic patterns/formats ~ Clickstreams There's a discernible pattern ~ Spreadsheets / XML / JSON Schema/defined data model ~ Database Data type
  • 7. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 How to deal with unstructured data? Common approaches were labeling and tagging There are labor intensive, subjective, and error-prone
  • 8. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024
  • 9. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024
  • 10. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024
  • 11. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Turning Data into Vectors The Old Fashion Way
  • 12. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vectors… What is a Vector? Numeric representation of something in N-dimensional space Can represent anything... entire documents, images, video, audio Quantifies features or characteristics of the item More importantly... they are comparable
  • 13. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector generating Techniques
  • 14. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Image Vector Generation example with HOG Pre-Processing Gradient Calculation Our Vector!
  • 15. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Enter ML Embeddings Using Machine Learning for Feature Extraction
  • 16. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Machine Learning/Deep Learning has leaped forward in the last decade ML model outperform humans in many tasks nowadays CV (Computer Vision) models excel at detection/classification LLMs (LArge Language Models) have advanced exponentially
  • 17. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Feature Engineering
  • 18. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 T-Shirt Jacket
  • 19. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Automated Feature Engineering ML model extract latent features ML embeddings catch the gray areas between features The process of generating the embeddings is vectorizing
  • 20. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vectors Storing and creating Vectors
  • 21. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Visually Semantic Relationship Syntactic Relationship
  • 22. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Visually https://jalammar.github.io/illustrated-word2vec
  • 23. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 https://jalammar.github.io/illustrated-word2vec Vectors can be operated upon
  • 24. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vectorizing Generating Vector Embeddings for your Data
  • 25. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vectorizing 1. Choose an Embedding Method 2. Clean and preprocess the data as needed 3. Train/Refine the embedding model 4. Generate Embeddings
  • 26. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vectorizing Better Models, better Vectors Embeddings can capture the semantics of complex data Option #1: Use a pre-trained model Option #2: train your models with custom data Vector similarity is a downline tool to analyze embeddings
  • 27. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Similarity Finding similar vectors
  • 28. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Similarity Metrics ➢ Measure “closeness” between vectors in multi-dimensional space ➢ Enable efficient similarity search in vector databases ➢ Improve relevance and precision of search results
  • 29. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Similarity/Distance Metrics
  • 30. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Cosine Similarity
  • 31. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector Similarity in Redis Redis as Vector Database
  • 32. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024
  • 33. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector Similarity in Redis Index and query vector data stored as BLOBs in Redis Hashes/JSON 3 distance metrics: Euclidean, Internal Product and Cosine 2 indexing methods: HNSW and Flat Pre-filtering queries with GEO, TAG, TEXT or NUMERIC fields
  • 34. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Demo with a Fashion Product Finder Image & Text - Hybrid Similarity Search
  • 35. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 eCommerce Searches There's a growing expectation for effective search functionality Unstructured Data is "high-dimensional" Needs to capture "meaning and context" in unstructured data Encompasses Recommendation Engines and Similarity Search
  • 36. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Natural Language Search Visual Search Recommenders
  • 37. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 How to implement the solution? Framework and libraries
  • 38. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024
  • 39. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 A Redis Framework It’s more than Object Mapping Redis OM stands for Redis Object Mapping, a suite of libraries designed to facilitate object-oriented interaction with Redis. It simplifies working with Redis by abstracting direct commands into higher-level operations. https://github.com/redis/redis-om-dotnet
  • 40. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 More to come...
  • 41. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Redis OM Why? ● Redis OM simplifies application development by abstracting Redis' complexity, increasing productivity, and enhancing code readability. What? ◆ Redis OM enables building real-time applications, supporting: ● Model Data ● Perform CRUD Operations ● Index and Search Data
  • 42. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Fashion Product Finder Breakdown ■ A Product domain mapped to Redis JSON ■ [Indexed] decorated field for text and numeric indexing ■ [ImageVectorizer] decorated field to generate embeddings ■ [SentenceVectorizer] decorated field to generate embeddings ■ Pre-filter the search if needed ■ Entity Streams to query for K nearest neighbors ■ Display results
  • 43. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 namespace ProductCatalog.Model; [Document(StorageType = StorageType.Json)] public class Product { // Other fields... } Model → Redis JSON [Document]
  • 44. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Make Product Searchable [Indexed] decoration namespace ProductCatalog.Model; [Document(StorageType = StorageType.Json)] public class Product { [RedisIdField] [Indexed] public int Id { get; set; } // Other fields... [Indexed] public string Gender { get; set; } [Indexed] public int? Year { get; set; } // Other fields... } Decorate what you want to make searchable
  • 45. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Automatic Embedding Generation [IVectorizer] decoration namespace ProductCatalog.Model; [Document(StorageType = StorageType.Json)] public class Product { // Other fields... [Indexed(Algorithm = VectorAlgorithm.HNSW, DistanceMetric = DistanceMetric.COSINE)] [ImageVectorizer]public Vector<string> ImageUrl { get; set; } [Indexed(Algorithm = VectorAlgorithm.FLAT, DistanceMetric = DistanceMetric.COSINE)] [SentenceVectorizer] public Vector<string> ProductDisplayName { get; set; }
  • 46. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Searching with Fluent API [IVectorizer] decoration [HttpGet("byImage")] public IEnumerable<CatalogResponse > ByImage([FromQuery]string url) { var collection = _provider.RedisCollection <Product>(); var response = collection.NearestNeighbors(x => x.ImageUrl, 15, url); return response.Select(CatalogResponse .Of); } [HttpGet("byDescription" )] public IEnumerable<CatalogResponse > ByDescription([FromQuery] string description) { var collection = _provider.RedisCollection <Product>(); var response = collection.NearestNeighbors(x => x.ProductDisplayName, 15, description); return response.Select(CatalogResponse .Of); }
  • 47. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 dotnet run --project ProductCatalog
  • 48. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 The tools and techniques to unlock the value in Unstructured Data have evolved greatly...
  • 49. Unleashing the Power of Vector Search and Semantic Caching in .NET Databases like Redis and frameworks like Redis OM can help! 2024
  • 50. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 INTEGRATIONS FEATURES Storage: HASH | JSON Indexing: HNSW (ANN) | Flat (KNN) Distance: L2 | Cosine | IP Search Types: KNN/ANN | Hybrid | Range | Full Text Management: Realtime CRUD operations, aliasing, temp indices, and more Ecosystem integrations NEW REDIS ENTERPRISE 7.2 FEATURE Scalable search and query for improved performance, up to 16X compared to previous versions Redis as Vector Database
  • 51. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector Similarity Search Use Cases
  • 52. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector Similarity Search Use Cases Question & Answering
  • 53. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector Similarity Search Use Cases 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.
  • 54. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector Similarity Search Use Cases 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.
  • 55. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Vector Similarity Search Use Cases 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.
  • 56. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024
  • 57. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Additional resources for learning about Redis Central place to find example apps that are built on Redis launchpad.redis.com Redis Launchpad Free online courses taught by Redis experts university.redis.com Redis University Create a database Code your application Explore your data developer.redis.com Developers Portal Professional certification program for developers university.redis.com/ certification Redis Certification
  • 58. Unleashing the Power of Vector Search and Semantic Caching in .NET 2024 Redis Stack for Application Modernization