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
Copy file name to clipboardExpand all lines: articles/search/vector-search-how-to-generate-embeddings.md
+29-11Lines changed: 29 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,34 +10,52 @@ ms.update-cycle: 180-days
10
10
ms.custom:
11
11
- ignite-2023
12
12
ms.topic: how-to
13
-
ms.date: 06/11/2025
13
+
ms.date: 08/04/2025
14
14
---
15
15
16
16
# Generate embeddings for search queries and documents
17
17
18
-
Azure AI Search doesn't host embedding models, so one of your challenges is creating vectors for query inputs and outputs. You can use any supported embedding model, but this article assumes Azure OpenAI embedding models for illustration.
18
+
Azure AI Search doesn't host embedding models, so you're responsible for creating vectors for query inputs and outputs. Choose one of the following approaches:
19
19
20
-
We recommend [integrated vectorization](vector-search-integrated-vectorization.md), which provides built-in data chunking and vectorization. Integrated vectorization takes a dependency on indexers, skillsets, and built-in or custom skills that point to a model that executes externally from Azure AI Search. Several built-in skills point to embedding models in Azure AI Foundry, which makes integrated vectorization your easiest solution for solving the embedding challenge.
20
+
| Approach | Description |
21
+
| --- | --- |
22
+
|[Integrated vectorization](vector-search-integrated-vectorization.md)| Use built-in data chunking and vectorization in Azure AI Search. This approach takes a dependency on indexers, skillsets, and built-in or custom skills that point to external embedding models, such as those in Azure AI Foundry. |
23
+
| Manual vectorization | Manage data chunking and vectorization yourself. For indexing, you [push prevectorized documents](vector-search-how-to-create-index.md#load-vector-data-for-indexing) into vector fields in a search index. For queries, you provide precomputed vectors to the search engine. For demos of this approach, see the [azure-search-vector-samples](https://github.com/Azure/azure-search-vector-samples/tree/main) GitHub repository. |
21
24
22
-
If you want to handle data chunking and vectorization yourself, we provide demos in the [sample repository](https://github.com/Azure/azure-search-vector-samples/tree/main) that show you how to integrate with other community solutions.
25
+
We recommend integrated vectorization for most scenarios and use it for illustration in this article. Although you can use any supported embedding model, this article assumes Azure OpenAI embedding models.
23
26
24
27
## How embedding models are used in vector queries
25
28
26
-
+ Query inputs are either vectors, or text or images that are converted to vectors during query processing. The built-in solution in Azure AI Search is to use a vectorizer.
29
+
Embedding models are used to generate vectors for both [query inputs](#query-inputs) and [query outputs](#query-outputs).
27
30
28
-
Alternatively, you can also handle the conversion yourself by passing the query input to an embedding model of your choice. To avoid [rate limiting](/azure/ai-services/openai/quotas-limits), you can implement retry logic in your workload. For the Python demo, we used [tenacity](https://pypi.org/project/tenacity/).
31
+
### Query inputs
29
32
30
-
+ Query outputs are any matching documents found in a search index. Your search index must have been previously loaded with documents having one or more vector fields with embeddings. Whatever embedding model you used for indexing, use that same model for queries.
33
+
Query inputs are one of the following:
34
+
35
+
+ Text or images that are converted to vectors during query processing. With integrated vectorization, a [vectorizer](vector-search-how-to-configure-vectorizer.md) handles this task.
36
+
37
+
+ Precomputed vectors. You can generate these vectors by passing the query input to an embedding model of your choice. To avoid [rate limiting](/azure/ai-services/openai/quotas-limits), implement retry logic in your workload. We use [tenacity](https://pypi.org/project/tenacity/) in our Python demo.
38
+
39
+
### Query outputs
40
+
41
+
Query outputs are the matching documents retrieved from a search index based on the query input.
42
+
43
+
Your search index must have been previously loaded with documents containing one or more vector fields with embeddings. These embeddings can be generated using either integrated or manual vectorization. To ensure accurate results, use the same embedding model for both indexing and querying.
31
44
32
45
## Create resources in the same region
33
46
34
47
Although integrated vectorization with Azure OpenAI embedding models doesn't require resources to be in the same region, using the same region can improve performance and reduce latency.
35
48
36
-
1.[Check regions for a text embedding model](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability).
49
+
To use the same region for your resources:
50
+
51
+
1. Check the [regional availability of text embedding models](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability).
52
+
53
+
1. Check the [regional availability of Azure AI Search](search-region-support.md).
37
54
38
-
1.[Find the same region for Azure AI Search](search-region-support.md).
55
+
1.Create an Azure OpenAI resource and Azure AI Search service in the same region.
39
56
40
-
1. To support hybrid queries that include [semantic ranking](semantic-how-to-query-request.md), or if you want to try machine learning model integration using a [custom skill](cognitive-search-custom-skill-interface.md) in an [AI enrichment pipeline](cognitive-search-concept-intro.md), select an Azure AI Search region that provides those features.
57
+
> [!NOTE]
58
+
> To use [semantic ranking](semantic-how-to-query-request.md) for hybrid queries or machine learning models for [AI enrichment](cognitive-search-concept-intro.md), choose an Azure AI Search region that provides those features.
41
59
42
60
## Generate an embedding for an improvised query
43
61
@@ -85,7 +103,7 @@ Your model must already be deployed and you must have permission to access it. F
85
103
86
104
+**Choose the right embedding model:** Select an appropriate model for your specific use case, such as word embeddings for text-based searches or image embeddings for visual searches. Consider using pretrained models like **text-embedding-ada-002** from OpenAI or **Image Retrieval** REST API from [Azure AI Computer Vision](/azure/ai-services/computer-vision/how-to/image-retrieval).
87
105
88
-
+**Normalize Vector lengths**: Ensure that the vector lengths are normalized before storing them in the search index to improve the accuracy and performance of similarity search. Most pretrained models already are normalized but not all.
106
+
+**Normalize Vector lengths**: Ensure that the vector lengths are normalized before storing them in the search index to improve the accuracy and performance of similarity search. Most pretrained models already are normalized but not all.
89
107
90
108
+**Fine-tune the model**: If needed, fine-tune the selected model on your domain-specific data to improve its performance and relevance to your search application.
0 commit comments