Skill 2.1.2
Implement retrieval-augmented generation (RAG) in an application
Key Concepts
A RAG request has three steps. Retrieve: the application turns the user's question (rewritten into a standalone query if it depends on earlier turns) into a hybrid search against Azure AI Search, with filters for permissions and metadata, and takes the top chunks. Augment: it places the chunks in the prompt, each with a source identifier, inside clear delimiters, with instructions to answer only from the sources, cite them and say when the answer is not present. Generate: the model writes the answer, which the application returns with citations.
RAG can also be delegated. A Foundry agent with the Azure AI Search tool or a Foundry IQ knowledge base retrieves automatically and returns annotations with citations, and agentic retrieval plans subqueries for complex questions. The quality of a RAG system depends on chunking, embeddings, query type, the number of chunks and the prompt, so each is tuned with an evaluation dataset that measures retrieval and groundedness separately.