Running Local and Cloud Evaluations
This lesson explains how evaluations run during development, in CI/CD pipelines and on production traffic, with local evaluation in the SDK and cloud evaluation in Foundry projects.
Learning outcomes
After completing this lesson, you will be able to:
- Run a local evaluation with evaluate().
- Describe cloud evaluations and how runs are compared.
- Add an evaluation gate to a CI/CD pipeline.
- Design a representative evaluation dataset.
Local evaluation
The evaluate() function in azure-ai-evaluation runs a set of evaluators over a dataset file, maps dataset columns to evaluator inputs and returns aggregate and per-row results. It can also call a target function (the application) to generate responses first. Passing the project endpoint logs the run to the Foundry project so that results appear in the portal.
from azure.ai.evaluation import evaluate, GroundednessEvaluator, RelevanceEvaluator
judge = {"azure_endpoint": aoai_endpoint, "azure_deployment": "judge", "api_version": "2024-10-21"}
result = evaluate(
data="rag_eval.jsonl", # rows with query, response, context
evaluators={
"groundedness": GroundednessEvaluator(model_config=judge, credential=credential),
"relevance": RelevanceEvaluator(model_config=judge, credential=credential),
},
azure_ai_project=project_endpoint, # log the run to the Foundry project
)
print(result["metrics"])Cloud evaluation and comparison
Cloud evaluations run in the Foundry project on uploaded datasets, without local compute, which suits large datasets and scheduled runs. The Foundry portal lists evaluation runs, shows metric distributions and per-row reasons, and compares runs side by side, which is how candidate models, prompts or agent versions are compared on the same dataset. Continuous evaluation applies evaluators to sampled production traffic of an agent or application, so that quality is tracked after release.
The following screenshot shows the Data step of a new agent evaluation in the Foundry portal. The dataset can be generated synthetically from the agent's instructions, uploaded, taken from benchmarks, sampled from the agent's existing traces, or drawn continuously from live traffic.

Evaluation in CI/CD
A pipeline step runs the evaluation on every change to prompts, agent definitions, retrieval configuration or model deployments, compares the aggregate scores with thresholds, and fails the build if they fall short. Thresholds are set from a baseline run and tightened as the system improves. Because AI-assisted evaluators have some variance, thresholds use averages over a dataset of adequate size rather than single examples.
Run evaluations
Designing the evaluation dataset
Evaluation results are only as meaningful as the dataset behind them. A good dataset represents the questions real users ask, in their wording and proportions, and adds cases that test known weaknesses: questions whose answer is not in the sources, ambiguous questions, multi-part questions and inputs in other languages. Adversarial inputs are kept in a separate safety dataset, because they are evaluated with different evaluators and thresholds.
Datasets are usually JSON Lines files in which each row contains the fields that the evaluators need, such as query, response, context and ground_truth. Ground truth is needed only for evaluators that compare with a reference answer. Datasets are versioned and uploaded to the project, so that every run can be traced to the exact data it used, and they are extended with failing cases found in production so that fixed problems stay fixed.
Comparing two models
A team must decide whether a smaller model can replace the current model for its RAG assistant without reducing quality.
Generate responses from both deployments for the same evaluation dataset (with the same retrieval and prompt), evaluate both runs with groundedness, relevance and response completeness, and compare them in the portal. If the smaller model's scores are within the agreed tolerance, it can replace the larger one, with continuous evaluation watching for regressions after the switch.
What does evaluate() do?
Show answer
It runs evaluators over a JSONL dataset locally and can log the results to the Foundry project.
Exam Tips
Remember for the exam
- evaluate() runs evaluators over a JSONL dataset locally and can log results to the project.
- Compare models, prompts or agent versions on the same dataset and evaluators.
- Gate pipelines on aggregate scores; use continuous evaluation after release.