Redis OM .NET has evolved to embrace the transformative world of vector database technology, now supporting Redis vector search and seamless integration with OpenAI, Azure OpenAI, Hugging Face, and ML.NET. This talk highlights the latest advancements in Redis OM .NET, focusing on how it simplifies the complex process of vector indexing, data modeling, and querying for AI-powered applications. Vector databases are redefining data handling, enabling semantic searches across text, images, and audio encoded as vectors. Redis OM .NET simplifies this innovative approach, making it accessible even for those new to vector data. We will explore the new capabilities of Redis OM .NET, including intuitive vector search interfaces and semantic caching, which reduce the overhead of large language model (LLM) calls.
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
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
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
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.
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