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/tutorial-rag-build-solution-index-schema.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ Chunked content typically derives from a larger document. And although the schem
57
57
58
58
An inflection point in schema design is whether to have two indexes for parent and child/chunked content, or a single index that repeats parent elements for each chunk.
59
59
60
-
In this tutorial, because all of the chunks of text originate from a single parent (NASA Earth Book), you don't need a separate index dedicated to up level the parent fields. However, if you're indexing from multiple parent PDFs, you might want a parent-child index pair to capture level-specific fields and then send [lookup queries](https://learn.microsoft.com/rest/api/searchservice/documents/get) to the parent index to retrieve those fields relevant to each chunk.
60
+
In this tutorial, because all of the chunks of text originate from a single parent (NASA Earth Book), you don't need a separate index dedicated to up level the parent fields. However, if you're indexing from multiple parent PDFs, you might want a parent-child index pair to capture level-specific fields and then send [lookup queries](/rest/api/searchservice/documents/get) to the parent index to retrieve those fields relevant to each chunk.
Copy file name to clipboardExpand all lines: articles/search/tutorial-rag-build-solution-pipeline.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,13 +40,15 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
40
40
41
41
- Azure OpenAI, with a deployment of text-embedding-002. For more information about embedding models used in RAG solutions, see [Choose embedding models for RAG in Azure AI Search](tutorial-rag-build-solution-models.md)
42
42
43
-
## Download file
43
+
## Download the sample
44
44
45
-
[Download a Jupyter notebook](https://github.com/Azure-Samples/azure-search-python-samples/blob/main/Tutorial-RAG/Tutorial-rag.ipynb) from GitHub to send the requests in this quickstart. For more information, see [Downloading files from GitHub](https://docs.github.com/get-started/start-your-journey/downloading-files-from-github).
45
+
[Download a Jupyter notebook](https://github.com/Azure-Samples/azure-search-python-samples/blob/main/Tutorial-RAG/Tutorial-rag.ipynb) from GitHub to send the requests to Azure AI Search. For more information, see [Downloading files from GitHub](https://docs.github.com/get-started/start-your-journey/downloading-files-from-github).
46
46
47
47
## Provide the index schema
48
48
49
-
Here's the index schema from the [previous tutorial](tutorial-rag-build-solution-index-schema.md). It's organized around vectorized and nonvectorized chunks. It includes a `locations` field that stores AI-generated content created by the skillset.
49
+
Open or create a Jupyter notebook (.ipynb) in Visual Studio code to contain the scripts that comprise the pipeline. Initial steps install packages and collect variables for the connections. After you complete the set up steps, you're ready to begin with the components of the indexing pipeline.
50
+
51
+
Let's start with the index schema from the [previous tutorial](tutorial-rag-build-solution-index-schema.md). It's organized around vectorized and nonvectorized chunks. It includes a `locations` field that stores AI-generated content created by the skillset.
Copy file name to clipboardExpand all lines: articles/search/tutorial-rag-build-solution-query.md
+46-3Lines changed: 46 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,45 @@ ms.date: 09/12/2024
14
14
15
15
# Tutorial: Search your data using a chat model (RAG in Azure AI Search)
16
16
17
+
The defining characteristic of a RAG solution on Azure AI Search is sending queries to a Large Language Model (LLM) and providing a conversational search experience over your indexed content. It can be surprisingly easy if you implement just the basics.
17
18
19
+
In this tutorial, you:
18
20
19
-
## Generate an answer
21
+
> [!div class="checklist"]
22
+
> - Set up clients
23
+
> - Write instructions for the LLM
24
+
> - Provide a query designed for LLM inputs
25
+
> - Review results and explore next steps
26
+
27
+
This tutorial builds on the previous tutorials. It assumes you have a search index created by the [indexing pipeline](tutorial-rag-build-solution-pipeline.md).
28
+
29
+
## Prerequisites
30
+
31
+
-[Visual Studio Code](https://code.visualstudio.com/download) with the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) and the [Jupyter package](https://pypi.org/project/jupyter/). For more information, see [Python in Visual Studio Code](https://code.visualstudio.com/docs/languages/python).
32
+
33
+
- Azure AI Search, in a region shared with Azure OpenAI.
34
+
35
+
- Azure OpenAI, with a deployment of gpt-35-turbo. For more information, see [Choose models for RAG in Azure AI Search](tutorial-rag-build-solution-models.md)
36
+
37
+
## Download the sample
38
+
39
+
You use the same notebook from the previous indexing pipeline tutorial. Scripts for querying the LLM follow the pipeline steps. If you don't already have the notebook, [download it](https://github.com/Azure-Samples/azure-search-python-samples/blob/main/Tutorial-RAG/Tutorial-rag.ipynb) from GitHub.
40
+
41
+
## Configure clients for sending queries
42
+
43
+
The RAG pattern in Azure AI Search is a synchronized connection to a search index to obtain the grounding data, followed by a connection to an LLM to formulate a response to the user's question. The same query string is used by both clients.
44
+
45
+
You're setting up two clients, so you need permissions on both resources. We use API keys for this exercise. The following endpoints and keys are used for queries:
46
+
47
+
```python
48
+
# Set endpoints and API keys for Azure services
49
+
AZURE_SEARCH_SERVICE: str="PUT YOUR SEARCH SERVICE URL HERE"
50
+
AZURE_SEARCH_KEY: str="PUT YOUR SEARCH SERVICE ADMIN KEY HERE"
51
+
AZURE_OPENAI_ACCOUNT: str="PUT YOUR AZURE OPENAI ACCOUNT URL HERE"
52
+
AZURE_OPENAI_KEY: str="PUT YOUR AZURE OPENAI KEY HERE"
In this example, the answer is based on a single input (`top=1`) consisting of the one chunk determined by the search engine to be the most relevant. Results from the query should look similar to the following example.
116
+
## Review results
117
+
118
+
In this example, the answer is based on a single input (`top=1`) consisting of the one chunk determined by the search engine to be the most relevant. Instructions in the prompt tell the LLM to use only the information in the `sources`, or formatted search results. Results from the first query`"how much of earth is covered by water"` should look similar to the following example.
81
119
82
120
```
83
121
About 72% of the Earth's surface is covered in water, according to page-79.pdf. The provided sources do not give further information on this topic.
84
122
```
85
123
86
-
Run the same query again after setting `top=3`. When you increase the inputs, the model returns different results each time, even if the query doesn't change. Here's one example of what the model returns after increasing the inputs to 3.
124
+
### Changing the inputs
125
+
126
+
Increasing or decreasing the number of inputs to the LLM can have a large impact on the response. Try running the same query again after setting `top=3`. When you increase the inputs, the model returns different results each time, even if the query doesn't change. Here's one example of what the model returns after increasing the inputs to 3.
87
127
88
128
```
89
129
About 71% of the earth is covered by water, while the remaining 29% is land. Canada has numerous water bodies like lakes, ponds, and streams, giving it a unique landscape. The Nunavut territory is unsuitable for agriculture due to being snow-covered most of the year and frozen during the summer thaw. Don Juan Pond in the McMurdo Dry Valleys of Antarctica is the saltiest body of water on earth with a salinity level over 40%, much higher than the Dead Sea and Great Salt Lake. It rarely snows in the valley and Don Juan's calcium chloride–rich waters rarely freeze. NASA studies our planet's physical processes, including the water cycle, carbon cycle, ocean circulation, heat movement, and light interaction. NASA has a unique vantage point of observing the earth and making sense of it from space.
90
130
```
91
131
132
+
### Changing the prompt
133
+
134
+
You can control the format of the output, tone, and whether you want the model to supplement the answer with its own training data by changing the prompt.
92
135
93
136
<!-- In this tutorial, learn how to send queries and prompts to a chat model for generative search.
0 commit comments