Skip to content

Commit d00f0d1

Browse files
add rough draft for multimodal search guide
1 parent 87f4d2b commit d00f0d1

File tree

3 files changed

+64
-27
lines changed

3 files changed

+64
-27
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
@@ -54,6 +54,11 @@
5454
"label": "Which embedder should I choose?",
5555
"slug": "choose_an_embedder"
5656
},
57+
{
58+
"source": "learn/ai_powered_search/multimodal.mdx",
59+
"label": "Image search with user-provided embeddings",
60+
"slug": "multimodal_search"
61+
},
5762
{
5863
"source": "learn/ai_powered_search/difference_full_text_ai_search.mdx",
5964
"label": "Differences between full-text and AI-powered search",
Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
---
2-
title: Implement image search — Meilisearch documentation
2+
title: Image search with user-provided embeddings — Meilisearch documentation
33
description:
44
---
55

6-
# Use AI-powered search with user-provided embeddings
6+
# Image search with user-provided embeddings
77

8-
This guide shows how to perform AI-powered searches with user-generated embeddings instead of relying on a third-party tool.
8+
This articles shows the main steps for performing multimodal searches where users use text to search through a database of images with no associated metadata.
99

1010
## Requirements
1111

12-
- A Meilisearch project with AI-powered search activated
12+
- A database of images
13+
- A Meilisearch project
1314

14-
## Configure a custom embedder
15+
## Configure your local embedding generation pipeline
16+
17+
First, set up a system that sends your images to your chosen embedding generation tool.
18+
19+
The exact procedure for this depend heavily on your specific setup, but should include these main steps:
20+
21+
1. Choose a provider you can run locally
22+
2. Choose a model that supports both image and text input
23+
3. Send your images to the provider
24+
4. Add the returned embeddings to the `_vector` field for each image in your database
25+
5. Periodically send your vectorized documents to Meilisearch
26+
27+
## Configure a user-provided embedder
1528

1629
Configure the `embedder` index setting, settings its source to `userProvided`:
1730

@@ -21,49 +34,66 @@ curl \
2134
-H 'Content-Type: application/json' \
2235
--data-binary '{
2336
"embedders": {
24-
"image2text": {
37+
"EMBEDDER_NAME": {
2538
"source": "userProvided",
26-
"dimensions": 3
39+
"dimensions": MODEL_DIMENSIONS
2740
}
2841
}
2942
}'
3043
```
3144

45+
Replace `EMBEDDER_NAME` with the name you wish to give your embedder. Replace `MODEL_DIMENSIONS` with the number of dimensions of your chosen model.
46+
3247
## Add documents to Meilisearch
3348

34-
Next, use [the `/documents` endpoint](/reference/api/documents?utm_campaign=vector-search&utm_source=docs&utm_medium=vector-search-guide) to upload vectorized documents. Place vector data in your documents' `_vectors` field:
49+
Next, use [the `/documents` endpoint](/reference/api/documents) to upload the vectorized images.
3550

36-
```sh
37-
curl -X POST -H 'content-type: application/json' \
38-
'localhost:7700/indexes/products/documents' \
39-
--data-binary '[
40-
{ "id": 0, "_vectors": {"image2text": [0, 0.8, -0.2]}, "text": "frying pan" },
41-
{ "id": 1, "_vectors": {"image2text": [1, -0.2, 0]}, "text": "baking dish" }
42-
]'
43-
```
51+
In most cases, you should automate this step so Meilisearch is up to date with your primary database.
4452

45-
## Vector search with user-provided embeddings
53+
## Set up pipeline for vectorizing queries
4654

47-
When using a custom embedder, you must vectorize both your documents and user queries.
55+
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:
4856

49-
Once you have the query's vector, pass it to the `vector` search parameter to perform an AI-powered search:
57+
1. Receive user query from your front-end
58+
2. Vectorize query with your local embedding provider
59+
3. Perform search using the vectorized query
60+
61+
## Vector search with user-provided embeddings
62+
63+
Once you have the query's vector, pass it to the `vector` search parameter to perform a semantic AI-powered search:
5064

5165
```sh
5266
curl -X POST -H 'content-type: application/json' \
5367
'localhost:7700/indexes/products/search' \
54-
--data-binary '{ "vector": [0, 1, 2] }'
68+
--data-binary '{
69+
"vector": VECTORIZED_QUERY,
70+
"hybrid": {
71+
"embedder": "EMBEDDER_NAME",
72+
}
73+
}'
5574
```
5675

57-
`vector` must be an array of numbers indicating the search vector. You must generate these yourself when using vector search with user-provided embeddings.
76+
Replace `VECTORIZED_QUERY` with the embedding generated by your provider and `EMBEDDER_NAME` with your embedder.
5877

59-
`vector` can be used together with [other search parameters](/reference/api/search?utm_campaign=vector-search&utm_source=docs&utm_medium=vector-search-guide), including [`filter`](/reference/api/search#filter) and [`sort`](/reference/api/search#sort):
78+
If your images have any associated metadata, you may perform a hybrid search by including the original `q`:
6079

6180
```sh
6281
curl -X POST -H 'content-type: application/json' \
6382
'localhost:7700/indexes/products/search' \
64-
--data-binary '{
65-
"vector": [0, 1, 2],
66-
"filter": "price < 10",
67-
"sort": ["price:asc"]
83+
--data-binary '{
84+
"vector": VECTORIZED_QUERY,
85+
"hybrid": {
86+
"embedder": "EMBEDDER_NAME",
87+
}
88+
"q": "QUERY",
6889
}'
6990
```
91+
92+
## Conclusion
93+
94+
You have seen the main steps for implementing multimodal search with Meilisearch:
95+
96+
1. Prepare a pipeline that converts your images into vectors
97+
2. Index the vectorized images with Meilisearch
98+
3. Prepare a pipeline that converts your users' queries into vectors
99+
4. Perform searches using the converted queries

0 commit comments

Comments
 (0)