Understand Retrieval Augmented Generation (RAG) with Azure OpenAI Service

Completed

Once you have your Azure OpenAI Service set up, you start building your own copilot agent by utilizing Azure OpenAI Studio or Azure AI Studio to deploy your Azure OpenAI models and add your own data by implementing Retrieval Augmented Generation (RAG) by connecting supporting AI chat models to your own data. Those models can reference specific sources of data to ground the response, augmenting the capabilities of the AI model when it creates a response.

Azure OpenAI Studio is essentially a subset of Azure AI Studio that focuses specifically on Azure OpenAI models and services, although the concepts discussed here are also relevant to Azure AI Studio. RAG with Azure OpenAI allows developers to use supported AI chat models that can reference specific sources of information to ground the response. Adding this information allows the model to reference both the specific data provided and its pretrained knowledge to provide more effective responses.

Add your own data source

Adding your data is done through the Azure OpenAI Studio, in the  Chat  playground, or by specifying your data source in an API call. The data source you add is then used to augment the prompt sent to the model. When setting up your data in the studio, you can choose to upload your data files, use data in a blob storage account, or connect to an existing AI Search index. If you're uploading or using files already in a storage account, Azure OpenAI on your data supports .md, .txt, .html, .pdf, and Microsoft Word or PowerPoint files. If any of these files contain graphics or images, the response quality depends on how well text can be extracted from the visual content. When uploading data or connecting to files in a storage account, it's recommended to use the Azure OpenAI Studio to create the search resource and index. Adding data this way allows the appropriate chunking to happen when inserting into the index, yielding better responses. If you're using large text files or forms, you should use the available data preparation script to improve the AI model's accuracy.

Enabling semantic search for your AI Search service can improve the result of searching your data index and you're likely to receive higher quality responses and citations. However, enabling semantic search may increase the cost of the search service. You can also use the wizard in your AI Search resource to vectorize your data appropriately, which you'll walk through in this module's exercise. It takes a few extra steps compared to doing so in AI Studio, however serves as a good example of using the RAG pattern with an existing dataset.

Connect your data

To connect your data, navigate to the Chat playground in Azure OpenAI Studio and select the Add your data tab. Select the Add a data source button to get your data connected. The prompts guide you through setting up the connection to each data source, and getting that data into a search index.