Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 15 of 39
❮Prev Next❯

Evaluate Models and Apps: Groundedness, Relevance and Safety

Module 2: GenAI & Agents ⏱ 12 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: Run evaluators on a dataset and read the scores Run groundedness and relevance on a dataset and read the scores.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    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
    1. Open Build ➜ Evaluations and select + New evaluation.
    2. Choose what to evaluate (a dataset, a model or an agent), the dataset, and the evaluators. AI-assisted ones use a judge model.
    3. Row 4 scores 1 on groundedness. Open it to see why.
    4. 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.

    😟 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
    🛠️ Solved with: Foundry evaluations

    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

    FamilyExamplesWhat it tells you
    Quality (AI-assisted)Groundedness, relevance, coherence, fluencyScored 1 to 5 by a judge model, with a pass threshold you choose
    Quality (compare to a reference)Similarity, F1 scoreHow close the answer is to a ground truth
    SafetyViolence, hate and unfairness, sexual, self-harm, indirect attack, protected materialWhether harmful content or manipulation is present
    AgentIntent resolution, tool call accuracy, task adherenceHow 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

    1. Build a small dataset from real questions, including some your documents can’t answer.
    2. Run quality and safety evaluators, and read the lowest rows.
    3. Change one thing, such as the prompt or the retrieval.
    4. 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

    Retail

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    A RAG chatbot sometimes states refund amounts that do not appear in the retrieved documents.

    Which evaluator detects this problem?

    Question 2

    Question 2 of 5

    A response is accurate and well written but answers a different question from the one the user asked.

    Which evaluator would score this response low?

    Question 3

    Question 3 of 5

    You must test whether retrieved documents containing hidden instructions can change the behaviour of your app.

    Which evaluator should you run?

    Question 4

    Question 4 of 5

    A team changes the system prompt and must prove quality did not drop before release.

    What should they do?

    Question 5

    Question 5 of 5

    AI-assisted evaluators such as groundedness and relevance are configured in a Python script.

    What must the script supply for them to run?

    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. 1.Which evaluator finds fabrications?Show

      Groundedness.

    2. 2.Which checks that the answer fits the question?Show

      Relevance.

    3. 3.What do AI-assisted evaluators need?Show

      A judge model deployment.

    4. 4.Why use a fixed dataset?Show

      To compare versions fairly.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.