Skip to main content
A Retrieval-Augmented Generation (RAG) system tries to generate the most relevant answer consistent with grounding documents in response to a user’s query. A user’s query triggers a search retrieval in the corpus of grounding documents to provide grounding context for the AI model to generate a response. Think about groundedness and response completeness as:
  • Groundedness focuses on the precision aspect of the response. It doesn’t contain content outside of the grounding context.
  • Response completeness focuses on the recall aspect of the response. It doesn’t miss critical information compared to the expected response or ground truth.

System evaluation

System evaluation examines the quality of the final response in your RAG workflow. These evaluators ensure that the AI-generated content is accurate, relevant, and complete based on the provided context and user query:
  • Groundedness - Is the response grounded in the provided context without fabrication?
  • Groundedness Pro - Does the response strictly adhere to the context (Azure AI Content Safety)?
  • Relevance - Does the response accurately address the user’s query?
  • Response Completeness (preview) - Does the response cover all critical information from ground truth?
Examples:

Process evaluation

Process evaluation assesses the quality of the document retrieval step in RAG systems. The retrieval step is crucial for providing relevant context to the language model:
  • Retrieval - How relevant are the retrieved context chunks to the query?
  • Document Retrieval - How well does retrieval match ground truth labels (requires qrels)?
For more examples, see all quality evaluator samples.

Using RAG evaluators

RAG evaluators assess how well AI systems retrieve and use context to generate grounded responses. Each evaluator requires specific data mappings and parameters:

Example input

Your test dataset should contain the fields referenced in your data mappings:

Context format

The context field is a plain string containing the retrieved context provided to the model. For multi-chunk retrieval, concatenate chunks into a single string using a separator such as \n\n between chunks:
For agent evaluation with {{sample.output_items}}, the context field is optional if the response contains tool call messages — the evaluator can extract context from tool call results.
Tool definitions for agent evaluation: When evaluating agent responses, provide tool_definitions to help the Groundedness evaluator better assess whether tool-assisted responses are grounded in the retrieved context. If your agent traces already include tool definitions, they’re used automatically.

Configuration example

Data mapping syntax:
  • {{item.field_name}} references fields from your test dataset (for example, {{item.query}}).
  • {{sample.output_items}} references agent responses generated or retrieved during evaluation. Use this when evaluating with an agent target or agent response data source. For agent evaluation, context is optional if the response contains tool calls—the evaluator can extract context from tool call results.
For best Groundedness results, provide all three fields — query, response, and context. The query field is optional but improves scoring accuracy when available.
See Run evaluations from the SDK for details on running evaluations and configuring data sources.

Example output

These evaluators return scores from 1 to 5, where 1 is very poor and 5 is excellent. The default pass threshold is 3. Scores at or above the threshold are considered passing. Key output fields:
Groundedness Pro uses the Azure AI Content Safety service and returns a boolean result instead of a numeric score:

Document retrieval

Because of its upstream role in RAG, the retrieval quality is important. If the retrieval quality is poor and the response requires corpus-specific knowledge, there’s less chance your language model gives you a satisfactory answer. The most precise measurement is to use the document_retrieval evaluator to evaluate retrieval quality and optimize your search parameters for RAG.
  • Document retrieval evaluator measures how well the RAG retrieves the correct documents from the document store. As a composite evaluator useful for RAG scenario with ground truth, it computes a list of useful search quality metrics for debugging your RAG pipelines:
  • To optimize your RAG in a scenario called parameter sweep, you can use these metrics to calibrate the search parameters for the optimal RAG results. Generate different retrieval results for various search parameters such as search algorithms (vector, semantic), top_k, and chunk sizes you’re interested in testing. Then use document_retrieval to find the search parameters that yield the highest retrieval quality.

Document retrieval example

The retrieval_ground_truth contains human-labeled relevance scores per document:
The retrieved_documents contains scores from your search system:

Document retrieval output

The document_retrieval evaluator returns multiple metrics for retrieval quality:
The evaluator also returns xdcg@3, top1_relevance, top3_max_relevance, holes, and holes_ratio metrics.