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/retrieval-augmented-generation-overview.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,7 +151,7 @@ Here are some tips for maximizing relevance and recall:
151
151
152
152
In comparison and benchmark testing, hybrid queries with text and vector fields, supplemented with semantic ranking, produce the most relevant results.
153
153
154
-
### Example code of an Azure AI Search query for RAG scenarios
154
+
### Example code for a RAG workflow
155
155
156
156
The following Python code demonstrates the essential components of a RAG workflow in Azure AI Search. You need to set up the clients, define a system prompt, and provide a query. The prompt tells the LLM to use just the results from the query, and how to return the results. For more steps based on this example, see this [RAG quickstart](search-get-started-rag.md).
157
157
@@ -176,7 +176,8 @@ search_client = SearchClient(
176
176
credential=credential
177
177
)
178
178
179
-
# This prompt provides instructions to the model
179
+
# This prompt provides instructions to the model.
180
+
# The prompt includes the query and the source, which are specified further down in the code.
180
181
GROUNDED_PROMPT="""
181
182
You are a friendly assistant that recommends hotels based on activities and amenities.
182
183
Answer the query using only the sources provided below in a friendly and concise bulleted manner.
@@ -187,7 +188,7 @@ Query: {query}
187
188
Sources:\n{sources}
188
189
"""
189
190
190
-
#Query is the question being asked
191
+
#The query is sent to the search engine, but it's also passed in the prompt
191
192
query="Can you recommend a few hotels near the ocean with beach access and good views"
192
193
193
194
# Retrieve the selected fields from the search index related to the question
Copy file name to clipboardExpand all lines: articles/search/search-get-started-rag.md
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: HeidiSteen
6
6
ms.author: heidist
7
7
ms.service: cognitive-search
8
8
ms.topic: quickstart
9
-
ms.date: 07/22/2024
9
+
ms.date: 08/16/2024
10
10
---
11
11
12
12
# Quickstart: Generative search (RAG) with grounding data from Azure AI Search
@@ -35,11 +35,11 @@ Requests to the search endpoint must be authenticated and authorized. You can us
35
35
36
36
1. Sign in to the [Azure portal](https://portal.azure.com).
37
37
38
-
1. Configure Azure OpenAI to use a system-assigned managed identity:
38
+
1. Configure Azure AI Search to use a system-assigned managed identity:
39
39
40
-
1. In the Azure portal, find your Azure OpenAI resource.
40
+
1. In the Azure portal, [find your search service](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices).
41
41
42
-
1. On the left menu, select **Resource management** > **Identity**.
42
+
1. On the left menu, select **Settings** > **Identity**.
43
43
44
44
1. On the System assigned tab, set status to **On**.
45
45
@@ -53,12 +53,13 @@ Requests to the search endpoint must be authenticated and authorized. You can us
53
53
54
54
1. On the left menu, select **Access control (IAM)**.
55
55
56
-
1. On Azure AI Search, add two role assignments for the Azure OpenAI managed identity:
56
+
1. On Azure AI Search, make sure you have permissions to create, load, and query a search index:
57
57
58
58
-**Search Index Data Reader**
59
+
-**Search Index Data Contributor**
59
60
-**Search Service Contributor**
60
61
61
-
1. On Azure OpenAI, select **Access control (IAM)** to assign yourself to a role. The code for this quickstart runs locally. Requests to Azure OpenAI originate from your system:
62
+
1. On Azure OpenAI, select **Access control (IAM)** to assign yourself and the search service identity permissions on Azure OpenAI. The code for this quickstart runs locally. Requests to Azure OpenAI originate from your system. Also, search results from the search engine are passed to Azure OpenAI. For these reasons, both you and the search service need permissions on Azure OpenAI.
62
63
63
64
-**Cognitive Services OpenAI User**
64
65
@@ -165,6 +166,7 @@ This section uses Visual Studio Code and Python to call the chat completion APIs
1. Set the following variables, substituting placeholders with the endpoints you collected in the previous step.
@@ -175,7 +177,7 @@ This section uses Visual Studio Code and Python to call the chat completion APIs
175
177
AZURE_DEPLOYMENT_MODEL: str="gpt-35-turbo"
176
178
```
177
179
178
-
1. Run the following code to set query parameters. The query is a keyword search using semantic ranking. In a keyword search, the search engine returns up to 50 matches, but only the top 5 are provided to the model. If you can't enable semantic ranking on your search service, set the value to false.
180
+
1. Run the following code to set query parameters. The query is a keyword search using semantic ranking. In a keyword search, the search engine returns up to 50 matches, but only the top 5 are provided to the model. If you can't [enable semantic ranking](semantic-how-to-enable-disable.md) on your search service, set the value to false.
179
181
180
182
```python
181
183
# Set query parameters for grounding the conversation on your search index
@@ -308,6 +310,8 @@ This section uses Visual Studio Code and Python to call the chat completion APIs
308
310
Several other hotels have views and water features, but do not offer beach access or views of the ocean.
309
311
```
310
312
313
+
If you get an authorization error message, wait a few minutes andtry again. It can take several minutes for role assignments to become operational.
314
+
311
315
To experiment further, change the query and rerun the last step to better understand how the model works with your data.
312
316
313
317
You can also modify the prompt to change the tone or structure of the output.
0 commit comments