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/redis/tutorial-vector-similarity.md
+16-20Lines changed: 16 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: "Tutorial: Conduct vector similarity search on Azure OpenAI embeddings using Azure Cache for Redis"
3
-
description: In this tutorial, you learn how to use Azure Cache for Redis to store and search for vector embeddings.
2
+
title: "Tutorial: Conduct vector similarity search on Azure OpenAI embeddings using Azure Managed Redis"
3
+
description: In this tutorial, you learn how to use Azure Managed Redis to store and search for vector embeddings.
4
4
ms.date: 02/27/2025
5
5
ms.topic: tutorial
6
6
ms.collection:
@@ -14,8 +14,7 @@ ms.custom:
14
14
15
15
# Tutorial: Conduct vector similarity search on Azure OpenAI embeddings using Azure Redis
16
16
17
-
<!-- cawa - need to mention AMR in this tutorial -->
18
-
In this tutorial, you walk through a basic vector similarity search use-case. You use embeddings generated by Azure OpenAI Service and the built-in vector search capabilities of the Enterprise tier of Azure Cache for Redis to query a dataset of movies to find the most relevant match.
17
+
In this tutorial, you walk through a basic vector similarity search use-case. You use embeddings generated by Azure OpenAI Service and the built-in vector search capabilities of Azure Managed Redis to query a dataset of movies to find the most relevant match.
19
18
20
19
The tutorial uses the [Wikipedia Movie Plots dataset](https://www.kaggle.com/datasets/jrobischon/wikipedia-movie-plots) that features plot descriptions of over 35,000 movies from Wikipedia covering the years 1901 to 2017. The dataset includes a plot summary for each movie, plus metadata such as the year the film was released, the director(s), main cast, and genre. You follow the steps of the tutorial to generate embeddings based on the plot summary and use the other metadata to run hybrid queries.
21
20
@@ -24,11 +23,11 @@ In this tutorial, you learn how to:
24
23
25
24
> [!div class="checklist"]
26
25
27
-
> - Create an Azure Cache for Redis instance configured for vector search
26
+
> - Create an Azure Managed Redis instance configured for vector search
28
27
> - Install Azure OpenAI and other required Python libraries.
29
28
> - Download the movie dataset and prepare it for analysis.
30
29
> - Use the **text-embedding-ada-002 (Version 2)** model to generate embeddings.
31
-
> - Create a vector index in Azure Cache for Redis
30
+
> - Create a vector index in Azure Managed Redis
32
31
> - Use cosine similarity to rank search results.
33
32
> - Use hybrid query functionality through [RediSearch](https://redis.io/docs/interact/search-and-query/) to prefilter the data and make the vector search even more powerful.
34
33
@@ -39,23 +38,22 @@ In this tutorial, you learn how to:
39
38
>If you would like to follow along in a completed Jupyter notebook instead, [download the Jupyter notebook file named _tutorial.ipynb_](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/tutorial/vector-similarity-search-open-ai) and save it into the new _redis-vector_ folder.
40
39
41
40
## Prerequisites
42
-
<!-- Continue here. -->
43
41
44
42
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
45
-
- Access granted to Azure OpenAI in the desired Azure subscription. Currently, you must apply for access to Azure OpenAI. You can apply for access to Azure OpenAI by completing the form at [https://aka.ms/oai/access](https://aka.ms/oai/access). <!-- I don't know if this is still true -->
43
+
- Access granted to Azure OpenAI in the desired Azure subscription. Currently, you must apply for access to Azure OpenAI. You can apply for access to Azure OpenAI by completing the form at [https://aka.ms/oai/access](https://aka.ms/oai/access). <!-- I don't know if
46
44
-[Python 3.8 or later version](https://www.python.org/)
- An Azure OpenAI resource with the **text-embedding-ada-002 (Version 2)** model deployed. This model is currently only available in [certain regions](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability). See the [resource deployment guide](/azure/ai-services/openai/how-to/create-resource) for instructions on how to deploy the model.
49
47
50
-
## Create an Azure Cache for Redis Instance
48
+
## Create an Azure Managed Redis Instance
51
49
52
-
1. Follow the [Quickstart: Create a Redis Enterprise cache](../azure-cache-for-redis/quickstart-create-redis-enterprise.md) guide, but make sure you add the RedisSearch module at create time.
50
+
1. Follow the [Quickstart](create-manage-cache) guide to create a cache, but make sure you add the RedisSearch module at create time.
53
51
54
52
1. On the **Advanced** page, make sure that you've added the **RediSearch** module and have chosen the **Enterprise** Cluster Policy. All other settings can match the default described in the quickstart.
55
53
56
54
It takes a few minutes for the cache to create. You can move on to the next step in the meantime.
@@ -82,13 +80,13 @@ In this tutorial, you learn how to:
82
80
83
81
## Import libraries and set up connection information
84
82
85
-
To successfully make a call against Azure OpenAI, you need an **endpoint** and a **key**. You also need an **endpoint** and a **key** to connect to Azure Cache for Redis.
83
+
To successfully make a call against Azure OpenAI, you need an **endpoint** and a **key**. You also need an **endpoint** and a **key** to connect to Azure Managed Redis.
86
84
87
85
1. Go to your Azure OpenAI resource in the Azure portal.
88
86
89
87
1. Locate **Endpoint and Keys** in the **Resource Management** section. Copy your endpoint and access key as you'll need both for authenticating your API calls. An example endpoint is: `https://docs-test-001.openai.azure.com`. You can use either `KEY1` or `KEY2`.
90
88
91
-
1. Go to the **Overview** page of your Azure Cache for Redis resource in the Azure portal. Copy your endpoint.
89
+
1. Go to the **Overview** page of your Azure Managed Redis resource in the Azure portal. Copy your endpoint.
92
90
93
91
1. Locate **Access keys** in the **Settings** section. Copy your access key. You can use either `Primary` or `Secondary`.
94
92
@@ -117,7 +115,7 @@ To successfully make a call against Azure OpenAI, you need an **endpoint** and a
117
115
118
116
1. Update the value of `API_KEY` and `RESOURCE_ENDPOINT` with the key and endpoint values from your Azure OpenAI deployment. `DEPLOYMENT_NAME` should be set to the name of your deployment using the `text-embedding-ada-002 (Version 2)` embeddings model, and `MODEL_NAME` should be the specific embeddings model used.
119
117
120
-
1. Update `REDIS_ENDPOINT` and `REDIS_PASSWORD` with the endpoint and key value from your Azure Cache for Redis instance.
118
+
1. Update `REDIS_ENDPOINT` and `REDIS_PASSWORD` with the endpoint and key value from your Azure Managed Redis instance.
121
119
122
120
> [!Important]
123
121
> We strongly recommend using environmental variables or a secret manager like [Azure Key Vault](/azure/key-vault/general/overview) to pass in the API key, endpoint, and deployment name information. These variables are set in plaintext here for the sake of simplicity.
@@ -228,7 +226,7 @@ Load the DataFrame into LangChain using the `DataFrameLoader` class. Once the da
228
226
229
227
## Generate embeddings and load them into Redis
230
228
231
-
Now that the data has been filtered and loaded into LangChain, you'll create embeddings so you can query on the plot for each movie. The following code configures Azure OpenAI, generates embeddings, and loads the embeddings vectors into Azure Cache for Redis.
229
+
Now that the data has been filtered and loaded into LangChain, you'll create embeddings so you can query on the plot for each movie. The following code configures Azure OpenAI, generates embeddings, and loads the embeddings vectors into Azure Managed Redis.
232
230
233
231
1. Add the following code a new code cell:
234
232
@@ -265,7 +263,7 @@ Now that the data has been filtered and loaded into LangChain, you'll create emb
265
263
vectorstore.write_schema("redis_schema.yaml")
266
264
```
267
265
268
-
1. Execute code cell 8. This can take over 30 minutes to complete. A `redis_schema.yaml` file is generated as well. This file is useful if you want to connect to your index in Azure Cache for Redis instance without re-generating embeddings.
266
+
1. Execute code cell 8. This can take over 30 minutes to complete. A `redis_schema.yaml` file is generated as well. This file is useful if you want to connect to your index in Azure Managed Redis instance without re-generating embeddings.
269
267
270
268
271
269
> [!Important]
@@ -341,16 +339,14 @@ Now that your dataset, Azure OpenAI service API, and Redis instance are set up,
341
339
Morons from Outer Space (Score: 0.8121)
342
340
```
343
341
344
-
With Azure Cache for Redis and Azure OpenAI Service, you can use embeddings and vector search to add powerful search capabilities to your application.
342
+
With Azure Managed Redis and Azure OpenAI Service, you can use embeddings and vector search to add powerful search capabilities to your application.
-[Learn more about Azure Cache for Redis](overview.md)
351
-
- Learn more about Azure Cache for Redis [vector search capabilities](overview-vector-similarity.md)
348
+
-[Learn more about Azure Managed Redis](overview.md)
352
349
- Learn more about [embeddings generated by Azure OpenAI Service](/azure/ai-services/openai/concepts/understand-embeddings)
353
350
- Learn more about [cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity)
354
351
-[Read how to build an AI-powered app with OpenAI and Redis](https://techcommunity.microsoft.com/blog/azuredevcommunityblog/vector-similarity-search-with-azure-cache-for-redis-enterprise/3822059)
355
352
-[Build a Q&A app with semantic answers](https://github.com/ruoccofabrizio/azure-open-ai-embeddings-qna)
0 commit comments