Evaluate Models and Apps: Groundedness, Relevance and Safety
30-second answer
Evaluators score your app's answers on a fixed test dataset. Groundedness checks whether the answer is supported by the context, which finds fabrications. Relevance checks the answer addresses the question, coherence and fluency check the writing, and safety evaluators check harm and attacks. AI-assisted evaluators need a judge model deployment. Run the same dataset before and after each change so you can compare.
Simulate it » No Azure account neededExam objective: 2.1.4 Evaluate models and apps, including detecting fabrications, relevance, quality and safety. (Skills measured as of April 16, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Build ➜ Evaluations</strong> and select <strong>+ New evaluation</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Build ➜ Evaluations and select + New evaluation.
- Choose what to evaluate (a dataset, a model or an agent), the dataset, and the evaluators. AI-assisted ones use a judge model.
- Row 4 scores 1 on groundedness. Open it to see why.
- Groundedness compares the answer with the context you supplied. A low score on one row finds a fabrication that an average would hide.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Evaluate before you ship
Evaluators score each answer on a test set: groundedness (is it supported by the context?), relevance, coherence and safety checks. A fabrication shows up as a low groundedness score on one row, so you fix it before users see it.
🤔 What happens if…
Read this tour as text
- Deploy a model, call the deployment. A deployment is a named copy of a model with a version, a deployment type and capacity. Your app calls the deployment name, never the model name. Pick a large model for hard work and a small language model for cheap, fast, simple work.
- RAG: retrieve first, then answer. Retrieval-augmented generation searches your own content (Azure AI Search, hybrid keyword plus vector), puts the best chunks in the prompt and asks the model to answer from them with citations. Without retrieval the model guesses.
- A multistep flow with checks. A workflow breaks one big request into steps you control: classify, extract to a JSON schema, call a tool, draft, then verify. Retries, fallbacks and a final check live in code, so one bad step can’t slip through unseen.
- Evaluate before you ship. Evaluators score each answer on a test set: groundedness (is it supported by the context?), relevance, coherence and safety checks. A fabrication shows up as a low groundedness score on one row, so you fix it before users see it.
- SDK, project endpoint and connections. The Foundry SDK (
azure-ai-projects) opens one door: AIProjectClient with the project endpoint and DefaultAzureCredential. From it your app gets an OpenAI-compatible client, deployments and connections (Azure AI Search, Application Insights) with no secrets in code. - Design the agent: role, goal, tool schema. An agent is a model plus instructions (role and goal), tools and a conversation (thread). A strict function schema names each parameter and marks the required ones, so the model asks the user instead of inventing a value.
- Retrieval, function calling and memory. One agent can use file search for documents, a function for live data and memory for what it learned about a user. The model asks to call a function; your code runs it and returns the result. Memory survives into a new conversation.
- Multi-agent orchestration. Several specialist agents can share a job. Sequential passes work down a line, concurrent fans out and merges, handoff moves control to the right specialist, group chat lets agents take turns in one shared conversation and Magentic lets a manager agent plan and delegate. Microsoft Agent Framework builds all five.
- Autonomy with approvals. Reads are safe, writes are not. A tool marked approval required pauses the run until a person decides. A hard limit in code blocks what no one should approve, whatever the model says.
- Monitor and debug agent runs. Agent evaluators read the whole run: intent resolution, tool call accuracy and task adherence. Error analysis groups the failing rows, such as a made-up tool argument, and points to the fix.
- Tune prompts and parameters. Instructions shape tone and rules, a few-shot example shows the format, temperature and top_p change how adventurous the wording is, and max output tokens caps length. A self-critique loop drafts, checks against a checklist and revises once.
- Trace every call and count tokens. OpenTelemetry spans record each agent run, model call and tool call, with tokens and latency, and Application Insights stores them. Tracing is opt-in, and recording message content is for development only because it captures prompts and answers.
- Route requests to the right model. A hybrid design puts rules first for answers code can decide, a small model for easy language work and a large or reasoning model only when needed. A model router can pick for you. Fewer big-model calls means a lower bill and faster replies.
The Contoso chatbot guesses return policies. Connect Azure AI Search, ingest the policy documents, compare an answer with and without retrieval, then score a dataset to find the fabricated reply and check safety.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
A prompt tweak “felt better” in the demo, and two weeks later customers got invented refund promises.
😊 THE SOLUTION
Score a fixed test set with evaluators before and after every change.
- Made-up details✓ Groundedness evaluator
- Off-topic answers✓ Relevance evaluator
- Harmful or injected content✓ Safety evaluators
Start with a question
How does a teacher know a student really understands?
A teacher doesn’t judge from one confident answer in class. She sets the same test, marks each question against the textbook, and looks at which answers fall apart. A student who says something the book never said gets marked down, however fluent it sounds.
Evaluators do that marking for your app. They take a set of questions, the sources the app had and the answers it gave, and score each row. A low groundedness score is the “that’s not in the book” mark.
Explain it like I’m 10
The technical explanation
The evaluator families
| Family | Examples | What it tells you |
|---|---|---|
| Quality (AI-assisted) | Groundedness, relevance, coherence, fluency | Scored 1 to 5 by a judge model, with a pass threshold you choose |
| Quality (compare to a reference) | Similarity, F1 score | How close the answer is to a ground truth |
| Safety | Violence, hate and unfairness, sexual, self-harm, indirect attack, protected material | Whether harmful content or manipulation is present |
| Agent | Intent resolution, tool call accuracy, task adherence | How an agent behaved (a later lesson) |
A dataset and a run
Each row of a JSONL file holds what the evaluator needs, for example query, context, response and ground_truth.
{"query": "When will my refund arrive?",
"context": "Refunds reach the original payment method in 5 to 7 working days.",
"response": "Refunds arrive instantly as store credit, plus a ₹500 voucher.",
"ground_truth": "5 to 7 working days"}
# pip install azure-ai-evaluation azure-identity
from azure.ai.evaluation import evaluate, AzureOpenAIModelConfiguration, GroundednessEvaluator, RelevanceEvaluator
judge = AzureOpenAIModelConfiguration(azure_endpoint=resource_endpoint, azure_deployment="support-chat")
result = evaluate(data="rag-eval.jsonl",
evaluators={"groundedness": GroundednessEvaluator(judge), "relevance": RelevanceEvaluator(judge)},
azure_ai_project=project_endpoint) # the run also appears under Evaluations in the portal
print(result["metrics"])
The example row scores 1 out of 5 on groundedness. The context says 5 to 7 working days, and the response invents instant credit and a voucher. That’s a fabrication, and the score catches it even if the average of the dataset looks fine.
Make evaluation a habit
- Build a small dataset from real questions, including some your documents can’t answer.
- Run quality and safety evaluators, and read the lowest rows.
- Change one thing, such as the prompt or the retrieval.
- Run the same dataset again and compare.
Architect level Judge models and cost
AI-assisted evaluators call a model for every row and every evaluator, so a dataset of 500 rows with four evaluators makes about 2,000 judge calls. Use a capable deployment as judge, keep the dataset focused, and run the full set on release rather than on every small edit. Safety evaluators for harm categories run on Foundry’s safety evaluation service and need a Foundry project, which is why the script passes the project endpoint.
Real-world business scenario
Contoso Retail (fictional)
- The problem
- After a prompt tweak, the support bot started promising store credit and vouchers. Nobody noticed until a customer posted the chat.
- What they used
- A 200-row evaluation set built from real tickets, run with groundedness, relevance and safety evaluators on every release, with the lowest rows reviewed by hand.
- Why that choice
- A fabricated promise shows up as a groundedness score of 1 on a known row, before it reaches a customer, and the same set proves the fix.
- The result
- The team blocked a release that scored lower than the previous one and shipped the fixed prompt two days later with scores restored.
When to use it and when not to
✓ Use it when…
- You change prompts, models or retrieval and need to know if quality moved.
- You must show a release meets a quality and safety bar.
- You want to find rows that fail, not only an average.
✕ Think twice when…
- You have no test data. Collect examples first.
- You only want an uptime check. Azure Monitor metrics cover that.
- You treat a single score as proof of safety. Combine evaluators with review.
↔ Alternatives to consider
- Continuous evaluation on sampled live traffic after release.
- Red teaming to attack the app on purpose.
- Human review for the lowest-scoring rows.
Test yourself with exercises
5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What does groundedness measure?
Model answer
Whether the answer is backed by the context the app supplied. If the answer says something the documents never said, groundedness drops.
Intermediate Why use a fixed dataset for evaluation?
Model answer
So the comparison is fair. If I change the prompt and run the same rows through the same evaluators, any change in score comes from my change and not from different questions.
Experienced developer Groundedness is high on average but customers complain. What now?
Model answer
Averages hide rows. I look at the lowest rows, read why they failed, and check whether the test set matches real traffic. I also add cases the documents can't answer, and run safety evaluators separately because they measure different things.
Scenario The model started promising vouchers that don't exist. How do you catch that before release?
Model answer
I add that case to the evaluation set with the real context, run groundedness, and see a very low score for the row. Then I fix the instructions or retrieval and run the same dataset again to prove the score recovered.
Quick revision
Key points
- Groundedness finds claims the context does not support.
- Relevance checks the answer addresses the query.
- Safety evaluators check harm categories and indirect attacks.
- AI-assisted evaluators need a judge model deployment.
- Compare changes on the same dataset.
Important terminology
- Evaluator
- A scoring function that rates a response on one quality, such as groundedness or violence.
- Groundedness
- How well a response is supported by the context it was given. Low scores point to fabrication.
- Fabrication
- A claim in an answer that the sources do not support.
- Relevance
- How well a response addresses the question that was asked.
- Judge model
- A model deployment that an AI-assisted evaluator uses to score each row.
- Evaluation dataset
- A fixed set of test rows, such as query, context, response and ground truth, used to compare versions.
Common mistakes
- Judging quality by a quick demo.
- Reading only the average score and not the failing rows.
- Running quality evaluators and skipping safety ones.
Exam tips
- "Answer contains details not in the documents" = groundedness.
- "Accurate but answers a different question" = relevance.
- "Hidden instructions in a document" = indirect attack evaluator.
Five quick revision questions
-
1.Which evaluator finds fabrications?Show
Groundedness.
-
2.Which checks that the answer fits the question?Show
Relevance.
-
3.What do AI-assisted evaluators need?Show
A judge model deployment.
-
4.Why use a fixed dataset?Show
To compare versions fairly.
-
5.Which evaluator checks injected instructions?Show
Indirect attack.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Foundry SDKs and Connectors
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.