Skip to content

Commit 1a02920

Browse files
Add multimodal search guide (#3170)
1 parent 61dbe25 commit 1a02920

File tree

3 files changed

+109
-1
lines changed

3 files changed

+109
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,9 @@ search_parameter_guide_vector_1: |-
14091409
-H 'content-type: application/json' \
14101410
--data-binary '{
14111411
"vector": [0, 1, 2],
1412-
"embedder": "EMBEDDER_NAME"
1412+
"hybrid": {
1413+
"embedder": "EMBEDDER_NAME"
1414+
}
14131415
}'
14141416
search_parameter_reference_retrieve_vectors_1: |-
14151417
curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \

config/sidebar-learn.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
"label": "Which embedder should I choose?",
6565
"slug": "choose_an_embedder"
6666
},
67+
{
68+
"source": "learn/ai_powered_search/image_search_with_user_provided_embeddings.mdx",
69+
"label": "Image search with user-provided embeddings",
70+
"slug": "image_search_with_user_provided_embeddings"
71+
},
6772
{
6873
"source": "learn/ai_powered_search/difference_full_text_ai_search.mdx",
6974
"label": "Differences between full-text and AI-powered search",
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: Image search with user-provided embeddings — Meilisearch documentation
3+
description: This article shows you the main steps for performing multimodal text-to-image searches
4+
---
5+
6+
# Image search with user-provided embeddings
7+
8+
This article shows you the main steps for performing multimodal searches where you can use text to search through a database of images with no associated metadata.
9+
10+
## Requirements
11+
12+
- A database of images
13+
- A Meilisearch project
14+
- An embedding generation provider you can install locally
15+
16+
## Configure your local embedding generation pipeline
17+
18+
First, set up a system that sends your images to your chosen embedding generation provider, then integrates the returned embeddings into your dataset.
19+
20+
The exact procedure depends heavily on your specific setup, but should include these main steps:
21+
22+
1. Choose a provider you can run locally
23+
2. Choose a model that supports both image and text input
24+
3. Send your images to the embedding generation provider
25+
4. Add the returned embeddings to the `_vector` field for each image in your database
26+
27+
In most cases your system should run these steps periodically or whenever you update your database.
28+
29+
## Configure a user-provided embedder
30+
31+
Configure the `embedder` index setting, settings its source to `userProvided`:
32+
33+
```sh
34+
curl \
35+
-X PATCH 'MEILISEARCH_URL/indexes/movies/settings' \
36+
-H 'Content-Type: application/json' \
37+
--data-binary '{
38+
"embedders": {
39+
"EMBEDDER_NAME": {
40+
"source": "userProvided",
41+
"dimensions": MODEL_DIMENSIONS
42+
}
43+
}
44+
}'
45+
```
46+
47+
Replace `EMBEDDER_NAME` with the name you wish to give your embedder. Replace `MODEL_DIMENSIONS` with the number of dimensions of your chosen model.
48+
49+
## Add documents to Meilisearch
50+
51+
Next, use [the `/documents` endpoint](/reference/api/documents) to upload the vectorized images.
52+
53+
In most cases, you should automate this step so Meilisearch is up to date with your primary database.
54+
55+
## Set up pipeline for vectorizing queries
56+
57+
Since you are using a `userProvided` embedder, you must also generate the embeddings for the search query. This process should be similar to generating embeddings for your images:
58+
59+
1. Receive user query from your front-end
60+
2. Send query to your local embedding generation provider
61+
3. Perform search using the returned query embedding
62+
63+
## Vector search with user-provided embeddings
64+
65+
Once you have the query's vector, pass it to the `vector` search parameter to perform a semantic AI-powered search:
66+
67+
```sh
68+
curl -X POST -H 'content-type: application/json' \
69+
'localhost:7700/indexes/products/search' \
70+
--data-binary '{
71+
"vector": VECTORIZED_QUERY,
72+
"hybrid": {
73+
"embedder": "EMBEDDER_NAME",
74+
}
75+
}'
76+
```
77+
78+
Replace `VECTORIZED_QUERY` with the embedding generated by your provider and `EMBEDDER_NAME` with your embedder.
79+
80+
If your images have any associated metadata, you may perform a hybrid search by including the original `q`:
81+
82+
```sh
83+
curl -X POST -H 'content-type: application/json' \
84+
'localhost:7700/indexes/products/search' \
85+
--data-binary '{
86+
"vector": VECTORIZED_QUERY,
87+
"hybrid": {
88+
"embedder": "EMBEDDER_NAME",
89+
}
90+
"q": "QUERY",
91+
}'
92+
```
93+
94+
## Conclusion
95+
96+
You have seen the main steps for implementing image search with Meilisearch:
97+
98+
1. Prepare a pipeline that converts your images into vectors
99+
2. Index the vectorized images with Meilisearch
100+
3. Prepare a pipeline that converts your users' queries into vectors
101+
4. Perform searches using the converted queries

0 commit comments

Comments
 (0)