SlideShare a Scribd company logo
1 | © Copyright 2024 Zilliz
1
Multimodal RAG with Milvus
Yi Wang @ Zilliz
2 | © Copyright 2024 Zilliz
2
01 RAG is the New Search
CONTENTS
02 Multimodal Retrieval with Milvus
3 | © Copyright 2024 Zilliz
3
RAG is the New Search
4 | © Copyright 2024 Zilliz
4
Retrieval-Augmented Generation
5 | © Copyright 2024 Zilliz
5
A Typical Search System
Picture Credit: https://web.eecs.umich.edu/~nham/EECS398F19/
6 | © Copyright 2024 Zilliz
6
Indexing
Query Retrieval Prompt&
Generation
Recap of RAG Architecture
7 | © Copyright 2024 Zilliz
7
Indexing
Query Retrieval Prompt&
Generation
Recap of RAG Architecture
Offline Indexing
8 | © Copyright 2024 Zilliz
8
Indexing
Query Retrieval Prompt&
Generation
Recap of RAG Architecture
Online Serving
9 | © Copyright 2024 Zilliz
9
How RAG Resembles Search
10 | © Copyright 2024 Zilliz
10
Multimodal Retrieval with Milvus
11 | © Copyright 2024 Zilliz
11
Multi-modal Retrieval
● Combining text and
image in the search
query
● Retrieving
multi-modal content
for generation
Query = "feuilles brunes pendant la journée"
(i.e. "brown leaves during daytime")
12 | © Copyright 2024 Zilliz
12
13 | © Copyright 2024 Zilliz
13
Easy to start with, can even run on edge devices!
14 | © Copyright 2024 Zilliz
14
Scale-up on Docker
15 | © Copyright 2024 Zilliz
15
Up to 100 billion vectors with K8s!
16 | © Copyright 2024 Zilliz
16
17 | © Copyright 2024 Zilliz
17
Data Preparation
󰗓 Download images.zip file directly from:
https://huggingface.co/datasets/unum-cloud/ann-unsplash-25k/tree/main
import glob, time, pprint
import numpy as np
from PIL import Image
import pandas as pd
# Load image files and descriptions
image_data = pd.read_csv('images.csv')
print(image_data.shape)
display(image_data.head(2))
# List of image urls and texts.
image_urls = list(image_data.photo_id)
image_texts = list(image_data.ai_description)
18 | © Copyright 2024 Zilliz
18
Create a Milvus Collection
# STEP 1. Connect to milvus
connection = connections.connect(
alias="default",
host='localhost', # or '0.0.0.0' or 'localhost'
port='19530'
)
# STEP 2. Create a new collection and build index
EMBEDDING_DIM = 256
MAX_LENGTH = 65535
# Step 2.1 Define the data schema for the new Collection.
fields = [
# Use auto generated id as primary key
FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True, max_length=100),
FieldSchema(name="text_vector", dtype=DataType.FLOAT_VECTOR, dim=EMBEDDING_DIM),
FieldSchema(name="image_vector", dtype=DataType.FLOAT_VECTOR, dim=EMBEDDING_DIM),
FieldSchema(name="chunk", dtype=DataType.VARCHAR, max_length=MAX_LENGTH),
FieldSchema(name="image_filepath", dtype=DataType.VARCHAR, max_length=MAX_LENGTH),
]
schema = CollectionSchema(fields, "")
# Step 2.2 create collection
col = Collection(“Demo_multimodal”, schema)
# Step 2.3 Build index for both vector columns .
image_index = {"metric_type": "COSINE"}
col.create_index("image_vector", image_index)
text_index = {"metric_type": "COSINE"}
col.create_index("text_vector", text_index)
col.load()
19 | © Copyright 2024 Zilliz
19
Data Vectorization & insertion
# STEP 4. Insert data into milvus OR zilliz.
# Prepare data batch.
chunk_dict_list = []
for chunk, img_url, img_embed, text_embed in zip(
batch_texts,
batch_urls,
image_embeddings, text_embeddings):
# Assemble embedding vector, original text chunk, metadata.
chunk_dict = {
'chunk': chunk,
'image_filepath': img_url,
'text_vector': text_embed,
'image_vector': img_embed
}
chunk_dict_list.append(chunk_dict)
# Actually insert data batch.
# If the data size is large, try bulk_insert()
col.insert(data=chunk_dict_list)
# STEP 3. Data vectorization(i.e. embedding).
image_embeddings, text_embeddings = embedding_model(
batch_images=batch_images,
batch_texts=batch_texts)
20 | © Copyright 2024 Zilliz
20
# STEP 4. hybrid_search() is the API for multimodal search
results = col.hybrid_search(
reqs=[image_req, text_req],
rerank=RRFRanker(),
limit=top_k,
output_fields=output_fields)
Final step: Search
21 | © Copyright 2024 Zilliz
21
[Multimodal] search with text-only query
Query = "feuilles brunes pendant la journée"
(i.e. "brown leaves during daytime")
22 | © Copyright 2024 Zilliz
22
[Multimodal] search with image-only query
[Query is an image]
23 | © Copyright 2024 Zilliz
23
[Multimodal] search with text + image query
Query = text + image
1. "silhouette d'une personne assise sur une
roche au couche du soleil"
(i.e. "silhouette of person sitting on rock formation
during golden hour")
2. Image below
Result
24 | © Copyright 2024 Zilliz
24
QA
25 | © Copyright 2024 Zilliz
25 | © Copyright 9/25/23 Zilliz
25
26 | © Copyright 2024 Zilliz
26 | © Copyright 9/25/23 Zilliz
26
curl --request POST 
--url “${MILVUS_HOST}:${MILVUS_PORT}/v2/vectordb/entities/advanced_search” 
--header “Authorization: Bearer ${TOKEN}” 
--header “accept: application/json” 
--header “content-type: application/json” 
-d
{
"collectionName": "book",
"search": {
"search_by": {
"field": "book_intro_vector",
"data": [1, 2, ...],
},
"search_by": {
"field": "book_cover_vector",
"data": [2, 3, ...],
},
},
"rerank": {
"strategy": "rrf",
},
"limit": 10,
}
Retrieve Params
Re-rank Params

More Related Content

Similar to Multimodal Retrieval Augmented Generation (RAG) with Milvus

Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
Akshay Mathur
 
Machine Learning for Web Developers
Machine Learning for Web DevelopersMachine Learning for Web Developers
Machine Learning for Web Developers
Riza Fahmi
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
Modern android development
Modern android developmentModern android development
Modern android development
Khiem-Kim Ho Xuan
 
d.mix: Programming by a Sample
d.mix: Programming by a Sampled.mix: Programming by a Sample
d.mix: Programming by a Sample
Leslie W
 
Analysis of Popular Uber Locations using Apache APIs: Spark Machine Learning...
Analysis of Popular Uber Locations using Apache APIs:  Spark Machine Learning...Analysis of Popular Uber Locations using Apache APIs:  Spark Machine Learning...
Analysis of Popular Uber Locations using Apache APIs: Spark Machine Learning...
Carol McDonald
 
Mood analyzer-ng poland
Mood analyzer-ng polandMood analyzer-ng poland
Mood analyzer-ng poland
Sherry List
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
Rohit Radhakrishnan
 
How Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and AnalyticsHow Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and Analytics
mattinsler
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
Zilliz
 
Build an Edge-to-Cloud Solution with the MING Stack
Build an Edge-to-Cloud Solution with the MING StackBuild an Edge-to-Cloud Solution with the MING Stack
Build an Edge-to-Cloud Solution with the MING Stack
InfluxData
 
An MVC Approach to WordPress Theme Development
An MVC Approach to WordPress Theme DevelopmentAn MVC Approach to WordPress Theme Development
An MVC Approach to WordPress Theme Development
Dream Production AG
 
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
Markus Eisele
 
Drone ppt
Drone pptDrone ppt
Drone ppt
Changik Choi
 
Using LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowUsing LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache Arrow
DataWorks Summit
 
Introducing DataWave
Introducing DataWaveIntroducing DataWave
Introducing DataWave
Data Works MD
 
The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)
David Gibbons
 
MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...
MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...
MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...
MongoDB
 
IRJET- Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud Storage
IRJET-  	  Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud StorageIRJET-  	  Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud Storage
IRJET- Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud Storage
IRJET Journal
 
MongoDB Days UK: Building Apps with the MEAN Stack
MongoDB Days UK: Building Apps with the MEAN StackMongoDB Days UK: Building Apps with the MEAN Stack
MongoDB Days UK: Building Apps with the MEAN Stack
MongoDB
 

Similar to Multimodal Retrieval Augmented Generation (RAG) with Milvus (20)

Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
 
Machine Learning for Web Developers
Machine Learning for Web DevelopersMachine Learning for Web Developers
Machine Learning for Web Developers
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
 
Modern android development
Modern android developmentModern android development
Modern android development
 
d.mix: Programming by a Sample
d.mix: Programming by a Sampled.mix: Programming by a Sample
d.mix: Programming by a Sample
 
Analysis of Popular Uber Locations using Apache APIs: Spark Machine Learning...
Analysis of Popular Uber Locations using Apache APIs:  Spark Machine Learning...Analysis of Popular Uber Locations using Apache APIs:  Spark Machine Learning...
Analysis of Popular Uber Locations using Apache APIs: Spark Machine Learning...
 
Mood analyzer-ng poland
Mood analyzer-ng polandMood analyzer-ng poland
Mood analyzer-ng poland
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
 
How Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and AnalyticsHow Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and Analytics
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Build an Edge-to-Cloud Solution with the MING Stack
Build an Edge-to-Cloud Solution with the MING StackBuild an Edge-to-Cloud Solution with the MING Stack
Build an Edge-to-Cloud Solution with the MING Stack
 
An MVC Approach to WordPress Theme Development
An MVC Approach to WordPress Theme DevelopmentAn MVC Approach to WordPress Theme Development
An MVC Approach to WordPress Theme Development
 
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
 
Drone ppt
Drone pptDrone ppt
Drone ppt
 
Using LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowUsing LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache Arrow
 
Introducing DataWave
Introducing DataWaveIntroducing DataWave
Introducing DataWave
 
The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)
 
MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...
MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...
MongoDB .local London 2019: Best Practices for Working with IoT and Time-seri...
 
IRJET- Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud Storage
IRJET-  	  Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud StorageIRJET-  	  Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud Storage
IRJET- Key-Aggregate Cryptosystem for Scalable Data Sharing in Cloud Storage
 
MongoDB Days UK: Building Apps with the MEAN Stack
MongoDB Days UK: Building Apps with the MEAN StackMongoDB Days UK: Building Apps with the MEAN Stack
MongoDB Days UK: Building Apps with the MEAN Stack
 

More from Zilliz

Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and OllamaTirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Zilliz
 
ASIMOV: Enterprise RAG at Dialog Axiata PLC
ASIMOV: Enterprise RAG at Dialog Axiata PLCASIMOV: Enterprise RAG at Dialog Axiata PLC
ASIMOV: Enterprise RAG at Dialog Axiata PLC
Zilliz
 
Metadata Lakes for Next-Gen AI/ML - Datastrato
Metadata Lakes for Next-Gen AI/ML - DatastratoMetadata Lakes for Next-Gen AI/ML - Datastrato
Metadata Lakes for Next-Gen AI/ML - Datastrato
Zilliz
 
Building an Agentic RAG locally with Ollama and Milvus
Building an Agentic RAG locally with Ollama and MilvusBuilding an Agentic RAG locally with Ollama and Milvus
Building an Agentic RAG locally with Ollama and Milvus
Zilliz
 
Specializing Small Language Models With Less Data
Specializing Small Language Models With Less DataSpecializing Small Language Models With Less Data
Specializing Small Language Models With Less Data
Zilliz
 
Occiglot - Open Language Models by and for Europe
Occiglot - Open Language Models by and for EuropeOcciglot - Open Language Models by and for Europe
Occiglot - Open Language Models by and for Europe
Zilliz
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
MemGPT: Introduction to Memory Augmented Chat
MemGPT: Introduction to Memory Augmented ChatMemGPT: Introduction to Memory Augmented Chat
MemGPT: Introduction to Memory Augmented Chat
Zilliz
 
Copilot Workspace: What it is, how it works, why it matters
Copilot Workspace: What it is, how it works, why it mattersCopilot Workspace: What it is, how it works, why it matters
Copilot Workspace: What it is, how it works, why it matters
Zilliz
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
Knowledge Graphs in Retrieval Augmented Generation with WhyHow.AI
Knowledge Graphs in Retrieval Augmented Generation with WhyHow.AIKnowledge Graphs in Retrieval Augmented Generation with WhyHow.AI
Knowledge Graphs in Retrieval Augmented Generation with WhyHow.AI
Zilliz
 
Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...
Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...
Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...
Zilliz
 
Advanced Retrieval Augmented Generation Techniques
Advanced Retrieval Augmented Generation TechniquesAdvanced Retrieval Augmented Generation Techniques
Advanced Retrieval Augmented Generation Techniques
Zilliz
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
Zilliz
 

More from Zilliz (20)

Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and OllamaTirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
 
ASIMOV: Enterprise RAG at Dialog Axiata PLC
ASIMOV: Enterprise RAG at Dialog Axiata PLCASIMOV: Enterprise RAG at Dialog Axiata PLC
ASIMOV: Enterprise RAG at Dialog Axiata PLC
 
Metadata Lakes for Next-Gen AI/ML - Datastrato
Metadata Lakes for Next-Gen AI/ML - DatastratoMetadata Lakes for Next-Gen AI/ML - Datastrato
Metadata Lakes for Next-Gen AI/ML - Datastrato
 
Building an Agentic RAG locally with Ollama and Milvus
Building an Agentic RAG locally with Ollama and MilvusBuilding an Agentic RAG locally with Ollama and Milvus
Building an Agentic RAG locally with Ollama and Milvus
 
Specializing Small Language Models With Less Data
Specializing Small Language Models With Less DataSpecializing Small Language Models With Less Data
Specializing Small Language Models With Less Data
 
Occiglot - Open Language Models by and for Europe
Occiglot - Open Language Models by and for EuropeOcciglot - Open Language Models by and for Europe
Occiglot - Open Language Models by and for Europe
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
MemGPT: Introduction to Memory Augmented Chat
MemGPT: Introduction to Memory Augmented ChatMemGPT: Introduction to Memory Augmented Chat
MemGPT: Introduction to Memory Augmented Chat
 
Copilot Workspace: What it is, how it works, why it matters
Copilot Workspace: What it is, how it works, why it mattersCopilot Workspace: What it is, how it works, why it matters
Copilot Workspace: What it is, how it works, why it matters
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
Knowledge Graphs in Retrieval Augmented Generation with WhyHow.AI
Knowledge Graphs in Retrieval Augmented Generation with WhyHow.AIKnowledge Graphs in Retrieval Augmented Generation with WhyHow.AI
Knowledge Graphs in Retrieval Augmented Generation with WhyHow.AI
 
Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...
Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...
Answer 'What's for Dinner?' with Vector Search and Natural Language using Hay...
 
Advanced Retrieval Augmented Generation Techniques
Advanced Retrieval Augmented Generation TechniquesAdvanced Retrieval Augmented Generation Techniques
Advanced Retrieval Augmented Generation Techniques
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 

Recently uploaded

Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
Yevgen Sysoyev
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...
“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...
“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...
Edge AI and Vision Alliance
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
Verti - EMEA Insurer Innovation Award 2024
Verti - EMEA Insurer Innovation Award 2024Verti - EMEA Insurer Innovation Award 2024
Verti - EMEA Insurer Innovation Award 2024
The Digital Insurer
 
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & SolutionsMYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
Linda Zhang
 
20240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 202420240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 2024
Matthew Sinclair
 
Performance Budgets for the Real World by Tammy Everts
Performance Budgets for the Real World by Tammy EvertsPerformance Budgets for the Real World by Tammy Everts
Performance Budgets for the Real World by Tammy Everts
ScyllaDB
 
Running a Go App in Kubernetes: CPU Impacts
Running a Go App in Kubernetes: CPU ImpactsRunning a Go App in Kubernetes: CPU Impacts
Running a Go App in Kubernetes: CPU Impacts
ScyllaDB
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
Matthew Sinclair
 
AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)
apoorva2579
 
Why do You Have to Redesign?_Redesign Challenge Day 1
Why do You Have to Redesign?_Redesign Challenge Day 1Why do You Have to Redesign?_Redesign Challenge Day 1
Why do You Have to Redesign?_Redesign Challenge Day 1
FellyciaHikmahwarani
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
shanthidl1
 
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Erasmo Purificato
 
@Call @Girls Thiruvananthapuram 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...
@Call @Girls Thiruvananthapuram  🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...@Call @Girls Thiruvananthapuram  🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...
@Call @Girls Thiruvananthapuram 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...
kantakumariji156
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 

Recently uploaded (20)

Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...
“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...
“Intel’s Approach to Operationalizing AI in the Manufacturing Sector,” a Pres...
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
Verti - EMEA Insurer Innovation Award 2024
Verti - EMEA Insurer Innovation Award 2024Verti - EMEA Insurer Innovation Award 2024
Verti - EMEA Insurer Innovation Award 2024
 
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & SolutionsMYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
MYIR Product Brochure - A Global Provider of Embedded SOMs & Solutions
 
20240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 202420240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 2024
 
Performance Budgets for the Real World by Tammy Everts
Performance Budgets for the Real World by Tammy EvertsPerformance Budgets for the Real World by Tammy Everts
Performance Budgets for the Real World by Tammy Everts
 
Running a Go App in Kubernetes: CPU Impacts
Running a Go App in Kubernetes: CPU ImpactsRunning a Go App in Kubernetes: CPU Impacts
Running a Go App in Kubernetes: CPU Impacts
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
 
AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)AC Atlassian Coimbatore Session Slides( 22/06/2024)
AC Atlassian Coimbatore Session Slides( 22/06/2024)
 
Why do You Have to Redesign?_Redesign Challenge Day 1
Why do You Have to Redesign?_Redesign Challenge Day 1Why do You Have to Redesign?_Redesign Challenge Day 1
Why do You Have to Redesign?_Redesign Challenge Day 1
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
 
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
Paradigm Shifts in User Modeling: A Journey from Historical Foundations to Em...
 
@Call @Girls Thiruvananthapuram 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...
@Call @Girls Thiruvananthapuram  🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...@Call @Girls Thiruvananthapuram  🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...
@Call @Girls Thiruvananthapuram 🚒 XXXXXXXXXX 🚒 Priya Sharma Beautiful And Cu...
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 

Multimodal Retrieval Augmented Generation (RAG) with Milvus

  • 1. 1 | © Copyright 2024 Zilliz 1 Multimodal RAG with Milvus Yi Wang @ Zilliz
  • 2. 2 | © Copyright 2024 Zilliz 2 01 RAG is the New Search CONTENTS 02 Multimodal Retrieval with Milvus
  • 3. 3 | © Copyright 2024 Zilliz 3 RAG is the New Search
  • 4. 4 | © Copyright 2024 Zilliz 4 Retrieval-Augmented Generation
  • 5. 5 | © Copyright 2024 Zilliz 5 A Typical Search System Picture Credit: https://web.eecs.umich.edu/~nham/EECS398F19/
  • 6. 6 | © Copyright 2024 Zilliz 6 Indexing Query Retrieval Prompt& Generation Recap of RAG Architecture
  • 7. 7 | © Copyright 2024 Zilliz 7 Indexing Query Retrieval Prompt& Generation Recap of RAG Architecture Offline Indexing
  • 8. 8 | © Copyright 2024 Zilliz 8 Indexing Query Retrieval Prompt& Generation Recap of RAG Architecture Online Serving
  • 9. 9 | © Copyright 2024 Zilliz 9 How RAG Resembles Search
  • 10. 10 | © Copyright 2024 Zilliz 10 Multimodal Retrieval with Milvus
  • 11. 11 | © Copyright 2024 Zilliz 11 Multi-modal Retrieval ● Combining text and image in the search query ● Retrieving multi-modal content for generation Query = "feuilles brunes pendant la journée" (i.e. "brown leaves during daytime")
  • 12. 12 | © Copyright 2024 Zilliz 12
  • 13. 13 | © Copyright 2024 Zilliz 13 Easy to start with, can even run on edge devices!
  • 14. 14 | © Copyright 2024 Zilliz 14 Scale-up on Docker
  • 15. 15 | © Copyright 2024 Zilliz 15 Up to 100 billion vectors with K8s!
  • 16. 16 | © Copyright 2024 Zilliz 16
  • 17. 17 | © Copyright 2024 Zilliz 17 Data Preparation 󰗓 Download images.zip file directly from: https://huggingface.co/datasets/unum-cloud/ann-unsplash-25k/tree/main import glob, time, pprint import numpy as np from PIL import Image import pandas as pd # Load image files and descriptions image_data = pd.read_csv('images.csv') print(image_data.shape) display(image_data.head(2)) # List of image urls and texts. image_urls = list(image_data.photo_id) image_texts = list(image_data.ai_description)
  • 18. 18 | © Copyright 2024 Zilliz 18 Create a Milvus Collection # STEP 1. Connect to milvus connection = connections.connect( alias="default", host='localhost', # or '0.0.0.0' or 'localhost' port='19530' ) # STEP 2. Create a new collection and build index EMBEDDING_DIM = 256 MAX_LENGTH = 65535 # Step 2.1 Define the data schema for the new Collection. fields = [ # Use auto generated id as primary key FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True, max_length=100), FieldSchema(name="text_vector", dtype=DataType.FLOAT_VECTOR, dim=EMBEDDING_DIM), FieldSchema(name="image_vector", dtype=DataType.FLOAT_VECTOR, dim=EMBEDDING_DIM), FieldSchema(name="chunk", dtype=DataType.VARCHAR, max_length=MAX_LENGTH), FieldSchema(name="image_filepath", dtype=DataType.VARCHAR, max_length=MAX_LENGTH), ] schema = CollectionSchema(fields, "") # Step 2.2 create collection col = Collection(“Demo_multimodal”, schema) # Step 2.3 Build index for both vector columns . image_index = {"metric_type": "COSINE"} col.create_index("image_vector", image_index) text_index = {"metric_type": "COSINE"} col.create_index("text_vector", text_index) col.load()
  • 19. 19 | © Copyright 2024 Zilliz 19 Data Vectorization & insertion # STEP 4. Insert data into milvus OR zilliz. # Prepare data batch. chunk_dict_list = [] for chunk, img_url, img_embed, text_embed in zip( batch_texts, batch_urls, image_embeddings, text_embeddings): # Assemble embedding vector, original text chunk, metadata. chunk_dict = { 'chunk': chunk, 'image_filepath': img_url, 'text_vector': text_embed, 'image_vector': img_embed } chunk_dict_list.append(chunk_dict) # Actually insert data batch. # If the data size is large, try bulk_insert() col.insert(data=chunk_dict_list) # STEP 3. Data vectorization(i.e. embedding). image_embeddings, text_embeddings = embedding_model( batch_images=batch_images, batch_texts=batch_texts)
  • 20. 20 | © Copyright 2024 Zilliz 20 # STEP 4. hybrid_search() is the API for multimodal search results = col.hybrid_search( reqs=[image_req, text_req], rerank=RRFRanker(), limit=top_k, output_fields=output_fields) Final step: Search
  • 21. 21 | © Copyright 2024 Zilliz 21 [Multimodal] search with text-only query Query = "feuilles brunes pendant la journée" (i.e. "brown leaves during daytime")
  • 22. 22 | © Copyright 2024 Zilliz 22 [Multimodal] search with image-only query [Query is an image]
  • 23. 23 | © Copyright 2024 Zilliz 23 [Multimodal] search with text + image query Query = text + image 1. "silhouette d'une personne assise sur une roche au couche du soleil" (i.e. "silhouette of person sitting on rock formation during golden hour") 2. Image below Result
  • 24. 24 | © Copyright 2024 Zilliz 24 QA
  • 25. 25 | © Copyright 2024 Zilliz 25 | © Copyright 9/25/23 Zilliz 25
  • 26. 26 | © Copyright 2024 Zilliz 26 | © Copyright 9/25/23 Zilliz 26 curl --request POST --url “${MILVUS_HOST}:${MILVUS_PORT}/v2/vectordb/entities/advanced_search” --header “Authorization: Bearer ${TOKEN}” --header “accept: application/json” --header “content-type: application/json” -d { "collectionName": "book", "search": { "search_by": { "field": "book_intro_vector", "data": [1, 2, ...], }, "search_by": { "field": "book_cover_vector", "data": [2, 3, ...], }, }, "rerank": { "strategy": "rrf", }, "limit": 10, } Retrieve Params Re-rank Params