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
description: Learn how to generate embeddings for downstream indexing into an Azure AI Search index.
5
5
@@ -10,7 +10,7 @@ ms.update-cycle: 180-days
10
10
ms.custom:
11
11
- ignite-2023
12
12
ms.topic: how-to
13
-
ms.date: 08/04/2025
13
+
ms.date: 08/05/2025
14
14
---
15
15
16
16
# Generate embeddings for search queries and documents
@@ -20,27 +20,43 @@ Azure AI Search doesn't host embedding models, so you're responsible for creatin
20
20
| Approach | Description |
21
21
| --- | --- |
22
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. |
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 querying, 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. |
24
24
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.
25
+
We recommend integrated vectorization for most scenarios. Although you can use any supported embedding model, this article uses Azure OpenAI embedding models for illustration.
26
26
27
27
## How embedding models are used in vector queries
28
28
29
-
Embedding models are used to generate vectors for both [query inputs](#query-inputs) and [query outputs](#query-outputs).
29
+
Embedding models generate vectors for both [query inputs](#query-inputs) and [query outputs](#query-outputs).
30
30
31
31
### Query inputs
32
32
33
-
Query inputs are one of the following:
33
+
Query inputs include the following:
34
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.
35
+
+**Text or images that are converted to vectors during query processing**. As part of integrated vectorization, a [vectorizer](vector-search-how-to-configure-vectorizer.md)performs this task.
36
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.
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. Our [Python demo](https://github.com/Azure/azure-search-vector-samples/tree/93c839591bf92c2f10001d287871497b0f204a7c/demo-python) uses [tenacity](https://pypi.org/project/tenacity/).
38
38
39
39
### Query outputs
40
40
41
-
Query outputs are the matching documents retrieved from a search index based on the query input.
41
+
Based on the query input, the search engine retrieves matching documents from your search index. These documents are the query outputs.
42
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.
43
+
Your search index must already contain documents with one or more vector fields populated by embeddings. You can create these embeddings through integrated or manual vectorization. To ensure accurate results, use the same embedding model for indexing and querying.
44
+
45
+
## Tips for embedding model integration
46
+
47
+
+**Identify use cases**. Evaluate specific use cases where embedding model integration for vector search features adds value to your search solution. Examples include [multimodal search](multimodal-search-overview.md) or matching image content with text content, multilingual search, and similarity search.
48
+
49
+
+**Design a chunking strategy**. Embedding models have limits on the number of tokens they accept, so data chunking is necessary for large files. For more information, see [Chunk large documents for vector search solutions](vector-search-how-to-chunk-documents.md).
50
+
51
+
+**Optimize cost and performance**. Vector search is resource intensive and subject to maximum limits, so vectorize only the fields that contain semantic meaning. [Reduce vector size](vector-search-how-to-configure-compression-storage.md) to store more vectors for the same price.
52
+
53
+
+**Choose the right embedding model**. Select a model for your use case, such as word embeddings for text-based searches or image embeddings for visual searches. Consider pretrained models, such as text-embedding-ada-002 from OpenAI or the Image Retrieval REST API from [Azure AI Computer Vision](/azure/ai-services/computer-vision/how-to/image-retrieval).
54
+
55
+
+**Normalize vector lengths**. To improve the accuracy and performance of similarity search, normalize vector lengths before you store them in a search index. Most pretrained models are already normalized.
56
+
57
+
+**Fine-tune the model**. If needed, fine-tune the model on your domain-specific data to improve its performance and relevance to your search application.
58
+
59
+
+**Test and iterate**. Continuously test and refine the embedding model integration to achieve your desired search performance and user satisfaction.
44
60
45
61
## Create resources in the same region
46
62
@@ -54,12 +70,142 @@ To use the same region for your resources:
54
70
55
71
1. Create an Azure OpenAI resource and Azure AI Search service in the same region.
56
72
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.
73
+
> [!TIP]
74
+
> Want to use [semantic ranking](semantic-how-to-query-request.md) for [hybrid queries](hybrid-search-overview.md) or a machine learning model in a [custom skill](cognitive-search-custom-skill-interface.md) for [AI enrichment](cognitive-search-concept-intro.md)? Choose an Azure AI Search region that provides those features.
75
+
76
+
## Choose an embedding model in Azure AI Foundry
77
+
78
+
When you add knowledge to an agent workflow in the [Azure AI Foundry portal](https://ai.azure.com/?cid=learnDocs), you have the option of creating a search index. A wizard guides you through the steps.
79
+
80
+
One step involves selecting an embedding model to vectorize your plain text content. The following models are supported:
81
+
82
+
+ text-embedding-3-large
83
+
+ text-embedding-3-small
84
+
+ text-embedding-ada-002
85
+
+ Cohere-embed-v3-english
86
+
+ Cohere-embed-v3-multilingual
87
+
88
+
Your model must already be deployed, and you must have permission to access it. For more information, see [Deployment overview for Azure AI Foundry Models](/azure/ai-foundry/concepts/deployments-overview).
59
89
60
90
## Generate an embedding for an improvised query
61
91
62
-
The following Python code generates an embedding that you can paste into the "values" property of a vector query.
92
+
If you don't want to use integrated vectorization, you can manually generate an embedding and paste it into the `vectorQueries.vector` property of a vector query. For more information, see [Create a vector query in Azure AI Search](vector-search-how-to-query.md).
93
+
94
+
The following examples assume the text-embedding-ada-002 model. Replace `YOUR-API-KEY` and `YOUR-OPENAI-RESOURCE` with your Azure OpenAI resource details.
In the Azure AI Foundry portal, you have the option of creating a search index when you add knowledge to your agent workflow. A wizard guides you through the steps. When asked to provide an embedding model that vectorizes your plain text content, you can use one of the following supported models:
87
-
88
-
+ text-embedding-3-large
89
-
+ text-embedding-3-small
90
-
+ text-embedding-ada-002
91
-
+ Cohere-embed-v3-english
92
-
+ Cohere-embed-v3-multilingual
93
-
94
-
Your model must already be deployed and you must have permission to access it. For more information, see [Deploy AI models in Azure AI Foundry portal](/azure/ai-foundry/concepts/deployments-overview).
95
-
96
-
## Tips and recommendations for embedding model integration
97
-
98
-
+**Identify use cases**: Evaluate the specific use cases where embedding model integration for vector search features can add value to your search solution. This can include multimodal or matching image content with text content, multilingual search, or similarity search.
99
-
100
-
+**Design a chunking strategy**: Embedding models have limits on the number of tokens they can accept, which introduces a data chunking requirement for large files. For more information, see [Chunk large documents for vector search solutions](vector-search-how-to-chunk-documents.md).
101
-
102
-
+**Optimize cost and performance**: Vector search can be resource-intensive and is subject to maximum limits, so consider only vectorizing the fields that contain semantic meaning. [Reduce vector size](vector-search-how-to-configure-compression-storage.md) so that you can store more vectors for the same price.
103
-
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).
105
-
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.
107
-
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.
230
+
```http
231
+
POST https://YOUR-OPENAI-RESOURCE.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2024-02-01
232
+
Authorization: Bearer YOUR-API-KEY
233
+
Content-Type: application/json
234
+
235
+
{
236
+
"input": "How do I use REST APIs in VS Code?"
237
+
}
238
+
```
109
239
110
-
+**Test and iterate**: Continuously test and refine your embedding model integration to achieve the desired search performance and user satisfaction.
240
+
The output is a vector array of 1,536 dimensions.
111
241
112
-
## Next steps
242
+
## Related content
113
243
114
-
+[Understanding embeddings in Azure OpenAI in Azure AI Foundry Models](/azure/ai-services/openai/concepts/understand-embeddings)
115
-
+[Learn how to generate embeddings](/azure/ai-services/openai/how-to/embeddings?tabs=console)
244
+
+[Understand embeddings in Azure OpenAI in Azure AI Foundry Models](/azure/ai-services/openai/concepts/understand-embeddings)
245
+
+[Generate embeddings with Azure OpenAI](/azure/ai-services/openai/how-to/embeddings?tabs=console)
116
246
+[Tutorial: Explore Azure OpenAI embeddings and document search](/azure/ai-services/openai/tutorials/embeddings?tabs=command-line)
117
247
+[Tutorial: Choose a model (RAG solutions in Azure AI Search)](tutorial-rag-build-solution-models.md)
0 commit comments