You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Image search with user-provided embeddings — Meilisearch documentation
3
3
description:
4
4
---
5
5
6
-
# Use AI-powered search with user-provided embeddings
6
+
# Image search with user-provided embeddings
7
7
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.
9
9
10
10
## Requirements
11
11
12
-
- A Meilisearch project with AI-powered search activated
12
+
- A database of images
13
+
- A Meilisearch project
13
14
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
15
28
16
29
Configure the `embedder` index setting, settings its source to `userProvided`:
17
30
@@ -21,49 +34,66 @@ curl \
21
34
-H 'Content-Type: application/json' \
22
35
--data-binary '{
23
36
"embedders": {
24
-
"image2text": {
37
+
"EMBEDDER_NAME": {
25
38
"source": "userProvided",
26
-
"dimensions": 3
39
+
"dimensions": MODEL_DIMENSIONS
27
40
}
28
41
}
29
42
}'
30
43
```
31
44
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
+
32
47
## Add documents to Meilisearch
33
48
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.
35
50
36
-
```sh
37
-
curl -X POST -H 'content-type: application/json' \
In most cases, you should automate this step so Meilisearch is up to date with your primary database.
44
52
45
-
## Vector search with user-provided embeddings
53
+
## Set up pipeline for vectorizing queries
46
54
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:
48
56
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:
50
64
51
65
```sh
52
66
curl -X POST -H 'content-type: application/json' \
53
67
'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
+
}'
55
74
```
56
75
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.
58
77
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`:
60
79
61
80
```sh
62
81
curl -X POST -H 'content-type: application/json' \
63
82
'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",
68
89
}'
69
90
```
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
0 commit comments